ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilSettingsPermissionGUI Class Reference

UI class for handling permissions that can be configured having the write permission for an object. More...

+ Collaboration diagram for ilSettingsPermissionGUI:

Public Member Functions

 __construct ($a_gui_obj)
 Constructor. More...
 
 determineRoles ()
 Determine roles. More...
 
 setRoleRequiredPermissions ($a_val)
 Set role required permissions (this permissions are required for a role to be listed) More...
 
 getRoleRequiredPermissions ()
 Get role required permissions. More...
 
 setRoleProhibitedPermissions ($a_val)
 Set role prohibited permissions (this permissions are prohibited for a role to be listed) More...
 
 getRoleProhibitedPermissions ()
 Get role prohibited permissions. More...
 
 setPermissions ($a_val)
 Set permissions. More...
 
 getPermissions ()
 Get permissions. More...
 
 executeCommand ()
 Execute command. More...
 
 showForm ()
 Show form. More...
 
 initPermissionForm ()
 Init permission form. More...
 
 save ()
 Save form. More...
 

Protected Attributes

 $permissions = array()
 
 $base_permissions = array()
 
 $base_permissions_by_op = array()
 
 $role_required_permissions = array()
 
 $role_prohibited_permissions = array()
 

Detailed Description

UI class for handling permissions that can be configured having the write permission for an object.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 13 of file class.ilSettingsPermissionGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilSettingsPermissionGUI::__construct (   $a_gui_obj)

Constructor.

Parameters
ilObjectGUI$a_gui_objobject gui object

Definition at line 26 of file class.ilSettingsPermissionGUI.php.

References $ilCtrl, $lng, $tpl, and ilRbacReview\_getOperationList().

27  {
28  global $objDefinition, $tpl, $ilCtrl, $lng, $rbacreview;
29 
30  $this->objDefinition = $objDefinition;
31  $this->tpl = $tpl;
32  $this->lng = $lng;
33  $this->lng->loadLanguageModule("rbac");
34 
35  $this->ctrl = $ilCtrl;
36 
37  $this->gui_obj = $a_gui_obj;
38  $this->obj = $a_gui_obj->object;
39  $this->red_id = $this->obj->getRefId();
40 
41 
42  foreach (ilRbacReview::_getOperationList($this->obj->getType()) as $p) {
43  $this->base_permissions[$p["ops_id"]] = $p["operation"];
44  $this->base_permissions_by_op[$p["operation"]] = $p["ops_id"];
45  }
46 
47  $this->base_roles = $rbacreview->getParentRoleIds($this->obj->getRefId());
48  }
$tpl
Definition: ilias.php:10
static _getOperationList($a_type=null)
get operation list by object type public static
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:17
+ Here is the call graph for this function:

Member Function Documentation

◆ determineRoles()

ilSettingsPermissionGUI::determineRoles ( )

Determine roles.

Definition at line 53 of file class.ilSettingsPermissionGUI.php.

References $r, array, getRoleProhibitedPermissions(), and getRoleRequiredPermissions().

Referenced by initPermissionForm(), and save().

54  {
55  global $rbacreview;
56 
57  $roles = array();
58  foreach ($this->base_roles as $k => $r) {
59  $ops = $rbacreview->getActiveOperationsOfRole($this->obj->getRefId(), $r["rol_id"]);
60  $use = true;
61  foreach ($this->getRoleRequiredPermissions() as $o) {
62  if (!in_array($o, $ops)) {
63  $use = false;
64  }
65  }
66  foreach ($this->getRoleProhibitedPermissions() as $o) {
67  if (in_array($o, $ops)) {
68  $use = false;
69  }
70  }
71  if ($use) {
72  $roles[$k] = $r;
73  }
74  }
75  return $roles;
76  }
$r
Definition: example_031.php:79
getRoleProhibitedPermissions()
Get role prohibited permissions.
Create styles array
The data for the language used.
getRoleRequiredPermissions()
Get role required permissions.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilSettingsPermissionGUI::executeCommand ( )

Execute command.

Definition at line 160 of file class.ilSettingsPermissionGUI.php.

References array.

161  {
162  $cmd = $this->ctrl->getCmd("showForm");
163  if (in_array($cmd, array("showForm", "save"))) {
164  $this->$cmd();
165  }
166  }
Create styles array
The data for the language used.

