BxDolQueueEmail.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 UnaCore UNA Core
  7. * @{
  8. */
  9. class BxDolQueueEmail extends BxDolQueue implements iBxDolSingleton
  10. {
  11. protected function __construct()
  12. {
  13. parent::__construct();
  14. $this->_oQuery = new BxDolQueueEmailQuery();
  15. }
  16. /**
  17. * Get singleton instance of the class
  18. */
  19. static function getInstance()
  20. {
  21. if(!isset($GLOBALS['bxDolClasses'][__CLASS__]))
  22. $GLOBALS['bxDolClasses'][__CLASS__] = new BxDolQueueEmail();
  23. return $GLOBALS['bxDolClasses'][__CLASS__];
  24. }
  25. /**
  26. * Add message to mail queue
  27. *
  28. * @param string $sEmail - recipient email
  29. * @param string $sSubject - message subject
  30. * @param string $sBody - message body
  31. * @return true on success, false on error
  32. */
  33. public function add($sEmail, $sSubject, $sBody, $iRecipientID, $aPlus, $iEmailType, $sEmailFlag, $isDisableAlert, $aCustomHeaders)
  34. {
  35. return (int)$this->_oQuery->insertItem(array(
  36. 'email' => $sEmail,
  37. 'subject' => $sSubject,
  38. 'body' => $sBody,
  39. 'params' => serialize(array($iRecipientID, $aPlus, $iEmailType, $sEmailFlag, $isDisableAlert, $aCustomHeaders))
  40. )) > 0;
  41. }
  42. /**
  43. * Internal method which performs sending using predefined list of params.
  44. */
  45. protected function _send($sEmail, $sSubject, $sBody, $sParams = '')
  46. {
  47. $aParams = array();
  48. if(!empty($sParams))
  49. $aParams = unserialize($sParams);
  50. return call_user_func_array('sendMail', array_merge(array($sEmail, $sSubject, $sBody), $aParams));
  51. }
  52. }
  53. /** @} */