/** * Register an open event. * * @param int $queue_id * The Queue Event ID of the recipient. */ public static function open($queue_id) { // First make sure there's a matching queue event. $success = FALSE; $q = new CRM_Mailing_Event_BAO_Queue(); $q->id = $queue_id; if ($q->find(TRUE)) { $oe = new CRM_Mailing_Event_BAO_Opened(); $oe->event_queue_id = $queue_id; $oe->time_stamp = date('YmdHis'); $oe->save(); $success = TRUE; } return $success; }
/** * Register an open event * * @param int $queue_id The Queue Event ID of the recipient * @return void * @access public * @static */ public static function open($queue_id) { /* First make sure there's a matching queue event */ require_once 'CRM/Mailing/Event/BAO/Queue.php'; $success = false; $q = new CRM_Mailing_Event_BAO_Queue(); $q->id = $queue_id; if ($q->find(true)) { $oe = new CRM_Mailing_Event_BAO_Opened(); $oe->event_queue_id = $queue_id; $oe->time_stamp = date('YmdHis'); $oe->save(); $success = true; } return $success; }
/** * Create a new delivery event * @param array $params Associative array of delivery event values * @return void * @access public * @static */ public static function &create(&$params) { $q =& CRM_Mailing_Event_BAO_Queue::verify($params['job_id'], $params['event_queue_id'], $params['hash']); if (!$q) { return null; } $q->free(); $delivered =& new CRM_Mailing_Event_BAO_Delivered(); $delivered->time_stamp = date('YmdHis'); $delivered->copyValues($params); $delivered->save(); $queue = new CRM_Mailing_Event_BAO_Queue(); $queue->id = $params['event_queue_id']; $queue->find(true); while ($queue->fetch()) { $email =& new CRM_Core_BAO_Email(); $email->id = $queue->email_id; $email->hold_date = ''; $email->reset_date = date('YmdHis'); $email->save(); } return $delivered; }
/** * Verify that a queue event exists with the specified id/job id/hash. * * @param int $job_id * The job ID of the event to find. * @param int $queue_id * The Queue Event ID to find. * @param string $hash * The hash to validate against. * * @return object|null * The queue event if verified, or null */ public static function &verify($job_id, $queue_id, $hash) { $success = NULL; $q = new CRM_Mailing_Event_BAO_Queue(); if (!empty($job_id) && !empty($queue_id) && !empty($hash)) { $q->id = $queue_id; $q->job_id = $job_id; $q->hash = $hash; if ($q->find(TRUE)) { $success = $q; } } return $success; }
/** * Helper function for Check contents in Activity. * @param $atype * @param $contactName * * return string */ public function _checkActivity($atype, $contactName, $subject, $withContact, $isHeader = TRUE, $mailingId = NULL) { $this->openCiviPage('activity/search', 'reset=1', '_qf_Search_refresh'); $this->select('activity_type_id', "label={$atype}"); $this->type('sort_name', $contactName); $this->clickLink('_qf_Search_refresh', 'Search'); // View your Activity $this->clickLink("xpath=id('Search')/div[3]/div/div[2]/table/tbody/tr[2]/td[9]/span/a[text()='View']", "_qf_Activity_cancel", FALSE); $this->assertTrue($this->isTextPresent($atype)); $expected = array(4 => $subject, 8 => 'Completed', 2 => $withContact, 10 => 'Urgent'); foreach ($expected as $label => $value) { $this->verifyText("xpath=id('Activity')/div[2]/table[1]/tbody/tr[{$label}]/td[2]", preg_quote($value)); } if (!$isHeader) { return FALSE; } $header = $this->urlArg('id', $this->getAttribute("xpath=id('Search')/div[3]/div/div[2]/table/tbody/tr[2]/td[9]/span/a[text()='View']@href")); if ($mailingId) { $cid = $this->urlArg('cid', $this->getAttribute("xpath=id('Search')/div[3]/div/div[2]/table/tbody/tr[2]/td[9]/span/a[text()='View']@href")); $queueId = CRM_Core_DAO::singleValueQuery("SELECT ce.id FROM `civicrm_mailing_event_queue` ce\nINNER JOIN civicrm_mailing_job mj ON mj.id = ce.job_id and ce.contact_id = {$cid} AND mj.mailing_id = {$mailingId}"); } else { $queueId = CRM_Core_DAO::singleValueQuery('SELECT mailing_queue_id FROM civicrm_mandrill_activity WHERE activity_id = ' . $header); } if ($queueId) { $queue = new CRM_Mailing_Event_BAO_Queue(); $queue->id = $queueId; if ($queue->find(TRUE)) { $header = implode(CRM_Core_Config::singleton()->verpSeparator, array($header, 'm', $queue->job_id, $queue->id, $queue->hash)); } } return $header; }