◆ getPermissions()

ilSettingsPermissionGUI::getPermissions ( )

Get permissions.

Returns
array array of operations (string) that should be offered

Definition at line 152 of file class.ilSettingsPermissionGUI.php.

References $permissions.

Referenced by initPermissionForm(), and save().

+ Here is the caller graph for this function:

◆ getRoleProhibitedPermissions()

ilSettingsPermissionGUI::getRoleProhibitedPermissions ( )

Get role prohibited permissions.

Returns
array permissions prohibited to be listed

Definition at line 126 of file class.ilSettingsPermissionGUI.php.

References $role_prohibited_permissions.

Referenced by determineRoles().

+ Here is the caller graph for this function:

◆ getRoleRequiredPermissions()

ilSettingsPermissionGUI::getRoleRequiredPermissions ( )

Get role required permissions.

Returns
array permissions required to be listed

Definition at line 100 of file class.ilSettingsPermissionGUI.php.

References $role_required_permissions.

Referenced by determineRoles().

+ Here is the caller graph for this function:

◆ initPermissionForm()

ilSettingsPermissionGUI::initPermissionForm ( )

Init permission form.

Definition at line 181 of file class.ilSettingsPermissionGUI.php.

References $form, $r, ilObjRole\_getTranslation(), array, determineRoles(), and getPermissions().

Referenced by save(), and showForm().

182  {
183  global $rbacreview;
184 
185  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
186  $form = new ilPropertyFormGUI();
187 
188  $roles = $this->determineRoles();
189  $ops = array();
190  foreach ($roles as $r) {
191  $ops[$r["rol_id"]] = $rbacreview->getActiveOperationsOfRole($this->obj->getRefId(), $r["rol_id"]);
192  }
193 
194  // for each permission, collect all roles that have the permission activated
195  $perm_roles = array();
196  foreach ($ops as $r => $o2) {
197  foreach ($o2 as $o) {
198  $perm_roles[$o][] = $r;
199  }
200  }
201 
202  // for each permission
203  include_once './Services/AccessControl/classes/class.ilObjRole.php';
204  foreach ($this->getPermissions() as $p) {
205  // roles
206  $cb = new ilCheckboxGroupInputGUI($this->lng->txt($p), $p);
207  reset($roles);
208  foreach ($roles as $k => $r) {
209  $option = new ilCheckboxOption(ilObjRole::_getTranslation($r["title"]), $k);
210  $cb->addOption($option);
211  }
212  if (is_array($perm_roles[$this->base_permissions_by_op[$p]])) {
213  $cb->setValue($perm_roles[$this->base_permissions_by_op[$p]]);
214  }
215  $form->addItem($cb);
216  }
217 
218  $form->addCommandButton("save", $this->lng->txt("save"));
219 
220  $form->setTitle($this->lng->txt("rbac_permissions"));
221  $form->setFormAction($this->ctrl->getFormAction($this));
222 
223  return $form;
224  }
This class represents an option in a checkbox group.
This class represents a property form user interface.
$r
Definition: example_031.php:79
if(isset($_POST['submit'])) $form
This class represents a property in a property form.
static _getTranslation($a_role_title)
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilSettingsPermissionGUI::save ( )

Save form.

Definition at line 229 of file class.ilSettingsPermissionGUI.php.

References $form, $key, $r, array, determineRoles(), getPermissions(), initPermissionForm(), and ilUtil\sendSuccess().

