Merge branch 'phpunit-ob-fix' of https://github.com/giant-rabbit/civicrm-core into...
[civicrm-core.git] / CRM / Contact / Selector / Custom.php
index 6ddea8213c211374892188c0497b6b48e2404bf3..afaa3f82e9e8bdc7406fc0447b13a88f2e0a82de 100644 (file)
@@ -50,7 +50,7 @@ class CRM_Contact_Selector_Custom extends CRM_Contact_Selector {
   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
@@ -65,7 +65,7 @@ class CRM_Contact_Selector_Custom extends CRM_Contact_Selector {
   static $_properties = array('contact_id', 'contact_type', 'display_name');
 
   /**
-   * formValues is the array returned by exportValues called on
+   * FormValues is the array returned by exportValues called on
    * the HTML_QuickForm_Controller for that page.
    *
    * @var array
@@ -74,7 +74,7 @@ class CRM_Contact_Selector_Custom extends CRM_Contact_Selector {
   public $_formValues;
 
   /**
-   * params is the array in a value used by the search query creator
+   * Params is the array in a value used by the search query creator
    *
    * @var array
    * @access protected
@@ -82,7 +82,7 @@ class CRM_Contact_Selector_Custom extends CRM_Contact_Selector {
   public $_params;
 
   /**
-   * represent the type of selector
+   * Represent the type of selector
    *
    * @var int
    * @access protected
@@ -92,7 +92,7 @@ class CRM_Contact_Selector_Custom extends CRM_Contact_Selector {
   protected $_query;
 
   /**
-   * the public visible fields to be shown to the user
+   * The public visible fields to be shown to the user
    *
    * @var array
    * @access protected
@@ -157,7 +157,6 @@ class CRM_Contact_Selector_Custom extends CRM_Contact_Selector {
       $this->_search = new $className($formValues);
     }
   }
-  //end of constructor
 
   /**
    * This method returns the links that are given for each search row.
@@ -171,18 +170,24 @@ class CRM_Contact_Selector_Custom extends CRM_Contact_Selector {
    *
    */
   static function &links() {
+    list($key) = func_get_args();
+    $searchContext = "&context=custom";
+    $extraParams = ($key) ? "&key={$key}" : NULL;
+
     if (!(self::$_links)) {
       self::$_links = array(
         CRM_Core_Action::VIEW => array(
           'name' => ts('View'),
           'url' => 'civicrm/contact/view',
-          'qs' => 'reset=1&cid=%%id%%',
+          'qs' => "reset=1&cid=%%id%%{$extraParams}{$searchContext}",
+          'class' => 'no-popup',
           'title' => ts('View Contact Details'),
         ),
         CRM_Core_Action::UPDATE => array(
           'name' => ts('Edit'),
           'url' => 'civicrm/contact/add',
           'qs' => 'reset=1&action=update&cid=%%id%%',
+          'class' => 'no-popup',
           'title' => ts('Edit Contact Details'),
         ),
       );
@@ -193,21 +198,20 @@ class CRM_Contact_Selector_Custom extends CRM_Contact_Selector {
           'name' => ts('Map'),
           'url' => 'civicrm/contact/map',
           'qs' => 'reset=1&cid=%%id%%&searchType=custom',
+          'class' => 'no-popup',
           'title' => ts('Map Contact'),
         );
       }
     }
     return self::$_links;
   }
-  //end of function
 
   /**
-   * 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) {
@@ -218,10 +222,9 @@ class CRM_Contact_Selector_Custom extends CRM_Contact_Selector {
     $params['buttonTop'] = 'PagerTopButton';
     $params['buttonBottom'] = 'PagerBottomButton';
   }
-  //end of function
 
   /**
-   * 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
@@ -266,7 +269,7 @@ class CRM_Contact_Selector_Custom extends CRM_Contact_Selector {
   }
 
   /**
-   * 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
@@ -299,7 +302,7 @@ class CRM_Contact_Selector_Custom extends CRM_Contact_Selector {
 
     $columns     = $this->_search->columns();
     $columnNames = array_values($columns);
-    $links       = self::links();
+    $links       = self::links($this->_key);
 
     $permissions = array(CRM_Core_Permission::getPermission());
     if (CRM_Core_Permission::check('delete contacts')) {
@@ -383,12 +386,15 @@ class CRM_Contact_Selector_Custom extends CRM_Contact_Selector {
     return NULL;
   }
 
+  /**
+   * @return mixed
+   */
   public function getSummary() {
     return $this->_search->summary();
   }
 
   /**
-   * name of export file.
+   * Name of export file.
    *
    * @param string $output type of output
    *
@@ -398,10 +404,22 @@ class CRM_Contact_Selector_Custom extends CRM_Contact_Selector {
     return ts('CiviCRM Custom Search');
   }
 
+  /**
+   * @return null
+   */
   function alphabetQuery() {
     return NULL;
   }
 
+  /**
+   * @param array $params
+   * @param $action
+   * @param int $sortID
+   * @param null $displayRelationshipType
+   * @param string $queryOperator
+   *
+   * @return Object
+   */
   function &contactIDQuery($params, $action, $sortID, $displayRelationshipType = NULL, $queryOperator = 'AND') {
     $params = array();
     $sql = $this->_search->contactIDs($params);
@@ -409,8 +427,11 @@ class CRM_Contact_Selector_Custom extends CRM_Contact_Selector {
     return CRM_Core_DAO::executeQuery($sql, $params);
   }
 
+  /**
+   * @param $rows
+   */
   function addActions(&$rows) {
-    $links = self::links();
+    $links = self::links($this->_key);
 
     $permissions = array(CRM_Core_Permission::getPermission());
     if (CRM_Core_Permission::check('delete contacts')) {
@@ -431,6 +452,9 @@ class CRM_Contact_Selector_Custom extends CRM_Contact_Selector {
     }
   }
 
+  /**
+   * @param $rows
+   */
   function removeActions(&$rows) {
     foreach ($rows as $rid => & $rValue) {
       unset($rValue['action']);