BxMassMailerAlertsResponse.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  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 MassMailer Mass Mailer
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxMassMailerAlertsResponse extends BxDolAlertsResponse
  12. {
  13. public function __construct()
  14. {
  15. parent::__construct();
  16. }
  17. public function response($oAlert)
  18. {
  19. if ($oAlert->sUnit == 'account' && $oAlert->sAction == 'change_receive_news'){
  20. $oModule = BxDolModule::getInstance('bx_massmailer');
  21. if ($oAlert->aExtras['account_id'] != '' && $oAlert->aExtras['old_value'] != $oAlert->aExtras['new_value']){
  22. $sHash = bx_get('lhash');
  23. $iCampagn_Id = 0;
  24. if ($sHash){
  25. $aLetter = $oModule->_oDb->getLetterByCode($sHash);
  26. if (isset($aLetter['campaign_id']))
  27. $iCampagn_Id = $aLetter['campaign_id'];
  28. }
  29. $oModule->_oDb->updateUnsubscribe($oAlert->aExtras['account_id'], $oAlert->aExtras['new_value'], $iCampagn_Id);
  30. }
  31. }
  32. }
  33. }
  34. /** @} */