CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, ]; /** * Build the form object. */ public function buildQuickForm() { $this->addFormRule(['CRM_Admin_Form_Setting_Component', 'formRule'], $this); parent::buildQuickForm(); } /** * Global form rule. * * @param array $fields * The input form values. * @param array $files * The uploaded files if any. * @param array $options * Additional user data. * * @return bool|array * true if no errors, else array of errors */ public static function formRule($fields, $files, $options) { $errors = []; if (array_key_exists('enable_components', $fields) && is_array($fields['enable_components'])) { if (!empty($fields['enable_components']['CiviPledge']) && empty($fields['enable_components']['CiviContribute']) ) { $errors['enable_components'] = ts('You need to enable CiviContribute before enabling CiviPledge.'); } if (!empty($fields['enable_components']['CiviCase']) && !CRM_Core_DAO::checkTriggerViewPermission(TRUE, FALSE) ) { $errors['enable_components'] = ts('CiviCase requires CREATE VIEW and DROP VIEW permissions for the database.'); } } return $errors; } }