Merge pull request #18714 from MegaphoneJon/financial-111
[civicrm-core.git] / CRM / ACL / Form / EntityRole.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
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 +--------------------------------------------------------------------+
10 */
11
12 /**
13 *
14 * @package CRM
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
16 */
17 class CRM_ACL_Form_EntityRole extends CRM_Admin_Form {
18
19 /**
20 * Build the form object.
21 */
22 public function buildQuickForm() {
23 parent::buildQuickForm();
24
25 if ($this->_action & CRM_Core_Action::DELETE) {
26 return;
27 }
28
29 $this->add('select', 'acl_role_id', ts('ACL Role'),
30 CRM_Core_OptionGroup::values('acl_role'), TRUE, ['placeholder' => TRUE]
31 );
32
33 $label = ts('Assigned to');
34 $group = ['' => ts('- select group -')] + CRM_Core_PseudoConstant::staticGroup(FALSE, 'Access');
35 $this->add('select', 'entity_id', $label, $group, TRUE, ['class' => 'crm-select2 huge']);
36
37 $this->add('checkbox', 'is_active', ts('Enabled?'));
38 }
39
40 /**
41 * Process the form submission.
42 */
43 public function postProcess() {
44 CRM_ACL_BAO_Cache::resetCache();
45
46 if ($this->_action & CRM_Core_Action::DELETE) {
47 CRM_ACL_BAO_EntityRole::del($this->_id);
48 CRM_Core_Session::setStatus(ts('Selected Entity Role has been deleted.'), ts('Record Deleted'), 'success');
49 }
50 else {
51 $params = $this->controller->exportValues($this->_name);
52 if ($this->_id) {
53 $params['id'] = $this->_id;
54 }
55
56 $params['entity_table'] = 'civicrm_group';
57 CRM_ACL_BAO_EntityRole::create($params);
58 }
59 }
60
61 }