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. /**
  12. * Send notifications from internal queue by moving them to system one.
  13. * Is working if Delivery Timeout is set.
  14. */
  15. class BxNtfsCronQueue extends BxDolCron
  16. {
  17. protected $_sModule;
  18. protected $_oModule;
  19. public function __construct()
  20. {
  21. $this->_sModule = 'bx_notifications';
  22. $this->_oModule = BxDolModule::getInstance($this->_sModule);
  23. parent::__construct();
  24. }
  25. public function processing()
  26. {
  27. $iDeliveryTimeout = $this->_oModule->_oConfig->getDeliveryTimeout();
  28. if($iDeliveryTimeout == 0)
  29. return;
  30. $aItems = $this->_oModule->_oDb->queueGet(array('type' => 'all_to_send', 'timeout' => $iDeliveryTimeout));
  31. if(empty($aItems) || !is_array($aItems))
  32. return;
  33. $this->_oModule->_oDb->queueDeleteByIds(array_keys($aItems));
  34. $aSent = array();
  35. foreach($aItems as $aItem)
  36. if($this->_oModule->{'sendNotification' . bx_gen_method_name($aItem['delivery'])}($aItem['profile_id'], unserialize($aItem['content'])) !== false)
  37. $aSent[] = $aItem['id'];
  38. }
  39. }
  40. /** @} */