Skip to content

Commit

Permalink
Merge pull request #13210 from eileenmcnaughton/search_ref
Browse files Browse the repository at this point in the history
[REF] refactor shared search functions in pre-Process
  • Loading branch information
seamuslee001 authored Dec 3, 2018
2 parents b91fc8b + 09e4739 commit a4e2c95
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 134 deletions.
9 changes: 1 addition & 8 deletions CRM/Activity/Form/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,7 @@ public function preProcess() {
$this->_done = FALSE;
$this->defaults = array();

// we allow the controller to set force/reset externally, useful when we are being
// driven by the wizard framework
$this->_reset = CRM_Utils_Request::retrieve('reset', 'Boolean');
$this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', $this, FALSE);
$this->_limit = CRM_Utils_Request::retrieve('limit', 'Positive', $this);
$this->_context = CRM_Utils_Request::retrieve('context', 'Alphanumeric', $this, FALSE, 'search');

$this->assign("context", $this->_context);
$this->getUrlVariables();

// get user submitted values
// get it from controller only if form has been submitted, else preProcess has set this
Expand Down
7 changes: 1 addition & 6 deletions CRM/Campaign/Form/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,7 @@ public function preProcess() {
$this->_printButtonName = $this->getButtonName('next', 'print');
$this->_actionButtonName = $this->getButtonName('next', 'action');

//we allow the controller to set force/reset externally,
//useful when we are being driven by the wizard framework
$this->_limit = CRM_Utils_Request::retrieve('limit', 'Positive', $this);
$this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', $this, FALSE);
$this->_context = CRM_Utils_Request::retrieve('context', 'Alphanumeric', $this, FALSE, 'search');
$this->_reset = CRM_Utils_Request::retrieve('reset', 'Boolean');
$this->getUrlVariables();

//operation for state machine.
$this->_operation = CRM_Utils_Request::retrieve('op', 'String', $this, FALSE, 'reserve');
Expand Down
28 changes: 2 additions & 26 deletions CRM/Case/Form/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,32 +89,8 @@ public function preProcess() {
$this->_done = FALSE;
$this->defaults = array();

/*
* we allow the controller to set force/reset externally, useful when we are being
* driven by the wizard framework
*/

$this->_reset = CRM_Utils_Request::retrieve('reset', 'Boolean');
$this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', $this, FALSE);
$this->_limit = CRM_Utils_Request::retrieve('limit', 'Positive', $this);
$this->_context = CRM_Utils_Request::retrieve('context', 'Alphanumeric', $this, FALSE, 'search');

$this->assign('context', $this->_context);

// get user submitted values
// get it from controller only if form has been submitted, else preProcess has set this
if (!empty($_POST) && !$this->controller->isModal()) {
$this->_formValues = $this->controller->exportValues($this->_name);
}
else {
$this->_formValues = $this->get('formValues');
}

if (empty($this->_formValues)) {
if (isset($this->_ssID)) {
$this->_formValues = CRM_Contact_BAO_SavedSearch::getFormValues($this->_ssID);
}
}
$this->getUrlVariables();
$this->getFormValues();

if ($this->_force) {
$this->postProcess();
Expand Down
12 changes: 1 addition & 11 deletions CRM/Contribute/Form/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,7 @@ public function preProcess() {
// @todo - is this an error - $this->_defaults is used.
$this->defaults = array();

/*
* we allow the controller to set force/reset externally, useful when we are being
* driven by the wizard framework
*/

$this->_reset = CRM_Utils_Request::retrieve('reset', 'Boolean');
$this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', $this, FALSE);
$this->_limit = CRM_Utils_Request::retrieve('limit', 'Positive', $this);
$this->_context = CRM_Utils_Request::retrieve('context', 'Alphanumeric', $this, FALSE, 'search');

$this->assign("context", $this->_context);
$this->getUrlVariables();

// get user submitted values
// get it from controller only if form has been submitted, else preProcess has set this
Expand Down
33 changes: 33 additions & 0 deletions CRM/Core/Form/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,4 +237,37 @@ protected function addContactSearchFields() {

}

/**
* we allow the controller to set force/reset externally, useful when we are being
* driven by the wizard framework
*/
protected function getUrlVariables() {
$this->_reset = CRM_Utils_Request::retrieve('reset', 'Boolean');
$this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', $this, FALSE);
$this->_limit = CRM_Utils_Request::retrieve('limit', 'Positive', $this);
$this->_context = CRM_Utils_Request::retrieve('context', 'Alphanumeric', $this, FALSE, 'search');
$this->_ssID = CRM_Utils_Request::retrieve('ssID', 'Positive', $this);
$this->assign("context", $this->_context);
}

/**
* Get user submitted values.
*
* Get it from controller only if form has been submitted, else preProcess has set this
*/
protected function getFormVariables() {
if (!empty($_POST) && !$this->controller->isModal()) {
$this->_formValues = $this->controller->exportValues($this->_name);
}
else {
$this->_formValues = $this->get('formValues');
}

if (empty($this->_formValues)) {
if (isset($this->_ssID)) {
$this->_formValues = CRM_Contact_BAO_SavedSearch::getFormValues($this->_ssID);
}
}
}

}
27 changes: 2 additions & 25 deletions CRM/Event/Form/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,31 +90,8 @@ public function preProcess() {
$this->_done = FALSE;
$this->defaults = array();

/*
* we allow the controller to set force/reset externally, useful when we are being
* driven by the wizard framework
*/
$this->_reset = CRM_Utils_Request::retrieve('reset', 'Boolean');
$this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', $this, FALSE);
$this->_limit = CRM_Utils_Request::retrieve('limit', 'Positive', $this);
$this->_context = CRM_Utils_Request::retrieve('context', 'Alphanumeric', $this, FALSE, 'search');
$this->_ssID = CRM_Utils_Request::retrieve('ssID', 'Positive', $this);
$this->assign("context", $this->_context);

// get user submitted values
// get it from controller only if form has been submitted, else preProcess has set this
if (!empty($_POST) && !$this->controller->isModal()) {
$this->_formValues = $this->controller->exportValues($this->_name);
}
else {
$this->_formValues = $this->get('formValues');
}

if (empty($this->_formValues)) {
if (isset($this->_ssID)) {
$this->_formValues = CRM_Contact_BAO_SavedSearch::getFormValues($this->_ssID);
}
}
$this->getUrlVariables();
$this->getFormValues();

if ($this->_force) {
$this->postProcess();
Expand Down
45 changes: 7 additions & 38 deletions CRM/Grant/Form/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,10 @@
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2018
* $Id$
*
*/

/**
* Files required
*/

/**
* This file is for civigrant search
* This file is for CiviGrant search
*/
class CRM_Grant_Form_Search extends CRM_Core_Form_Search {

Expand All @@ -57,9 +51,9 @@ class CRM_Grant_Form_Search extends CRM_Core_Form_Search {
protected $_single = FALSE;

/**
* Are we restricting ourselves to a single contact.
* Return limit.
*
* @var boolean
* @var int
*/
protected $_limit = NULL;

Expand All @@ -68,6 +62,8 @@ class CRM_Grant_Form_Search extends CRM_Core_Form_Search {
*/
protected $_prefix = "grant_";

protected $entity = 'grant';

/**
* Processing needed for buildForm and later.
*
Expand All @@ -83,32 +79,8 @@ public function preProcess() {
$this->_done = FALSE;
$this->defaults = array();

/*
* we allow the controller to set force/reset externally, useful when we are being
* driven by the wizard framework
*/

$this->_reset = CRM_Utils_Request::retrieve('reset', 'Boolean');
$this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', $this, FALSE);
$this->_limit = CRM_Utils_Request::retrieve('limit', 'Positive', $this);
$this->_context = CRM_Utils_Request::retrieve('context', 'Alphanumeric', $this, FALSE, 'search');

$this->assign("context", $this->_context);

// get user submitted values
// get it from controller only if form has been submitted, else preProcess has set this
if (!empty($_POST)) {
$this->_formValues = $this->controller->exportValues($this->_name);
}
else {
$this->_formValues = $this->get('formValues');
}

if (empty($this->_formValues)) {
if (isset($this->_ssID)) {
$this->_formValues = CRM_Contact_BAO_SavedSearch::getFormValues($this->_ssID);
}
}
$this->getUrlVariables();
$this->getFormVariables();

if ($this->_force) {
$this->postProcess();
Expand Down Expand Up @@ -154,9 +126,6 @@ public function preProcess() {

/**
* Build the form object.
*
*
* @return void
*/
public function buildQuickForm() {
parent::buildQuickForm();
Expand Down
12 changes: 1 addition & 11 deletions CRM/Member/Form/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,7 @@ public function preProcess() {

$this->defaults = array();

/*
* we allow the controller to set force/reset externally, useful when we are being
* driven by the wizard framework
*/

$this->_reset = CRM_Utils_Request::retrieve('reset', 'Boolean');
$this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', $this, FALSE);
$this->_limit = CRM_Utils_Request::retrieve('limit', 'Positive', $this);
$this->_context = CRM_Utils_Request::retrieve('context', 'Alphanumeric', $this, FALSE, 'search');

$this->assign("context", $this->_context);
$this->getUrlVariables();

// get user submitted values
// get it from controller only if form has been submitted, else preProcess has set this
Expand Down
10 changes: 1 addition & 9 deletions CRM/Pledge/Form/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,7 @@ public function preProcess() {
$this->_done = FALSE;
$this->defaults = array();

// we allow the controller to set force/reset externally, useful when we are being
// driven by the wizard framework

$this->_reset = CRM_Utils_Request::retrieve('reset', 'Boolean');
$this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', $this, FALSE);
$this->_limit = CRM_Utils_Request::retrieve('limit', 'Positive', $this);
$this->_context = CRM_Utils_Request::retrieve('context', 'Alphanumeric', $this, FALSE, 'search');

$this->assign("context", $this->_context);
$this->getUrlVariables();

// get user submitted values
// get it from controller only if form has been submitted, else preProcess has set this
Expand Down

0 comments on commit a4e2c95

Please sign in to comment.