Skip to content
Snippets Groups Projects
Unverified Commit 55258ad5 authored by Eileen McNaughton's avatar Eileen McNaughton Committed by GitHub
Browse files

Merge pull request #15966 from seamuslee001/permission_access_metadata

Conditionally add metadata for advanced search only if the user has a…
parents 64c4d392 e26bc72e
No related branches found
No related tags found
No related merge requests found
......@@ -906,16 +906,30 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search {
return ts('Search');
}
/**
* Check Access for a component
* @param string $component
* @return bool
*/
protected static function checkComponentAccess($component) {
$enabledComponents = CRM_Core_Component::getEnabledComponents();
if (!array_key_exists($component, $enabledComponents)) {
return FALSE;
}
return CRM_Core_Permission::access($component);
}
/**
* 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()]);
if (self::checkComponentAccess('CiviContribute')) {
$this->addSearchFieldMetadata(['Contribution' => CRM_Contribute_BAO_Query::getSearchFieldMetadata()]);
$this->addSearchFieldMetadata(['ContributionRecur' => CRM_Contribute_BAO_ContributionRecur::getContributionRecurSearchFieldMetadata()]);
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment