BxNtfsCronQueue.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. if($this->_oModule->{'sendNotification' . bx_gen_method_name($aItem['delivery'])}($aItem['profile_id'], unserialize($aItem['content'])) !== false)
  33. $aSent[] = $aItem['id'];
  34. }
  35. }
  36. /** @} */