BxNtfsCronQueue.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 Notifications Notifications
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxNtfsCronQueue extends BxDolCron
  12. {
  13. protected $_sModule;
  14. protected $_oModule;
  15. public function __construct()
  16. {
  17. $this->_sModule = 'bx_notifications';
  18. $this->_oModule = BxDolModule::getInstance($this->_sModule);
  19. parent::__construct();
  20. }
  21. public function processing()
  22. {
  23. $iDeliveryTimeout = $this->_oModule->_oConfig->getDeliveryTimeout();
  24. if($iDeliveryTimeout == 0)
  25. return;
  26. $aItems = $this->_oModule->_oDb->queueGet(array('type' => 'all_to_send', 'timeout' => $iDeliveryTimeout));
  27. if(empty($aItems) || !is_array($aItems))
  28. return;
  29. $this->_oModule->_oDb->queueDeleteByIds(array_keys($aItems));
  30. $aSent = array();
  31. foreach($aItems as $aItem) {
  32. $sMethod = 'sendNotification' . bx_gen_method_name($aItem['delivery']);
  33. $oProfile = BxDolProfile::getInstance($aItem['profile_id']);
  34. if($this->_oModule->$sMethod($oProfile, unserialize($aItem['content'])) !== false)
  35. $aSent[] = $aItem['id'];
  36. }
  37. }
  38. }
  39. /** @} */