Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function updateQueuedContacts ()
- {
- /**
- * @var DataList
- */
- $oTemplate = $this->EmailTemplate();
- /**
- * @var DataList
- */
- $oConditions = $this->EmailConditions();
- $aIncludes = array();
- $aExcludes = array();
- foreach ( $oConditions as /* @var $oCondition EmailCondition */ $oCondition )
- {
- $sKey = $oCondition->ContactField;
- switch ( $oCondition->ConditionOperator )
- {
- case EmailCondition::EC_OPERATOR_GREATERTHAN:
- $sKey .= ':GreaterThan';
- break;
- case EmailCondition::EC_OPERATOR_LESSTHAN:
- $sKey .= 'LessThan';
- break;
- case EmailCondition::EC_OPERATOR_LIKE:
- $sKey .= ':PartialMatch';
- break;
- default:
- $sKey .= ':ExactMatch';
- break;
- }
- switch ( $oCondition->ConditionAction )
- {
- case EmailCondition::EC_ACTION_INCLUDE:
- $aIncludes[$sKey] = $oCondition->FieldValue;
- break;
- case EmailCondition::EC_ACTION_EXCLUDE:
- $aExcludes[$sKey] = $oCondition->FieldValue;
- break;
- }
- }
- $this->QueuedEmails()->removeAll();
- $oQueues = Contact::get()->filter($aIncludes)->exclude($aExcludes);
- foreach ( $oQueues as $oQueued )
- {
- $aInsert = array();
- $aInsert['ContactID'] = $oQueued->ID;
- $aInsert['EmailCampaignID'] = $this->ID;
- $aInsert['Sent'] = 0;
- $aInsert['SentDate'] = '0000-00-00';
- $aInsert['SentTime'] = '00:00:00';
- ContactEmailQueued::create($aInsert)->write();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement