dev/translation#65 Further remove moneyValueFormat
[civicrm-core.git] / CRM / Admin / Form / Setting / Component.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
bc77d7c0 4 | Copyright CiviCRM LLC. All rights reserved. |
6a488035 5 | |
bc77d7c0
TO
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
6a488035 9 +--------------------------------------------------------------------+
d25dd0ee 10 */
6a488035
TO
11
12/**
13 *
14 * @package CRM
ca5cec67 15 * @copyright CiviCRM LLC https://civicrm.org/licensing
6a488035
TO
16 */
17
18/**
ce064e4f 19 * This class generates form components for Component.
6a488035
TO
20 */
21class CRM_Admin_Form_Setting_Component extends CRM_Admin_Form_Setting {
22 protected $_components;
23
281db812 24 protected $_settings = [
25 'enable_components' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
26 ];
27
6a488035 28 /**
eceb18cc 29 * Build the form object.
6a488035
TO
30 */
31 public function buildQuickForm() {
be2fb01f 32 $this->addFormRule(['CRM_Admin_Form_Setting_Component', 'formRule'], $this);
6a488035
TO
33 parent::buildQuickForm();
34 }
35
36 /**
eceb18cc 37 * Global form rule.
6a488035 38 *
5173bd95
TO
39 * @param array $fields
40 * The input form values.
41 * @param array $files
42 * The uploaded files if any.
43 * @param array $options
44 * Additional user data.
6a488035 45 *
72b3a70c
CW
46 * @return bool|array
47 * true if no errors, else array of errors
6a488035 48 */
00be9182 49 public static function formRule($fields, $files, $options) {
be2fb01f 50 $errors = [];
6a488035 51
281db812 52 if (array_key_exists('enable_components', $fields) && is_array($fields['enable_components'])) {
77d03cb4
CW
53 if (!empty($fields['enable_components']['CiviPledge']) &&
54 empty($fields['enable_components']['CiviContribute'])
6a488035 55 ) {
281db812 56 $errors['enable_components'] = ts('You need to enable CiviContribute before enabling CiviPledge.');
6a488035 57 }
77d03cb4 58 if (!empty($fields['enable_components']['CiviCase']) &&
6a488035
TO
59 !CRM_Core_DAO::checkTriggerViewPermission(TRUE, FALSE)
60 ) {
281db812 61 $errors['enable_components'] = ts('CiviCase requires CREATE VIEW and DROP VIEW permissions for the database.');
6a488035
TO
62 }
63 }
64
65 return $errors;
66 }
67
6a488035 68}