Merge pull request #6065 from yashodha/CRM-16665.master
[civicrm-core.git] / CRM / Contribute / Form / Search.php
index 9f50f5cccf32693d1fc59545532ac15f607d73d2..21d9a62046f0d91d4baedcd620dd3170645073d0 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
- * $Id$
- *
- */
-
-/**
- * Files required
+ * @copyright CiviCRM LLC (c) 2004-2015
  */
 
 /**
- * advanced search, extends basic search
+ * Advanced search, extends basic search.
  */
 class CRM_Contribute_Form_Search extends CRM_Core_Form_Search {
 
   /**
-   * The params that are sent to the query
+   * The params that are sent to the query.
    *
    * @var array
    */
   protected $_queryParams;
 
   /**
-   * Are we restricting ourselves to a single contact
+   * Are we restricting ourselves to a single contact.
    *
    * @var boolean
    */
   protected $_single = FALSE;
 
   /**
-   * Are we restricting ourselves to a single contact
+   * Are we restricting ourselves to a single contact.
    *
    * @var boolean
    */
@@ -66,25 +60,21 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form_Search {
   protected $_defaults;
 
   /**
-   * Prefix for the controller
+   * Prefix for the controller.
    */
   protected $_prefix = "contribute_";
 
   /**
-   * Processing needed for buildForm and later
-   *
-   * @return void
+   * Processing needed for buildForm and later.
    */
   public function preProcess() {
     $this->set('searchFormName', 'Search');
 
-    /**
-     * set the button names
-     */
     $this->_searchButtonName = $this->getButtonName('refresh');
     $this->_actionButtonName = $this->getButtonName('next', 'action');
 
     $this->_done = FALSE;
+    // @todo - is this an error - $this->_defaults is used.
     $this->defaults = array();
 
     /*
@@ -161,6 +151,11 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form_Search {
     $this->assign('contributionSummary', $this->get('summary'));
   }
 
+  /**
+   * Set defaults.
+   *
+   * @return array
+   */
   public function setDefaultValues() {
     if (empty($this->_defaults['contribution_status'])) {
       $this->_defaults['contribution_status'][1] = 1;
@@ -169,10 +164,7 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form_Search {
   }
 
   /**
-   * Build the form object
-   *
-   *
-   * @return void
+   * Build the form object.
    */
   public function buildQuickForm() {
     parent::buildQuickForm();
@@ -228,17 +220,13 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form_Search {
    * The post processing of the form gets done here.
    *
    * Key things done during post processing are
-   *      - check for reset or next request. if present, skip post procesing.
+   *      - check for reset or next request. if present, skip post processing.
    *      - now check if user requested running a saved search, if so, then
    *        the form values associated with the saved search are used for searching.
-   *      - if user has done a submit with new values the regular post submissing is
+   *      - if user has done a submit with new values the regular post submission is
    *        done.
    * The processing consists of using a Selector / Controller framework for getting the
    * search results.
-   *
-   * @param
-   *
-   * @return void
    */
   public function postProcess() {
     if ($this->_done) {
@@ -275,6 +263,8 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form_Search {
         'contribution_status_id',
         'contribution_source',
         'contribution_trxn_id',
+        'contribution_page_id',
+        'contribution_product_id',
       );
       foreach ($specialParams as $element) {
         $value = CRM_Utils_Array::value($element, $this->_formValues);
@@ -377,10 +367,12 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form_Search {
     $controller->run();
   }
 
+  /**
+   * Use values from $_GET if force is set to TRUE.
+   *
+   * Note that this means that GET over-rides POST. This was a historical decision & the reasoning is not explained.
+   */
   public function fixFormValues() {
-    // if this search has been forced
-    // then see if there are any get values, and if so over-ride the post values
-    // note that this means that GET over-rides POST :)
     if (!$this->_force) {
       return;
     }
@@ -399,6 +391,7 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form_Search {
       $cid = CRM_Utils_Type::escape($cid, 'Integer');
       if ($cid > 0) {
         $this->_formValues['contact_id'] = $cid;
+        // @todo - why do we retrieve these when they are not used?
         list($display, $image) = CRM_Contact_BAO_Contact::getDisplayAndImage($cid);
         $this->_defaults['sort_name'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $cid,
           'sort_name'
@@ -460,11 +453,12 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form_Search {
   }
 
   /**
-   * Return a descriptive name for the page, used in wizard header
+   * Return a descriptive name for the page, used in wizard header.
    *
    * @return string
    */
   public function getTitle() {
     return ts('Find Contributions');
   }
+
 }