3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2018 |
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-2018
33 class CRM_ACL_Page_EntityRole
extends CRM_Core_Page_Basic
{
35 public $useLivePageJS = TRUE;
38 * The action links that we need to display for the browse screen.
42 static $_links = NULL;
50 public function getBAOName() {
51 return 'CRM_ACL_BAO_EntityRole';
58 * (reference) of action links
60 public function &links() {
61 if (!(self
::$_links)) {
62 self
::$_links = array(
63 CRM_Core_Action
::UPDATE
=> array(
65 'url' => 'civicrm/acl/entityrole',
66 'qs' => 'action=update&id=%%id%%',
67 'title' => ts('Edit ACL Role Assignment'),
69 CRM_Core_Action
::DISABLE
=> array(
70 'name' => ts('Disable'),
71 'ref' => 'crm-enable-disable',
72 'title' => ts('Disable ACL Role Assignment'),
74 CRM_Core_Action
::ENABLE
=> array(
75 'name' => ts('Enable'),
76 'ref' => 'crm-enable-disable',
77 'title' => ts('Enable ACL Role Assignment'),
79 CRM_Core_Action
::DELETE
=> array(
80 'name' => ts('Delete'),
81 'url' => 'civicrm/acl/entityrole',
82 'qs' => 'action=delete&id=%%id%%',
83 'title' => ts('Delete ACL Role Assignment'),
93 * This method is called after the page is created. It checks for the
94 * type of action and executes that action.
95 * Finally it calls the parent's run method.
97 public function run() {
98 $id = $this->getIdAndAction();
100 // set breadcrumb to append to admin/access
103 'title' => ts('Access Control'),
104 'url' => CRM_Utils_System
::url('civicrm/admin/access',
109 CRM_Utils_System
::appendBreadCrumb($breadCrumb);
110 CRM_Utils_System
::setTitle(ts('Assign Users to Roles'));
112 // what action to take ?
113 if ($this->_action
& (CRM_Core_Action
::UPDATE | CRM_Core_Action
::ADD | CRM_Core_Action
::DELETE
)) {
114 $this->edit($this->_action
, $id);
117 // reset cache if enabled/disabled
118 if ($this->_action
& (CRM_Core_Action
::DISABLE | CRM_Core_Action
::ENABLE
)) {
119 CRM_ACL_BAO_Cache
::resetCache();
122 // finally browse the acl's
123 if ($this->_action
& CRM_Core_Action
::BROWSE
) {
127 // This replaces parent run, but do parent's parent run
128 return CRM_Core_Page
::run();
134 public function browse() {
136 // get all acl's sorted by weight
137 $entityRoles = array();
138 $dao = new CRM_ACL_DAO_EntityRole();
141 $aclRoles = CRM_Core_OptionGroup
::values('acl_role');
142 $groups = CRM_Core_PseudoConstant
::staticGroup();
144 while ($dao->fetch()) {
145 $entityRoles[$dao->id
] = array();
146 CRM_Core_DAO
::storeValues($dao, $entityRoles[$dao->id
]);
148 $entityRoles[$dao->id
]['acl_role'] = CRM_Utils_Array
::value($dao->acl_role_id
, $aclRoles);
149 $entityRoles[$dao->id
]['entity'] = $groups[$dao->entity_id
];
151 // form all action links
152 $action = array_sum(array_keys($this->links()));
153 if ($dao->is_active
) {
154 $action -= CRM_Core_Action
::ENABLE
;
157 $action -= CRM_Core_Action
::DISABLE
;
160 $entityRoles[$dao->id
]['action'] = CRM_Core_Action
::formLink(
163 array('id' => $dao->id
),
166 'entityRole.manage.action',
171 $this->assign('rows', $entityRoles);
175 * Get name of edit form.
178 * Classname of edit form.
180 public function editForm() {
181 return 'CRM_ACL_Form_EntityRole';
185 * Get edit form name.
190 public function editName() {
191 return 'ACL EntityRole';
202 public function userContext($mode = NULL) {
203 return 'civicrm/acl/entityrole';