Merge pull request #6460 from yashodha/CRM-16943
[civicrm-core.git] / CRM / Mailing / Selector / Search.php
index 85563166fa3dd69b4dae2e95f3a3da7a93c6240f..584a8f3960f5117401618fa8155fe630dbc57da5 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014                                |
+ | Copyright CiviCRM LLC (c) 2004-2015                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
+ * @copyright CiviCRM LLC (c) 2004-2015
  * $Id$
  *
  */
@@ -45,7 +45,6 @@ class CRM_Mailing_Selector_Search extends CRM_Core_Selector_Base implements CRM_
    * This defines two actions- View and Edit.
    *
    * @var array
-   * @static
    */
   static $_links = NULL;
 
@@ -53,14 +52,12 @@ class CRM_Mailing_Selector_Search extends CRM_Core_Selector_Base implements CRM_
    * We use desc to remind us what that column is, name is used in the tpl
    *
    * @var array
-   * @static
    */
   static $_columnHeaders;
 
   /**
    * Properties of contact we're interested in displaying
    * @var array
-   * @static
    */
   static $_properties = array(
     'contact_id',
@@ -72,13 +69,12 @@ class CRM_Mailing_Selector_Search extends CRM_Core_Selector_Base implements CRM_
     'email_on_hold',
     'contact_opt_out',
     'mailing_job_status',
-    'mailing_job_end_date'
+    'mailing_job_end_date',
   );
 
   /**
    * Are we restricting ourselves to a single contact
    *
-   * @access protected
    * @var boolean
    */
   protected $_single = FALSE;
@@ -86,7 +82,6 @@ class CRM_Mailing_Selector_Search extends CRM_Core_Selector_Base implements CRM_
   /**
    * Are we restricting ourselves to a single contact
    *
-   * @access protected
    * @var boolean
    */
   protected $_limit = NULL;
@@ -94,7 +89,6 @@ class CRM_Mailing_Selector_Search extends CRM_Core_Selector_Base implements CRM_
   /**
    * What context are we being invoked from
    *
-   * @access protected
    * @var string
    */
   protected $_context = NULL;
@@ -102,7 +96,6 @@ class CRM_Mailing_Selector_Search extends CRM_Core_Selector_Base implements CRM_
   /**
    * What component context are we being invoked from
    *
-   * @access protected
    * @var string
    */
   protected $_compContext = NULL;
@@ -112,48 +105,50 @@ class CRM_Mailing_Selector_Search extends CRM_Core_Selector_Base implements CRM_
    * 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;
 
   /**
-   * The additional clause that we restrict the search with
+   * The additional clause that we restrict the search with.
    *
    * @var string
    */
   protected $_mailingClause = NULL;
 
   /**
-   * The query object
+   * The query object.
    *
    * @var string
    */
   protected $_query;
 
   /**
-   * Class constructor
+   * 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 $mailingClause if the caller wants to further restrict the search
-   * @param boolean $single are we dealing only with one contact?
-   * @param int $limit how many mailing do we want returned
+   * @param string $mailingClause
+   *   If the caller wants to further restrict the search.
+   * @param bool $single
+   *   Are we dealing only with one contact?.
+   * @param int $limit
+   *   How many mailing do we want returned.
    *
    * @param string $context
    * @param null $compContext
    *
    * @return \CRM_Mailing_Selector_Search
-  @access public
    */
