3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2015
33 class CRM_ACL_Form_ACLBasic
extends CRM_Admin_Form
{
36 * Set default values for the form.
38 public function setDefaultValues() {
44 $defaults['entity_id'] = $this->_id
;
50 AND ( object_table NOT IN ( 'civicrm_saved_search', 'civicrm_uf_group', 'civicrm_custom_group' ) )
52 $params = array(1 => array($this->_id
, 'Integer'));
53 $dao = CRM_Core_DAO
::executeQuery($query, $params);
54 $defaults['object_table'] = array();
55 while ($dao->fetch()) {
56 $defaults['object_table'][$dao->object_table
] = 1;
64 * Build the form object.
66 public function buildQuickForm() {
67 parent
::buildQuickForm();
69 if ($this->_action
& CRM_Core_Action
::DELETE
) {
73 $permissions = array_flip(CRM_Core_Permission
::basicPermissions());
74 $this->addCheckBox('object_table',
77 NULL, NULL, TRUE, NULL,
78 array('</td><td>', '</td></tr><tr><td>')
83 '-1' => ts('- select role -'),
84 '0' => ts('Everyone'),
85 ) + CRM_Core_OptionGroup
::values('acl_role');
86 $entityID = &$this->add('select', 'entity_id', $label, $role, TRUE);
91 $this->add('checkbox', 'is_active', ts('Enabled?'));
93 $this->addFormRule(array('CRM_ACL_Form_ACLBasic', 'formRule'));
97 * @param array $params
101 public static function formRule($params) {
102 if ($params['entity_id'] == -1) {
103 $errors = array('entity_id' => ts('Role is a required field'));
111 * Process the form submission.
113 public function postProcess() {
114 CRM_ACL_BAO_Cache
::resetCache();
116 $params = $this->controller
->exportValues($this->_name
);
124 AND ( object_table NOT IN ( 'civicrm_saved_search', 'civicrm_uf_group', 'civicrm_custom_group' ) )
126 $deleteParams = array(1 => array($this->_id
, 'Integer'));
127 CRM_Core_DAO
::executeQuery($query, $deleteParams);
129 if ($this->_action
& CRM_Core_Action
::DELETE
) {
130 CRM_Core_Session
::setStatus(ts('Selected ACL has been deleted.'), ts('Record Deleted'), 'success');
135 $params['operation'] = 'All';
137 $params['is_active'] = 1;
138 $params['entity_table'] = 'civicrm_acl_role';
139 $params['name'] = 'Core ACL';
141 foreach ($params['object_table'] as $object_table => $value) {
143 $newParams = $params;
144 unset($newParams['object_table']);
145 $newParams['object_table'] = $object_table;
146 CRM_ACL_BAO_ACL
::create($newParams);