3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
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-2013
39 * @copyright CiviCRM LLC (c) 2004-2013
43 class CRM_ACL_Form_ACLBasic
extends CRM_Admin_Form
{
46 * This function sets the default values for the form.
52 function setDefaultValues() {
58 $defaults['entity_id'] = $this->_id
;
64 AND ( object_table NOT IN ( 'civicrm_saved_search', 'civicrm_uf_group', 'civicrm_custom_group' ) )
66 $params = array(1 => array($this->_id
, 'Integer'));
67 $dao = CRM_Core_DAO
::executeQuery($query, $params);
68 $defaults['object_table'] = array();
69 while ($dao->fetch()) {
70 $defaults['object_table'][$dao->object_table
] = 1;
78 * Function to build the form
83 public function buildQuickForm() {
84 parent
::buildQuickForm();
86 if ($this->_action
& CRM_Core_Action
::DELETE
) {
90 $permissions = array_flip(CRM_Core_Permission
::basicPermissions());
91 $this->addCheckBox('object_table',
94 NULL, NULL, TRUE, NULL,
95 array('</td><td>', '</td></tr><tr><td>')
100 $role = array('-1' => ts('- select role -'),
101 '0' => ts('Everyone'),
102 ) + CRM_Core_OptionGroup
::values('acl_role');
103 $entityID = &$this->add('select', 'entity_id', $label, $role, TRUE);
108 $this->add('checkbox', 'is_active', ts('Enabled?'));
110 $this->addFormRule(array('CRM_ACL_Form_ACLBasic', 'formRule'));
113 static function formRule($params) {
114 if ($params['entity_id'] == -1) {
115 $errors = array('entity_id' => ts('Role is a required field'));
123 * Function to process the form
129 public function postProcess() {
130 CRM_ACL_BAO_Cache
::resetCache();
132 $params = $this->controller
->exportValues($this->_name
);
140 AND ( object_table NOT IN ( 'civicrm_saved_search', 'civicrm_uf_group', 'civicrm_custom_group' ) )
142 $deleteParams = array(1 => array($this->_id
, 'Integer'));
143 $dao = CRM_Core_DAO
::executeQuery($query, $deleteParams);
145 if ($this->_action
& CRM_Core_Action
::DELETE
) {
146 CRM_Core_Session
::setStatus(ts('Selected ACL has been deleted.'), ts('Record Deleted'), 'success');
151 $params['operation'] = 'All';
153 $params['is_active'] = 1;
154 $params['entity_table'] = 'civicrm_acl_role';
155 $params['name'] = 'Core ACL';
157 foreach ($params['object_table'] as $object_table => $value) {
159 $newParams = $params;
160 unset($newParams['object_table']);
161 $newParams['object_table'] = $object_table;
162 CRM_ACL_BAO_ACL
::create($newParams);