ILIAS  release_8 Revision v8.24
class.ilWorkspaceAccessGUI.php
Go to the documentation of this file.
1<?php
2
20
29{
30 public const PERMISSION_REGISTERED = -1;
31 public const PERMISSION_ALL_PASSWORD = -3;
32 public const PERMISSION_ALL = -5;
33 protected bool $is_portfolio;
34 protected ilTabsGUI $tabs;
37 protected ilObjUser $user;
39 protected ilCtrl $ctrl;
40 protected ilLanguage $lng;
41 protected int $node_id;
45 protected $access_handler;
46 protected string $footer = "";
47
48 protected string $blocking_message = "";
50
54 public function __construct(
55 int $a_node_id,
56 $a_access_handler,
57 bool $a_is_portfolio = false,
58 string $a_footer = ""
59 ) {
60 global $DIC;
61
62 $this->tabs = $DIC->tabs();
63 $this->tpl = $DIC->ui()->mainTemplate();
64 $this->toolbar = $DIC->toolbar();
65 $this->user = $DIC->user();
66 $this->settings = $DIC->settings();
67 $ilCtrl = $DIC->ctrl();
68 $lng = $DIC->language();
69
70 $this->ctrl = $ilCtrl;
71 $this->lng = $lng;
72 $this->node_id = $a_node_id;
73 $this->access_handler = $a_access_handler;
74 $this->is_portfolio = $a_is_portfolio;
75 $this->footer = $a_footer;
76 $this->std_request = new StandardGUIRequest(
77 $DIC->http(),
78 $DIC->refinery()
79 );
80 }
81
82 // Set blocking message
83 public function setBlockingMessage(string $a_val): void
84 {
85 $this->blocking_message = $a_val;
86 }
87
88 public function getBlockingMessage(): string
89 {
91 }
92
93 public function executeCommand(): void
94 {
95 $ilTabs = $this->tabs;
97 $next_class = $this->ctrl->getNextClass($this);
98 $cmd = $this->ctrl->getCmd();
99
100 switch ($next_class) {
101 case "ilmailsearchcoursesgui":
102 $ilTabs->setBackTarget(
103 $this->lng->txt("back"),
104 $this->ctrl->getLinkTarget($this, "share")
105 );
106 $csearch = new ilMailSearchCoursesGUI($this->access_handler, $this->node_id);
107 $this->ctrl->setReturn($this, 'share');
108 $this->ctrl->forwardCommand($csearch);
109
110 $this->setObjectTitle();
111 break;
112
113 case "ilmailsearchgroupsgui":
114 $ilTabs->setBackTarget(
115 $this->lng->txt("back"),
116 $this->ctrl->getLinkTarget($this, "share")
117 );
118 $gsearch = new ilMailSearchGroupsGUI($this->access_handler, $this->node_id);
119 $this->ctrl->setReturn($this, 'share');
120 $this->ctrl->forwardCommand($gsearch);
121
122 $this->setObjectTitle();
123 break;
124
125 case "ilmailsearchgui":
126 $ilTabs->setBackTarget(
127 $this->lng->txt("back"),
128 $this->ctrl->getLinkTarget($this, "share")
129 );
130 $usearch = new ilMailSearchGUI($this->access_handler, $this->node_id);
131 $this->ctrl->setReturn($this, 'share');
132 $this->ctrl->forwardCommand($usearch);
133
134 $this->setObjectTitle();
135 break;
136
137 case "ilsingleusersharegui":
138 $ilTabs->setBackTarget(
139 $this->lng->txt("back"),
140 $this->ctrl->getLinkTarget($this, "share")
141 );
142 $ushare = new ilSingleUserShareGUI($this->access_handler, $this->node_id);
143 $this->ctrl->setReturn($this, 'share');
144 $this->ctrl->forwardCommand($ushare);
145
146 $this->setObjectTitle();
147 break;
148
149 case "ilpublicuserprofilegui":
150 $ilTabs->clearTargets();
151 $ilTabs->setBackTarget(
152 $this->lng->txt("back"),
153 $this->ctrl->getLinkTarget($this, "share")
154 );
155
156 $prof = new ilPublicUserProfileGUI(
157 $this->std_request->getUser()
158 );
159 $prof->setBackUrl($this->ctrl->getLinkTarget($this, "share"));
160 $tpl->setContent($prof->getHTML());
161 break;
162
163 default:
164 // $this->prepareOutput();
165 if (!$cmd) {
166 $cmd = "share";
167 }
168 //return $this->$cmd();
169 $this->$cmd();
170 break;
171 }
172 }
173
174 protected function setObjectTitle(): void
175 {
177
178 if (!$this->is_portfolio) {
179 $obj_id = $this->access_handler->getTree()->lookupObjectId($this->node_id);
180 } else {
181 $obj_id = $this->node_id;
182 }
184 }
185
189 protected function getAccessHandler()
190 {
192 }
193
194 protected function share(): void
195 {
196 $ilToolbar = $this->toolbar;
200
201
202 // blocking message
203 if ($this->getBlockingMessage() != "") {
204 $tpl->setContent($this->getBlockingMessage());
205 return;
206 }
207
208 $options = array();
209 $options["user"] = $this->lng->txt("wsp_set_permission_single_user");
210
211 $grp_ids = ilGroupParticipants::_getMembershipByType($ilUser->getId(), ['grp']);
212 if (sizeof($grp_ids)) {
213 $options["group"] = $this->lng->txt("wsp_set_permission_group");
214 }
215
216 $crs_ids = ilCourseParticipants::_getMembershipByType($ilUser->getId(), ['crs']);
217 if (sizeof($crs_ids)) {
218 $options["course"] = $this->lng->txt("wsp_set_permission_course");
219 }
220
221 if (!$this->getAccessHandler()->hasRegisteredPermission($this->node_id)) {
222 $options["registered"] = $this->lng->txt("wsp_set_permission_registered");
223 }
224
225 if ($ilSetting->get("enable_global_profiles")) {
226 if (!$this->getAccessHandler()->hasGlobalPasswordPermission($this->node_id)) {
227 $options["password"] = $this->lng->txt("wsp_set_permission_all_password");
228 }
229
230 if (!$this->getAccessHandler()->hasGlobalPermission($this->node_id)) {
231 $options["all"] = $this->lng->txt("wsp_set_permission_all");
232 }
233 }
234
235 $actions = new ilSelectInputGUI("", "action");
236 $actions->setOptions($options);
237 $ilToolbar->addStickyItem($actions);
238
239 $ilToolbar->setFormAction($this->ctrl->getFormAction($this));
240
241 $button = ilSubmitButton::getInstance();
242 $button->setCaption("add");
243 $button->setCommand("addpermissionhandler");
244 $ilToolbar->addStickyItem($button);
245
246 $table = new ilWorkspaceAccessTableGUI($this, "share", $this->node_id, $this->getAccessHandler());
247 $tpl->setContent($table->getHTML() . $this->footer);
248 }
249
250 public function addPermissionHandler(): void
251 {
252 switch ($this->std_request->getAction()) {
253 case "user":
254
255 if (ilUserAccountSettings::getInstance()->isUserAccessRestricted()) {
256 $this->ctrl->redirectByClass("ilsingleusersharegui");
257 } else {
258 $this->ctrl->setParameterByClass("ilmailsearchgui", "ref", "wsp");
259 $this->ctrl->redirectByClass("ilmailsearchgui");
260 }
261 break;
262
263 case "group":
264 $this->ctrl->setParameterByClass("ilmailsearchgroupsgui", "ref", "wsp");
265 $this->ctrl->redirectByClass("ilmailsearchgroupsgui");
266 break;
267
268 case "course":
269 $this->ctrl->setParameterByClass("ilmailsearchcoursesgui", "ref", "wsp");
270 $this->ctrl->redirectByClass("ilmailsearchcoursesgui");
271 break;
272
273 case "registered":
274 $this->getAccessHandler()->addPermission($this->node_id, self::PERMISSION_REGISTERED);
275 $this->tpl->setOnScreenMessage('success', $this->lng->txt("wsp_permission_registered_info"), true);
276 $this->ctrl->redirect($this, "share");
277 break;
278
279 case "password":
280 $this->showPasswordForm();
281 break;
282
283 case "all":
284 $this->getAccessHandler()->addPermission($this->node_id, self::PERMISSION_ALL);
285 $this->tpl->setOnScreenMessage('success', $this->lng->txt("wsp_permission_all_info"), true);
286 $this->ctrl->redirect($this, "share");
287 }
288 }
289
290 public function removePermission(): void
291 {
292 $obj_id = $this->std_request->getObjId();
293 if ($obj_id !== 0) {
294 $this->getAccessHandler()->removePermission($this->node_id, $obj_id);
295 $this->tpl->setOnScreenMessage('success', $this->lng->txt("wsp_permission_removed"), true);
296 }
297
298 $this->ctrl->redirect($this, "share");
299 }
300
302 {
303 $form = new ilPropertyFormGUI();
304 $form->setFormAction($this->ctrl->getFormAction($this));
305 $form->setTitle($this->lng->txt("wsp_set_permission_all_password"));
306
307 $password = new ilPasswordInputGUI($this->lng->txt("password"), "password");
308 $password->setRequired(true);
309 $form->addItem($password);
310
311 $form->addCommandButton('savepasswordform', $this->lng->txt("save"));
312 $form->addCommandButton('share', $this->lng->txt("cancel"));
313
314 return $form;
315 }
316
317 protected function showPasswordForm(ilPropertyFormGUI $a_form = null): void
318 {
320
321 if (!$a_form) {
322 $a_form = $this->initPasswordForm();
323 }
324 $tpl->setContent($a_form->getHTML());
325 }
326
327 protected function savePasswordForm(): void
328 {
329 $form = $this->initPasswordForm();
330 if ($form->checkInput()) {
331 $this->getAccessHandler()->addPermission(
332 $this->node_id,
333 self::PERMISSION_ALL_PASSWORD,
334 md5($form->getInput("password"))
335 );
336 $this->tpl->setOnScreenMessage('success', $this->lng->txt("wsp_permission_all_pw_info"), true);
337 $this->ctrl->redirect($this, "share");
338 }
339
340 $form->setValuesByPost();
341 $this->showPasswordForm($form);
342 }
343}
Class ilCtrl provides processing control methods.
language handling
User class.
static _lookupTitle(int $obj_id)
static _getMembershipByType(int $a_usr_id, array $a_type, bool $a_only_member_role=false)
get membership by type Get course or group membership
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a property form user interface.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a selection list property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(int $a_node_id, $a_access_handler, bool $a_is_portfolio=false, string $a_footer="")
showPasswordForm(ilPropertyFormGUI $a_form=null)
ilGlobalTemplateInterface $tpl
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setContent(string $a_html)
Sets content for standard template.
setTitle(string $a_title, bool $hidden=false)
Sets title in standard template.
global $ilSetting
Definition: privfeed.php:17