_event_type = $event; $this->_is_distinct = $distinct; $this->_mailing_id = $mailing; $this->_job_id = $job; $this->_url_id = $url; } /** * This method returns the links that are given for each search row. * * @return array * @static */ public static function &links() { return self::$_links; } /** * Getter for array of the parameters required for creating pager. * * @param $action * @param array $params */ public function getPagerParams($action, &$params) { $params['csvString'] = NULL; $params['rowCount'] = CRM_Utils_Pager::ROWCOUNT; $params['status'] = ts('%1 %%StatusMessage%%', array(1 => $this->eventToTitle())); $params['buttonTop'] = 'PagerTopButton'; $params['buttonBottom'] = 'PagerBottomButton'; } /** * Returns the column headers as an array of tuples: * (name, sortName (key to the sort array)) * * @param string $action * The action being performed. * @param enum $output * What should the result set include (web/email/csv). * * @return array * the column headers that need to be displayed */ public function &getColumnHeaders($action = NULL, $output = NULL) { $mailing = CRM_Mailing_BAO_Mailing::getTableName(); $contact = CRM_Contact_BAO_Contact::getTableName(); $email = CRM_Core_BAO_Email::getTableName(); $job = CRM_Mailing_BAO_MailingJob::getTableName(); if (!isset($this->_columnHeaders)) { $this->_columnHeaders = array( array( 'name' => ts('Contact'), 'sort' => $contact . '.sort_name', 'direction' => CRM_Utils_Sort::ASCENDING, ), array( 'name' => ts('Email Address'), 'sort' => $email . '.email', 'direction' => CRM_Utils_Sort::DONTCARE, ), ); switch ($this->_event_type) { case 'queue': $dateSort = $job . '.start_date'; break; case 'delivered': $dateSort = CRM_Mailing_Event_BAO_Delivered::getTableName() . '.time_stamp'; break; case 'opened': $dateSort = CRM_Mailing_Event_BAO_Opened::getTableName() . '.time_stamp'; break; case 'bounce': $dateSort = CRM_Mailing_Event_BAO_Bounce::getTableName() . '.time_stamp'; $this->_columnHeaders = array_merge($this->_columnHeaders, array( array( 'name' => ts('Bounce Type'), ), array( 'name' => ts('Bounce Reason'), ), ) ); break; case 'forward': $dateSort = CRM_Mailing_Event_BAO_Forward::getTableName() . '.time_stamp'; $this->_columnHeaders = array_merge($this->_columnHeaders, array( array( 'name' => ts('Forwarded Email'), ), ) ); break; case 'reply': $dateSort = CRM_Mailing_Event_BAO_Reply::getTableName() . '.time_stamp'; break; case 'unsubscribe': $dateSort = CRM_Mailing_Event_BAO_Unsubscribe::getTableName() . '.time_stamp'; $this->_columnHeaders = array_merge($this->_columnHeaders, array( array( 'name' => ts('Unsubscribe'), ), )); break; case 'optout': $dateSort = CRM_Mailing_Event_BAO_Unsubscribe::getTableName() . '.time_stamp'; $this->_columnHeaders = array_merge($this->_columnHeaders, array( array( 'name' => ts('Opt-Out'), ), )); break; case 'click': $dateSort = CRM_Mailing_Event_BAO_TrackableURLOpen::getTableName() . '.time_stamp'; $this->_columnHeaders = array_merge($this->_columnHeaders, array( array( 'name' => ts('URL'), ), )); break; default: return 0; } $this->_columnHeaders = array_merge($this->_columnHeaders, array( array( 'name' => ts('Date'), 'sort' => $dateSort, 'direction' => CRM_Utils_Sort::DESCENDING, ), ) ); } return $this->_columnHeaders; } /** * Returns total number of rows for the query. * * @param * * @return int * Total number of rows */ public function getTotalCount($action) { switch ($this->_event_type) { case 'queue': $event = new CRM_Mailing_Event_BAO_Queue(); return $event->getTotalCount($this->_mailing_id, $this->_job_id ); break; case 'delivered': $event = new CRM_Mailing_Event_BAO_Delivered(); return $event->getTotalCount($this->_mailing_id, $this->_job_id, $this->_is_distinct ); break; case 'opened': $event = new CRM_Mailing_Event_BAO_Opened(); return $event->getTotalCount($this->_mailing_id, $this->_job_id, $this->_is_distinct ); break; case 'bounce': $event = new CRM_Mailing_Event_BAO_Bounce(); return $event->getTotalCount($this->_mailing_id, $this->_job_id, $this->_is_distinct ); break; case 'forward': $event = new CRM_Mailing_Event_BAO_Forward(); return $event->getTotalCount($this->_mailing_id, $this->_job_id, $this->_is_distinct ); break; case 'reply': $event = new CRM_Mailing_Event_BAO_Reply(); return $event->getTotalCount($this->_mailing_id, $this->_job_id, $this->_is_distinct ); break; case 'unsubscribe': $event = new CRM_Mailing_Event_BAO_Unsubscribe(); return $event->getTotalCount($this->_mailing_id, $this->_job_id, $this->_is_distinct ); break; case 'optout': $event = new CRM_Mailing_Event_BAO_Unsubscribe(); return $event->getTotalCount($this->_mailing_id, $this->_job_id, $this->_is_distinct, FALSE ); break; case 'click': $event = new CRM_Mailing_Event_BAO_TrackableURLOpen(); return $event->getTotalCount($this->_mailing_id, $this->_job_id, $this->_is_distinct, $this->_url_id ); break; default: return 0; } } /** * Returns all the rows in the given offset and rowCount * * @param enum $action * The action being performed. * @param int $offset * The row number to start from. * @param int $rowCount * The number of rows to return. * @param string $sort * The sql string that describes the sort order. * @param enum $output * What should the result set include (web/email/csv). * * @return int * the total number of rows for this action */ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { switch ($this->_event_type) { case 'queue': return CRM_Mailing_Event_BAO_Queue::getRows($this->_mailing_id, $this->_job_id, $offset, $rowCount, $sort ); break; case 'delivered': return CRM_Mailing_Event_BAO_Delivered::getRows($this->_mailing_id, $this->_job_id, $this->_is_distinct, $offset, $rowCount, $sort ); break; case 'opened': return CRM_Mailing_Event_BAO_Opened::getRows($this->_mailing_id, $this->_job_id, $this->_is_distinct, $offset, $rowCount, $sort ); break; case 'bounce': return CRM_Mailing_Event_BAO_Bounce::getRows($this->_mailing_id, $this->_job_id, $this->_is_distinct, $offset, $rowCount, $sort ); break; case 'forward': return CRM_Mailing_Event_BAO_Forward::getRows($this->_mailing_id, $this->_job_id, $this->_is_distinct, $offset, $rowCount, $sort ); case 'reply': return CRM_Mailing_Event_BAO_Reply::getRows($this->_mailing_id, $this->_job_id, $this->_is_distinct, $offset, $rowCount, $sort ); break; case 'unsubscribe': return CRM_Mailing_Event_BAO_Unsubscribe::getRows($this->_mailing_id, $this->_job_id, $this->_is_distinct, $offset, $rowCount, $sort, TRUE ); break; case 'optout': return CRM_Mailing_Event_BAO_Unsubscribe::getRows($this->_mailing_id, $this->_job_id, $this->_is_distinct, $offset, $rowCount, $sort, FALSE ); break; case 'click': return CRM_Mailing_Event_BAO_TrackableURLOpen::getRows( $this->_mailing_id, $this->_job_id, $this->_is_distinct, $this->_url_id, $offset, $rowCount, $sort ); break; default: return NULL; } } /** * Name of export file. * * @param string $output * Type of output. * * @return string * name of the file */ public function getExportFileName($output = 'csv') {} public function eventToTitle() { static $events = NULL; if (empty($events)) { $events = array( 'queue' => ts('Intended Recipients'), 'delivered' => ts('Successful Deliveries'), 'bounce' => ts('Bounces'), 'forward' => ts('Forwards'), 'reply' => $this->_is_distinct ? ts('Unique Replies') : ts('Replies'), 'unsubscribe' => ts('Unsubscribe Requests'), 'optout' => ts('Opt-out Requests'), 'click' => $this->_is_distinct ? ts('Unique Click-throughs') : ts('Click-throughs'), 'opened' => $this->_is_distinct ? ts('Unique Tracked Opens') : ts('Tracked Opens'), ); } return $events[$this->_event_type]; } public function getTitle() { return $this->eventToTitle(); } }