more tidy ups
[civicrm-core.git] / CRM / Mailing / Selector / Event.php
index fe09cbff07e53dd4427a0c45ee498dd0bcd5900a..eefd5ede4bf10680002c4e5e705d17359084a269 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
@@ -45,7 +45,6 @@ class CRM_Mailing_Selector_Event extends CRM_Core_Selector_Base implements CRM_C
    * Array of supported links, currenly null
    *
    * @var array
-   * @static
    */
   static $_links = NULL;
 
@@ -84,31 +83,33 @@ class CRM_Mailing_Selector_Event extends CRM_Core_Selector_Base implements CRM_C
   /**
    * Class constructor
    *
-   * @param string $event The event type (queue/delivered/open...)
-   * @param boolean $distinct Count only distinct contact events?
-   * @param int $mailing ID of the mailing to query
-   * @param int $job ID of the job to query.  If null, all jobs from $mailing are queried.
-   * @param int $url If the event type is a click-through, do we want only those from a specific url?
+   * @param string $event
+   *   The event type (queue/delivered/open...).
+   * @param bool $distinct
+   *   Count only distinct contact events?.
+   * @param int $mailing
+   *   ID of the mailing to query.
+   * @param int $job
+   *   ID of the job to query. If null, all jobs from $mailing are queried.
+   * @param int $url
+   *   If the event type is a click-through, do we want only those from a specific url?.
    *
    * @return \CRM_Mailing_Selector_Event
-  @access public
    */
-  function __construct($event, $distinct, $mailing, $job = NULL, $url = NULL) {
-    $this->_event_type  = $event;
+  public function __construct($event, $distinct, $mailing, $job = NULL, $url = NULL) {
+    $this->_event_type = $event;
     $this->_is_distinct = $distinct;
-    $this->_mailing_id  = $mailing;
-    $this->_job_id      = $job;
-    $this->_url_id      = $url;
+    $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
-   * @access public
-   * @static
    */
-  static function &links() {
+  public static function &links() {
     return self::$_links;
   }
 
@@ -117,13 +118,11 @@ class CRM_Mailing_Selector_Event extends CRM_Core_Selector_Base implements CRM_C
    *
    * @param $action
    * @param array $params
-   *
-   * @access public
    */
-  function getPagerParams($action, &$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['rowCount'] = CRM_Utils_Pager::ROWCOUNT;
+    $params['status'] = ts('%1 %%StatusMessage%%', array(1 => $this->eventToTitle()));
     $params['buttonTop'] = 'PagerTopButton';
     $params['buttonBottom'] = 'PagerBottomButton';
   }
@@ -132,13 +131,15 @@ class CRM_Mailing_Selector_Event extends CRM_Core_Selector_Base implements CRM_C
    * 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)
+   * @param string $action
+   *   The action being performed.
+   * @param string $output
+   *   What should the result set include (web/email/csv).
    *
-   * @return array the column headers that need to be displayed
-   * @access public
+   * @return array
+   *   the column headers that need to be displayed
    */
-  function &getColumnHeaders($action = NULL, $output = NULL) {
+  public function &getColumnHeaders($action = NULL, $output = NULL) {
     $mailing = CRM_Mailing_BAO_Mailing::getTableName();
 
     $contact = CRM_Contact_BAO_Contact::getTableName();
@@ -208,27 +209,27 @@ class CRM_Mailing_Selector_Event extends CRM_Core_Selector_Base implements CRM_C
           $dateSort = CRM_Mailing_Event_BAO_Unsubscribe::getTableName() . '.time_stamp';
           $this->_columnHeaders = array_merge($this->_columnHeaders, array(
             array(
-                'name' => ts('Unsubscribe'),
-              ),
-            ));
+              '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'),
-              ),
-            ));
+              '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'),
-              ),
-            ));
+              'name' => ts('URL'),
+            ),
+          ));
           break;
 
         default:
