Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
6a488035 TO |
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 | class CRM_ACL_Form_EntityRole extends CRM_Admin_Form { | |
18 | ||
88aae6d4 A |
19 | /** |
20 | * @var bool | |
21 | */ | |
22 | public $submitOnce = TRUE; | |
23 | ||
6a488035 | 24 | /** |
d2e5d2ce | 25 | * Build the form object. |
6a488035 TO |
26 | */ |
27 | public function buildQuickForm() { | |
28 | parent::buildQuickForm(); | |
29 | ||
30 | if ($this->_action & CRM_Core_Action::DELETE) { | |
31 | return; | |
32 | } | |
33 | ||
6a488035 | 34 | $this->add('select', 'acl_role_id', ts('ACL Role'), |
a2eb6152 | 35 | CRM_Core_OptionGroup::values('acl_role'), TRUE, ['placeholder' => TRUE] |
6a488035 TO |
36 | ); |
37 | ||
3bd48a28 | 38 | $label = ts('Assigned to'); |
cf0d1c08 | 39 | $group = ['' => ts('- select group -')] + CRM_Core_PseudoConstant::staticGroup(FALSE, 'Access'); |
40 | $this->add('select', 'entity_id', $label, $group, TRUE, ['class' => 'crm-select2 huge']); | |
6a488035 TO |
41 | |
42 | $this->add('checkbox', 'is_active', ts('Enabled?')); | |
43 | } | |
44 | ||
45 | /** | |
d2e5d2ce | 46 | * Process the form submission. |
6a488035 TO |
47 | */ |
48 | public function postProcess() { | |
49 | CRM_ACL_BAO_Cache::resetCache(); | |
50 | ||
51 | if ($this->_action & CRM_Core_Action::DELETE) { | |
52 | CRM_ACL_BAO_EntityRole::del($this->_id); | |
53 | CRM_Core_Session::setStatus(ts('Selected Entity Role has been deleted.'), ts('Record Deleted'), 'success'); | |
54 | } | |
55 | else { | |
56 | $params = $this->controller->exportValues($this->_name); | |
57 | if ($this->_id) { | |
58 | $params['id'] = $this->_id; | |
59 | } | |
60 | ||
61 | $params['entity_table'] = 'civicrm_group'; | |
62 | CRM_ACL_BAO_EntityRole::create($params); | |
63 | } | |
64 | } | |
96025800 | 65 | |
6a488035 | 66 | } |