Advertisement
Guest User

Untitled

a guest
Jan 15th, 2013
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. public function updateQueuedContacts ()
  2. {
  3. /**
  4. * @var DataList
  5. */
  6. $oTemplate = $this->EmailTemplate();
  7.  
  8. /**
  9. * @var DataList
  10. */
  11. $oConditions = $this->EmailConditions();
  12.  
  13. $aIncludes = array();
  14. $aExcludes = array();
  15.  
  16. foreach ( $oConditions as /* @var $oCondition EmailCondition */ $oCondition )
  17. {
  18. $sKey = $oCondition->ContactField;
  19.  
  20. switch ( $oCondition->ConditionOperator )
  21. {
  22. case EmailCondition::EC_OPERATOR_GREATERTHAN:
  23. $sKey .= ':GreaterThan';
  24. break;
  25.  
  26. case EmailCondition::EC_OPERATOR_LESSTHAN:
  27. $sKey .= 'LessThan';
  28. break;
  29.  
  30. case EmailCondition::EC_OPERATOR_LIKE:
  31. $sKey .= ':PartialMatch';
  32. break;
  33.  
  34. default:
  35. $sKey .= ':ExactMatch';
  36. break;
  37.  
  38. }
  39.  
  40. switch ( $oCondition->ConditionAction )
  41. {
  42. case EmailCondition::EC_ACTION_INCLUDE:
  43. $aIncludes[$sKey] = $oCondition->FieldValue;
  44. break;
  45.  
  46. case EmailCondition::EC_ACTION_EXCLUDE:
  47. $aExcludes[$sKey] = $oCondition->FieldValue;
  48. break;
  49. }
  50.  
  51. }
  52.  
  53. $this->QueuedEmails()->removeAll();
  54.  
  55. $oQueues = Contact::get()->filter($aIncludes)->exclude($aExcludes);
  56.  
  57. foreach ( $oQueues as $oQueued )
  58. {
  59. $aInsert = array();
  60. $aInsert['ContactID'] = $oQueued->ID;
  61. $aInsert['EmailCampaignID'] = $this->ID;
  62. $aInsert['Sent'] = 0;
  63. $aInsert['SentDate'] = '0000-00-00';
  64. $aInsert['SentTime'] = '00:00:00';
  65. ContactEmailQueued::create($aInsert)->write();
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement