INFRA-132 - Fix incorrect param types
[civicrm-core.git] / CRM / Activity / Selector / Activity.php
index 1c38efc0c79561551893a031d5dcba961048a0c9..02606caacb584744f327f13aa145bc031f4a23f4 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
@@ -40,7 +40,7 @@
 class CRM_Activity_Selector_Activity extends CRM_Core_Selector_Base implements CRM_Core_Selector_API {
 
   /**
-   * 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
@@ -48,10 +48,9 @@ class CRM_Activity_Selector_Activity extends CRM_Core_Selector_Base implements C
   static $_columnHeaders;
 
   /**
-   * contactId - contact id of contact whose activies are displayed
+   * ContactId - contact id of contact whose activies are displayed
    *
    * @var int
-   * @access protected
    */
   protected $_contactId;
 
@@ -66,21 +65,24 @@ class CRM_Activity_Selector_Activity extends CRM_Core_Selector_Base implements C
   /**
    * Class constructor
    *
-   * @param int $contactId - contact whose activities we want to display
-   * @param int $permission - the permission we have for this contact
+   * @param int $contactId
+   *   Contact whose activities we want to display.
+   * @param int $permission
+   *   The permission we have for this contact.
    *
    * @param bool $admin
    * @param string $context
    * @param null $activityTypeIDs
    *
    * @return \CRM_Activity_Selector_Activity
-  @access public
+   * @access public
    */
-  function __construct($contactId,
-                       $permission,
-                       $admin           = FALSE,
-                       $context         = 'activity',
-                       $activityTypeIDs = NULL) {
+  function __construct(
+    $contactId,
+    $permission,
+    $admin = FALSE,
+    $context = 'activity',
+    $activityTypeIDs = NULL) {
     $this->_contactId = $contactId;
     $this->_permission = $permission;
     $this->_admin = $admin;
@@ -99,24 +101,22 @@ class CRM_Activity_Selector_Activity extends CRM_Core_Selector_Base implements C
    *
    * - View
    *
-   * @param $activityTypeId
-   * @param null $sourceRecordId
+   * @param int $activityTypeId
+   * @param int $sourceRecordId
    * @param bool $accessMailingReport
-   * @param null $activityId
+   * @param int $activityId
    * @param null $key
    * @param null $compContext
    *
-   * @internal param string $activityType type of activity
-   *
    * @return array
-   * @access public
    */
-  public static function actionLinks($activityTypeId,
-                                     $sourceRecordId      = NULL,
-                                     $accessMailingReport = FALSE,
-                                     $activityId          = NULL,
-                                     $key                 = NULL,
-                                     $compContext         = NULL) {
+  public static function actionLinks(
+    $activityTypeId,
+    $sourceRecordId = NULL,
+    $accessMailingReport = FALSE,
+    $activityId = NULL,
+    $key = NULL,
+    $compContext = NULL) {
     static $activityActTypes = NULL;
     //CRM-14277 added addtitional param to handle activity search
     $extraParams = "&searchContext=activity";
@@ -126,7 +126,7 @@ class CRM_Activity_Selector_Activity extends CRM_Core_Selector_Base implements C
       $extraParams .= "&compContext={$compContext}";
     }
 
-    $showView   = TRUE;
+    $showView = TRUE;
     $showUpdate = $showDelete = FALSE;
     $qsUpdate = NULL;
 
@@ -175,7 +175,7 @@ class CRM_Activity_Selector_Activity extends CRM_Core_Selector_Base implements C
 
       case 'Email':
       case 'Bulk Email':
-        $url    = 'civicrm/activity/view';
+        $url = 'civicrm/activity/view';
         $delUrl = 'civicrm/activity';
         $qsView = "atype={$activityTypeId}&action=view&reset=1&id=%%id%%&cid=%%cid%%&context=%%cxt%%{$extraParams}";
         if ($activityTypeName == 'Email') {
@@ -193,15 +193,15 @@ class CRM_Activity_Selector_Activity extends CRM_Core_Selector_Base implements C
       case 'Change Case Status':
       case 'Change Case Start Date':
         $showUpdate = $showDelete = FALSE;
-        $url        = 'civicrm/activity';
-        $qsView     = "atype={$activityTypeId}&action=view&reset=1&id=%%id%%&cid=%%cid%%&context=%%cxt%%{$extraParams}";
-        $qsUpdate   = "atype={$activityTypeId}&action=update&reset=1&id=%%id%%&cid=%%cid%%&context=%%cxt%%{$extraParams}";
+        $url = 'civicrm/activity';
+        $qsView = "atype={$activityTypeId}&action=view&reset=1&id=%%id%%&cid=%%cid%%&context=%%cxt%%{$extraParams}";
+        $qsUpdate = "atype={$activityTypeId}&action=update&reset=1&id=%%id%%&cid=%%cid%%&context=%%cxt%%{$extraParams}";
         break;
 
       default:
-        $url      = 'civicrm/activity';
+        $url = 'civicrm/activity';
         $showView = $showDelete = $showUpdate = TRUE;
-        $qsView   = "atype={$activityTypeId}&action=view&reset=1&id=%%id%%&cid=%%cid%%&context=%%cxt%%{$extraParams}";
+        $qsView = "atype={$activityTypeId}&action=view&reset=1&id=%%id%%&cid=%%cid%%&context=%%cxt%%{$extraParams}";
         $qsUpdate = "atype={$activityTypeId}&action=update&reset=1&id=%%id%%&cid=%%cid%%&context=%%cxt%%{$extraParams}";
 
         //when type is not available lets hide view and update.
@@ -216,11 +216,15 @@ class CRM_Activity_Selector_Activity extends CRM_Core_Selector_Base implements C
     $actionLinks = array();
 
     if ($showView) {
-      $actionLinks += array(CRM_Core_Action::VIEW => array('name' => ts('View'),
-        'url' => $url,
-        'qs' => $qsView,
-        'title' => ts('View Activity'),
-      ));
+      $actionLinks += array(
+        CRM_Core_Action::
+        VIEW => array(
+          'name' => ts('View'),
+          'url' => $url,
+          'qs' => $qsView,
+          'title' => ts('View Activity'),
+        )
+      );
     }
 
     if ($showUpdate) {
@@ -231,12 +235,16 @@ class CRM_Activity_Selector_Activity extends CRM_Core_Selector_Base implements C
       elseif ($activityTypeName == 'Print PDF Letter') {
         $updateUrl = 'civicrm/activity/pdf/add';
       }
-      if ( CRM_Activity_BAO_Activity::checkPermission($activityId, CRM_Core_Action::UPDATE) ) {
-        $actionLinks += array(CRM_Core_Action::UPDATE => array('name' => ts('Edit'),
-          'url' => $updateUrl,
-          'qs' => $qsUpdate,
-          'title' => ts('Update Activity'),
-        ));
+      if (CRM_Activity_BAO_Activity::checkPermission($activityId, CRM_Core_Action::UPDATE)) {
+        $actionLinks += array(
+          CRM_Core_Action::
+          UPDATE => array(
+            'name' => ts('Edit'),
+            'url' => $updateUrl,
+            'qs' => $qsUpdate,
+            'title' => ts('Update Activity'),
+          )
+        );
       }
     }
 
@@ -244,64 +252,75 @@ class CRM_Activity_Selector_Activity extends CRM_Core_Selector_Base implements C
       $activityTypeName &&
       CRM_Case_BAO_Case::checkPermission($activityId, 'File On Case', $activityTypeId)
     ) {
-      $actionLinks += array(CRM_Core_Action::ADD => array('name' => ts('File on Case'),
-        'url' => '#',
-        'extra' => 'onclick="javascript:fileOnCase( \'file\', \'%%id%%\', null, this ); return false;"',
-        'title' => ts('File on Case'),
-      ));
+      $actionLinks += array(
+        CRM_Core_Action::
+        ADD => array(
+          'name' => ts('File on Case'),
+          'url' => '#',
+          'extra' => 'onclick="javascript:fileOnCase( \'file\', \'%%id%%\', null, this ); return false;"',
+          'title' => ts('File on Case'),
+        )
+      );
     }
 
     if ($showDelete) {
       if (!isset($delUrl) || !$delUrl) {
         $delUrl = $url;
       }
-      $actionLinks += array(CRM_Core_Action::DELETE => array('name' => ts('Delete'),
-        'url' => $delUrl,
-        'qs' => $qsDelete,
-        'title' => ts('Delete Activity'),
-      ));
+      $actionLinks += array(
+        CRM_Core_Action::
+        DELETE => array(
+          'name' => ts('Delete'),
+          'url' => $delUrl,
+          'qs' => $qsDelete,
+          'title' => ts('Delete Activity'),
+        )
+      );
     }
 
     if ($accessMailingReport) {
-      $actionLinks += array(CRM_Core_Action::BROWSE => array('name' => ts('Mailing Report'),
-        'url' => 'civicrm/mailing/report',
-        'qs' => "mid={$sourceRecordId}&reset=1&cid=%%cid%%&context=activitySelector",
-        'title' => ts('View Mailing Report'),
-      ));
+      $actionLinks += array(
+        CRM_Core_Action::
+        BROWSE => array(
+          'name' => ts('Mailing Report'),
+          'url' => 'civicrm/mailing/report',
+          'qs' => "mid={$sourceRecordId}&reset=1&cid=%%cid%%&context=activitySelector",
+          'title' => ts('View Mailing Report'),
+        )
+      );
     }
 
     return $actionLinks;
   }
 
   /**
-   * getter for array of the parameters required for creating pager.
+   * Getter for array of the parameters required for creating pager.
    *
    * @param $action
-   * @param $params
-   *
-   * @internal param $
-   * @access public
+   * @param array $params
    */
-  function getPagerParams($action, &$params) {
-    $params['status']    = ts('Activities %%StatusMessage%%');
+  public function getPagerParams($action, &$params) {
+    $params['status'] = ts('Activities %%StatusMessage%%');
     $params['csvString'] = NULL;
-    $params['rowCount']  = CRM_Utils_Pager::ROWCOUNT;
+    $params['rowCount'] = CRM_Utils_Pager::ROWCOUNT;
 
     $params['buttonTop'] = 'PagerTopButton';
     $params['buttonBottom'] = 'PagerBottomButton';
   }
 
   /**
-   * 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 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) {
     if ($output == CRM_Core_Selector_Controller::EXPORT || $output == CRM_Core_Selector_Controller::SCREEN) {
       $csvHeaders = array(ts('Activity Type'), ts('Description'), ts('Activity Date'));
       foreach (self::_getColumnHeaders() as $column) {
@@ -319,14 +338,15 @@ class CRM_Activity_Selector_Activity extends CRM_Core_Selector_Base implements C
   /**
    * Returns total number of rows for the query.
    *
-   * @param string $action - action being performed
+   * @param string $action
+   *   Action being performed.
    *
    * @param null $case
    *
-   * @return int Total number of rows
-   * @access public
+   * @return int
+   *   Total number of rows
    */
-  function getTotalCount($action, $case = NULL) {
+  public function getTotalCount($action, $case = NULL) {
     $params = array(
       'contact_id' => $this->_contactId,
       'admin' => $this->_admin,
@@ -341,19 +361,25 @@ class CRM_Activity_Selector_Activity extends CRM_Core_Selector_Base implements C
   }
 
   /**
-   * 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 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).
    *
    * @param null $case
    *
-   * @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, $case = NULL) {
+  public function &getRows($action, $offset, $rowCount, $sort, $output = NULL, $case = NULL) {
     $params = array(
       'contact_id' => $this->_contactId,
       'admin' => $this->_admin,
@@ -467,35 +493,39 @@ class CRM_Activity_Selector_Activity extends CRM_Core_Selector_Base implements C
   }
 
   /**
-   * 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
+   * @return string
+   *   name of the file
    */
-  function getExportFileName($output = 'csv') {
+  public function getExportFileName($output = 'csv') {
     return ts('CiviCRM Activity');
   }
 
   /**
-   * get colunmn headers for search selector
+   * Get colunmn headers for search selector
    *
    *
-   * @return array $_columnHeaders
-   * @access private
+   * @return array
    */
   private static function &_getColumnHeaders() {
     if (!isset(self::$_columnHeaders)) {
       self::$_columnHeaders = array(
-        array('name' => ts('Type'),
+        array(
+          'name' => ts('Type'),
           'sort' => 'activity_type',
           'direction' => CRM_Utils_Sort::DONTCARE,
         ),
-        array('name' => ts('Subject'),
+        array(
+          'name' => ts('Subject'),
           'sort' => 'subject',
           'direction' => CRM_Utils_Sort::DONTCARE,
         ),
-        array('name' => ts('Added By'),
+        array(
+          'name' => ts('Added By'),
           'sort' => 'source_contact_name',
           'direction' => CRM_Utils_Sort::DONTCARE,
         ),
@@ -518,4 +548,3 @@ class CRM_Activity_Selector_Activity extends CRM_Core_Selector_Base implements C
     return self::$_columnHeaders;
   }
 }
-