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_ACLBasic
extends CRM_Core_Page_Basic
{
20 * The action links that we need to display for the browse screen.
24 public static $_links = NULL;
32 public function getBAOName() {
33 return 'CRM_ACL_BAO_ACL';
40 * (reference) of action links
42 public function &links() {
43 if (!(self
::$_links)) {
45 CRM_Core_Action
::UPDATE
=> [
47 'url' => 'civicrm/acl/basic',
48 'qs' => 'reset=1&action=update&id=%%id%%',
49 'title' => ts('Edit ACL'),
51 CRM_Core_Action
::DELETE
=> [
52 'name' => ts('Delete'),
53 'url' => 'civicrm/acl/basic',
54 'qs' => 'reset=1&action=delete&id=%%id%%',
55 'title' => ts('Delete ACL'),
65 * This method is called after the page is created. It checks for the
66 * type of action and executes that action.
67 * Finally it calls the parent's run method.
69 public function run() {
70 $id = $this->getIdAndAction();
72 // set breadcrumb to append to admin/access
75 'title' => ts('Access Control'),
76 'url' => CRM_Utils_System
::url('civicrm/admin/access', 'reset=1'),
79 CRM_Utils_System
::appendBreadCrumb($breadCrumb);
81 // what action to take ?
82 if ($this->_action
& (CRM_Core_Action
::UPDATE | CRM_Core_Action
::ADD | CRM_Core_Action
::DELETE
)) {
83 $this->edit($this->_action
, $id);
86 // finally browse the acl's
89 // This replaces parent run, but do parent's parent run
90 return CRM_Core_Page
::run();
96 public function browse() {
98 // get all acl's sorted by weight
103 WHERE ( object_table NOT IN ( 'civicrm_saved_search', 'civicrm_uf_group', 'civicrm_custom_group' ) )
106 $dao = CRM_Core_DAO
::executeQuery($query);
108 $roles = CRM_Core_OptionGroup
::values('acl_role');
110 $permissions = CRM_Core_Permission
::basicPermissions();
111 while ($dao->fetch()) {
112 if (!array_key_exists($dao->entity_id
, $acl)) {
113 $acl[$dao->entity_id
] = [];
114 $acl[$dao->entity_id
]['name'] = $dao->name
;
115 $acl[$dao->entity_id
]['entity_id'] = $dao->entity_id
;
116 $acl[$dao->entity_id
]['entity_table'] = $dao->entity_table
;
117 $acl[$dao->entity_id
]['object_table'] = CRM_Utils_Array
::value($dao->object_table
, $permissions);
118 $acl[$dao->entity_id
]['is_active'] = 1;
120 if ($acl[$dao->entity_id
]['entity_id']) {
121 $acl[$dao->entity_id
]['entity'] = $roles[$acl[$dao->entity_id
]['entity_id']];
124 $acl[$dao->entity_id
]['entity'] = ts('Any Role');
127 // form all action links
128 $action = array_sum(array_keys($this->links()));
130 $acl[$dao->entity_id
]['action'] = CRM_Core_Action
::formLink(
133 ['id' => $dao->entity_id
],
136 'aclRole.manage.action',
141 elseif (!empty($permissions[$dao->object_table
])) {
142 $acl[$dao->entity_id
]['object_table'] .= ", {$permissions[$dao->object_table]}";
145 $this->assign('rows', $acl);
149 * Get name of edit form.
152 * Classname of edit form.
154 public function editForm() {
155 return 'CRM_ACL_Form_ACLBasic';
159 * Get edit form name.
164 public function editName() {
176 public function userContext($mode = NULL) {
177 return 'civicrm/acl/basic';