3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
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
39 * @copyright CiviCRM LLC (c) 2004-2015
43 class CRM_ACL_Form_ACLBasic
extends CRM_Admin_Form
{
46 * Set default values for the form.
51 public function setDefaultValues() {
57 $defaults['entity_id'] = $this->_id
;
63 AND ( object_table NOT IN ( 'civicrm_saved_search', 'civicrm_uf_group', 'civicrm_custom_group' ) )
65 $params = array(1 => array($this->_id
, 'Integer'));
66 $dao = CRM_Core_DAO
::executeQuery($query, $params);
67 $defaults['object_table'] = array();
68 while ($dao->fetch()) {
69 $defaults['object_table'][$dao->object_table
] = 1;
77 * Build the form object.
81 public function buildQuickForm() {
82 parent
::buildQuickForm();
84 if ($this->_action
& CRM_Core_Action
::DELETE
) {
88 $permissions = array_flip(CRM_Core_Permission
::basicPermissions());
89 $this->addCheckBox('object_table',
92 NULL, NULL, TRUE, NULL,
93 array('</td><td>', '</td></tr><tr><td>')
98 '-1' => ts('- select role -'),
99 '0' => ts('Everyone'),
100 ) + CRM_Core_OptionGroup
::values('acl_role');
101 $entityID = &$this->add('select', 'entity_id', $label, $role, TRUE);
106 $this->add('checkbox', 'is_active', ts('Enabled?'));
108 $this->addFormRule(array('CRM_ACL_Form_ACLBasic', 'formRule'));
112 * @param array $params
116 public static function formRule($params) {
117 if ($params['entity_id'] == -1) {
118 $errors = array('entity_id' => ts('Role is a required field'));
126 * Process the form submission.
131 public function postProcess() {
132 CRM_ACL_BAO_Cache
::resetCache();
134 $params = $this->controller
->exportValues($this->_name
);
142 AND ( object_table NOT IN ( 'civicrm_saved_search', 'civicrm_uf_group', 'civicrm_custom_group' ) )
144 $deleteParams = array(1 => array($this->_id
, 'Integer'));
145 CRM_Core_DAO
::executeQuery($query, $deleteParams);
147 if ($this->_action
& CRM_Core_Action
::DELETE
) {
148 CRM_Core_Session
::setStatus(ts('Selected ACL has been deleted.'), ts('Record Deleted'), 'success');
153 $params['operation'] = 'All';
155 $params['is_active'] = 1;
156 $params['entity_table'] = 'civicrm_acl_role';
157 $params['name'] = 'Core ACL';
159 foreach ($params['object_table'] as $object_table => $value) {
161 $newParams = $params;
162 unset($newParams['object_table']);
163 $newParams['object_table'] = $object_table;
164 CRM_ACL_BAO_ACL
::create($newParams);