8b2e61a84aa5fd6f75f0aaa9c6a1ac5bb0c96b31
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_ACLBasic
extends CRM_Core_Page_Basic
{
46 * The action links that we need to display for the browse screen
51 static $_links = NULL;
56 * @return string Classname of BAO.
58 public function getBAOName() {
59 return 'CRM_ACL_BAO_ACL';
65 * @return array (reference) of action links
67 public function &links() {
68 if (!(self
::$_links)) {
69 self
::$_links = array(
70 CRM_Core_Action
::UPDATE
=> array(
72 'url' => 'civicrm/acl/basic',
73 'qs' => 'reset=1&action=update&id=%%id%%',
74 'title' => ts('Edit ACL'),
76 CRM_Core_Action
::DELETE
=> array(
77 'name' => ts('Delete'),
78 'url' => 'civicrm/acl/basic',
79 'qs' => 'reset=1&action=delete&id=%%id%%',
80 'title' => ts('Delete ACL'),
90 * This method is called after the page is created. It checks for the
91 * type of action and executes that action.
92 * Finally it calls the parent's run method.
98 public function run() {
99 // get the requested action
100 $action = CRM_Utils_Request
::retrieve('action', 'String',
101 // default to 'browse'
102 $this, FALSE, 'browse'
105 // assign vars to templates
106 $this->assign('action', $action);
107 $id = CRM_Utils_Request
::retrieve('id', 'Positive',
111 // set breadcrumb to append to admin/access
112 $breadCrumb = array(array('title' => ts('Access Control'),
113 'url' => CRM_Utils_System
::url('civicrm/admin/access', 'reset=1'),
115 CRM_Utils_System
::appendBreadCrumb($breadCrumb);
117 // what action to take ?
118 if ($action & (CRM_Core_Action
::UPDATE | CRM_Core_Action
::ADD | CRM_Core_Action
::DELETE
)) {
119 $this->edit($action, $id);
122 // finally browse the acl's
126 return parent
::run();
136 public function browse() {
138 // get all acl's sorted by weight
143 WHERE ( object_table NOT IN ( 'civicrm_saved_search', 'civicrm_uf_group', 'civicrm_custom_group' ) )
146 $dao = CRM_Core_DAO
::executeQuery($query,
147 CRM_Core_DAO
::$_nullArray
150 $roles = CRM_Core_OptionGroup
::values('acl_role');
152 $permissions = CRM_Core_Permission
::basicPermissions();
153 while ($dao->fetch()) {
154 if (!array_key_exists($dao->entity_id
, $acl)) {
155 $acl[$dao->entity_id
] = array();
156 $acl[$dao->entity_id
]['name'] = $dao->name
;
157 $acl[$dao->entity_id
]['entity_id'] = $dao->entity_id
;
158 $acl[$dao->entity_id
]['entity_table'] = $dao->entity_table
;
159 $acl[$dao->entity_id
]['object_table'] = CRM_Utils_Array
::value($dao->object_table
, $permissions);
160 $acl[$dao->entity_id
]['is_active'] = 1;
162 if ($acl[$dao->entity_id
]['entity_id']) {
163 $acl[$dao->entity_id
]['entity'] = $roles[$acl[$dao->entity_id
]['entity_id']];
166 $acl[$dao->entity_id
]['entity'] = ts('Any Role');
169 // form all action links
170 $action = array_sum(array_keys($this->links()));
172 $acl[$dao->entity_id
]['action'] = CRM_Core_Action
::formLink(
175 array('id' => $dao->entity_id
),
178 'aclRole.manage.action',
183 elseif (!empty($permissions[$dao->object_table
])) {
184 $acl[$dao->entity_id
]['object_table'] .= ", {$permissions[$dao->object_table]}";
187 $this->assign('rows', $acl);
191 * Get name of edit form
193 * @return string Classname of edit form.
195 public function editForm() {
196 return 'CRM_ACL_Form_ACLBasic';
202 * @return string name of this page.
204 public function editName() {
213 * @return string user context.
215 public function userContext($mode = NULL) {
216 return 'civicrm/acl/basic';