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_ACLBasic
extends CRM_Core_Page_Basic
{
36 * The action links that we need to display for the browse screen.
40 public static $_links = NULL;
48 public function getBAOName() {
49 return 'CRM_ACL_BAO_ACL';
56 * (reference) of action links
58 public function &links() {
59 if (!(self
::$_links)) {
61 CRM_Core_Action
::UPDATE
=> [
63 'url' => 'civicrm/acl/basic',
64 'qs' => 'reset=1&action=update&id=%%id%%',
65 'title' => ts('Edit ACL'),
67 CRM_Core_Action
::DELETE
=> [
68 'name' => ts('Delete'),
69 'url' => 'civicrm/acl/basic',
70 'qs' => 'reset=1&action=delete&id=%%id%%',
71 'title' => ts('Delete ACL'),
81 * This method is called after the page is created. It checks for the
82 * type of action and executes that action.
83 * Finally it calls the parent's run method.
85 public function run() {
86 $id = $this->getIdAndAction();
88 // set breadcrumb to append to admin/access
91 'title' => ts('Access Control'),
92 'url' => CRM_Utils_System
::url('civicrm/admin/access', 'reset=1'),
95 CRM_Utils_System
::appendBreadCrumb($breadCrumb);
97 // what action to take ?
98 if ($this->_action
& (CRM_Core_Action
::UPDATE | CRM_Core_Action
::ADD | CRM_Core_Action
::DELETE
)) {
99 $this->edit($this->_action
, $id);
102 // finally browse the acl's
105 // This replaces parent run, but do parent's parent run
106 return CRM_Core_Page
::run();
112 public function browse() {
114 // get all acl's sorted by weight
119 WHERE ( object_table NOT IN ( 'civicrm_saved_search', 'civicrm_uf_group', 'civicrm_custom_group' ) )
122 $dao = CRM_Core_DAO
::executeQuery($query);
124 $roles = CRM_Core_OptionGroup
::values('acl_role');
126 $permissions = CRM_Core_Permission
::basicPermissions();
127 while ($dao->fetch()) {
128 if (!array_key_exists($dao->entity_id
, $acl)) {
129 $acl[$dao->entity_id
] = [];
130 $acl[$dao->entity_id
]['name'] = $dao->name
;
131 $acl[$dao->entity_id
]['entity_id'] = $dao->entity_id
;
132 $acl[$dao->entity_id
]['entity_table'] = $dao->entity_table
;
133 $acl[$dao->entity_id
]['object_table'] = CRM_Utils_Array
::value($dao->object_table
, $permissions);
134 $acl[$dao->entity_id
]['is_active'] = 1;
136 if ($acl[$dao->entity_id
]['entity_id']) {
137 $acl[$dao->entity_id
]['entity'] = $roles[$acl[$dao->entity_id
]['entity_id']];
140 $acl[$dao->entity_id
]['entity'] = ts('Any Role');
143 // form all action links
144 $action = array_sum(array_keys($this->links()));
146 $acl[$dao->entity_id
]['action'] = CRM_Core_Action
::formLink(
149 ['id' => $dao->entity_id
],
152 'aclRole.manage.action',
157 elseif (!empty($permissions[$dao->object_table
])) {
158 $acl[$dao->entity_id
]['object_table'] .= ", {$permissions[$dao->object_table]}";
161 $this->assign('rows', $acl);
165 * Get name of edit form.
168 * Classname of edit form.
170 public function editForm() {
171 return 'CRM_ACL_Form_ACLBasic';
175 * Get edit form name.
180 public function editName() {
192 public function userContext($mode = NULL) {
193 return 'civicrm/acl/basic';