@@ -253,83 +254,83 @@ class CRM_Mailing_Selector_Event extends CRM_Core_Selector_Base implements CRM_C
    *
    * @param
    *
-   * @return int Total number of rows
-   * @access public
+   * @return int
+   *   Total number of rows
    */
-  function getTotalCount($action) {
+  public function getTotalCount($action) {
     switch ($this->_event_type) {
       case 'queue':
         $event = new CRM_Mailing_Event_BAO_Queue();
-        return $event->getTotalCount($this->_mailing_id,
+        $result = $event->getTotalCount($this->_mailing_id,
           $this->_job_id
         );
-      break;
+        return $result;
 
       case 'delivered':
         $event = new CRM_Mailing_Event_BAO_Delivered();
-        return $event->getTotalCount($this->_mailing_id,
+        $result = $event->getTotalCount($this->_mailing_id,
           $this->_job_id,
           $this->_is_distinct
         );
-      break;
+        return $result;
 
       case 'opened':
         $event = new CRM_Mailing_Event_BAO_Opened();
-        return $event->getTotalCount($this->_mailing_id,
+        $result = $event->getTotalCount($this->_mailing_id,
           $this->_job_id,
           $this->_is_distinct
         );
-      break;
+        return $result;
 
       case 'bounce':
         $event = new CRM_Mailing_Event_BAO_Bounce();
-        return $event->getTotalCount($this->_mailing_id,
+        $result = $event->getTotalCount($this->_mailing_id,
           $this->_job_id,
           $this->_is_distinct
         );
-      break;
+        return $result;
 
       case 'forward':
         $event = new CRM_Mailing_Event_BAO_Forward();
-        return $event->getTotalCount($this->_mailing_id,
+        $result = $event->getTotalCount($this->_mailing_id,
           $this->_job_id,
           $this->_is_distinct
         );
-      break;
+        return $result;
 
       case 'reply':
         $event = new CRM_Mailing_Event_BAO_Reply();
-        return $event->getTotalCount($this->_mailing_id,
+        $result = $event->getTotalCount($this->_mailing_id,
           $this->_job_id,
           $this->_is_distinct
         );
-      break;
+        return $result;
 
       case 'unsubscribe':
         $event = new CRM_Mailing_Event_BAO_Unsubscribe();
-        return $event->getTotalCount($this->_mailing_id,
+        $result = $event->getTotalCount($this->_mailing_id,
           $this->_job_id,
           $this->_is_distinct
         );
-      break;
+        return $result;
 
       case 'optout':
         $event = new CRM_Mailing_Event_BAO_Unsubscribe();
-        return $event->getTotalCount($this->_mailing_id,
+        $result = $event->getTotalCount($this->_mailing_id,
           $this->_job_id,
           $this->_is_distinct,
           FALSE
         );
-      break;
+        return $result;
 
       case 'click':
         $event = new CRM_Mailing_Event_BAO_TrackableURLOpen();
-        return $event->getTotalCount($this->_mailing_id,
+        $result = $event->getTotalCount($this->_mailing_id,
           $this->_job_id,
           $this->_is_distinct,
           $this->_url_id
         );
-      break;
+        return $result;
 
       default:
         return 0;
@@ -339,77 +340,84 @@ class CRM_Mailing_Selector_Event extends CRM_Core_Selector_Base implements CRM_C
   /**
    * 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)
+   * @param string $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 string $output
+   *   What should the result set include (web/email/csv).
    *
-   * @return int   the total number of rows for this action
+   * @return int
+   *   the total number of rows for this action
    */
-  function &getRows($action, $offset, $rowCount, $sort, $output = NULL) {
+  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,
+        $rows = CRM_Mailing_Event_BAO_Queue::getRows($this->_mailing_id,
           $this->_job_id, $offset, $rowCount, $sort
         );
-      break;
+        return $rows;
 
       case 'delivered':
-        return CRM_Mailing_Event_BAO_Delivered::getRows($this->_mailing_id,
+        $rows = CRM_Mailing_Event_BAO_Delivered::getRows($this->_mailing_id,
           $this->_job_id, $this->_is_distinct,
           $offset, $rowCount, $sort
         );
-      break;
+        return $rows;
 
       case 'opened':
-        return CRM_Mailing_Event_BAO_Opened::getRows($this->_mailing_id,
+        $rows = CRM_Mailing_Event_BAO_Opened::getRows($this->_mailing_id,
           $this->_job_id, $this->_is_distinct,
           $offset, $rowCount, $sort
         );
-      break;
+        return $rows;
 
       case 'bounce':
-        return CRM_Mailing_Event_BAO_Bounce::getRows($this->_mailing_id,
+        $rows = CRM_Mailing_Event_BAO_Bounce::getRows($this->_mailing_id,
           $this->_job_id, $this->_is_distinct,
           $offset, $rowCount, $sort
         );
-      break;
+        return $rows;
 
       case 'forward':
-        return CRM_Mailing_Event_BAO_Forward::getRows($this->_mailing_id,
+        $rows = CRM_Mailing_Event_BAO_Forward::getRows($this->_mailing_id,
           $this->_job_id, $this->_is_distinct,
           $offset, $rowCount, $sort
         );
+        return $rows;
 
       case 'reply':
-        return CRM_Mailing_Event_BAO_Reply::getRows($this->_mailing_id,
+        $rows = CRM_Mailing_Event_BAO_Reply::getRows($this->_mailing_id,
           $this->_job_id, $this->_is_distinct,
           $offset, $rowCount, $sort
         );
-      break;
+        return $rows;
 
       case 'unsubscribe':
-        return CRM_Mailing_Event_BAO_Unsubscribe::getRows($this->_mailing_id,
+        $rows = CRM_Mailing_Event_BAO_Unsubscribe::getRows($this->_mailing_id,
           $this->_job_id, $this->_is_distinct,
           $offset, $rowCount, $sort, TRUE
         );
-      break;
+        return $rows;
 
       case 'optout':
-        return CRM_Mailing_Event_BAO_Unsubscribe::getRows($this->_mailing_id,
+        $rows = CRM_Mailing_Event_BAO_Unsubscribe::getRows($this->_mailing_id,
           $this->_job_id, $this->_is_distinct,
           $offset, $rowCount, $sort, FALSE
         );
-      break;
+        return $rows;
 
       case 'click':
-        return CRM_Mailing_Event_BAO_TrackableURLOpen::getRows(
+        $rows = CRM_Mailing_Event_BAO_TrackableURLOpen::getRows(
           $this->_mailing_id, $this->_job_id,
           $this->_is_distinct, $this->_url_id,
           $offset, $rowCount, $sort
         );
-      break;
+        return $rows;
 
       default:
         return NULL;
@@ -419,13 +427,17 @@ class CRM_Mailing_Selector_Event extends CRM_Core_Selector_Base implements CRM_C
   /**
    * Name of export file.
    *
-   * @param string $output type of output
+   * @param string $output
+   *   Type of output.
    *
-   * @return string name of the file
+   * @return string|NULL
+   *   name of the file
    */
-  function getExportFileName($output = 'csv') {}
+  public function getExportFileName($output = 'csv') {
+    return NULL;
+  }
 
-  function eventToTitle() {
+  public function eventToTitle() {
     static $events = NULL;
 
     if (empty($events)) {
@@ -434,24 +446,17 @@ class CRM_Mailing_Selector_Event extends CRM_Core_Selector_Base implements CRM_C
         'delivered' => ts('Successful Deliveries'),
         'bounce' => ts('Bounces'),
         'forward' => ts('Forwards'),
-        'reply' => $this->_is_distinct
-         ? ts('Unique Replies')
-         : ts('Replies'),
+        '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'),
+        '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];
   }
 
-  function getTitle() {
+  public function getTitle() {
     return $this->eventToTitle();
   }
 }
-