Merge pull request #4812 from colemanw/CRM-15495
[civicrm-core.git] / CRM / Contribute / Form / Search.php
index 12d1c078bf21db7110efc566fcb97688e0817198..212bccfe397b1cbb5f5f623ec49b5b80ffb9baaf 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
 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
-   * @access protected
    */
   protected $_queryParams;
 
   /**
-   * 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;
@@ -69,16 +66,15 @@ 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
+   * Processing needed for buildForm and later
    *
    * @return void
-   * @access public
    */ function preProcess() {
     $this->set('searchFormName', 'Search');
 
@@ -165,7 +161,7 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form_Search {
     $this->assign('contributionSummary', $this->get('summary'));
   }
 
-  function setDefaultValues() {
+  public function setDefaultValues() {
     if (empty($this->_defaults
 ['contribution_status'])) {
       $this->_defaults['contribution_status'][1] = 1;
@@ -174,13 +170,12 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form_Search {
   }
 
   /**
-   * Build the form
+   * Build the form object
    *
-   * @access public
    *
    * @return void
    */
-  function buildQuickForm() {
+  public function buildQuickForm() {
     parent::buildQuickForm();
     // text for sort_name
     $this->addElement('text',
@@ -191,7 +186,7 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form_Search {
       )
     );
 
-    $this->_group = CRM_Core_PseudoConstant::group();
+    $this->_group = CRM_Core_PseudoConstant::nestedGroup();
 
     // multiselect for groups
     if ($this->_group) {
@@ -211,30 +206,12 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form_Search {
 
     CRM_Contribute_BAO_Query::buildSearchForm($this);
 
-    /*
-     * add form checkboxes for each row. This is needed out here to conform to QF protocol
-     * of all elements being declared in builQuickForm
-     */
-
     $rows = $this->get('rows');
     if (is_array($rows)) {
       if (!$this->_single) {
-        $this->addElement('checkbox',
-          'toggleSelect',
-          NULL,
-          NULL,
-          array('onclick' => "toggleTaskAction( true );", 'class' => 'select-rows')
-        );
-        foreach ($rows as $row) {
-          $this->addElement('checkbox', $row['checkbox'],
-            NULL, NULL,
-            array('onclick' => "toggleTaskAction( true );", 'class' => 'select-row')
-          );
-        }
+        $this->addRowSelectors($rows);
       }
 
-      $total = $cancel = 0;
-
       $permission = CRM_Core_Permission::getPermission();
 
       $queryParams = $this->get('queryParams');
@@ -244,10 +221,6 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form_Search {
       }
       $tasks = CRM_Contribute_Task::permissionedTaskTitles($permission, $softCreditFiltering);
       $this->addTaskMenu($tasks);
-
-      // need to perform tasks on all or selected items ? using radio_ts(task selection) for it
-      $this->addElement('radio', 'radio_ts', NULL, '', 'ts_sel', array('checked' => 'checked'));
-      $this->addElement('radio', 'radio_ts', NULL, '', 'ts_all', array('class' => 'select-rows', 'onclick' => $this->getName() . ".toggleSelect.checked = false; toggleTaskAction( true );"));
     }
 
   }
@@ -267,9 +240,8 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form_Search {
    * @param
    *
    * @return void
-   * @access public
    */
-  function postProcess() {
+  public function postProcess() {
     if ($this->_done) {
       return;
     }
@@ -283,7 +255,7 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form_Search {
     $this->fixFormValues();
 
     // We don't show test records in summaries or dashboards
-    if (empty($this->_formValues['contribution_test']) && $this->_force) {
+    if (empty($this->_formValues['contribution_test']) && $this->_force && !empty($this->_context) && $this->_context == 'dashboard') {
       $this->_formValues["contribution_test"] = 0;
     }
 
@@ -396,7 +368,7 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form_Search {
     $controller->run();
   }
 
-  function fixFormValues() {
+  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 :)
@@ -482,10 +454,8 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form_Search {
    * Return a descriptive name for the page, used in wizard header
    *
    * @return string
-   * @access public
    */
   public function getTitle() {
     return ts('Find Contributions');
   }
 }
-