3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
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-2019
33 class CRM_ACL_Page_ACL
extends CRM_Core_Page_Basic
{
35 public $useLivePageJS = TRUE;
38 * The action links that we need to display for the browse screen.
42 public static $_links = NULL;
50 public function getBAOName() {
51 return 'CRM_ACL_BAO_ACL';
58 * (reference) of action links
60 public function &links() {
61 if (!(self
::$_links)) {
63 CRM_Core_Action
::UPDATE
=> [
65 'url' => 'civicrm/acl',
66 'qs' => 'reset=1&action=update&id=%%id%%',
67 'title' => ts('Edit ACL'),
69 CRM_Core_Action
::DISABLE
=> [
70 'name' => ts('Disable'),
71 'ref' => 'crm-enable-disable',
72 'title' => ts('Disable ACL'),
74 CRM_Core_Action
::ENABLE
=> [
75 'name' => ts('Enable'),
76 'ref' => 'crm-enable-disable',
77 'title' => ts('Enable ACL'),
79 CRM_Core_Action
::DELETE
=> [
80 'name' => ts('Delete'),
81 'url' => 'civicrm/acl',
82 'qs' => 'reset=1&action=delete&id=%%id%%',
83 'title' => ts('Delete ACL'),
93 * Set the breadcrumb before beginning the standard page run.
95 public function run() {
96 // set breadcrumb to append to admin/access
99 'title' => ts('Access Control'),
100 'url' => CRM_Utils_System
::url('civicrm/admin/access', 'reset=1'),
103 CRM_Utils_System
::appendBreadCrumb($breadCrumb);
106 return parent
::run();
112 public function browse() {
113 // get all acl's sorted by weight
118 WHERE ( object_table IN ( 'civicrm_saved_search', 'civicrm_uf_group', 'civicrm_custom_group', 'civicrm_event' ) )
121 $dao = CRM_Core_DAO
::executeQuery($query);
123 $roles = CRM_Core_OptionGroup
::values('acl_role');
126 '-1' => ts('- select -'),
127 '0' => ts('All Groups'),
128 ] + CRM_Core_PseudoConstant
::group();
130 '-1' => ts('- select -'),
131 '0' => ts('All Custom Groups'),
132 ] + CRM_Core_PseudoConstant
::get('CRM_Core_DAO_CustomField', 'custom_group_id');
134 '-1' => ts('- select -'),
135 '0' => ts('All Profiles'),
136 ] + CRM_Core_PseudoConstant
::get('CRM_Core_DAO_UFField', 'uf_group_id');
139 '-1' => ts('- select -'),
140 '0' => ts('All Events'),
141 ] + CRM_Event_PseudoConstant
::event();
143 while ($dao->fetch()) {
145 $acl[$dao->id
]['name'] = $dao->name
;
146 $acl[$dao->id
]['operation'] = $dao->operation
;
147 $acl[$dao->id
]['entity_id'] = $dao->entity_id
;
148 $acl[$dao->id
]['entity_table'] = $dao->entity_table
;
149 $acl[$dao->id
]['object_table'] = $dao->object_table
;
150 $acl[$dao->id
]['object_id'] = $dao->object_id
;
151 $acl[$dao->id
]['is_active'] = $dao->is_active
;
153 if ($acl[$dao->id
]['entity_id']) {
154 $acl[$dao->id
]['entity'] = CRM_Utils_Array
::value($acl[$dao->id
]['entity_id'], $roles);
157 $acl[$dao->id
]['entity'] = ts('Everyone');
160 switch ($acl[$dao->id
]['object_table']) {
161 case 'civicrm_saved_search':
162 $acl[$dao->id
]['object'] = CRM_Utils_Array
::value($acl[$dao->id
]['object_id'], $group);
163 $acl[$dao->id
]['object_name'] = ts('Group');
166 case 'civicrm_uf_group':
167 $acl[$dao->id
]['object'] = CRM_Utils_Array
::value($acl[$dao->id
]['object_id'], $ufGroup);
168 $acl[$dao->id
]['object_name'] = ts('Profile');
171 case 'civicrm_custom_group':
172 $acl[$dao->id
]['object'] = CRM_Utils_Array
::value($acl[$dao->id
]['object_id'], $customGroup);
173 $acl[$dao->id
]['object_name'] = ts('Custom Group');
176 case 'civicrm_event':
177 $acl[$dao->id
]['object'] = CRM_Utils_Array
::value($acl[$dao->id
]['object_id'], $event);
178 $acl[$dao->id
]['object_name'] = ts('Event');
182 // form all action links
183 $action = array_sum(array_keys($this->links()));
185 if ($dao->is_active
) {
186 $action -= CRM_Core_Action
::ENABLE
;
189 $action -= CRM_Core_Action
::DISABLE
;
192 $acl[$dao->id
]['action'] = CRM_Core_Action
::formLink(
203 $this->assign('rows', $acl);
207 * Get name of edit form.
210 * Classname of edit form.
212 public function editForm() {
213 return 'CRM_ACL_Form_ACL';
217 * Get edit form name.
222 public function editName() {
234 public function userContext($mode = NULL) {
235 return 'civicrm/acl';
242 * What mode for the form ?.
244 * Id of the entity (for update, view operations).
245 * @param bool $imageUpload
246 * Not used in this case, but extended from CRM_Core_Page_Basic.
247 * @param bool $pushUserContext
248 * Not used in this case, but extended from CRM_Core_Page_Basic.
250 public function edit($mode, $id = NULL, $imageUpload = FALSE, $pushUserContext = TRUE) {
251 if ($mode & (CRM_Core_Action
::UPDATE
)) {
253 $aclName = CRM_Core_DAO
::getFieldValue('CRM_ACL_DAO_ACL', $id);
254 CRM_Utils_System
::setTitle(ts('Edit ACL – %1', [1 => $aclName]));
257 parent
::edit($mode, $id, $imageUpload, $pushUserContext);