3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
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 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
17 class CRM_ACL_Page_ACL
extends CRM_Core_Page_Basic
{
19 public $useLivePageJS = TRUE;
22 * The action links that we need to display for the browse screen.
26 public static $_links = NULL;
34 public function getBAOName() {
35 return 'CRM_ACL_BAO_ACL';
42 * (reference) of action links
44 public function &links() {
45 if (!(self
::$_links)) {
47 CRM_Core_Action
::UPDATE
=> [
49 'url' => 'civicrm/acl',
50 'qs' => 'reset=1&action=update&id=%%id%%',
51 'title' => ts('Edit ACL'),
53 CRM_Core_Action
::DISABLE
=> [
54 'name' => ts('Disable'),
55 'ref' => 'crm-enable-disable',
56 'title' => ts('Disable ACL'),
58 CRM_Core_Action
::ENABLE
=> [
59 'name' => ts('Enable'),
60 'ref' => 'crm-enable-disable',
61 'title' => ts('Enable ACL'),
63 CRM_Core_Action
::DELETE
=> [
64 'name' => ts('Delete'),
65 'url' => 'civicrm/acl',
66 'qs' => 'reset=1&action=delete&id=%%id%%',
67 'title' => ts('Delete ACL'),
77 * Set the breadcrumb before beginning the standard page run.
79 public function run() {
80 // set breadcrumb to append to admin/access
83 'title' => ts('Access Control'),
84 'url' => CRM_Utils_System
::url('civicrm/admin/access', 'reset=1'),
87 CRM_Utils_System
::appendBreadCrumb($breadCrumb);
96 public function browse() {
97 // get all acl's sorted by weight
102 WHERE ( object_table IN ( 'civicrm_saved_search', 'civicrm_uf_group', 'civicrm_custom_group', 'civicrm_event' ) )
105 $dao = CRM_Core_DAO
::executeQuery($query);
107 $roles = CRM_Core_OptionGroup
::values('acl_role');
110 '-1' => ts('- select -'),
111 '0' => ts('All Groups'),
112 ] + CRM_Core_PseudoConstant
::group();
114 '-1' => ts('- select -'),
115 '0' => ts('All Custom Groups'),
116 ] + CRM_Core_PseudoConstant
::get('CRM_Core_DAO_CustomField', 'custom_group_id');
118 '-1' => ts('- select -'),
119 '0' => ts('All Profiles'),
120 ] + CRM_Core_PseudoConstant
::get('CRM_Core_DAO_UFField', 'uf_group_id');
123 '-1' => ts('- select -'),
124 '0' => ts('All Events'),
125 ] + CRM_Event_PseudoConstant
::event();
127 while ($dao->fetch()) {
129 $acl[$dao->id
]['name'] = $dao->name
;
130 $acl[$dao->id
]['operation'] = $dao->operation
;
131 $acl[$dao->id
]['entity_id'] = $dao->entity_id
;
132 $acl[$dao->id
]['entity_table'] = $dao->entity_table
;
133 $acl[$dao->id
]['object_table'] = $dao->object_table
;
134 $acl[$dao->id
]['object_id'] = $dao->object_id
;
135 $acl[$dao->id
]['is_active'] = $dao->is_active
;
137 if ($acl[$dao->id
]['entity_id']) {
138 $acl[$dao->id
]['entity'] = CRM_Utils_Array
::value($acl[$dao->id
]['entity_id'], $roles);
141 $acl[$dao->id
]['entity'] = ts('Everyone');
144 switch ($acl[$dao->id
]['object_table']) {
145 case 'civicrm_saved_search':
146 $acl[$dao->id
]['object'] = CRM_Utils_Array
::value($acl[$dao->id
]['object_id'], $group);
147 $acl[$dao->id
]['object_name'] = ts('Group');
150 case 'civicrm_uf_group':
151 $acl[$dao->id
]['object'] = CRM_Utils_Array
::value($acl[$dao->id
]['object_id'], $ufGroup);
152 $acl[$dao->id
]['object_name'] = ts('Profile');
155 case 'civicrm_custom_group':
156 $acl[$dao->id
]['object'] = CRM_Utils_Array
::value($acl[$dao->id
]['object_id'], $customGroup);
157 $acl[$dao->id
]['object_name'] = ts('Custom Group');
160 case 'civicrm_event':
161 $acl[$dao->id
]['object'] = CRM_Utils_Array
::value($acl[$dao->id
]['object_id'], $event);
162 $acl[$dao->id
]['object_name'] = ts('Event');
166 // form all action links
167 $action = array_sum(array_keys($this->links()));
169 if ($dao->is_active
) {
170 $action -= CRM_Core_Action
::ENABLE
;
173 $action -= CRM_Core_Action
::DISABLE
;
176 $acl[$dao->id
]['action'] = CRM_Core_Action
::formLink(
187 $this->assign('rows', $acl);
191 * Get name of edit form.
194 * Classname of edit form.
196 public function editForm() {
197 return 'CRM_ACL_Form_ACL';
201 * Get edit form name.
206 public function editName() {
218 public function userContext($mode = NULL) {
219 return 'civicrm/acl';
226 * What mode for the form ?.
228 * Id of the entity (for update, view operations).
229 * @param bool $imageUpload
230 * Not used in this case, but extended from CRM_Core_Page_Basic.
231 * @param bool $pushUserContext
232 * Not used in this case, but extended from CRM_Core_Page_Basic.
234 public function edit($mode, $id = NULL, $imageUpload = FALSE, $pushUserContext = TRUE) {
235 if ($mode & (CRM_Core_Action
::UPDATE
)) {
237 $aclName = CRM_Core_DAO
::getFieldValue('CRM_ACL_DAO_ACL', $id);
238 CRM_Utils_System
::setTitle(ts('Edit ACL – %1', [1 => $aclName]));
241 parent
::edit($mode, $id, $imageUpload, $pushUserContext);