230  {
231  global $rbacreview, $rbacadmin;
232 
233  $form = $this->initPermissionForm();
234  if ($form->checkInput()) {
235  foreach ($this->determineRoles() as $r) {
236  // get active operations for role
237  $ops = $rbacreview->getActiveOperationsOfRole($this->obj->getRefId(), $r["rol_id"]);
238 
239  // revode all permissions for the role
240  $rbacadmin->revokePermission($this->obj->getRefId(), $r["rol_id"]);
241 
242  // for all permissions of the form...
243  foreach ($this->getPermissions() as $p) {
244  $roles = $form->getInput($p);
245  if (!is_array($roles)) {
246  $roles = array();
247  }
248  $o = $this->base_permissions_by_op[$p];
249 
250  // ... if in original operations, but not checked, remove it from operations
251  if (in_array($o, $ops) && !in_array($r["rol_id"], $roles)) {
252  if (($key = array_search($o, $ops)) !== false) {
253  unset($ops[$key]);
254  }
255  }
256 
257  // ...if not in original operations, but checked, add to operations
258  if (!in_array($o, $ops) && in_array($r["rol_id"], $roles)) {
259  $ops[] = $o;
260  }
261  }
262 
263  // now grant resulting permissions
264  $rbacadmin->grantPermission(
265  $r["rol_id"],
266  array_unique($ops),
267  $this->obj->getRefId()
268  );
269  }
270 
271  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
272  $this->ctrl->redirect($this, "");
273  } else {
274  $form->setValuesByPost();
275  $this->tpl->setContent($form->getHtml());
276  }
277  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
initPermissionForm()
Init permission form.
$r
Definition: example_031.php:79
if(isset($_POST['submit'])) $form
Create styles array
The data for the language used.
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

◆ setPermissions()

ilSettingsPermissionGUI::setPermissions (   $a_val)

Set permissions.

Parameters
array$a_valarray of operations (string) that should be offered

Definition at line 136 of file class.ilSettingsPermissionGUI.php.

137  {
138  if (is_array($a_val)) {
139  foreach ($a_val as $p) {
140  if (in_array($p, $this->base_permissions)) {
141  $this->permissions[$this->base_permissions_by_op[$p]] = $p;
142  }
143  }
144  }
145  }

◆ setRoleProhibitedPermissions()

ilSettingsPermissionGUI::setRoleProhibitedPermissions (   $a_val)

Set role prohibited permissions (this permissions are prohibited for a role to be listed)

Parameters
array$a_valpermissions prohibited to be listed

Definition at line 110 of file class.ilSettingsPermissionGUI.php.

111  {
112  if (is_array($a_val)) {
113  foreach ($a_val as $p) {
114  if (in_array($p, $this->base_permissions)) {
115  $this->role_prohibited_permissions[] = $this->base_permissions_by_op[$p];
116  }
117  }
118  }
119  }

◆ setRoleRequiredPermissions()

ilSettingsPermissionGUI::setRoleRequiredPermissions (   $a_val)

Set role required permissions (this permissions are required for a role to be listed)

Parameters
array$a_valpermissions required to be listed

Definition at line 84 of file class.ilSettingsPermissionGUI.php.

85  {
86  if (is_array($a_val)) {
87  foreach ($a_val as $p) {
88  if (in_array($p, $this->base_permissions)) {
89  $this->role_required_permissions[] = $this->base_permissions_by_op[$p];
90  }
91  }
92  }
93  }

◆ showForm()

ilSettingsPermissionGUI::showForm ( )

Show form.

Definition at line 171 of file class.ilSettingsPermissionGUI.php.

References $form, and initPermissionForm().

172  {
173  $form = $this->initPermissionForm();
174  $this->tpl->setContent($form->getHTML());
175  }
initPermissionForm()
Init permission form.
if(isset($_POST['submit'])) $form
+ Here is the call graph for this function:

Field Documentation

◆ $base_permissions

ilSettingsPermissionGUI::$base_permissions = array()
protected

Definition at line 16 of file class.ilSettingsPermissionGUI.php.

◆ $base_permissions_by_op

ilSettingsPermissionGUI::$base_permissions_by_op = array()
protected

Definition at line 17 of file class.ilSettingsPermissionGUI.php.

◆ $permissions

ilSettingsPermissionGUI::$permissions = array()
protected

Definition at line 15 of file class.ilSettingsPermissionGUI.php.

Referenced by getPermissions().

◆ $role_prohibited_permissions

ilSettingsPermissionGUI::$role_prohibited_permissions = array()
protected

Definition at line 19 of file class.ilSettingsPermissionGUI.php.

Referenced by getRoleProhibitedPermissions().

◆ $role_required_permissions

ilSettingsPermissionGUI::$role_required_permissions = array()
protected

Definition at line 18 of file class.ilSettingsPermissionGUI.php.

Referenced by getRoleRequiredPermissions().


The documentation for this class was generated from the following file: