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_EntityRole
extends CRM_Core_Page_Basic
{
19 public $useLivePageJS = TRUE;
22 * The action links that we need to display for the browse screen.
26 public static $_links = NULL;
34 public function getBAOName() {
35 return 'CRM_ACL_BAO_EntityRole';
42 * (reference) of action links
44 public function &links() {
45 if (!(self
::$_links)) {
47 CRM_Core_Action
::UPDATE
=> [
49 'url' => 'civicrm/acl/entityrole',
50 'qs' => 'action=update&id=%%id%%',
51 'title' => ts('Edit ACL Role Assignment'),
53 CRM_Core_Action
::DISABLE
=> [
54 'name' => ts('Disable'),
55 'ref' => 'crm-enable-disable',
56 'title' => ts('Disable ACL Role Assignment'),
58 CRM_Core_Action
::ENABLE
=> [
59 'name' => ts('Enable'),
60 'ref' => 'crm-enable-disable',
61 'title' => ts('Enable ACL Role Assignment'),
63 CRM_Core_Action
::DELETE
=> [
64 'name' => ts('Delete'),
65 'url' => 'civicrm/acl/entityrole',
66 'qs' => 'action=delete&id=%%id%%',
67 'title' => ts('Delete ACL Role Assignment'),
77 * This method is called after the page is created. It checks for the
78 * type of action and executes that action.
79 * Finally it calls the parent's run method.
81 public function run() {
82 $id = $this->getIdAndAction();
84 // set breadcrumb to append to admin/access
87 'title' => ts('Access Control'),
88 'url' => CRM_Utils_System
::url('civicrm/admin/access', 'reset=1'),
91 CRM_Utils_System
::appendBreadCrumb($breadCrumb);
92 CRM_Utils_System
::setTitle(ts('Assign Users to Roles'));
94 // what action to take ?
95 if ($this->_action
& (CRM_Core_Action
::UPDATE | CRM_Core_Action
::ADD | CRM_Core_Action
::DELETE
)) {
96 $this->edit($this->_action
, $id);
99 // reset cache if enabled/disabled
100 if ($this->_action
& (CRM_Core_Action
::DISABLE | CRM_Core_Action
::ENABLE
)) {
101 CRM_ACL_BAO_Cache
::resetCache();
104 // finally browse the acl's
105 if ($this->_action
& CRM_Core_Action
::BROWSE
) {
109 // This replaces parent run, but do parent's parent run
110 return CRM_Core_Page
::run();
116 public function browse() {
118 // get all acl's sorted by weight
120 $dao = new CRM_ACL_DAO_EntityRole();
123 $aclRoles = CRM_Core_OptionGroup
::values('acl_role');
124 $groups = CRM_Core_PseudoConstant
::staticGroup();
126 while ($dao->fetch()) {
127 $entityRoles[$dao->id
] = [];
128 CRM_Core_DAO
::storeValues($dao, $entityRoles[$dao->id
]);
130 $entityRoles[$dao->id
]['acl_role'] = $aclRoles[$dao->acl_role_id
] ??
NULL;
131 $entityRoles[$dao->id
]['entity'] = $groups[$dao->entity_id
];
133 // form all action links
134 $action = array_sum(array_keys($this->links()));
135 if ($dao->is_active
) {
136 $action -= CRM_Core_Action
::ENABLE
;
139 $action -= CRM_Core_Action
::DISABLE
;
142 $entityRoles[$dao->id
]['action'] = CRM_Core_Action
::formLink(
148 'entityRole.manage.action',
153 $this->assign('rows', $entityRoles);
157 * Get name of edit form.
160 * Classname of edit form.
162 public function editForm() {
163 return 'CRM_ACL_Form_EntityRole';
167 * Get edit form name.
172 public function editName() {
173 return 'ACL EntityRole';
184 public function userContext($mode = NULL) {
185 return 'civicrm/acl/entityrole';