-  function __construct(&$queryParams,
+  public function __construct(
+    &$queryParams,
     $action = CRM_Core_Action::NONE,
     $mailingClause = NULL,
     $single = FALSE,
@@ -164,9 +159,9 @@ class CRM_Mailing_Selector_Search extends CRM_Core_Selector_Base implements CRM_
     // submitted form values
     $this->_queryParams = &$queryParams;
 
-    $this->_single      = $single;
-    $this->_limit       = $limit;
-    $this->_context     = $context;
+    $this->_single = $single;
+    $this->_limit = $limit;
+    $this->_context = $context;
     $this->_compContext = $compContext;
 
     $this->_mailingClause = $mailingClause;
@@ -192,35 +187,33 @@ class CRM_Mailing_Selector_Search extends CRM_Core_Selector_Base implements CRM_
    * - Edit
    *
    * @return array
-   * @access public
-   *
    */
-  static function &links() {
+  public static function &links() {
     if (!(self::$_links)) {
-    list($context, $key) = func_get_args();
-    $extraParams = ($key) ? "&key={$key}" : NULL;
-    $searchContext = ($context) ? "&context=$context" : NULL;
-
-    self::$_links = array(
-      CRM_Core_Action::VIEW => array(
-        'name' => ts('View'),
-        'url' => 'civicrm/contact/view',
-        'qs' => "reset=1&cid=%%cid%%{$searchContext}{$extraParams}",
-        'title' => ts('View Contact Details'),
-      ),
-      CRM_Core_Action::UPDATE => array(
-        'name' => ts('Edit'),
-        'url' => 'civicrm/contact/add',
-        'qs' => "reset=1&action=update&cid=%%cid%%{$searchContext}{$extraParams}",
-        'title' => ts('Edit Contact Details'),
-      ),
-      CRM_Core_Action::DELETE => array(
-        'name' => ts('Delete'),
-        'url' => 'civicrm/contact/view/delete',
-        'qs' => "reset=1&delete=1&cid=%%cid%%{$searchContext}{$extraParams}",
-        'title' => ts('Delete Contact'),
-      ),
-    );
+      list($context, $key) = func_get_args();
+      $extraParams = ($key) ? "&key={$key}" : NULL;
+      $searchContext = ($context) ? "&context=$context" : NULL;
+
+      self::$_links = array(
+        CRM_Core_Action::VIEW => array(
+          'name' => ts('View'),
+          'url' => 'civicrm/contact/view',
+          'qs' => "reset=1&cid=%%cid%%{$searchContext}{$extraParams}",
+          'title' => ts('View Contact Details'),
+        ),
+        CRM_Core_Action::UPDATE => array(
+          'name' => ts('Edit'),
+          'url' => 'civicrm/contact/add',
+          'qs' => "reset=1&action=update&cid=%%cid%%{$searchContext}{$extraParams}",
+          'title' => ts('Edit Contact Details'),
+        ),
+        CRM_Core_Action::DELETE => array(
+          'name' => ts('Delete'),
+          'url' => 'civicrm/contact/view/delete',
+          'qs' => "reset=1&delete=1&cid=%%cid%%{$searchContext}{$extraParams}",
+          'title' => ts('Delete Contact'),
+        ),
+      );
     }
     return self::$_links;
   }
@@ -230,10 +223,8 @@ class CRM_Mailing_Selector_Search extends CRM_Core_Selector_Base implements CRM_
    *
    * @param $action
    * @param array $params
-   *
-   * @access public
    */
-  function getPagerParams($action, &$params) {
+  public function getPagerParams($action, &$params) {
     $params['status'] = ts('Mailing Recipient') . ' %%StatusMessage%%';
     $params['csvString'] = NULL;
     if ($this->_limit) {
@@ -252,10 +243,10 @@ class CRM_Mailing_Selector_Search extends CRM_Core_Selector_Base implements CRM_
    *
    * @param
    *
-   * @return int Total number of rows
-   * @access public
+   * @return int
+   *   Total number of rows
    */
-  function getTotalCount($action) {
+  public function getTotalCount($action) {
     return $this->_query->searchQuery(0, 0, NULL,
       TRUE, FALSE,
       FALSE, FALSE,
@@ -265,17 +256,23 @@ class CRM_Mailing_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 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) {
     $result = $this->_query->searchQuery($offset, $rowCount, $sort,
       FALSE, FALSE,
       FALSE, FALSE,
@@ -292,7 +289,7 @@ class CRM_Mailing_Selector_Search extends CRM_Core_Selector_Base implements CRM_
     $mask = CRM_Core_Action::mask($permissions);
     $qfKey = $this->_key;
 
-    While ($result->fetch()) {
+    while ($result->fetch()) {
       $row = array();
       // the columns we are interested in
       foreach (self::$_properties as $property) {
@@ -318,8 +315,7 @@ class CRM_Mailing_Selector_Search extends CRM_Core_Selector_Base implements CRM_
         'Contact',
         $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
+      $row['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type, FALSE, $result->contact_id
       );
 
       $rows[] = $row;
@@ -328,12 +324,8 @@ class CRM_Mailing_Selector_Search extends CRM_Core_Selector_Base implements CRM_
   }
 
   /**
-   * @return array   $qill         which contains an array of strings
-   * @access public
+   * @inheritDoc
    */
-
-  // the current internationalisation is bad, but should more or less work
-  // for most of "European" languages
   public function getQILL() {
     return $this->_query->qill();
   }
@@ -342,11 +334,13 @@ class CRM_Mailing_Selector_Search extends CRM_Core_Selector_Base implements CRM_
    * 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
    */
   public function &getColumnHeaders($action = NULL, $output = NULL) {
     if (!isset(self::$_columnHeaders)) {
@@ -391,25 +385,28 @@ class CRM_Mailing_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.
    *
-   * @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 Mailing Search');
   }
+
 }