Skip to content

Commit

Permalink
quickfix for crash if civigrant not enabled and have admin rights
Browse files Browse the repository at this point in the history
  • Loading branch information
demeritcowboy committed Feb 9, 2022
1 parent c27d601 commit 5dcfb8e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
8 changes: 8 additions & 0 deletions CRM/Contact/Form/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,14 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search {

protected $_openedPanes = [];

public function __construct($state = NULL, $action = CRM_Core_Action::NONE, $method = 'post', $name = NULL) {
parent::__construct($state, $action, $method, $name);
// Because this is a static variable, reset it in case it got changed elsewhere.
// Should only come up during unit tests.
// Note the only subclass that seems to set this does it in preprocess (custom searches)
self::$_selectorName = 'CRM_Contact_Selector';
}

/**
* Explicitly declare the entity api name.
*/
Expand Down
2 changes: 1 addition & 1 deletion CRM/Core/BAO/Mapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ public static function addComponentFields(&$fields, $mappingType, $exportMode) {
}
}
if (($mappingType == 'Search Builder') || ($exportMode == CRM_Export_Form_Select::GRANT_EXPORT)) {
if (CRM_Core_Permission::check('access CiviGrant')) {
if (method_exists('CRM_Grant_BAO_Grant', 'exportableFields') && CRM_Core_Permission::check('access CiviGrant')) {
$fields['Grant'] = CRM_Grant_BAO_Grant::exportableFields();
unset($fields['Grant']['grant_contact_id']);
if ($mappingType == 'Search Builder') {
Expand Down
14 changes: 14 additions & 0 deletions tests/phpunit/CRM/Core/InvokeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,18 @@ public function testInvokeDashboardWithGettingStartedDashlet(): void {
ob_end_clean();
}

public function testOpeningSearchBuilder(): void {
$_SERVER['REQUEST_URI'] = 'civicrm/contact/search/builder?reset=1';
$_GET['q'] = 'civicrm/contact/search/builder';
$_GET['reset'] = 1;

$item = CRM_Core_Invoke::getItem([$_GET['q']]);
ob_start();
CRM_Core_Invoke::runItem($item);
$contents = ob_get_clean();

unset($_GET['reset']);
$this->assertRegExp('/form.+id="Builder" class="CRM_Contact_Form_Search_Builder/', $contents);
}

}

0 comments on commit 5dcfb8e

Please sign in to comment.