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
{
22 public $submitOnce = TRUE;
25 * Set default values for the form.
27 public function setDefaultValues() {
33 $defaults['entity_id'] = $this->_id
;
39 AND ( object_table NOT IN ( 'civicrm_saved_search', 'civicrm_uf_group', 'civicrm_custom_group' ) )
41 $params = [1 => [$this->_id
, 'Integer']];
42 $dao = CRM_Core_DAO
::executeQuery($query, $params);
43 $defaults['object_table'] = [];
44 while ($dao->fetch()) {
45 $defaults['object_table'][$dao->object_table
] = 1;
53 * Build the form object.
55 public function buildQuickForm() {
56 parent
::buildQuickForm();
58 if ($this->_action
& CRM_Core_Action
::DELETE
) {
62 $permissions = array_flip(CRM_Core_Permission
::basicPermissions());
63 $this->addCheckBox('object_table',
66 NULL, NULL, TRUE, NULL,
67 ['</td><td>', '</td></tr><tr><td>']
72 '-1' => ts('- select role -'),
73 '0' => ts('Everyone'),
74 ] + CRM_Core_OptionGroup
::values('acl_role');
75 $entityID = &$this->add('select', 'entity_id', $label, $role, TRUE);
80 $this->add('checkbox', 'is_active', ts('Enabled?'));
82 $this->addFormRule(['CRM_ACL_Form_ACLBasic', 'formRule']);
86 * @param array $params
90 public static function formRule($params) {
91 if ($params['entity_id'] == -1) {
92 $errors = ['entity_id' => ts('Role is a required field')];
100 * Process the form submission.
102 public function postProcess() {
103 CRM_ACL_BAO_Cache
::resetCache();
105 $params = $this->controller
->exportValues($this->_name
);
113 AND ( object_table NOT IN ( 'civicrm_saved_search', 'civicrm_uf_group', 'civicrm_custom_group' ) )
115 $deleteParams = [1 => [$this->_id
, 'Integer']];
116 CRM_Core_DAO
::executeQuery($query, $deleteParams);
118 if ($this->_action
& CRM_Core_Action
::DELETE
) {
119 CRM_Core_Session
::setStatus(ts('Selected ACL has been deleted.'), ts('Record Deleted'), 'success');
124 $params['operation'] = 'All';
126 $params['is_active'] = 1;
127 $params['entity_table'] = 'civicrm_acl_role';
128 $params['name'] = 'Core ACL';
130 foreach ($params['object_table'] as $object_table => $value) {
132 $newParams = $params;
133 unset($newParams['object_table']);
134 $newParams['object_table'] = $object_table;
135 CRM_ACL_BAO_ACL
::create($newParams);