3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
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 |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
17 class CRM_ACL_Form_ACLBasic
extends CRM_Admin_Form
{
20 * Set default values for the form.
22 public function setDefaultValues() {
28 $defaults['entity_id'] = $this->_id
;
34 AND ( object_table NOT IN ( 'civicrm_saved_search', 'civicrm_uf_group', 'civicrm_custom_group' ) )
36 $params = [1 => [$this->_id
, 'Integer']];
37 $dao = CRM_Core_DAO
::executeQuery($query, $params);
38 $defaults['object_table'] = [];
39 while ($dao->fetch()) {
40 $defaults['object_table'][$dao->object_table
] = 1;
48 * Build the form object.
50 public function buildQuickForm() {
51 parent
::buildQuickForm();
53 if ($this->_action
& CRM_Core_Action
::DELETE
) {
57 $permissions = array_flip(CRM_Core_Permission
::basicPermissions());
58 $this->addCheckBox('object_table',
61 NULL, NULL, TRUE, NULL,
62 ['</td><td>', '</td></tr><tr><td>']
67 '-1' => ts('- select role -'),
68 '0' => ts('Everyone'),
69 ] + CRM_Core_OptionGroup
::values('acl_role');
70 $entityID = &$this->add('select', 'entity_id', $label, $role, TRUE);
75 $this->add('checkbox', 'is_active', ts('Enabled?'));
77 $this->addFormRule(['CRM_ACL_Form_ACLBasic', 'formRule']);
81 * @param array $params
85 public static function formRule($params) {
86 if ($params['entity_id'] == -1) {
87 $errors = ['entity_id' => ts('Role is a required field')];
95 * Process the form submission.
97 public function postProcess() {
98 CRM_ACL_BAO_Cache
::resetCache();
100 $params = $this->controller
->exportValues($this->_name
);
108 AND ( object_table NOT IN ( 'civicrm_saved_search', 'civicrm_uf_group', 'civicrm_custom_group' ) )
110 $deleteParams = [1 => [$this->_id
, 'Integer']];
111 CRM_Core_DAO
::executeQuery($query, $deleteParams);
113 if ($this->_action
& CRM_Core_Action
::DELETE
) {
114 CRM_Core_Session
::setStatus(ts('Selected ACL has been deleted.'), ts('Record Deleted'), 'success');
119 $params['operation'] = 'All';
121 $params['is_active'] = 1;
122 $params['entity_table'] = 'civicrm_acl_role';
123 $params['name'] = 'Core ACL';
125 foreach ($params['object_table'] as $object_table => $value) {
127 $newParams = $params;
128 unset($newParams['object_table']);
129 $newParams['object_table'] = $object_table;
130 CRM_ACL_BAO_ACL
::create($newParams);