Skip to content

Commit

Permalink
Extend contribute search url parsing to advanced search
Browse files Browse the repository at this point in the history
  • Loading branch information
eileenmcnaughton committed Jul 31, 2019
1 parent 8fb8e7a commit f90f8d3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
14 changes: 13 additions & 1 deletion CRM/Contact/Form/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ public function preProcess() {
$controller->setDynamicAction($setDynamic);

if ($this->_force) {

$this->loadMetadata();
$this->postProcess();

/*
Expand Down Expand Up @@ -909,4 +909,16 @@ public function getTitle() {
return ts('Search');
}

/**
* Load metadata for fields on the form.
*
* @throws \CiviCRM_API3_Exception
*/
protected function loadMetadata() {
// @todo - check what happens if the person does not have 'access civicontribute' - make sure they
// can't by pass acls by passing search criteria in the url.
$this->addSearchFieldMetadata(['Contribution' => CRM_Contribute_BAO_Query::getSearchFieldMetadata()]);
$this->addSearchFieldMetadata(['ContributionRecur' => CRM_Contribute_BAO_ContributionRecur::getContributionRecurSearchFieldMetadata()]);
}

}
2 changes: 0 additions & 2 deletions CRM/Contribute/Form/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,6 @@ public function fixFormValues() {
if (!$this->_force) {
return;
}
// Start by loading url defaults.
$this->_formValues = $this->setDefaultValues();

$status = CRM_Utils_Request::retrieve('status', 'String');
if ($status) {
Expand Down
7 changes: 6 additions & 1 deletion CRM/Core/Form/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,19 +133,24 @@ public function addSearchFieldMetadata($searchFieldMetadata) {
*/
public function setDefaultValues() {
$defaults = (array) $this->_formValues;
foreach (['Contact', $this->getDefaultEntity()] as $entity) {
foreach (array_keys($this->getSearchFieldMetadata()) as $entity) {
$defaults = array_merge($this->getEntityDefaults($entity), $defaults);
}
return $defaults;
}

/**
* Set the form values based on input and preliminary processing.
*
* @throws \Exception
*/
protected function setFormValues() {
if (!empty($_POST) && !$this->_force) {
$this->_formValues = $this->controller->exportValues($this->_name);
}
elseif ($this->_force) {
$this->_formValues = $this->setDefaultValues();
}
$this->convertTextStringsToUseLikeOperator();
}

Expand Down

0 comments on commit f90f8d3

Please sign in to comment.