ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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.

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 {
44 $this->base_permissions[$p["ops_id"]] = $p["operation"];
45 $this->base_permissions_by_op[$p["operation"]] = $p["ops_id"];
46 }
47
48 $this->base_roles = $rbacreview->getParentRoleIds($this->obj->getRefId());
49 }
global $tpl
Definition: ilias.php:8
static _getOperationList($a_type=null)
get operation list by object type @access public @access static
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40

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

+ Here is the call graph for this function:

Member Function Documentation

◆ determineRoles()

ilSettingsPermissionGUI::determineRoles ( )

Determine roles.

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

55 {
56 global $rbacreview;
57
58 $roles = array();
59 foreach ($this->base_roles as $k => $r)
60 {
61 $ops = $rbacreview->getActiveOperationsOfRole($this->obj->getRefId(), $r["rol_id"]);
62 $use = true;
63 foreach ($this->getRoleRequiredPermissions() as $o)
64 {
65 if (!in_array($o, $ops))
66 {
67 $use = false;
68 }
69 }
70 foreach ($this->getRoleProhibitedPermissions() as $o)
71 {
72 if (in_array($o, $ops))
73 {
74 $use = false;
75 }
76 }
77 if ($use)
78 {
79 $roles[$k] = $r;
80 }
81 }
82 return $roles;
83 }
getRoleProhibitedPermissions()
Get role prohibited permissions.
getRoleRequiredPermissions()
Get role required permissions.
$r
Definition: example_031.php:79

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

Referenced by initPermissionForm(), and save().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilSettingsPermissionGUI::executeCommand ( )

Execute command.

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

177 {
178 $cmd = $this->ctrl->getCmd("showForm");
179 if (in_array($cmd, array("showForm", "save")))
180 {
181 $this->$cmd();
182 }
183 }
$cmd
Definition: sahs_server.php:35

References $cmd.

◆ getPermissions()

ilSettingsPermissionGUI::getPermissions ( )

Get permissions.

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

Definition at line 168 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 139 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 110 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 198 of file class.ilSettingsPermissionGUI.php.

199 {
200 global $rbacreview;
201
202 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
203 $form = new ilPropertyFormGUI();
204
205 $roles = $this->determineRoles();
206 $ops = array();
207 foreach ($roles as $r)
208 {
209 $ops[$r["rol_id"]] = $rbacreview->getActiveOperationsOfRole($this->obj->getRefId(), $r["rol_id"]);
210 }
211
212 // for each permission, collect all roles that have the permission activated
213 $perm_roles = array();
214 foreach ($ops as $r => $o2)
215 {
216 foreach ($o2 as $o)
217 {
218 $perm_roles[$o][] = $r;
219 }
220 }
221
222 // for each permission
223 foreach ($this->getPermissions() as $p)
224 {
225 // roles
226 $cb = new ilCheckboxGroupInputGUI($this->lng->txt($p), $p);
227 reset($roles);
228 foreach ($roles as $k => $r)
229 {
230 $option = new ilCheckboxOption($r["title"], $k);
231 $cb->addOption($option);
232 }
233 if (is_array($perm_roles[$this->base_permissions_by_op[$p]]))
234 {
235 $cb->setValue($perm_roles[$this->base_permissions_by_op[$p]]);
236 }
237 $form->addItem($cb);
238
239 }
240
241 $form->addCommandButton("save", $this->lng->txt("save"));
242
243 $form->setTitle($this->lng->txt("rbac_permissions"));
244 $form->setFormAction($this->ctrl->getFormAction($this));
245
246 return $form;
247 }
This class represents a property in a property form.
This class represents an option in a checkbox group.
This class represents a property form user interface.

References $r, determineRoles(), and getPermissions().

Referenced by save(), and showForm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilSettingsPermissionGUI::save ( )

Save form.

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

253 {
254 global $rbacreview, $rbacadmin;
255
256 $form = $this->initPermissionForm();
257 if ($form->checkInput())
258 {
259 foreach ($this->determineRoles() as $r)
260 {
261 // get active operations for role
262 $ops = $rbacreview->getActiveOperationsOfRole($this->obj->getRefId(), $r["rol_id"]);
263
264 // revode all permissions for the role
265 $rbacadmin->revokePermission($this->obj->getRefId(), $r["rol_id"]);
266
267 // for all permissions of the form...
268 foreach ($this->getPermissions() as $p)
269 {
270 $roles = $form->getInput($p);
271 if (!is_array($roles))
272 {
273 $roles = array();
274 }
275 $o = $this->base_permissions_by_op[$p];
276
277 // ... if in original operations, but not checked, remove it from operations
278 if (in_array($o, $ops) && !in_array($r["rol_id"], $roles))
279 {
280 if(($key = array_search($o, $ops)) !== false) {
281 unset($ops[$key]);
282 }
283 }
284
285 // ...if not in original operations, but checked, add to operations
286 if (!in_array($o, $ops) && in_array($r["rol_id"], $roles))
287 {
288 $ops[] = $o;
289 }
290 }
291
292 // now grant resulting permissions
293 $rbacadmin->grantPermission(
294 $r["rol_id"],
295 array_unique($ops),
296 $this->obj->getRefId()
297 );
298 }
299
300 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
301 $this->ctrl->redirect($this, "");
302 }
303 else
304 {
305 $form->setValuesByPost();
306 $this->tpl->setContent($form->getHtml());
307 }
308 }
initPermissionForm()
Init permission form.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.

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

+ 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 149 of file class.ilSettingsPermissionGUI.php.

150 {
151 if (is_array($a_val))
152 {
153 foreach ($a_val as $p)
154 {
155 if (in_array($p, $this->base_permissions))
156 {
157 $this->permissions[$this->base_permissions_by_op[$p]] = $p;
158 }
159 }
160 }
161 }

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

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

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

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

◆ showForm()

ilSettingsPermissionGUI::showForm ( )

Show form.

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

189 {
190 $form = $this->initPermissionForm();
191 $this->tpl->setContent($form->getHTML());
192 }

References initPermissionForm().

+ 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: