From: Bernardo Araujo Date: Fri, 16 Sep 2016 22:04:41 +0000 (-0300) Subject: Fixed CRM-19334 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=ea0805867c68fc2b6be0d807667c853cd6660df2;p=civicrm-core.git Fixed CRM-19334 --- diff --git a/CRM/Contact/Form/Search/Criteria.php b/CRM/Contact/Form/Search/Criteria.php index ae31277548..4c2446cba4 100644 --- a/CRM/Contact/Form/Search/Criteria.php +++ b/CRM/Contact/Form/Search/Criteria.php @@ -159,6 +159,8 @@ class CRM_Contact_Form_Search_Criteria { $componentModes = CRM_Contact_Form_Search::getModeSelect(); + self::validatePossibleComponents($componentModes); + // unset contributions or participants if user does not have // permission on them if (!CRM_Core_Permission::access('CiviContribute')) { @@ -539,4 +541,19 @@ class CRM_Contact_Form_Search_Criteria { CRM_Case_BAO_Query::buildSearchForm($form); } + public static function getEnabledComponents() { + $apiResult = civicrm_api3('Setting', 'Get', array()); + return $apiResult['values'][1]['enable_components']; + } + + //the idea is to validate everything in here and remove based on possible situations + public static function validatePossibleComponents(&$componentModes) { + $enabledComponents = self::getEnabledComponents(); + + //e.g. this validation that removes the 'Mailing' option if CiviMail is not enabled + if (!in_array('CiviMail', $enabledComponents)) { + unset($componentModes['8']); + } + } + }