ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilObjRoleGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once "./Services/Object/classes/class.ilObjectGUI.php";
5include_once './Services/AccessControl/classes/class.ilObjRole.php';
6require_once('./Services/Repository/classes/class.ilObjectPlugin.php');
7
21{
26
32 public $type;
33
34
35 protected $obj_ref_id = 0;
36 protected $obj_obj_id = 0;
37 protected $obj_obj_type = '';
38 protected $container_type = '';
39
40
41 public $ctrl;
42
47 public function __construct($a_data, $a_id, $a_call_by_reference = false, $a_prepare_output = true)
48 {
49 global $tree,$lng;
50
51 $lng->loadLanguageModule('rbac');
52
53 //TODO: move this to class.ilias.php
54 define("USER_FOLDER_ID", 7);
55
56 // Add ref_id of object that contains this role folder
57
58 $this->obj_ref_id =
59 (
60 (int) $_REQUEST['rolf_ref_id'] ?
61 (int) $_REQUEST['rolf_ref_id'] :
62 (int) $_REQUEST['ref_id']
63 );
64
65 $this->obj_obj_id = ilObject::_lookupObjId($this->getParentRefId());
66 $this->obj_obj_type = ilObject::_lookupType($this->getParentObjId());
67
68 $this->container_type = ilObject::_lookupType(ilObject::_lookupObjId($this->obj_ref_id));
69
70 $this->type = "role";
71 parent::__construct($a_data, $a_id, $a_call_by_reference, false);
72 $this->ctrl->saveParameter($this, array('obj_id', 'rolf_ref_id'));
73 }
74
75
76 public function executeCommand()
77 {
78 global $rbacsystem;
79
80 $this->prepareOutput();
81
82 $next_class = $this->ctrl->getNextClass($this);
83 $cmd = $this->ctrl->getCmd();
84
86
87 switch ($next_class) {
88 case 'ilrepositorysearchgui':
89
90 if (!$GLOBALS['ilAccess']->checkAccess('edit_permission', '', $this->obj_ref_id)) {
91 $GLOBALS['ilErr']->raiseError($GLOBALS['lng']->txt('permission_denied'), $GLOBALS['ilErr']->WARNING);
92 }
93 include_once('./Services/Search/classes/class.ilRepositorySearchGUI.php');
94 $rep_search = new ilRepositorySearchGUI();
95 $rep_search->setTitle($this->lng->txt('role_add_user'));
96 $rep_search->setCallback($this, 'addUserObject');
97
98 // Set tabs
99 $this->tabs_gui->setTabActive('user_assignment');
100 $this->ctrl->setReturn($this, 'userassignment');
101 $ret =&$this->ctrl->forwardCommand($rep_search);
102 break;
103
104 case 'ilexportgui':
105
106 $this->tabs_gui->setTabActive('export');
107
108 include_once './Services/Export/classes/class.ilExportOptions.php';
110 $eo->addOption(ilExportOptions::KEY_ROOT, 0, $this->object->getId(), $this->obj_ref_id);
111
112 include_once './Services/Export/classes/class.ilExportGUI.php';
113 $exp = new ilExportGUI($this, new ilObjRole($this->object->getId()));
114 $exp->addFormat('xml');
115 $this->ctrl->forwardCommand($exp);
116 break;
117
118 default:
119 if (!$cmd) {
120 if ($this->showDefaultPermissionSettings()) {
121 $cmd = "perm";
122 } else {
123 $cmd = 'userassignment';
124 }
125 }
126 $cmd .= "Object";
127 $this->$cmd();
128
129 break;
130 }
131
132 return true;
133 }
134
139 public function getParentRefId()
140 {
141 return $this->obj_ref_id;
142 }
143
148 public function getParentObjId()
149 {
150 return $this->obj_obj_id;
151 }
152
157 public function getParentType()
158 {
159 return $this->obj_obj_type;
160 }
161
165 public function setBackTarget($a_text, $a_link)
166 {
167 $this->back_target = array("text" => $a_text,
168 "link" => $a_link);
169 }
170
171 public function getBackTarget()
172 {
173 return $this->back_target ? $this->back_target : array();
174 }
175
179 public function getAdminTabs()
180 {
181 $this->getTabs();
182 }
183
188 protected function getContainerType()
189 {
191 }
192
197 protected function showDefaultPermissionSettings()
198 {
199 global $objDefinition;
200
201 return $objDefinition->isContainer($this->getContainerType());
202 }
203
204
205 public function listDesktopItemsObject()
206 {
208
209 if (!$rbacreview->isAssignable($this->object->getId(), $this->obj_ref_id) &&
210 $this->obj_ref_id != ROLE_FOLDER_ID) {
211 ilUtil::sendInfo($this->lng->txt('role_no_users_no_desk_items'));
212 return true;
213 }
214
215 if ($rbacsystem->checkAccess('push_desktop_items', USER_FOLDER_ID)) {
216 $this->__showButton('selectDesktopItem', $this->lng->txt('role_desk_add'));
217 }
218
219 include_once 'Services/AccessControl/classes/class.ilRoleDesktopItemsTableGUI.php';
220 $tbl = new ilRoleDesktopItemsTableGUI($this, 'listDesktopItems', $this->object);
221 $this->tpl->setContent($tbl->getHTML());
222
223 return true;
224 }
225
227 {
228 global $rbacsystem;
229
230
231 if (!$this->checkAccess('edit_permission')) {
232 $this->ilias->raiseError($this->lng->txt("permission_denied"), $this->ilias->error_obj->MESSAGE);
233 }
234 if (!$rbacsystem->checkAccess('push_desktop_items', USER_FOLDER_ID)) {
235 $this->ilias->raiseError($this->lng->txt("permission_denied"), $this->ilias->error_obj->MESSAGE);
236 }
237 if (!count($_POST['del_desk_item'])) {
238 ilUtil::sendFailure($this->lng->txt('role_select_one_item'));
239
240 $this->listDesktopItemsObject();
241
242 return true;
243 }
244
245 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
246 $confirmation_gui = new ilConfirmationGUI();
247 $confirmation_gui->setFormAction($this->ctrl->getFormAction($this));
248 $confirmation_gui->setHeaderText($this->lng->txt('role_assigned_desk_items') .
249 ' "' . $this->object->getTitle() . '": ' .
250 $this->lng->txt('role_sure_delete_desk_items'));
251 $confirmation_gui->setCancel($this->lng->txt("cancel"), "listDesktopItems");
252 $confirmation_gui->setConfirm($this->lng->txt("delete"), "deleteDesktopItems");
253
254 include_once 'Services/AccessControl/classes/class.ilRoleDesktopItem.php';
255 $role_desk_item_obj = new ilRoleDesktopItem($this->object->getId());
256 $counter = 0;
257 foreach ($_POST['del_desk_item'] as $role_item_id) {
258 $item_data = $role_desk_item_obj->getItem($role_item_id);
259 $tmp_obj =&ilObjectFactory::getInstanceByRefId($item_data['item_id']);
260
261 if (strlen($desc = $tmp_obj->getDescription())) {
262 $desc = '<div class="il_Description_no_margin">' . $desc . '</div>';
263 }
264
265 $confirmation_gui->addItem("del_desk_item[]", $role_item_id, $tmp_obj->getTitle() . $desc);
266 }
267
268 $this->tpl->setContent($confirmation_gui->getHTML());
269
270 return true;
271 }
272
273 public function deleteDesktopItemsObject()
274 {
275 global $rbacsystem;
276
277 if (!$this->checkAccess('edit_permission')) {
278 $this->ilias->raiseError($this->lng->txt("permission_denied"), $this->ilias->error_obj->MESSAGE);
279 }
280
281 if (!$rbacsystem->checkAccess('push_desktop_items', USER_FOLDER_ID)) {
282 $this->ilias->raiseError($this->lng->txt("permission_denied"), $this->ilias->error_obj->MESSAGE);
283 }
284
285 if (!count($_POST['del_desk_item'])) {
286 ilUtil::sendFailure($this->lng->txt('role_select_one_item'));
287
288 $this->listDesktopItemsObject();
289
290 return true;
291 }
292
293 include_once 'Services/AccessControl/classes/class.ilRoleDesktopItem.php';
294
295 $role_desk_item_obj = new ilRoleDesktopItem($this->object->getId());
296
297 foreach ($_POST['del_desk_item'] as $role_item_id) {
298 $role_desk_item_obj->delete($role_item_id);
299 }
300
301 ilUtil::sendSuccess($this->lng->txt('role_deleted_desktop_items'));
302 $this->listDesktopItemsObject();
303
304 return true;
305 }
306
307
308 public function selectDesktopItemObject()
309 {
310 global $rbacsystem,$tree;
311
312 include_once 'Services/AccessControl/classes/class.ilRoleDesktopItemSelector.php';
313 include_once 'Services/AccessControl/classes/class.ilRoleDesktopItem.php';
314
315 if (!$rbacsystem->checkAccess('push_desktop_items', USER_FOLDER_ID)) {
316 #$this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
317 ilUtil::sendFailure($this->lng->txt('permission_denied'));
318 $this->listDesktopItemsObject();
319 return false;
320 }
321
322 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.role_desktop_item_selector.html", "Services/AccessControl");
323 $this->__showButton('listDesktopItems', $this->lng->txt('back'));
324
325 ilUtil::sendInfo($this->lng->txt("role_select_desktop_item"));
326
327 $exp = new ilRoleDesktopItemSelector(
328 $this->ctrl->getLinkTarget($this, 'selectDesktopItem'),
329 new ilRoleDesktopItem($this->object->getId())
330 );
331 $exp->setExpand($_GET["role_desk_item_link_expand"] ? $_GET["role_desk_item_link_expand"] : $tree->readRootId());
332 $exp->setExpandTarget($this->ctrl->getLinkTarget($this, 'selectDesktopItem'));
333
334 $exp->setOutput(0);
335
336 $output = $exp->getOutput();
337 $this->tpl->setVariable("EXPLORER", $output);
338 //$this->tpl->setVariable("EXPLORER", $exp->getOutput());
339
340 return true;
341 }
342
343 public function assignDesktopItemObject()
344 {
345 global $rbacsystem;
346
347 if (!$rbacsystem->checkAccess('push_desktop_items', USER_FOLDER_ID)) {
348 $this->ilias->raiseError($this->lng->txt("permission_denied"), $this->ilias->error_obj->MESSAGE);
349 return false;
350 }
351
352
353 if (!isset($_GET['item_id'])) {
354 ilUtil::sendFailure($this->lng->txt('role_no_item_selected'));
356
357 return false;
358 }
359
360 include_once 'Services/AccessControl/classes/class.ilRoleDesktopItem.php';
361
362 $role_desk_item_obj = new ilRoleDesktopItem($this->object->getId());
363 $role_desk_item_obj->add((int) $_GET['item_id'], ilObject::_lookupType((int) $_GET['item_id'], true));
364
365 ilUtil::sendSuccess($this->lng->txt('role_assigned_desktop_item'));
366
367 $this->ctrl->redirect($this, 'listDesktopItems');
368 return true;
369 }
370
376 protected function initFormRoleProperties($a_mode)
377 {
378 include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
379 $this->form = new ilPropertyFormGUI();
380
381 if ($this->creation_mode) {
382 $this->ctrl->setParameter($this, "new_type", 'role');
383 }
384 $this->form->setFormAction($this->ctrl->getFormAction($this));
385
386 switch ($a_mode) {
388 $this->form->setTitle($this->lng->txt('role_new'));
389 $this->form->addCommandButton('save', $this->lng->txt('role_new'));
390 break;
391
393 $this->form->setTitle($this->lng->txt('role_edit'));
394 $this->form->addCommandButton('update', $this->lng->txt('save'));
395 break;
396
399 }
400 // Fix cancel
401 $this->form->addCommandButton('cancel', $this->lng->txt('cancel'));
402
403 $title = new ilTextInputGUI($this->lng->txt('title'), 'title');
404 if (ilObjRole::isAutoGenerated($this->object->getId())) {
405 $title->setDisabled(true);
406 } else {
407 //#17111 No validation for disabled fields
408 $title->setValidationRegexp('/^(?!il_).*$/');
409 $title->setValidationFailureMessage($this->lng->txt('msg_role_reserved_prefix'));
410 }
411
412 $title->setSize(40);
413 $title->setMaxLength(70);
414 $title->setRequired(true);
415 $this->form->addItem($title);
416
417 $desc = new ilTextAreaInputGUI($this->lng->txt('description'), 'desc');
418 if (ilObjRole::isAutoGenerated($this->object->getId())) {
419 $desc->setDisabled(true);
420 }
421 $desc->setCols(40);
422 $desc->setRows(3);
423 $this->form->addItem($desc);
424
425 if ($a_mode != self::MODE_LOCAL_CREATE && $a_mode != self::MODE_GLOBAL_CREATE) {
426 $ilias_id = new ilNonEditableValueGUI($this->lng->txt("ilias_id"), "ilias_id");
427 $this->form->addItem($ilias_id);
428 }
429
430 if ($this->obj_ref_id == ROLE_FOLDER_ID) {
431 $reg = new ilCheckboxInputGUI($this->lng->txt('allow_register'), 'reg');
432 $reg->setValue(1);
433 #$reg->setInfo($this->lng->txt('rbac_new_acc_reg_info'));
434 $this->form->addItem($reg);
435
436 $la = new ilCheckboxInputGUI($this->lng->txt('allow_assign_users'), 'la');
437 $la->setValue(1);
438 #$la->setInfo($this->lng->txt('rbac_local_admin_info'));
439 $this->form->addItem($la);
440 }
441
442 $pro = new ilCheckboxInputGUI($this->lng->txt('role_protect_permissions'), 'pro');
443 $pro->setValue(1);
444 #$pro->setInfo($this->lng->txt('role_protext_permission_info'));
445 $this->form->addItem($pro);
446
447 include_once 'Services/WebDAV/classes/class.ilDiskQuotaActivationChecker.php';
449 $quo = new ilNumberInputGUI($this->lng->txt('disk_quota'), 'disk_quota');
450 $quo->setMinValue(0);
451 $quo->setSize(4);
452 $quo->setInfo($this->lng->txt('enter_in_mb_desc') . '<br />' . $this->lng->txt('disk_quota_on_role_desc'));
453 $this->form->addItem($quo);
454 }
456 $this->lng->loadLanguageModule("file");
457 $wquo = new ilNumberInputGUI($this->lng->txt('personal_workspace_disk_quota'), 'wsp_disk_quota');
458 $wquo->setMinValue(0);
459 $wquo->setSize(4);
460 $wquo->setInfo($this->lng->txt('enter_in_mb_desc') . '<br />' . $this->lng->txt('disk_quota_on_role_desc'));
461 $this->form->addItem($wquo);
462 }
463
464 return true;
465 }
466
472 protected function loadRoleProperties(ilObjRole $role)
473 {
474 //Don't set if fields are disabled to prevent html manipulation.
475 if (!$this->form->getItemByPostVar('title')->getDisabled()) {
476 $role->setTitle($this->form->getInput('title'));
477 }
478 if (!$this->form->getItemByPostVar('desc')->getDisabled()) {
479 $role->setDescription($this->form->getInput('desc'));
480 }
481 $role->setAllowRegister($this->form->getInput('reg'));
482 $role->toggleAssignUsersStatus($this->form->getInput('la'));
483 $role->setDiskQuota(ilUtil::MB2Bytes($this->form->getInput('disk_quota')));
484 $role->setPersonalWorkspaceDiskQuota(ilUtil::MB2Bytes($this->form->getInput('wsp_disk_quota')));
485 return true;
486 }
487
493 protected function readRoleProperties(ilObjRole $role)
494 {
495 global $rbacreview;
496
497 include_once 'Services/WebDAV/classes/class.ilDiskQuotaActivationChecker.php';
498
499 $data['title'] = $role->getTitle();
500 $data['desc'] = $role->getDescription();
501 $data['ilias_id'] = 'il_' . IL_INST_ID . '_' . ilObject::_lookupType($role->getId()) . '_' . $role->getId();
502 $data['reg'] = $role->getAllowRegister();
503 $data['la'] = $role->getAssignUsersStatus();
505 $data['disk_quota'] = ilUtil::Bytes2MB($role->getDiskQuota());
506 }
508 $data['wsp_disk_quota'] = ilUtil::Bytes2MB($role->getPersonalWorkspaceDiskQuota());
509 }
510 $data['pro'] = $rbacreview->isProtected($this->obj_ref_id, $role->getId());
511
512 $this->form->setValuesByArray($data);
513 }
514
515
516
517
523 public function createObject()
524 {
525 global $rbacsystem;
526
527 if (!$rbacsystem->checkAccess('create_role', $this->obj_ref_id)) {
528 $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->MESSAGE);
529 }
530
531 $this->initFormRoleProperties(self::MODE_GLOBAL_CREATE);
532 $this->tpl->setContent($this->form->getHTML());
533 }
534
539 public function editObject()
540 {
541 global $rbacsystem, $rbacreview, $ilSetting,$ilErr,$ilToolbar;
542
543 if (!$this->checkAccess('write', 'edit_permission')) {
544 $ilErr->raiseError($this->lng->txt("msg_no_perm_write"), $ilErr->MESSAGE);
545 }
546
547 // Show copy role button
548 if ($this->object->getId() != SYSTEM_ROLE_ID) {
549 $ilToolbar->setFormAction($this->ctrl->getFormAction($this));
550 if ($rbacreview->isDeleteable($this->object->getId(), $this->obj_ref_id)) {
551 $ilToolbar->addButton(
552 $this->lng->txt('rbac_delete_role'),
553 $this->ctrl->getLinkTarget($this, 'confirmDeleteRole')
554 );
555 }
556 }
557
558 $this->initFormRoleProperties(self::MODE_GLOBAL_UPDATE);
559 $this->readRoleProperties($this->object);
560 $this->tpl->setContent($this->form->getHTML());
561 }
562
563
568 public function saveObject()
569 {
570 global $rbacadmin,$rbacreview;
571
572 $this->initFormRoleProperties(self::MODE_GLOBAL_CREATE);
573 if ($this->form->checkInput() and !$this->checkDuplicate()) {
574 include_once './Services/AccessControl/classes/class.ilObjRole.php';
575 $this->loadRoleProperties($this->role = new ilObjRole());
576 $this->role->create();
577 $rbacadmin->assignRoleToFolder($this->role->getId(), $this->obj_ref_id, 'y');
578 $rbacadmin->setProtected(
579 $this->obj_ref_id,
580 $this->role->getId(),
581 $this->form->getInput('pro') ? 'y' : 'n'
582 );
583 ilUtil::sendSuccess($this->lng->txt("role_added"), true);
584 $this->ctrl->setParameter($this, 'obj_id', $this->role->getId());
585 $this->ctrl->redirect($this, 'perm');
586 }
587
588 ilUtil::sendFailure($this->lng->txt('err_check_input'));
589 $this->form->setValuesByPost();
590 $this->tpl->setContent($this->form->getHTML());
591 return false;
592 }
593
598 protected function checkDuplicate($a_role_id = 0)
599 {
600 // disabled due to mantis #0013742: Renaming global roles: ILIAS denies if title fits other role title partially
601 return false;
602 }
603
608 public function updateObject()
609 {
610 global $rbacadmin;
611
612 $this->initFormRoleProperties(self::MODE_GLOBAL_UPDATE);
613 if ($this->form->checkInput() and !$this->checkDuplicate($this->object->getId())) {
614 include_once './Services/AccessControl/classes/class.ilObjRole.php';
615 $this->loadRoleProperties($this->object);
616 $this->object->update();
617 $rbacadmin->setProtected(
618 $this->obj_ref_id,
619 $this->object->getId(),
620 $this->form->getInput('pro') ? 'y' : 'n'
621 );
622 ilUtil::sendSuccess($this->lng->txt("saved_successfully"), true);
623 $this->ctrl->redirect($this, 'edit');
624 }
625
626 ilUtil::sendFailure($this->lng->txt('err_check_input'));
627 $this->form->setValuesByPost();
628 $this->tpl->setContent($this->form->getHTML());
629 return false;
630 }
631
636 protected function permObject($a_show_admin_permissions = false)
637 {
638 global $ilTabs, $ilErr, $ilToolbar, $objDefinition,$rbacreview;
639
640 $ilTabs->setTabActive('default_perm_settings');
641
642 $this->setSubTabs('default_perm_settings');
643
644 if ($a_show_admin_permissions) {
645 $ilTabs->setSubTabActive('rbac_admin_permissions');
646 } else {
647 $ilTabs->setSubTabActive('rbac_repository_permissions');
648 }
649
650 if (!$this->checkAccess('write', 'edit_permission')) {
651 $ilErr->raiseError($this->lng->txt('msg_no_perm_perm'), $ilErr->MESSAGE);
652 return true;
653 }
654
655 // Show copy role button
656 if ($this->object->getId() != SYSTEM_ROLE_ID) {
657 $ilToolbar->setFormAction($this->ctrl->getFormAction($this));
658 $ilToolbar->addButton(
659 $this->lng->txt("adopt_perm_from_template"),
660 $this->ctrl->getLinkTarget($this, 'adoptPerm')
661 );
662 if ($rbacreview->isDeleteable($this->object->getId(), $this->obj_ref_id)) {
663 $ilToolbar->addButton(
664 $this->lng->txt('rbac_delete_role'),
665 $this->ctrl->getLinkTarget($this, 'confirmDeleteRole')
666 );
667 }
668 }
669
670 $this->tpl->addBlockFile(
671 'ADM_CONTENT',
672 'adm_content',
673 'tpl.rbac_template_permissions.html',
674 'Services/AccessControl'
675 );
676
677 $this->tpl->setVariable('PERM_ACTION', $this->ctrl->getFormAction($this));
678
679 include_once './Services/Accordion/classes/class.ilAccordionGUI.php';
680 $acc = new ilAccordionGUI();
681 $acc->setBehaviour(ilAccordionGUI::FORCE_ALL_OPEN);
682 $acc->setId('template_perm_' . $this->getParentRefId());
683
684 if ($this->obj_ref_id == ROLE_FOLDER_ID) {
685 if ($a_show_admin_permissions) {
686 $subs = $objDefinition->getSubObjectsRecursively('adm', true, true);
687 } else {
688 $subs = $objDefinition->getSubObjectsRecursively('root', true, $a_show_admin_permissions);
689 }
690 } else {
691 $subs = $objDefinition->getSubObjectsRecursively($this->getParentType(), true, $a_show_admin_permissions);
692 }
693
694 $sorted = array();
695 foreach ($subs as $subtype => $def) {
696 if ($objDefinition->isPlugin($subtype)) {
697 $translation = ilObjectPlugin::lookupTxtById($subtype, "obj_" . $subtype);
698 } elseif ($objDefinition->isSystemObject($subtype)) {
699 $translation = $this->lng->txt("obj_" . $subtype);
700 } else {
701 $translation = $this->lng->txt('objs_' . $subtype);
702 }
703
704 $sorted[$subtype] = $def;
705 $sorted[$subtype]['translation'] = $translation;
706 }
707
708
709 $sorted = ilUtil::sortArray($sorted, 'translation', 'asc', true, true);
710 foreach ($sorted as $subtype => $def) {
711 if ($objDefinition->isPlugin($subtype)) {
712 $translation = ilObjectPlugin::lookupTxtById($subtype, "obj_" . $subtype);
713 } elseif ($objDefinition->isSystemObject($subtype)) {
714 $translation = $this->lng->txt("obj_" . $subtype);
715 } else {
716 $translation = $this->lng->txt('objs_' . $subtype);
717 }
718
719 include_once 'Services/AccessControl/classes/class.ilObjectRoleTemplatePermissionTableGUI.php';
721 $this,
722 'perm',
723 $this->getParentRefId(),
724 $this->object->getId(),
725 $subtype,
726 $a_show_admin_permissions
727 );
728 $tbl->parse();
729
730 $acc->addItem($translation, $tbl->getHTML());
731 }
732
733 $this->tpl->setVariable('ACCORDION', $acc->getHTML());
734
735 // Add options table
736 include_once './Services/AccessControl/classes/class.ilObjectRoleTemplateOptionsTableGUI.php';
738 $this,
739 'perm',
740 $this->obj_ref_id,
741 $this->object->getId(),
742 $a_show_admin_permissions
743 );
744 if ($this->object->getId() != SYSTEM_ROLE_ID) {
745 $options->addMultiCommand(
746 $a_show_admin_permissions ? 'adminPermSave' : 'permSave',
747 $this->lng->txt('save')
748 );
749 }
750
751 $options->parse();
752 $this->tpl->setVariable('OPTIONS_TABLE', $options->getHTML());
753 }
754
759 protected function adminPermObject()
760 {
761 return $this->permObject(true);
762 }
763
768 protected function adminPermSaveObject()
769 {
770 return $this->permSaveObject(true);
771 }
772
773 protected function adoptPermObject()
774 {
775 global $rbacreview;
776
777 $output = array();
778
779 $parent_role_ids = $rbacreview->getParentRoleIds($this->obj_ref_id, true);
780 $ids = array();
781 foreach ($parent_role_ids as $id => $tmp) {
782 $ids[] = $id;
783 }
784 // Sort ids
785 $sorted_ids = ilUtil::_sortIds($ids, 'object_data', 'type,title', 'obj_id');
786 $key = 0;
787 foreach ($sorted_ids as $id) {
788 $par = $parent_role_ids[$id];
789 if ($par["obj_id"] != SYSTEM_ROLE_ID && $this->object->getId() != $par["obj_id"]) {
790 $output[$key]["role_id"] = $par["obj_id"];
791 $output[$key]["type"] = ($par["type"] == 'role' ? $this->lng->txt('obj_role') : $this->lng->txt('obj_rolt'));
792 $output[$key]["role_name"] = ilObjRole::_getTranslation($par["title"]);
793 $output[$key]["role_desc"] = $par["desc"];
794 $key++;
795 }
796 }
797
798
799 include_once('./Services/AccessControl/classes/class.ilRoleAdoptPermissionTableGUI.php');
800
801 $tbl = new ilRoleAdoptPermissionTableGUI($this, "adoptPerm");
802 $tbl->setTitle($this->lng->txt("adopt_perm_from_template"));
803 $tbl->setData($output);
804
805 $this->tpl->setContent($tbl->getHTML());
806 }
807
812 protected function confirmDeleteRoleObject()
813 {
815
816 $access = $this->checkAccess('visible,write', 'edit_permission');
817 if (!$access) {
818 $ilErr->raiseError($this->lng->txt('msg_no_perm_perm'), $ilErr->WARNING);
819 }
820
821 $question = $this->lng->txt('rbac_role_delete_qst');
822 if ($rbacreview->isAssigned($ilUser->getId(), $this->object->getId())) {
823 $question .= ('<br />' . $this->lng->txt('rbac_role_delete_self'));
824 }
825 ilUtil::sendQuestion($question);
826
827 include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
828
829 $confirm = new ilConfirmationGUI();
830 $confirm->setFormAction($this->ctrl->getFormAction($this));
831 $confirm->setHeaderText($question);
832 $confirm->setCancel($this->lng->txt('cancel'), 'perm');
833 $confirm->setConfirm($this->lng->txt('rbac_delete_role'), 'performDeleteRole');
834
835 $confirm->addItem(
836 'role',
837 $this->object->getId(),
838 $this->object->getTitle(),
839 ilUtil::getImagePath('icon_role.svg')
840 );
841
842 $this->tpl->setContent($confirm->getHTML());
843 return true;
844 }
845
846
851 protected function performDeleteRoleObject()
852 {
853 global $ilErr;
854
855 $access = $this->checkAccess('visible,write', 'edit_permission');
856 if (!$access) {
857 $ilErr->raiseError($this->lng->txt('msg_no_perm_perm'), $ilErr->WARNING);
858 }
859
860 $this->object->setParent((int) $this->obj_ref_id);
861 $this->object->delete();
862 ilUtil::sendSuccess($this->lng->txt('msg_deleted_role'), true);
863
864 $this->ctrl->returnToParent($this);
865 }
866
872 public function permSaveObject($a_show_admin_permissions = false)
873 {
874 global $rbacsystem, $rbacadmin, $rbacreview, $objDefinition, $tree;
875
876 // for role administration check write of global role folder
877 $access = $this->checkAccess('visible,write', 'edit_permission');
878
879 if (!$access) {
880 $this->ilias->raiseError($this->lng->txt("msg_no_perm_perm"), $this->ilias->error_obj->MESSAGE);
881 }
882
883 // rbac log
884 include_once "Services/AccessControl/classes/class.ilRbacLog.php";
885 $rbac_log_active = ilRbacLog::isActive();
886 if ($rbac_log_active) {
887 $rbac_log_old = ilRbacLog::gatherTemplate($this->obj_ref_id, $this->object->getId());
888 }
889
890 // delete all template entries of enabled types
891 if ($this->obj_ref_id == ROLE_FOLDER_ID) {
892 if ($a_show_admin_permissions) {
893 $subs = $objDefinition->getSubObjectsRecursively('adm', true, true);
894 } else {
895 $subs = $objDefinition->getSubObjectsRecursively('root', true, false);
896 }
897 } else {
898 $subs = $objDefinition->getSubObjectsRecursively($this->getParentType(), true, false);
899 }
900
901 foreach ($subs as $subtype => $def) {
902 // Delete per object type
903 $rbacadmin->deleteRolePermission($this->object->getId(), $this->obj_ref_id, $subtype);
904 }
905
906 if (empty($_POST["template_perm"])) {
907 $_POST["template_perm"] = array();
908 }
909
910 foreach ($_POST["template_perm"] as $key => $ops_array) {
911 // sets new template permissions
912 $rbacadmin->setRolePermission($this->object->getId(), $key, $ops_array, $this->obj_ref_id);
913 }
914
915 if ($rbac_log_active) {
916 $rbac_log_new = ilRbacLog::gatherTemplate($this->obj_ref_id, $this->object->getId());
917 $rbac_log_diff = ilRbacLog::diffTemplate($rbac_log_old, $rbac_log_new);
918 ilRbacLog::add(ilRbacLog::EDIT_TEMPLATE, $this->obj_ref_id, $rbac_log_diff);
919 }
920
921 // update object data entry (to update last modification date)
922 $this->object->update();
923
924 // set protected flag
925 if ($this->obj_ref_id == ROLE_FOLDER_ID or $rbacreview->isAssignable($this->object->getId(), $this->obj_ref_id)) {
926 $rbacadmin->setProtected($this->obj_ref_id, $this->object->getId(), ilUtil::tf2yn($_POST['protected']));
927 }
928
929 if ($a_show_admin_permissions) {
930 $_POST['recursive'] = true;
931 }
932
933 // Redirect if Change existing objects is not chosen
934 if (!$_POST['recursive'] and !is_array($_POST['recursive_list'])) {
935 ilUtil::sendSuccess($this->lng->txt("saved_successfully"), true);
936 if ($a_show_admin_permissions) {
937 $this->ctrl->redirect($this, 'adminPerm');
938 } else {
939 $this->ctrl->redirect($this, 'perm');
940 }
941 }
942 // New implementation
943 if ($this->isChangeExistingObjectsConfirmationRequired() and !$a_show_admin_permissions) {
945 return true;
946 }
947
948 $start = ($this->obj_ref_id == ROLE_FOLDER_ID ? ROOT_FOLDER_ID : $this->obj_ref_id);
949 if ($a_show_admin_permissions) {
950 $start = $tree->getParentId($this->obj_ref_id);
951 }
952
953 if ($_POST['protected']) {
954 $this->object->changeExistingObjects(
955 $start,
957 array('all'),
958 array()
959 #$a_show_admin_permissions ? array('adm') : array()
960 );
961 } else {
962 $this->object->changeExistingObjects(
963 $start,
965 array('all'),
966 array()
967 #$a_show_admin_permissions ? array('adm') : array()
968 );
969 }
970 ilUtil::sendSuccess($this->lng->txt("saved_successfully"), true);
971
972 if ($a_show_admin_permissions) {
973 $this->ctrl->redirect($this, 'adminPerm');
974 } else {
975 $this->ctrl->redirect($this, 'perm');
976 }
977 return true;
978 }
979
980
986 public function adoptPermSaveObject()
987 {
988 global $rbacadmin, $rbacsystem, $rbacreview, $tree;
989
990 if (!$_POST['adopt']) {
991 ilUtil::sendFailure($this->lng->txt('select_one'));
992 $this->adoptPermObject();
993 return false;
994 }
995
996 $access = $this->checkAccess('visible,write', 'edit_permission');
997 if (!$access) {
998 $this->ilias->raiseError($this->lng->txt("msg_no_perm_perm"), $this->ilias->error_obj->MESSAGE);
999 }
1000
1001 if ($this->object->getId() == $_POST["adopt"]) {
1002 ilUtil::sendFailure($this->lng->txt("msg_perm_adopted_from_itself"), true);
1003 } else {
1004 $rbacadmin->deleteRolePermission($this->object->getId(), $this->obj_ref_id);
1005 $parentRoles = $rbacreview->getParentRoleIds($this->obj_ref_id, true);
1006 $rbacadmin->copyRoleTemplatePermissions(
1007 $_POST["adopt"],
1008 $parentRoles[$_POST["adopt"]]["parent"],
1009 $this->obj_ref_id,
1010 $this->object->getId(),
1011 false
1012 );
1013
1014 // update object data entry (to update last modification date)
1015 $this->object->update();
1016
1017 // send info
1018 $obj_data =&$this->ilias->obj_factory->getInstanceByObjId($_POST["adopt"]);
1019 ilUtil::sendSuccess($this->lng->txt("msg_perm_adopted_from1") . " '" . $obj_data->getTitle() . "'.<br/>" .
1020 $this->lng->txt("msg_perm_adopted_from2"), true);
1021 }
1022
1023 $this->ctrl->redirect($this, "perm");
1024 }
1025
1031 public function assignSaveObject()
1032 {
1033 $this->assignUserObject();
1034 }
1035
1036
1037
1043 public function addUserObject($a_user_ids)
1044 {
1045 global $rbacreview,$rbacadmin;
1046
1047 if (!$this->checkAccess('edit_userassignment', 'edit_permission')) {
1048 ilUtil::sendFailure($this->lng->txt('msg_no_perm_assign_user_to_role'), true);
1049 return false;
1050 }
1051 if (!$rbacreview->isAssignable($this->object->getId(), $this->obj_ref_id) &&
1052 $this->obj_ref_id != ROLE_FOLDER_ID) {
1053 ilUtil::sendFailure($this->lng->txt('err_role_not_assignable'), true);
1054 return false;
1055 }
1056 if (!$a_user_ids) {
1057 $GLOBALS['lng']->loadLanguageModule('search');
1058 ilUtil::sendFailure($this->lng->txt('search_err_user_not_exist'), true);
1059 return false;
1060 }
1061
1062 $assigned_users_all = $rbacreview->assignedUsers($this->object->getId());
1063
1064 // users to assign
1065 $assigned_users_new = array_diff($a_user_ids, array_intersect($a_user_ids, $assigned_users_all));
1066
1067 // selected users all already assigned. stop
1068 if (count($assigned_users_new) == 0) {
1069 ilUtil::sendInfo($this->lng->txt("rbac_msg_user_already_assigned"), true);
1070 $this->ctrl->redirect($this, 'userassignment');
1071 }
1072
1073 // assign new users
1074 foreach ($assigned_users_new as $user) {
1075 $rbacadmin->assignUser($this->object->getId(), $user, false);
1076 }
1077
1078 // update object data entry (to update last modification date)
1079 $this->object->update();
1080
1081 ilUtil::sendSuccess($this->lng->txt("msg_userassignment_changed"), true);
1082 $this->ctrl->redirect($this, 'userassignment');
1083 }
1084
1090 public function deassignUserObject()
1091 {
1092 global $rbacsystem, $rbacadmin, $rbacreview;
1093
1094 if (!$this->checkAccess('edit_userassignment', 'edit_permission')) {
1095 $this->ilias->raiseError($this->lng->txt("msg_no_perm_assign_user_to_role"), $this->ilias->error_obj->MESSAGE);
1096 }
1097
1098 $selected_users = ($_POST["user_id"]) ? $_POST["user_id"] : array($_GET["user_id"]);
1099
1100 if ($selected_users[0]=== null) {
1101 $this->ilias->raiseError($this->lng->txt("no_checkbox"), $this->ilias->error_obj->MESSAGE);
1102 }
1103
1104 // prevent unassignment of system user from system role
1105 if ($this->object->getId() == SYSTEM_ROLE_ID) {
1106 if ($admin = array_search(SYSTEM_USER_ID, $selected_users) !== false) {
1107 unset($selected_users[$admin]);
1108 }
1109 }
1110
1111 // check for each user if the current role is his last global role before deassigning him
1112 $last_role = array();
1113 $global_roles = $rbacreview->getGlobalRoles();
1114
1115 foreach ($selected_users as $user) {
1116 $assigned_roles = $rbacreview->assignedRoles($user);
1117 $assigned_global_roles = array_intersect($assigned_roles, $global_roles);
1118
1119 if (count($assigned_roles) == 1 or (count($assigned_global_roles) == 1 and in_array($this->object->getId(), $assigned_global_roles))) {
1120 $userObj = $this->ilias->obj_factory->getInstanceByObjId($user);
1121 $last_role[$user] = $userObj->getFullName();
1122 unset($userObj);
1123 }
1124 }
1125
1126
1127 // ... else perform deassignment
1128 foreach ($selected_users as $user) {
1129 if (!isset($last_role[$user])) {
1130 $rbacadmin->deassignUser($this->object->getId(), $user);
1131 }
1132 }
1133
1134 // update object data entry (to update last modification date)
1135 $this->object->update();
1136
1137 // raise error if last role was taken from a user...
1138 if (count($last_role)) {
1139 $user_list = implode(", ", $last_role);
1140 ilUtil::sendFailure($this->lng->txt('msg_is_last_role') . ': ' . $user_list . '<br />' . $this->lng->txt('msg_min_one_role'), true);
1141 } else {
1142 ilUtil::sendSuccess($this->lng->txt("msg_userassignment_changed"), true);
1143 }
1144 $this->ctrl->redirect($this, 'userassignment');
1145 }
1146
1147
1151 public function userassignmentObject()
1152 {
1154
1155 if (!$this->checkAccess('edit_userassignment', 'edit_permission')) {
1156 $this->ilias->raiseError($this->lng->txt("msg_no_perm_assign_user_to_role"), $this->ilias->error_obj->MESSAGE);
1157 }
1158
1159 $this->tabs_gui->setTabActive('user_assignment');
1160
1161 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.rbac_ua.html', 'Services/AccessControl');
1162
1163 include_once './Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php';
1164 $tb = new ilToolbarGUI();
1165
1166 // protected admin role
1167 include_once './Services/PrivacySecurity/classes/class.ilSecuritySettings.php';
1168 if (
1169 $this->object->getId() != SYSTEM_ROLE_ID ||
1170 (
1171 !$rbacreview->isAssigned($ilUser->getId(), SYSTEM_ROLE_ID) or
1172 !ilSecuritySettings::_getInstance()->isAdminRoleProtected()
1173 )
1174 ) {
1175
1176
1177 // add member
1178 include_once './Services/Search/classes/class.ilRepositorySearchGUI.php';
1180 $this,
1181 $tb,
1182 array(
1183 'auto_complete_name' => $lng->txt('user'),
1184 'submit_name' => $lng->txt('add')
1185 )
1186 );
1187
1188 /*
1189 // add button
1190 $tb->addFormButton($lng->txt("add"), "assignUser");
1191 */
1192 $tb->addSpacer();
1193
1194 $tb->addButton(
1195 $this->lng->txt('search_user'),
1196 $this->ctrl->getLinkTargetByClass('ilRepositorySearchGUI', 'start')
1197 );
1198 $tb->addSpacer();
1199 }
1200
1201 $tb->addButton(
1202 $this->lng->txt('role_mailto'),
1203 $this->ctrl->getLinkTarget($this, 'mailToRole')
1204 );
1205 $this->tpl->setVariable('BUTTONS_UA', $tb->getHTML());
1206
1207
1208 include_once './Services/PrivacySecurity/classes/class.ilSecuritySettings.php';
1209 $role_assignment_editable = true;
1210 if (
1211 $this->object->getId() == SYSTEM_ROLE_ID &&
1212 !ilSecuritySettings::_getInstance()->checkAdminRoleAccessible($ilUser->getId())) {
1213 $role_assignment_editable = false;
1214 }
1215
1216 include_once './Services/AccessControl/classes/class.ilAssignedUsersTableGUI.php';
1217 $ut = new ilAssignedUsersTableGUI($this, 'userassignment', $this->object->getId(), $role_assignment_editable);
1218
1219 $this->tpl->setVariable('TABLE_UA', $ut->getHTML());
1220
1221 return true;
1222 }
1223
1224
1229 public function cancelObject()
1230 {
1231 if ($_GET["new_type"] != "role") {
1232 $this->ctrl->redirect($this, "userassignment");
1233 } else {
1234 $this->ctrl->redirectByClass("ilobjrolefoldergui", "view");
1235 }
1236 }
1237
1238
1239 public function listUsersRoleObject()
1240 {
1241 global $rbacsystem,$rbacreview;
1242
1243 $_SESSION["role_role"] = $_POST["role"] = $_POST["role"] ? $_POST["role"] : $_SESSION["role_role"];
1244
1245 if (!is_array($_POST["role"])) {
1246 ilUtil::sendFailure($this->lng->txt("role_no_roles_selected"));
1247 $this->searchObject();
1248
1249 return false;
1250 }
1251
1252 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.role_usr_selection.html", "Services/AccessControl");
1253 $this->__showButton("searchUserForm", $this->lng->txt("role_new_search"));
1254
1255 // GET ALL MEMBERS
1256 $members = array();
1257
1258 foreach ($_POST["role"] as $role_id) {
1259 $members = array_merge($rbacreview->assignedUsers($role_id), $members);
1260 }
1261
1262 $members = array_unique($members);
1263
1264 // FORMAT USER DATA
1265 $counter = 0;
1266 $f_result = array();
1267
1268 foreach ($members as $user) {
1269 if (!$tmp_obj = ilObjectFactory::getInstanceByObjId($user, false)) {
1270 continue;
1271 }
1272
1273 $user_ids[$counter] = $user;
1274
1275 // TODO: exclude anonymous user
1276 $f_result[$counter][] = ilUtil::formCheckbox(0, "user[]", $user);
1277 $f_result[$counter][] = $tmp_obj->getLogin();
1278 $f_result[$counter][] = $tmp_obj->getFirstname();
1279 $f_result[$counter][] = $tmp_obj->getLastname();
1280
1281 unset($tmp_obj);
1282 ++$counter;
1283 }
1284
1285 $this->__showSearchUserTable($f_result, $user_ids, "listUsersRole");
1286
1287 return true;
1288 }
1289
1290 public function __prepareOutput()
1291 {
1292 // output objects
1293 $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
1294 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
1295
1296 // output message
1297 if ($this->message) {
1298 ilUtil::sendInfo($this->message);
1299 }
1300
1301 // display infopanel if something happened
1303
1304 // set header
1305 $this->__setHeader();
1306 }
1307
1308 public function __setHeader()
1309 {
1310 $this->tpl->setTitle($this->lng->txt('role'));
1311 $this->tpl->setDescription($this->object->getTitle());
1312 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_role.svg"));
1313
1314 $this->getTabs($this->tabs_gui);
1315 }
1316
1317
1321 protected function addAdminLocatorItems($a_do_not_add_object = false)
1322 {
1323 global $DIC;
1324
1325 $ilLocator = $DIC['ilLocator'];
1326
1327 if (
1328 $_GET["admin_mode"] == "settings"
1329 && $_GET["ref_id"] == ROLE_FOLDER_ID) { // system settings
1330 parent::addAdminLocatorItems(true);
1331
1332 $ilLocator->addItem(
1333 $this->lng->txt("obj_" . ilObject::_lookupType(ilObject::_lookupObjId($_GET["ref_id"]))),
1334 $this->ctrl->getLinkTargetByClass("ilobjrolefoldergui", 'view')
1335 );
1336
1337 if ($_GET["obj_id"] > 0) {
1338 $ilLocator->addItem(
1339 $this->object->getTitle(),
1340 $this->ctrl->getLinkTarget($this, 'perm')
1341 );
1342 }
1343 } else {
1344 parent::addAdminLocatorItems($a_do_not_add_object);
1345 }
1346 }
1347
1348
1349
1350
1351 public function getTabs()
1352 {
1353 global $rbacreview, $ilHelp;
1354
1355 $base_role_container = $rbacreview->getFoldersAssignedToRole($this->object->getId(), true);
1356
1357
1358 $activate_role_edit = false;
1359
1360 // todo: activate the following (allow editing of local roles in
1361 // roles administration)
1362 if (in_array($this->obj_ref_id, $base_role_container) ||
1363 (strtolower($_GET["baseClass"]) == "iladministrationgui" &&
1364 $_GET["admin_mode"] == "settings")) {
1365 $activate_role_edit = true;
1366 }
1367
1368 // not so nice (workaround for using tabs in repository)
1369 $this->tabs_gui->clearTargets();
1370
1371 $ilHelp->setScreenIdComponent("role");
1372
1373 if ($this->back_target != "") {
1374 $this->tabs_gui->setBackTarget(
1375 $this->back_target["text"],
1376 $this->back_target["link"]
1377 );
1378 }
1379
1380 if ($this->checkAccess('write', 'edit_permission') && $activate_role_edit) {
1381 $this->tabs_gui->addTarget(
1382 "edit_properties",
1383 $this->ctrl->getLinkTarget($this, "edit"),
1384 array("edit","update"),
1385 get_class($this)
1386 );
1387 }
1388 /*
1389 if($this->checkAccess('write','edit_permission') and $this->showDefaultPermissionSettings())
1390 {
1391 $force_active = ($_GET["cmd"] == "perm" || $_GET["cmd"] == "")
1392 ? true
1393 : false;
1394 $this->tabs_gui->addTarget("default_perm_settings",
1395 $this->ctrl->getLinkTarget($this, "perm"), array("perm", "adoptPermSave", "permSave"),
1396 get_class($this),
1397 "", $force_active);
1398 }
1399 */
1400 if ($this->checkAccess('write', 'edit_permission') and $this->showDefaultPermissionSettings()) {
1401 $this->tabs_gui->addTarget(
1402 "default_perm_settings",
1403 $this->ctrl->getLinkTarget($this, "perm"),
1404 array(),
1405 get_class($this)
1406 );
1407 }
1408
1409 if ($this->checkAccess('write', 'edit_permission') && $activate_role_edit && $this->object->getId() != ANONYMOUS_ROLE_ID) {
1410 $this->tabs_gui->addTarget(
1411 "user_assignment",
1412 $this->ctrl->getLinkTarget($this, "userassignment"),
1413 array("deassignUser", "userassignment", "assignUser", "searchUserForm", "search"),
1414 get_class($this)
1415 );
1416 }
1417
1418 if ($this->checkAccess('write', 'edit_permission') && $activate_role_edit && $this->object->getId() != ANONYMOUS_ROLE_ID) {
1419 $this->tabs_gui->addTarget(
1420 "desktop_items",
1421 $this->ctrl->getLinkTarget($this, "listDesktopItems"),
1422 array("listDesktopItems", "deleteDesktopItems", "selectDesktopItem", "askDeleteDesktopItem"),
1423 get_class($this)
1424 );
1425 }
1426 if ($this->checkAccess('write', 'edit_permission')) {
1427 $this->tabs_gui->addTarget(
1428 'export',
1429 $this->ctrl->getLinkTargetByClass('ilExportGUI'),
1430 array()
1431 );
1432 }
1433 }
1434
1435 public function mailToRoleObject()
1436 {
1437 $obj_ids = ilObject::_getIdsForTitle($this->object->getTitle(), $this->object->getType());
1438 if (count($obj_ids) > 1) {
1439 $_SESSION['mail_roles'][] = '#il_role_' . $this->object->getId();
1440 } else {
1441 require_once 'Services/Mail/classes/Address/Type/class.ilMailRoleAddressType.php';
1442 $_SESSION['mail_roles'][] = ilMailRoleAddressType::getRoleMailboxAddress($this->object->getId());
1443 }
1444
1445 require_once 'Services/Mail/classes/class.ilMailFormCall.php';
1446 $script = ilMailFormCall::getRedirectTarget($this, 'userassignment', array(), array('type' => 'role'));
1447 ilUtil::redirect($script);
1448 }
1449
1450 public function checkAccess($a_perm_global, $a_perm_obj = '')
1451 {
1452 global $rbacsystem,$ilAccess;
1453
1454 $a_perm_obj = $a_perm_obj ? $a_perm_obj : $a_perm_global;
1455
1456 if ($this->obj_ref_id == ROLE_FOLDER_ID) {
1457 return $rbacsystem->checkAccess($a_perm_global, $this->obj_ref_id);
1458 } else {
1459 return $ilAccess->checkAccess($a_perm_obj, '', $this->obj_ref_id);
1460 }
1461 }
1462
1468 {
1469 global $rbacreview;
1470
1471 if (!(int) $_POST['recursive'] and !is_array($_POST['recursive_list'])) {
1472 return false;
1473 }
1474
1475 // Role is protected
1476 if ($rbacreview->isProtected($this->obj_ref_id, $this->object->getId())) {
1477 // TODO: check if recursive_list is enabled
1478 // and if yes: check if inheritance is broken for the relevant object types
1479 return count($rbacreview->getFoldersAssignedToRole($this->object->getId())) > 1;
1480 } else {
1481 // TODO: check if recursive_list is enabled
1482 // and if yes: check if inheritance is broken for the relevant object types
1483 return count($rbacreview->getFoldersAssignedToRole($this->object->getId())) > 1;
1484 }
1485 }
1486
1492 {
1493 $protected = $_POST['protected'];
1494
1495 include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
1496 $form = new ilPropertyFormGUI();
1497 $form->setFormAction($this->ctrl->getFormAction($this, 'changeExistingObjects'));
1498 $form->setTitle($this->lng->txt('rbac_change_existing_confirm_tbl'));
1499
1500 $form->addCommandButton('changeExistingObjects', $this->lng->txt('change_existing_objects'));
1501 $form->addCommandButton('perm', $this->lng->txt('cancel'));
1502
1503 $hidden = new ilHiddenInputGUI('type_filter');
1504 $hidden->setValue(
1505 $_POST['recursive'] ?
1506 serialize(array('all')) :
1507 serialize($_POST['recursive_list'])
1508 );
1509 $form->addItem($hidden);
1510
1511 $rad = new ilRadioGroupInputGUI($this->lng->txt('rbac_local_policies'), 'mode');
1512
1513 if ($protected) {
1515 $keep = new ilRadioOption(
1516 $this->lng->txt('rbac_keep_local_policies'),
1518 $this->lng->txt('rbac_keep_local_policies_info')
1519 );
1520 } else {
1522 $keep = new ilRadioOption(
1523 $this->lng->txt('rbac_keep_local_policies'),
1525 $this->lng->txt('rbac_unprotected_keep_local_policies_info')
1526 );
1527 }
1528 $rad->addOption($keep);
1529
1530 if ($protected) {
1531 $del = new ilRadioOption(
1532 $this->lng->txt('rbac_delete_local_policies'),
1534 $this->lng->txt('rbac_delete_local_policies_info')
1535 );
1536 } else {
1537 $del = new ilRadioOption(
1538 $this->lng->txt('rbac_delete_local_policies'),
1540 $this->lng->txt('rbac_unprotected_delete_local_policies_info')
1541 );
1542 }
1543 $rad->addOption($del);
1544
1545 $form->addItem($rad);
1546 $this->tpl->setContent($form->getHTML());
1547 }
1548
1553 protected function changeExistingObjectsObject()
1554 {
1555 global $tree,$rbacreview,$rbacadmin;
1556
1557 $mode = (int) $_POST['mode'];
1558 $start = ($this->obj_ref_id == ROLE_FOLDER_ID ? ROOT_FOLDER_ID : $this->obj_ref_id);
1559
1560 $this->object->changeExistingObjects($start, $mode, unserialize(ilUtil::stripSlashes($_POST['type_filter'])));
1561
1562 ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
1563 $this->ctrl->redirect($this, 'perm');
1564 }
1565
1571 protected function setSubTabs($a_tab)
1572 {
1573 global $ilTabs;
1574
1575 switch ($a_tab) {
1576 case 'default_perm_settings':
1577 if ($this->obj_ref_id != ROLE_FOLDER_ID) {
1578 return true;
1579 }
1580 $ilTabs->addSubTabTarget(
1581 'rbac_repository_permissions',
1582 $this->ctrl->getLinkTarget($this, 'perm')
1583 );
1584 $ilTabs->addSubTabTarget(
1585 'rbac_admin_permissions',
1586 $this->ctrl->getLinkTarget($this, 'adminPerm')
1587 );
1588 }
1589 return true;
1590 }
1591
1595 protected function addToClipboardObject()
1596 {
1597 global $lng, $ilCtrl;
1598
1599 $users = (array) $_POST['user_id'];
1600 if (!count($users)) {
1601 ilUtil::sendFailure($this->lng->txt('select_one'), true);
1602 $ilCtrl->redirect($this, 'userassignment');
1603 }
1604 include_once './Services/User/classes/class.ilUserClipboard.php';
1605 $clip = ilUserClipboard::getInstance($GLOBALS['ilUser']->getId());
1606 $clip->add($users);
1607 $clip->save();
1608
1609 $lng->loadLanguageModule('user');
1610 ilUtil::sendSuccess($this->lng->txt('clipboard_user_added'), true);
1611 $ilCtrl->redirect($this, 'userassignment');
1612 }
1613
1617 protected function addLocatorItems()
1618 {
1619 global $DIC;
1620
1621 $ilLocator = $DIC['ilLocator'];
1622
1623 if ($_GET["admin_mode"] == "") {
1624 $this->ctrl->setParameterByClass(
1625 "ilobjrolegui",
1626 "obj_id",
1627 (int) $_GET["obj_id"]
1628 );
1629 $ilLocator->addItem(
1630 ilObjRole::_getTranslation($this->object->getTitle()),
1631 $this->ctrl->getLinkTargetByClass(
1632 array(
1633 "ilpermissiongui",
1634 "ilobjrolegui"),
1635 "perm"
1636 )
1637 );
1638 }
1639 }
1640
1641 /*
1642 * Ensure access to role for ref_id
1643 * @throws ilObjectException
1644 */
1645 protected function ensureRoleAccessForContext()
1646 {
1647 global $DIC;
1648
1649 $review = $DIC->rbac()->review();
1650 $logger = $DIC->logger()->ac();
1651
1652 // creation of roles
1653 if (
1654 !$this->object->getId() ||
1655 $this->object->getId() == ROLE_FOLDER_ID
1656 ) {
1657 return true;
1658 }
1659
1660
1661 $possible_roles = [];
1662 try {
1663 $possible_roles = $review->getRolesOfObject(
1664 $this->obj_ref_id,
1665 false
1666 );
1667 } catch (\InvalidArgumentException $e) {
1668 $logger->warning('Role access check failed: ' . $e);
1669
1670 include_once "Services/Object/exceptions/class.ilObjectException.php";
1671 throw new \ilObjectException($this->lng->txt('permission_denied'));
1672 }
1673
1674 if (!in_array($this->object->getId(), $possible_roles)) {
1675 $logger->warning('Object id: ' . $this->object->getId() . ' is not accessible for ref_id: ' . $this->obj_ref_id);
1676 include_once "Services/Object/exceptions/class.ilObjectException.php";
1677 throw new \ilObjectException($this->lng->txt('permission_denied'));
1678 }
1679 return true;
1680 }
1681} // END class.ilObjRoleGUI
if(!isset( $_REQUEST[ 'ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
$users
Definition: authpage.php:44
$_GET["client_id"]
$_POST["username"]
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
const USER_FOLDER_ID
Class ilObjUserFolder.
Accordion user interface class.
TableGUI class for role administration.
This class represents a checkbox property in a property form.
Confirmation screen class.
Export User Interface Class.
static newInstance($a_export_id)
Create new instance.
static allocateExportId()
Allocate a new export id.
This class represents a hidden form property in a property form.
static getRedirectTarget($gui, $cmd, array $gui_params=array(), array $mail_params=array(), array $context_params=array())
static getRoleMailboxAddress( $a_role_id, $is_localize=true, ilMailRfc822AddressParserFactory $mailAddressParserFactory=null)
Returns the mailbox address of a role.
This class represents a non editable value in a property form.
This class represents a number property in a property form.
Class ilObjRoleGUI.
getAdminTabs()
admin and normal tabs are equal for roles
editObject()
Edit role properties.
getTabs()
get tabs abstract method.
performDeleteRoleObject()
Delete role.
saveObject()
Save new role.
updateObject()
Save role settings.
initFormRoleProperties($a_mode)
Create role prperty form.
userassignmentObject()
display user assignment panel
showChangeExistingObjectsConfirmation()
Show confirmation screen.
__construct($a_data, $a_id, $a_call_by_reference=false, $a_prepare_output=true)
Constructor @access public.
setBackTarget($a_text, $a_link)
set back tab target
readRoleProperties(ilObjRole $role)
Read role properties and write them to form.
addLocatorItems()
should be overwritten to add object specific items (repository items are preloaded)
deassignUserObject()
de-assign users from role
permObject($a_show_admin_permissions=false)
Show template permissions.
loadRoleProperties(ilObjRole $role)
Store form input in role object.
assignSaveObject()
wrapper for renamed function
permSaveObject($a_show_admin_permissions=false)
save permissions
getParentType()
get type of current object (not role folder)
getContainerType()
Get type of role container.
addAdminLocatorItems($a_do_not_add_object=false)
should be overwritten to add object specific items (repository items are preloaded)
addUserObject($a_user_ids)
Assign user (callback from ilRepositorySearchGUI)
checkAccess($a_perm_global, $a_perm_obj='')
cancelObject()
cancelObject is called when an operation is canceled, method links back @access public
showDefaultPermissionSettings()
check if default permissions are shown or not
adminPermObject()
Show administration permissions.
executeCommand()
execute command
adminPermSaveObject()
Save admin permissions.
checkDuplicate($a_role_id=0)
Check if role with same name already exists in this folder.
confirmDeleteRoleObject()
Show delete confirmation screen.
createObject()
Only called from administration -> role folder ? Otherwise this check access is wrong.
getParentRefId()
Get ref id of current object (not role folder id)
isChangeExistingObjectsConfirmationRequired()
Check if a confirmation about further settings is required or not.
adoptPermSaveObject()
copy permissions from role
getParentObjId()
Get obj_id of current object.
setSubTabs($a_tab)
Set sub tabs.
addToClipboardObject()
Add selected users to user clipboard.
changeExistingObjectsObject()
Change existing objects.
Class ilObjRole.
setAllowRegister($a_allow_register)
set allow_register of role
const MODE_UNPROTECTED_KEEP_LOCAL_POLICIES
const MODE_PROTECTED_DELETE_LOCAL_POLICIES
const MODE_UNPROTECTED_DELETE_LOCAL_POLICIES
getPersonalWorkspaceDiskQuota()
Gets the minimal personal workspace disk quota imposed by this role.
getAllowRegister()
get allow_register
static _getTranslation($a_role_title)
const MODE_PROTECTED_KEEP_LOCAL_POLICIES
static isAutoGenerated($a_role_id)
getDiskQuota()
Gets the minimal disk quota imposed by this role.
toggleAssignUsersStatus($a_assign_users)
setDiskQuota($a_disk_quota)
Sets the minimal disk quota imposed by this role.
setPersonalWorkspaceDiskQuota($a_disk_quota)
Sets the minimal personal workspace disk quota imposed by this role.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
Class ilObjectGUI Basic methods of all Output classes.
__showButton($a_cmd, $a_text, $a_target='')
prepareOutput($a_show_subobjects=true)
prepare output
static lookupTxtById($plugin_id, $lang_var)
static _lookupObjId($a_id)
setTitle($a_title)
set object title
setDescription($a_desc)
set object description
getDescription()
get object description
getId()
get object id @access public
static _lookupType($a_id, $a_reference=false)
lookup object type
static _getIdsForTitle($title, $type='', $partialmatch=false)
getTitle()
get object title @access public
This class represents a property form user interface.
This class represents a property in a property form.
This class represents an option in a radio group.
static diffTemplate(array $a_old, array $a_new)
static add($a_action, $a_ref_id, array $a_diff, $a_source_ref_id=false)
static gatherTemplate($a_role_ref_id, $a_role_id)
const EDIT_TEMPLATE
static isActive()
static fillAutoCompleteToolbar($parent_object, ilToolbarGUI $toolbar=null, $a_options=array(), $a_sticky=false)
fill toolbar with
Copyright (c) 1998-2015 ILIAS open source, Extended GPL, see docs/LICENSE Date: 07....
static _getInstance()
Get instance of ilSecuritySettings.
This class represents a text area property in a property form.
This class represents a text property in a property form.
static getInstance($a_usr_id)
Get singelton instance.
static formCheckbox($checked, $varname, $value, $disabled=false)
??? @access public
static _sortIds($a_ids, $a_table, $a_field, $a_id_name)
Function that sorts ids by a given table field using WHERE IN E.g: __sort(array(6,...
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static sendQuestion($a_info="", $a_keep=false)
Send Question to Screen.
static tf2yn($a_tf)
convert true/false to "y"/"n"
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static redirect($a_script)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static MB2Bytes($a_value)
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static infoPanel($a_keep=true)
static Bytes2MB($a_value)
$counter
$def
Definition: croninfo.php:21
$key
Definition: croninfo.php:18
$tbl
Definition: example_048.php:81
if(!array_key_exists('StateId', $_REQUEST)) $id
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\s+" &#(? foreach( $entity_files as $file) $output
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
global $ilCtrl
Definition: ilias.php:18
redirection script todo: (a better solution should control the processing via a xml file)
$ret
Definition: parser.php:6
global $ilSetting
Definition: privfeed.php:17
if(isset($_POST['submit'])) $form
global $DIC
Definition: saml.php:7
$ilUser
Definition: imgupload.php:18