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_EntityRole
extends CRM_Core_Page_Basic
{
45 public $useLivePageJS = TRUE;
48 * The action links that we need to display for the browse screen
52 static $_links = NULL;
60 public function getBAOName() {
61 return 'CRM_ACL_BAO_EntityRole';
68 * (reference) of action links
70 public function &links() {
71 if (!(self
::$_links)) {
72 self
::$_links = array(
73 CRM_Core_Action
::UPDATE
=> array(
75 'url' => 'civicrm/acl/entityrole',
76 'qs' => 'action=update&id=%%id%%',
77 'title' => ts('Edit ACL Role Assignment'),
79 CRM_Core_Action
::DISABLE
=> array(
80 'name' => ts('Disable'),
81 'ref' => 'crm-enable-disable',
82 'title' => ts('Disable ACL Role Assignment'),
84 CRM_Core_Action
::ENABLE
=> array(
85 'name' => ts('Enable'),
86 'ref' => 'crm-enable-disable',
87 'title' => ts('Enable ACL Role Assignment'),
89 CRM_Core_Action
::DELETE
=> array(
90 'name' => ts('Delete'),
91 'url' => 'civicrm/acl/entityrole',
92 'qs' => 'action=delete&id=%%id%%',
93 'title' => ts('Delete ACL Role Assignment'),
103 * This method is called after the page is created. It checks for the
104 * type of action and executes that action.
105 * Finally it calls the parent's run method.
109 public function run() {
110 // get the requested action
111 $action = CRM_Utils_Request
::retrieve('action', 'String',
112 // default to 'browse'
113 $this, FALSE, 'browse'
116 // assign vars to templates
117 $this->assign('action', $action);
118 $id = CRM_Utils_Request
::retrieve('id', 'Positive',
122 // set breadcrumb to append to admin/access
125 'title' => ts('Access Control'),
126 'url' => CRM_Utils_System
::url('civicrm/admin/access',
131 CRM_Utils_System
::appendBreadCrumb($breadCrumb);
132 CRM_Utils_System
::setTitle(ts('Assign Users to Roles'));
134 // what action to take ?
135 if ($action & (CRM_Core_Action
::UPDATE | CRM_Core_Action
::ADD | CRM_Core_Action
::DELETE
)) {
136 $this->edit($action, $id);
139 // reset cache if enabled/disabled
140 if ($action & (CRM_Core_Action
::DISABLE | CRM_Core_Action
::ENABLE
)) {
141 CRM_ACL_BAO_Cache
::resetCache();
144 // finally browse the acl's
145 if ($action & CRM_Core_Action
::BROWSE
) {
149 return parent
::run();
157 public function browse() {
159 // get all acl's sorted by weight
160 $entityRoles = array();
161 $dao = new CRM_ACL_DAO_EntityRole();
164 $aclRoles = CRM_Core_OptionGroup
::values('acl_role');
165 $groups = CRM_Core_PseudoConstant
::staticGroup();
167 while ($dao->fetch()) {
168 $entityRoles[$dao->id
] = array();
169 CRM_Core_DAO
::storeValues($dao, $entityRoles[$dao->id
]);
171 $entityRoles[$dao->id
]['acl_role'] = $aclRoles[$dao->acl_role_id
];
172 $entityRoles[$dao->id
]['entity'] = $groups[$dao->entity_id
];
174 // form all action links
175 $action = array_sum(array_keys($this->links()));
176 if ($dao->is_active
) {
177 $action -= CRM_Core_Action
::ENABLE
;
180 $action -= CRM_Core_Action
::DISABLE
;
183 $entityRoles[$dao->id
]['action'] = CRM_Core_Action
::formLink(
186 array('id' => $dao->id
),
189 'entityRole.manage.action',
194 $this->assign('rows', $entityRoles);
198 * Get name of edit form
201 * Classname of edit form.
203 public function editForm() {
204 return 'CRM_ACL_Form_EntityRole';
213 public function editName() {
214 return 'ACL EntityRole';
225 public function userContext($mode = NULL) {
226 return 'civicrm/acl/entityrole';