ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 $DIC, $ilCtrl, $lng, $tpl, and ilRbacReview\_getOperationList().

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

Member Function Documentation

◆ determineRoles()

ilSettingsPermissionGUI::determineRoles ( )

Determine roles.

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

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

Referenced by initPermissionForm(), and save().

60  {
61  global $DIC;
62 
63  $rbacreview = $DIC['rbacreview'];
64 
65  $roles = array();
66  foreach ($this->base_roles as $k => $r) {
67  $ops = $rbacreview->getActiveOperationsOfRole($this->obj->getRefId(), $r["rol_id"]);
68  $use = true;
69  foreach ($this->getRoleRequiredPermissions() as $o) {
70  if (!in_array($o, $ops)) {
71  $use = false;
72  }
73  }
74  foreach ($this->getRoleProhibitedPermissions() as $o) {
75  if (in_array($o, $ops)) {
76  $use = false;
77  }
78  }
79  if ($use) {
80  $roles[$k] = $r;
81  }
82  }
83  return $roles;
84  }
global $DIC
Definition: saml.php:7
$r
Definition: example_031.php:79
getRoleProhibitedPermissions()
Get role prohibited permissions.
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 168 of file class.ilSettingsPermissionGUI.php.

169  {
170  $cmd = $this->ctrl->getCmd("showForm");
171  if (in_array($cmd, array("showForm", "save"))) {
172  $this->$cmd();
173  }
174  }

◆ getPermissions()

ilSettingsPermissionGUI::getPermissions ( )

Get permissions.

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

Definition at line 160 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 134 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 108 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 189 of file class.ilSettingsPermissionGUI.php.

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

Referenced by save(), and showForm().

190  {
191  global $DIC;
192 
193  $rbacreview = $DIC['rbacreview'];
194 
195  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
196  $form = new ilPropertyFormGUI();
197 
198  $roles = $this->determineRoles();
199  $ops = array();
200  foreach ($roles as $r) {
201  $ops[$r["rol_id"]] = $rbacreview->getActiveOperationsOfRole($this->obj->getRefId(), $r["rol_id"]);
202  }
203 
204  // for each permission, collect all roles that have the permission activated
205  $perm_roles = array();
206  foreach ($ops as $r => $o2) {
207  foreach ($o2 as $o) {
208  $perm_roles[$o][] = $r;
209  }
210  }
211 
212  // for each permission
213  include_once './Services/AccessControl/classes/class.ilObjRole.php';
214  foreach ($this->getPermissions() as $p) {
215  // roles
216  $cb = new ilCheckboxGroupInputGUI($this->lng->txt($p), $p);
217  reset($roles);
218  foreach ($roles as $k => $r) {
219  $option = new ilCheckboxOption(ilObjRole::_getTranslation($r["title"]), $k);
220  $cb->addOption($option);
221  }
222  if (is_array($perm_roles[$this->base_permissions_by_op[$p]])) {
223  $cb->setValue($perm_roles[$this->base_permissions_by_op[$p]]);
224  }
225  $form->addItem($cb);
226  }
227 
228  $form->addCommandButton("save", $this->lng->txt("save"));
229 
230  $form->setTitle($this->lng->txt("rbac_permissions"));
231  $form->setFormAction($this->ctrl->getFormAction($this));
232 
233  return $form;
234  }
This class represents an option in a checkbox group.
This class represents a property form user interface.
global $DIC
Definition: saml.php:7
$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)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilSettingsPermissionGUI::save ( )

Save form.

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

References $DIC, $form, $key, $r, determineRoles(), getPermissions(), and initPermissionForm().

240  {
241  global $DIC;
242 
243  $rbacreview = $DIC['rbacreview'];
244  $rbacadmin = $DIC['rbacadmin'];
245 
246  $form = $this->initPermissionForm();
247  if ($form->checkInput()) {
248  foreach ($this->determineRoles() as $r) {
249  // get active operations for role
250  $ops = $rbacreview->getActiveOperationsOfRole($this->obj->getRefId(), $r["rol_id"]);
251 
252  // revode all permissions for the role
253  $rbacadmin->revokePermission($this->obj->getRefId(), $r["rol_id"]);
254 
255  // for all permissions of the form...
256  foreach ($this->getPermissions() as $p) {
257  $roles = $form->getInput($p);
258  if (!is_array($roles)) {
259  $roles = array();
260  }
261  $o = $this->base_permissions_by_op[$p];
262 
263  // ... if in original operations, but not checked, remove it from operations
264  if (in_array($o, $ops) && !in_array($r["rol_id"], $roles)) {
265  if (($key = array_search($o, $ops)) !== false) {
266  unset($ops[$key]);
267  }
268  }
269 
270  // ...if not in original operations, but checked, add to operations
271  if (!in_array($o, $ops) && in_array($r["rol_id"], $roles)) {
272  $ops[] = $o;
273  }
274  }
275 
276  // now grant resulting permissions
277  $rbacadmin->grantPermission(
278  $r["rol_id"],
279  array_unique($ops),
280  $this->obj->getRefId()
281  );
282  }
283 
284  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
285  $this->ctrl->redirect($this, "");
286  } else {
287  $form->setValuesByPost();
288  $this->tpl->setContent($form->getHtml());
289  }
290  }
initPermissionForm()
Init permission form.
global $DIC
Definition: saml.php:7
$r
Definition: example_031.php:79
if(isset($_POST['submit'])) $form
$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 144 of file class.ilSettingsPermissionGUI.php.

145  {
146  if (is_array($a_val)) {
147  foreach ($a_val as $p) {
148  if (in_array($p, $this->base_permissions)) {
149  $this->permissions[$this->base_permissions_by_op[$p]] = $p;
150  }
151  }
152  }
153  }

◆ 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 118 of file class.ilSettingsPermissionGUI.php.

119  {
120  if (is_array($a_val)) {
121  foreach ($a_val as $p) {
122  if (in_array($p, $this->base_permissions)) {
123  $this->role_prohibited_permissions[] = $this->base_permissions_by_op[$p];
124  }
125  }
126  }
127  }

◆ 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 92 of file class.ilSettingsPermissionGUI.php.

93  {
94  if (is_array($a_val)) {
95  foreach ($a_val as $p) {
96  if (in_array($p, $this->base_permissions)) {
97  $this->role_required_permissions[] = $this->base_permissions_by_op[$p];
98  }
99  }
100  }
101  }

◆ showForm()

ilSettingsPermissionGUI::showForm ( )

Show form.

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

References $form, and initPermissionForm().

180  {
181  $form = $this->initPermissionForm();
182  $this->tpl->setContent($form->getHTML());
183  }
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: