INFRA-132 - CRM/Activity - phpcbf
[civicrm-core.git] / CRM / Activity / Selector / Search.php
index 910ff505370af50e6528f5af43f54e840d092c75..c46c439b4678dc5332eec44c346c9a9be35f5556 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
@@ -49,7 +49,7 @@ class CRM_Activity_Selector_Search extends CRM_Core_Selector_Base implements CRM
   static $_links = NULL;
 
   /**
-   * we use desc to remind us what that column is, name is used in the tpl
+   * We use desc to remind us what that column is, name is used in the tpl
    *
    * @var array
    * @static
@@ -82,51 +82,45 @@ class CRM_Activity_Selector_Search extends CRM_Core_Selector_Base implements CRM
   );
 
   /**
-   * are we restricting ourselves to a single contact
+   * Are we restricting ourselves to a single contact
    *
-   * @access protected
    * @var boolean
    */
   protected $_single = FALSE;
 
   /**
-   * are we restricting ourselves to a single contact
+   * Are we restricting ourselves to a single contact
    *
-   * @access protected
    * @var boolean
    */
   protected $_limit = NULL;
 
   /**
-   * what context are we being invoked from
+   * What context are we being invoked from
    *
-   * @access protected
    * @var string
    */
   protected $_context = NULL;
 
   /**
-   * what component context are we being invoked from
+   * What component context are we being invoked from
    *
-   * @access protected
    * @var string
    */
   protected $_compContext = NULL;
 
   /**
-   * queryParams is the array returned by exportValues called on
+   * QueryParams is the array returned by exportValues called on
    * the HTML_QuickForm_Controller for that page.
    *
    * @var array
-   * @access protected
    */
   public $_queryParams;
 
   /**
-   * represent the type of selector
+   * Represent the type of selector
    *
    * @var int
-   * @access protected
    */
   protected $_action;
 
@@ -147,11 +141,15 @@ class CRM_Activity_Selector_Search extends CRM_Core_Selector_Base implements CRM
   /**
    * Class constructor
    *
-   * @param array $queryParams array of parameters for query
+   * @param array $queryParams
+   *   Array of parameters for query.
    * @param \const|int $action - action of search basic or advanced.
-   * @param string $activityClause if the caller wants to further restrict the search (used in activities)
-   * @param boolean $single are we dealing only with one contact?
-   * @param int $limit how many activities do we want returned
+   * @param string $activityClause
+   *   If the caller wants to further restrict the search (used in activities).
+   * @param bool $single
+   *   Are we dealing only with one contact?.
+   * @param int $limit
+   *   How many activities do we want returned.
    *
    * @param string $context
    * @param null $compContext
@@ -160,12 +158,12 @@ class CRM_Activity_Selector_Search extends CRM_Core_Selector_Base implements CRM
   @access public
    */
   function __construct(&$queryParams,
-    $action         = CRM_Core_Action::NONE,
+    $action = CRM_Core_Action::NONE,
     $activityClause = NULL,
-    $single         = FALSE,
-    $limit          = NULL,
-    $context        = 'search',
-    $compContext    = NULL
+    $single = FALSE,
+    $limit = NULL,
+    $context = 'search',
+    $compContext = NULL
   ) {
     // submitted form values
     $this->_queryParams = &$queryParams;
@@ -188,27 +186,22 @@ class CRM_Activity_Selector_Search extends CRM_Core_Selector_Base implements CRM
     );
     $this->_query->_distinctComponentClause = '( civicrm_activity.id )';
     $this->_query->_groupByComponentClause = " GROUP BY civicrm_activity.id ";
-    //CRM_Core_Error::debug( $this->_query ); exit();
   }
-  //end of constructor
 
   /**
-   * getter for array of the parameters required for creating pager.
+   * Getter for array of the parameters required for creating pager.
    *
    * @param $action
-   * @param $params
+   * @param array $params
    *
-   * @internal param $
-   * @access public
    */
