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