ILIAS  release_8 Revision v8.24
class.ilPermission2GUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
23
31{
32 private const TAB_POSITION_PERMISSION_SETTINGS = "position_permission_settings";
33
34 protected object $gui_obj;
36 protected ilCtrl $ctrl;
37 protected ilLanguage $lng;
44 protected ilTabsGUI $tabs;
46 protected Factory $refinery;
47
48 private array $roles = [];
49 private int $num_roles = 0;
50
51 public function __construct(object $a_gui_obj)
52 {
53 global $DIC;
54
55 $this->objDefinition = $DIC['objDefinition'];
56 $this->objectDataCache = $DIC['ilObjDataCache'];
57 $this->tpl = $DIC->ui()->mainTemplate();
58 $this->lng = $DIC->language();
59 $this->lng->loadLanguageModule("rbac");
60 $this->ctrl = $DIC->ctrl();
61 $this->rbacsystem = $DIC->rbac()->system();
62 $this->rbacreview = $DIC->rbac()->review();
63 $this->rbacadmin = $DIC->rbac()->admin();
64 $this->tabs = $DIC->tabs();
65 $this->ilErr = $DIC['ilErr'];
66 $this->http = $DIC->http();
67 $this->refinery = $DIC->refinery();
68
69 $this->gui_obj = $a_gui_obj;
70 $this->tabs->activateTab('perm_settings');
71 }
72
73 // show owner sub tab
74 public function owner(): void
75 {
76 $this->__initSubTabs("owner");
77
78 $form = new ilPropertyFormGUI();
79 $form->setFormAction($this->ctrl->getFormAction($this, "owner"));
80 $form->setTitle($this->lng->txt("info_owner_of_object"));
81
82 $login = new ilTextInputGUI($this->lng->txt("login"), "owner");
83 $login->setDataSource($this->ctrl->getLinkTargetByClass(array(get_class($this),
84 'ilRepositorySearchGUI'
85 ), 'doUserAutoComplete', '', true));
86 $login->setRequired(true);
87 $login->setSize(50);
88 $login->setInfo($this->lng->txt("chown_warning"));
89 $login->setValue(ilObjUser::_lookupLogin($this->gui_obj->getObject()->getOwner()));
90 $form->addItem($login);
91 $form->addCommandButton("changeOwner", $this->lng->txt("change_owner"));
92 $this->tpl->setContent($form->getHTML());
93 }
94
95 public function changeOwner(): void
96 {
97 $owner = '';
98 if ($this->http->wrapper()->post()->has('owner')) {
99 $owner = $this->http->wrapper()->post()->retrieve(
100 'owner',
101 $this->refinery->kindlyTo()->string()
102 );
103 }
104 if (!$user_id = ilObjUser::_lookupId($owner)) {
105 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('user_not_known'));
106 $this->owner();
107 return;
108 }
109
110 // no need to change?
111 if ($user_id != $this->gui_obj->getObject()->getOwner()) {
112 $this->gui_obj->getObject()->setOwner($user_id);
113 $this->gui_obj->getObject()->updateOwner();
114 $this->objectDataCache->deleteCachedEntry($this->gui_obj->getObject()->getId());
115
116 if (ilRbacLog::isActive()) {
117 ilRbacLog::add(ilRbacLog::CHANGE_OWNER, $this->gui_obj->getObject()->getRefId(), array($user_id));
118 }
119 }
120
121 $this->tpl->setOnScreenMessage('success', $this->lng->txt('owner_updated'), true);
122
123 if (!$this->rbacsystem->checkAccess("edit_permission", $this->gui_obj->getObject()->getRefId())) {
124 $this->ctrl->redirect($this->gui_obj);
125 return;
126 }
127 $this->ctrl->redirect($this, 'owner');
128 }
129
130 // init sub tabs
131 public function __initSubTabs(string $a_cmd): void
132 {
133 $perm = $a_cmd === 'perm';
134 $perm_positions = $a_cmd === ilPermissionGUI::CMD_PERM_POSITIONS;
135 $info = $a_cmd === 'perminfo';
136 $owner = $a_cmd === 'owner';
137 $log = $a_cmd === 'log';
138
139 $this->tabs->addSubTabTarget(
140 "permission_settings",
141 $this->ctrl->getLinkTarget($this, "perm"),
142 "",
143 "",
144 "",
145 $perm
146 );
147
148 if (ilOrgUnitGlobalSettings::getInstance()->isPositionAccessActiveForObject($this->gui_obj->getObject()->getId())) {
149 $this->tabs->addSubTabTarget(
150 self::TAB_POSITION_PERMISSION_SETTINGS,
151 $this->ctrl->getLinkTarget($this, ilPermissionGUI::CMD_PERM_POSITIONS),
152 "",
153 "",
154 "",
155 $perm_positions
156 );
157 }
158
159 $this->tabs->addSubTabTarget(
160 "info_status_info",
161 $this->ctrl->getLinkTargetByClass(array(get_class($this), "ilobjectpermissionstatusgui"), "perminfo"),
162 "",
163 "",
164 "",
165 $info
166 );
167 $this->tabs->addSubTabTarget(
168 "owner",
169 $this->ctrl->getLinkTarget($this, "owner"),
170 "",
171 "",
172 "",
173 $owner
174 );
175
176 if (ilRbacLog::isActive()) {
177 $this->tabs->addSubTabTarget(
178 "rbac_log",
179 $this->ctrl->getLinkTarget($this, "log"),
180 "",
181 "",
182 "",
183 $log
184 );
185 }
186 }
187
188 public function log(): void
189 {
190 if (!ilRbacLog::isActive()) {
191 $this->ctrl->redirect($this, "perm");
192 }
193
194 $this->__initSubTabs("log");
195
196 $table = new ilRbacLogTableGUI($this, "log", $this->gui_obj->getObject()->getRefId());
197 $this->tpl->setContent($table->getHTML());
198 }
199
200 public function applyLogFilter(): void
201 {
202 $table = new ilRbacLogTableGUI($this, "log", $this->gui_obj->getObject()->getRefId());
203 $table->resetOffset();
204 $table->writeFilterToSession();
205 $this->log();
206 }
207
208 public function resetLogFilter(): void
209 {
210 $table = new ilRbacLogTableGUI($this, "log", $this->gui_obj->getObject()->getRefId());
211 $table->resetOffset();
212 $table->resetFilter();
213 $this->log();
214 }
215}
Builds data types.
Definition: Factory.php:21
Class ilCtrl provides processing control methods.
Error Handling & global info handling uses PEAR error class.
language handling
static _lookupId($a_user_str)
static _lookupLogin(int $a_user_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
parses the objects.xml it handles the xml-description of all ilias objects
Class ilPermissionGUI RBAC related output.
ilObjectDefinition $objDefinition
ilObjectDataCache $objectDataCache
__initSubTabs(string $a_cmd)
__construct(object $a_gui_obj)
ilGlobalTemplateInterface $tpl
This class represents a property form user interface.
Class ilRbacAdmin Core functions for role based access control.
Class ilRbacLogTableGUI.
static add(int $a_action, int $a_ref_id, array $a_diff, bool $a_source_ref_id=false)
const CHANGE_OWNER
static isActive()
class ilRbacReview Contains Review functions of core Rbac.
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a text property in a property form.
global $DIC
Definition: feed.php:28
Interface GlobalHttpState.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static http()
Fetches the global http state from ILIAS.
$log
Definition: result.php:33