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