BxCreditsAlertsResponse.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup Credits Credits
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxCreditsAlertsResponse extends BxBaseModGeneralAlertsResponse
  12. {
  13. public function __construct()
  14. {
  15. $this->MODULE = 'bx_credits';
  16. parent::__construct();
  17. }
  18. public function response($oAlert)
  19. {
  20. parent::response($oAlert);
  21. $sMethod = '_process' . bx_gen_method_name($oAlert->sUnit . '_' . $oAlert->sAction);
  22. if(!method_exists($this, $sMethod))
  23. return;
  24. return $this->$sMethod($oAlert);
  25. }
  26. protected function _processProfileAdd($oAlert)
  27. {
  28. $CNF = &$this->_oModule->_oConfig->CNF;
  29. $iProfile = (int)$oAlert->iObject;
  30. $oProfile = BxDolProfile::getInstance($iProfile);
  31. if(!$oProfile)
  32. return;
  33. if(getParam($CNF['PARAM_PROVIDER_ENABLE']) == 'on') {
  34. $oProvider = BxDolPayments::getInstance()->getProvider($CNF['PARAM_PROVIDER_NAME'], $iProfile);
  35. if($oProvider)
  36. $oProvider->setOption('active', 'on', true);
  37. }
  38. }
  39. protected function _processProfileDelete($oAlert)
  40. {
  41. if(empty($oAlert->aExtras['delete_with_content']))
  42. return;
  43. return BxDolService::call($this->MODULE, 'delete_entities_by_author', array($oAlert->iObject));
  44. }
  45. }
  46. /** @} */