3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
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-2014
39 * @copyright CiviCRM LLC (c) 2004-2014
43 class CRM_ACL_Page_ACL
extends CRM_Core_Page_Basic
{
45 public $useLivePageJS = TRUE;
48 * The action links that we need to display for the browse screen
53 static $_links = NULL;
58 * @return string Classname of BAO.
60 public function getBAOName() {
61 return 'CRM_ACL_BAO_ACL';
67 * @return array (reference) of action links
69 public function &links() {
70 if (!(self
::$_links)) {
71 self
::$_links = array(
72 CRM_Core_Action
::UPDATE
=> array(
74 'url' => 'civicrm/acl',
75 'qs' => 'reset=1&action=update&id=%%id%%',
76 'title' => ts('Edit ACL'),
78 CRM_Core_Action
::DISABLE
=> array(
79 'name' => ts('Disable'),
80 'ref' => 'crm-enable-disable',
81 'title' => ts('Disable ACL'),
83 CRM_Core_Action
::ENABLE
=> array(
84 'name' => ts('Enable'),
85 'ref' => 'crm-enable-disable',
86 'title' => ts('Enable ACL'),
88 CRM_Core_Action
::DELETE
=> array(
89 'name' => ts('Delete'),
90 'url' => 'civicrm/acl',
91 'qs' => 'reset=1&action=delete&id=%%id%%',
92 'title' => ts('Delete ACL'),
102 * This method is called after the page is created. It checks for the
103 * type of action and executes that action.
104 * Finally it calls the parent's run method.
109 public function run() {
110 // get the requested action
111 $action = CRM_Utils_Request
::retrieve('action', 'String',
112 // default to 'browse'
113 $this, FALSE, 'browse'
116 // assign vars to templates
117 $this->assign('action', $action);
118 $id = CRM_Utils_Request
::retrieve('id', 'Positive',
122 // set breadcrumb to append to admin/access
123 $breadCrumb = array(array('title' => ts('Access Control'),
124 'url' => CRM_Utils_System
::url('civicrm/admin/access',
128 CRM_Utils_System
::appendBreadCrumb($breadCrumb);
129 // what action to take ?
130 if ($action & (CRM_Core_Action
::ADD | CRM_Core_Action
::DELETE
)) {
131 $this->edit($action, $id);
134 if ($action & (CRM_Core_Action
::UPDATE
)) {
135 $this->edit($action, $id);
138 $aclName = CRM_Core_DAO
::getFieldValue('CRM_ACL_DAO_ACL', $id);
139 CRM_Utils_System
::setTitle(ts('Edit ACL - %1', array(1 => $aclName)));
143 // finally browse the acl's
144 if ($action & CRM_Core_Action
::BROWSE
) {
149 return parent
::run();
158 public function browse() {
159 // get all acl's sorted by weight
164 WHERE ( object_table IN ( 'civicrm_saved_search', 'civicrm_uf_group', 'civicrm_custom_group', 'civicrm_event' ) )
167 $dao = CRM_Core_DAO
::executeQuery($query,
168 CRM_Core_DAO
::$_nullArray
171 $roles = CRM_Core_OptionGroup
::values('acl_role');
173 $group = array('-1' => ts('- select -'),
174 '0' => ts('All Groups'),
175 ) + CRM_Core_PseudoConstant
::group();
176 $customGroup = array('-1' => ts('- select -'),
177 '0' => ts('All Custom Groups'),
178 ) + CRM_Core_PseudoConstant
::get('CRM_Core_DAO_CustomField', 'custom_group_id');
179 $ufGroup = array('-1' => ts('- select -'),
180 '0' => ts('All Profiles'),
181 ) + CRM_Core_PseudoConstant
::get('CRM_Core_DAO_UFField', 'uf_group_id');
183 $event = array('-1' => ts('- select -'),
184 '0' => ts('All Events'),
185 ) + CRM_Event_PseudoConstant
::event();
187 while ($dao->fetch()) {
188 $acl[$dao->id
] = array();
189 $acl[$dao->id
]['name'] = $dao->name
;
190 $acl[$dao->id
]['operation'] = $dao->operation
;
191 $acl[$dao->id
]['entity_id'] = $dao->entity_id
;
192 $acl[$dao->id
]['entity_table'] = $dao->entity_table
;
193 $acl[$dao->id
]['object_table'] = $dao->object_table
;
194 $acl[$dao->id
]['object_id'] = $dao->object_id
;
195 $acl[$dao->id
]['is_active'] = $dao->is_active
;
198 if ($acl[$dao->id
]['entity_id']) {
199 $acl[$dao->id
]['entity'] = $roles[$acl[$dao->id
]['entity_id']];
202 $acl[$dao->id
]['entity'] = ts('Everyone');
205 switch ($acl[$dao->id
]['object_table']) {
206 case 'civicrm_saved_search':
207 $acl[$dao->id
]['object'] = $group[$acl[$dao->id
]['object_id']];
208 $acl[$dao->id
]['object_name'] = ts('Group');
211 case 'civicrm_uf_group':
212 $acl[$dao->id
]['object'] = $ufGroup[$acl[$dao->id
]['object_id']];
213 $acl[$dao->id
]['object_name'] = ts('Profile');
216 case 'civicrm_custom_group':
217 $acl[$dao->id
]['object'] = $customGroup[$acl[$dao->id
]['object_id']];
218 $acl[$dao->id
]['object_name'] = ts('Custom Group');
221 case 'civicrm_event':
222 $acl[$dao->id
]['object'] = $event[$acl[$dao->id
]['object_id']];
223 $acl[$dao->id
]['object_name'] = ts('Event');
227 // form all action links
228 $action = array_sum(array_keys($this->links()));
230 if ($dao->is_active
) {
231 $action -= CRM_Core_Action
::ENABLE
;
234 $action -= CRM_Core_Action
::DISABLE
;
237 $acl[$dao->id
]['action'] = CRM_Core_Action
::formLink(
240 array('id' => $dao->id
),
248 $this->assign('rows', $acl);
252 * Get name of edit form
254 * @return string Classname of edit form.
256 public function editForm() {
257 return 'CRM_ACL_Form_ACL';
263 * @return string name of this page.
265 public function editName() {
274 * @return string user context.
276 public function userContext($mode = NULL) {
277 return 'civicrm/acl';