-  function getPagerParams($action, &$params) {
+  public function getPagerParams($action, &$params) {
     $params['status'] = ts('Activities %%StatusMessage%%');
     $params['csvString'] = NULL;
     $params['rowCount'] = CRM_Utils_Pager::ROWCOUNT;
     $params['buttonTop'] = 'PagerTopButton';
     $params['buttonBottom'] = 'PagerBottomButton';
   }
-  //end of function
 
   /**
    * Returns total number of rows for the query.
@@ -216,9 +209,8 @@ class CRM_Activity_Selector_Search extends CRM_Core_Selector_Base implements CRM
    * @param
    *
    * @return int Total number of rows
-   * @access public
    */
-  function getTotalCount($action) {
+  public function getTotalCount($action) {
     return $this->_query->searchQuery(0, 0, NULL,
       TRUE, FALSE,
       FALSE, FALSE,
@@ -228,17 +220,22 @@ class CRM_Activity_Selector_Search extends CRM_Core_Selector_Base implements CRM
   }
 
   /**
-   * returns all the rows in the given offset and rowCount
+   * 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 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 array  rows in the given offset and rowCount
    */
-  function &getRows($action, $offset, $rowCount, $sort, $output = NULL) {
+  public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) {
     $result = $this->_query->searchQuery(
       $offset, $rowCount, $sort,
       FALSE, FALSE,
@@ -290,8 +287,7 @@ class CRM_Activity_Selector_Search extends CRM_Core_Selector_Base implements CRM
       if ($this->_context == 'search') {
         $row['checkbox'] = CRM_Core_Form::CB_PREFIX . $result->activity_id;
       }
-      $row['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ?
-        $result->contact_sub_type : $result->contact_type, FALSE, $result->contact_id
+      $row['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type, FALSE, $result->contact_id
       );
       $accessMailingReport = FALSE;
       $activityTypeId      = $row['activity_type_id'];
@@ -344,6 +340,17 @@ class CRM_Activity_Selector_Search extends CRM_Core_Selector_Base implements CRM
         );
       }
 
+      //Check if recurring activity
+      $isRecurringActivity = CRM_Core_BAO_RecurringEntity::getParentFor($row['activity_id'], 'civicrm_activity');
+      $row['repeat'] = '';
+      if ($isRecurringActivity) {
+        if ($row['activity_id'] == $isRecurringActivity) {
+          $row['repeat'] = 'Recurring Activity - (Parent)';
+        }
+        else {
+          $row['repeat'] = 'Recurring Activity - (Child)';
+        }
+      }
       $rows[] = $row;
     }
 
@@ -351,23 +358,22 @@ class CRM_Activity_Selector_Search extends CRM_Core_Selector_Base implements CRM
   }
 
   /**
-   *
    * @return array  $qill  which contains an array of strings
-   * @access public
    */
   public function getQILL() {
     return $this->_query->qill();
   }
 
   /**
-   * returns the column headers as an array of tuples:
+   * 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 enum $output
+   *   What should the result set include (web/email/csv).
    *
    * @return array the column headers that need to be displayed
-   * @access public
    */
   public function &getColumnHeaders($action = NULL, $output = NULL) {
     if (!isset(self::$_columnHeaders)) {
@@ -379,7 +385,7 @@ class CRM_Activity_Selector_Search extends CRM_Core_Selector_Base implements CRM
         ),
         array(
           'name' => ts('Subject'),
-          'sort' => 'subject',
+          'sort' => 'activity_subject',
           'direction' => CRM_Utils_Sort::DONTCARE,
         ),
         array(
@@ -396,7 +402,7 @@ class CRM_Activity_Selector_Search extends CRM_Core_Selector_Base implements CRM
         ),
         array(
           'name' => ts('Status'),
-          'sort' => 'status_id',
+          'sort' => 'activity_status',
           'direction' => CRM_Utils_Sort::DONTCARE,
         ),
         array(
@@ -410,27 +416,26 @@ class CRM_Activity_Selector_Search extends CRM_Core_Selector_Base implements CRM
   /**
    * @return mixed
    */
-  function alphabetQuery() {
+  public function alphabetQuery() {
     return $this->_query->searchQuery(NULL, NULL, NULL, FALSE, FALSE, TRUE);
   }
 
   /**
    * @return string
    */
-  function &getQuery() {
+  public function &getQuery() {
     return $this->_query;
   }
 
   /**
-   * name of export file.
+   * Name of export file.
    *
-   * @param string $output type of output
+   * @param string $output
+   *   Type of output.
    *
    * @return string name of the file
    */
-  function getExportFileName($output = 'csv') {
+  public function getExportFileName($output = 'csv') {
     return ts('CiviCRM Activity Search');
   }
 }
-//end of class
-