ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilSharedResourceGUI Class Reference

Workspace deep link handler GUI. More...

+ Inheritance diagram for ilSharedResourceGUI:
+ Collaboration diagram for ilSharedResourceGUI:

Public Member Functions

 __construct ()
 
 executeCommand ()
 

Static Public Member Functions

static hasAccess (int $a_node_id, bool $a_is_portfolio=false)
 

Protected Member Functions

 process ()
 
 redirectToResource (int $a_node_id, bool $a_is_portfolio=false)
 
 passwordForm (?ilPropertyFormGUI $form=null)
 
 initPasswordForm ()
 
 cancelPassword ()
 
 checkPassword ()
 

Protected Attributes

ilCtrl $ctrl
 
ilGlobalTemplateInterface $tpl
 
ilLocatorGUI $locator
 
ilObjUser $user
 
ilLanguage $lng
 
ilObjectDefinition $obj_definition
 
ilTabsGUI $tabs
 
int $node_id
 
int $portfolio_id
 
StandardGUIRequest $request
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilSharedResourceGUI::__construct ( )

Definition at line 42 of file class.ilSharedResourceGUI.php.

References $DIC, ILIAS\Repository\ctrl(), ILIAS\PersonalWorkspace\StandardGUIRequest\getWspId(), ILIAS\Repository\lng(), ILIAS\Repository\locator(), ILIAS\Repository\tabs(), and ILIAS\Repository\user().

43  {
44  global $DIC;
45 
46  $this->ctrl = $DIC->ctrl();
47  $this->tpl = $DIC->ui()->mainTemplate();
48  $this->locator = $DIC["ilLocator"];
49  $this->user = $DIC->user();
50  $this->lng = $DIC->language();
51  $this->obj_definition = $DIC["objDefinition"];
52  $this->tabs = $DIC->tabs();
53  $ilCtrl = $DIC->ctrl();
54 
55  $this->request = new StandardGUIRequest(
56  $DIC->http(),
57  $DIC->refinery()
58  );
59 
60  $ilCtrl->saveParameter($this, "wsp_id");
61  $ilCtrl->saveParameter($this, "prt_id");
62  $this->node_id = $this->request->getWspId();
63  $this->portfolio_id = $this->request->getPrtId();
64  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ cancelPassword()

ilSharedResourceGUI::cancelPassword ( )
protected

Definition at line 335 of file class.ilSharedResourceGUI.php.

References $ilUser, $user, ANONYMOUS_USER_ID, ilWorkspaceTree\lookupOwner(), and ilUtil\redirect().

335  : void
336  {
338 
339  if ($ilUser->getId() && $ilUser->getId() != ANONYMOUS_USER_ID) {
340  if ($this->node_id) {
341  $tree = new ilWorkspaceTree($ilUser->getId());
342  $owner = $tree->lookupOwner($this->node_id);
343  ilUtil::redirect("ilias.php?baseClass=ilDashboardGUI&cmd=jumpToWorkspace&dsh=" . $owner);
344  } else {
345  $prtf = new ilObjPortfolio($this->portfolio_id, false);
346  $owner = $prtf->getOwner();
347  ilUtil::redirect("ilias.php?baseClass=ilDashboardGUI&cmd=jumpToPortfolio&dsh=" . $owner);
348  }
349  }
350  }
const ANONYMOUS_USER_ID
Definition: constants.php:27
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...
static redirect(string $a_script)
lookupOwner(int $a_node_id)
Get owner for node id.
$ilUser
Definition: imgupload.php:34
+ Here is the call graph for this function:

◆ checkPassword()

ilSharedResourceGUI::checkPassword ( )
protected

Definition at line 352 of file class.ilSharedResourceGUI.php.

References $lng, ilWorkspaceAccessHandler\getSharedNodePassword(), ilPortfolioAccessHandler\getSharedNodePassword(), initPasswordForm(), ilWorkspaceAccessHandler\keepSharedSessionPassword(), ilPortfolioAccessHandler\keepSharedSessionPassword(), ilLanguage\loadLanguageModule(), passwordForm(), redirectToResource(), and ilLanguage\txt().

352  : void
353  {
354  $lng = $this->lng;
355 
356  $lng->loadLanguageModule("wsp");
357 
358  $form = $this->initPasswordForm();
359  if ($form->checkInput()) {
360  $input = md5($form->getInput("password"));
361  if ($this->node_id) {
362  $password = ilWorkspaceAccessHandler::getSharedNodePassword($this->node_id);
363  } else {
364  $password = ilPortfolioAccessHandler::getSharedNodePassword($this->portfolio_id);
365  }
366  if ($input == $password) {
367  if ($this->node_id) {
369  $this->redirectToResource($this->node_id);
370  } else {
371  ilPortfolioAccessHandler::keepSharedSessionPassword($this->portfolio_id, $input);
372  $this->redirectToResource($this->portfolio_id, true);
373  }
374  } else {
375  $item = $form->getItemByPostVar("password");
376  $item->setAlert($lng->txt("wsp_invalid_password"));
377  $this->tpl->setOnScreenMessage('failure', $lng->txt("form_input_not_valid"));
378  }
379  }
380 
381  $form->setValuesByPost();
382  $this->passwordForm($form);
383  }
passwordForm(?ilPropertyFormGUI $form=null)
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static getSharedNodePassword(int $a_node_id)
redirectToResource(int $a_node_id, bool $a_is_portfolio=false)
loadLanguageModule(string $a_module)
Load language module.
static keepSharedSessionPassword(int $a_node_id, string $a_password)
static keepSharedSessionPassword(int $a_node_id, string $a_password)
static getSharedNodePassword(int $a_node_id)
+ Here is the call graph for this function:

◆ executeCommand()

ilSharedResourceGUI::executeCommand ( )

Definition at line 66 of file class.ilSharedResourceGUI.php.

References $ctrl, $ilUser, $lng, $locator, $tpl, $user, ilObject\_lookupTitle(), ANONYMOUS_USER_ID, ilUserUtil\getNamePresentation(), ilLanguage\loadLanguageModule(), ilGlobalTemplateInterface\loadStandardTemplate(), ilGlobalTemplateInterface\printToStdout(), ilGlobalTemplateInterface\setLocator(), ilLanguage\txt(), and ilObject2GUI\WORKSPACE_NODE_ID.

66  : void
67  {
68  $ilCtrl = $this->ctrl;
69  $tpl = $this->tpl;
70  $ilLocator = $this->locator;
72  $lng = $this->lng;
73 
74  $next_class = $ilCtrl->getNextClass($this);
75  $cmd = $ilCtrl->getCmd();
76 
78 
79  // #12096
80  if ($ilUser->getId() != ANONYMOUS_USER_ID &&
81  $next_class &&
82  !in_array($next_class, array("ilobjbloggui", "ilobjportfoliogui"))) {
83  $tree = new ilWorkspaceTree($ilUser->getId());
84  $access_handler = new ilWorkspaceAccessHandler($tree);
85  $owner_id = $tree->lookupOwner($this->node_id);
86  $obj_id = $tree->lookupObjectId($this->node_id);
87 
88  $lng->loadLanguageModule("wsp");
89 
90  // see ilPersonalWorkspaceGUI
91  if ($owner_id != $ilUser->getId()) {
92  $ilCtrl->setParameterByClass("ildashboardgui", "dsh", $owner_id);
93  $link = $ilCtrl->getLinkTargetByClass("ildashboardgui", "jumptoworkspace");
94  $ilLocator->addItem($lng->txt("wsp_tab_shared"), $link);
95 
96  $ilLocator->addItem(ilUserUtil::getNamePresentation($owner_id), $link);
97  } else {
98  $link = $ilCtrl->getLinkTargetByClass("ildashboardgui", "jumptoworkspace");
99  $ilLocator->addItem($lng->txt("wsp_tab_personal"), $link);
100  }
101 
102  $link = $access_handler->getGotoLink($this->node_id, $obj_id);
103  $ilLocator->addItem(ilObject::_lookupTitle($obj_id), $link);
104  $tpl->setLocator();
105  }
106 
107  switch ($next_class) {
108  case "ilobjbloggui":
109  $bgui = new ilObjBlogGUI($this->node_id, ilObject2GUI::WORKSPACE_NODE_ID);
110  $ilCtrl->forwardCommand($bgui);
111  break;
112 
113  case "ilobjfilegui":
114  $fgui = new ilObjFileGUI($this->node_id, ilObject2GUI::WORKSPACE_NODE_ID);
115  $ilCtrl->forwardCommand($fgui);
116  break;
117 
118  case "ilobjtestverificationgui":
119  $tgui = new ilObjTestVerificationGUI($this->node_id, ilObject2GUI::WORKSPACE_NODE_ID);
120  $ilCtrl->forwardCommand($tgui);
121  break;
122 
123  case "ilobjexerciseverificationgui":
125  $ilCtrl->forwardCommand($egui);
126  break;
127 
128  case "ilobjlinkresourcegui":
129  $lgui = new ilObjLinkResourceGUI($this->node_id, ilObject2GUI::WORKSPACE_NODE_ID);
130  $ilCtrl->forwardCommand($lgui);
131  break;
132 
133  case "ilobjportfoliogui":
134  $pgui = new ilObjPortfolioGUI($this->portfolio_id);
135  $ilCtrl->forwardCommand($pgui);
136  break;
137 
138  default:
139  if (!$cmd) {
140  $cmd = "process";
141  }
142  $this->$cmd();
143  }
144 
145  $tpl->printToStdout();
146  }
printToStdout(string $part=self::DEFAULT_BLOCK, bool $has_tabs=true, bool $skip_main_menu=false)
setLocator()
Insert locator.
const ANONYMOUS_USER_ID
Definition: constants.php:27
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link="", bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
Class ilObjLinkResourceGUI.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
loadLanguageModule(string $a_module)
Load language module.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Portfolio view gui class.
static _lookupTitle(int $obj_id)
Class ilObjBlogGUI.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
loadStandardTemplate()
This loads the standard template "tpl.adm_content.html" and "tpl.statusline.html" the CONTENT and STA...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
GUI class for file objects.
$ilUser
Definition: imgupload.php:34
ilGlobalTemplateInterface $tpl
+ Here is the call graph for this function:

◆ hasAccess()

static ilSharedResourceGUI::hasAccess ( int  $a_node_id,
bool  $a_is_portfolio = false 
)
static

Definition at line 168 of file class.ilSharedResourceGUI.php.

References $DIC, $ilSetting, $ilUser, ilWorkspaceAccessHandler\_getPermissions(), ilPortfolioAccessHandler\_getPermissions(), ANONYMOUS_USER_ID, ilWorkspaceAccessGUI\PERMISSION_ALL, ilWorkspaceAccessGUI\PERMISSION_ALL_PASSWORD, and ilUtil\redirect().

Referenced by ilObjPortfolioAccess\_checkGoto(), ilObjExerciseVerificationAccess\_checkGoto(), ilObjTestVerificationAccess\_checkGoto(), ilObjCourseVerificationAccess\_checkGoto(), ilObjSCORMVerificationAccess\_checkGoto(), ilObjLTIConsumerVerificationAccess\_checkGoto(), ilObjCmiXapiVerificationAccess\_checkGoto(), ilObjBlogAccess\_checkGoto(), and ilObjFileAccess\_checkGoto().

171  : bool {
172  global $DIC;
173 
174  $ilUser = $DIC->user();
175  $ilSetting = $DIC->settings();
176 
177  // if we have current user - check with normal access handler
178  if ($ilUser->getId() != ANONYMOUS_USER_ID) {
179  if (!$a_is_portfolio) {
180  $tree = new ilWorkspaceTree($ilUser->getId());
181  $access_handler = new ilWorkspaceAccessHandler($tree);
182  } else {
183  $access_handler = new ilPortfolioAccessHandler();
184  }
185  if ($access_handler->checkAccess("read", "", $a_node_id)) {
186  return true;
187  }
188  }
189 
190  if (!$a_is_portfolio) {
191  $shared = ilWorkspaceAccessHandler::_getPermissions($a_node_id);
192  } else {
193  // #12059
194  if (!$ilSetting->get('user_portfolios')) {
195  return false;
196  }
197 
198  // #12039
199  $prtf = new ilObjPortfolio($a_node_id, false);
200  if (!$prtf->isOnline()) {
201  return false;
202  }
203 
204  $shared = ilPortfolioAccessHandler::_getPermissions($a_node_id);
205  }
206 
207  // object is "public"
208  if (in_array(ilWorkspaceAccessGUI::PERMISSION_ALL, $shared)) {
209  return true;
210  }
211 
212  // password protected
213  if (in_array(ilWorkspaceAccessGUI::PERMISSION_ALL_PASSWORD, $shared)) {
214  if (!$a_is_portfolio) {
215  ilUtil::redirect("ilias.php?baseClass=ilSharedResourceGUI&cmd=passwordForm&wsp_id=" . $a_node_id);
216  } else {
217  ilUtil::redirect("ilias.php?baseClass=ilSharedResourceGUI&cmd=passwordForm&prt_id=" . $a_node_id);
218  }
219  }
220 
221  return false;
222  }
const ANONYMOUS_USER_ID
Definition: constants.php:27
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...
global $DIC
Definition: feed.php:28
static _getPermissions(int $a_node_id)
Get all permissions to node.
static redirect(string $a_script)
global $ilSetting
Definition: privfeed.php:17
Access handler for portfolio NOTE: This file needs to stay in the classes directory, WAC will be confused otherwise.
$ilUser
Definition: imgupload.php:34
static _getPermissions(int $a_node_id)
Get all permissions to node.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initPasswordForm()

ilSharedResourceGUI::initPasswordForm ( )
protected

Definition at line 302 of file class.ilSharedResourceGUI.php.

References $ctrl, $ilUser, $lng, $tabs, $user, ilObject\_lookupTitle(), ANONYMOUS_USER_ID, ilWorkspaceAccessHandler\getObjectDataFromNode(), ilPasswordInputGUI\setRetype(), and ilLanguage\txt().

Referenced by checkPassword(), and passwordForm().

303  {
304  $ilCtrl = $this->ctrl;
305  $lng = $this->lng;
307  $ilTabs = $this->tabs;
308 
309  if ($this->node_id) {
310  $object_data = ilWorkspaceAccessHandler::getObjectDataFromNode($this->node_id);
311  } else {
312  $object_data["title"] = ilObject::_lookupTitle($this->portfolio_id);
313  }
314 
315  $form = new ilPropertyFormGUI();
316  $form->setFormAction($ilCtrl->getFormAction($this, "checkPassword"));
317  $form->setTitle($lng->txt("wsp_password_for") . ": " . $object_data["title"]);
318 
319  $password = new ilPasswordInputGUI($lng->txt("password"), "password");
320  $password->setRetype(false);
321  $password->setRequired(true);
322  $password->setSkipSyntaxCheck(true); // #17757
323  $form->addItem($password);
324 
325  $form->addCommandButton("checkPassword", $lng->txt("submit"));
326 
327  if ($ilUser->getId() && $ilUser->getId() != ANONYMOUS_USER_ID) {
328  $ilTabs->setBackTarget($lng->txt("back"), $ilCtrl->getLinkTarget($this, "cancelPassword"));
329  $form->addCommandButton("cancelPassword", $lng->txt("cancel"));
330  }
331 
332  return $form;
333  }
const ANONYMOUS_USER_ID
Definition: constants.php:27
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static _lookupTitle(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ilUser
Definition: imgupload.php:34
static getObjectDataFromNode(int $a_node_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ passwordForm()

ilSharedResourceGUI::passwordForm ( ?ilPropertyFormGUI  $form = null)
protected

Definition at line 285 of file class.ilSharedResourceGUI.php.

References $lng, $tpl, initPasswordForm(), ilLanguage\loadLanguageModule(), ilGlobalTemplateInterface\setContent(), ilGlobalTemplateInterface\setDescription(), ilGlobalTemplateInterface\setTitle(), and ilLanguage\txt().

Referenced by checkPassword().

285  : void
286  {
287  $tpl = $this->tpl;
288  $lng = $this->lng;
289 
290  $lng->loadLanguageModule("wsp");
291 
292  $tpl->setTitle($lng->txt("wsp_password_protected_resource"));
293  $tpl->setDescription($lng->txt("wsp_password_protected_resource_info"));
294 
295  if (!$form) {
296  $form = $this->initPasswordForm();
297  }
298 
299  $tpl->setContent($form->getHTML());
300  }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
loadLanguageModule(string $a_module)
Load language module.
setContent(string $a_html)
Sets content for standard template.
setTitle(string $a_title, bool $hidden=false)
Sets title in standard template.
setDescription(string $a_descr)
Sets description below title in standard template.
ilGlobalTemplateInterface $tpl
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ process()

ilSharedResourceGUI::process ( )
protected

Definition at line 148 of file class.ilSharedResourceGUI.php.

References redirectToResource().

148  : void
149  {
150  if (!$this->node_id && !$this->portfolio_id) {
151  throw new ilPermissionException("invalid call");
152  }
153 
154  // if already logged in, we need to re-check for public password
155  if ($this->node_id) {
156  if (!self::hasAccess($this->node_id)) {
157  throw new ilPermissionException("no permission");
158  }
159  $this->redirectToResource($this->node_id);
160  } else {
161  if (!self::hasAccess($this->portfolio_id, true)) {
162  throw new ilPermissionException("no permission");
163  }
164  $this->redirectToResource($this->portfolio_id, true);
165  }
166  }
redirectToResource(int $a_node_id, bool $a_is_portfolio=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ redirectToResource()

ilSharedResourceGUI::redirectToResource ( int  $a_node_id,
bool  $a_is_portfolio = false 
)
protected

Definition at line 224 of file class.ilSharedResourceGUI.php.

References $ctrl, $obj_definition, ilObject\_lookupType(), exit, and ilWorkspaceAccessHandler\getObjectDataFromNode().

Referenced by checkPassword(), and process().

227  : void {
228  $ilCtrl = $this->ctrl;
229  $objDefinition = $this->obj_definition;
230 
231  if (!$a_is_portfolio) {
232  $object_data = ilWorkspaceAccessHandler::getObjectDataFromNode($a_node_id);
233  if (!$object_data["obj_id"]) {
234  throw new ilPermissionException("invalid object");
235  }
236  } else {
237  if (!ilObject::_lookupType($a_node_id, false)) {
238  throw new ilPermissionException("invalid object");
239  }
240  $object_data["obj_id"] = $a_node_id;
241  $object_data["type"] = "prtf";
242  }
243 
244  $class = $objDefinition->getClassName($object_data["type"]);
245  $gui = "ilobj" . $class . "gui";
246 
247  switch ($object_data["type"]) {
248  case "blog":
249  $ilCtrl->setParameterByClass($gui, "wsp_id", $a_node_id);
250  $ilCtrl->setParameterByClass($gui, "gtp", $this->request->getBlogGtp());
251  $ilCtrl->setParameterByClass($gui, "edt", $this->request->getBlogEdt());
252  $ilCtrl->redirectByClass($gui, "preview");
253  break;
254 
255  case "tstv":
256  case "excv":
257  case "crsv":
258  case "scov":
259  case "cmxv":
260  case "ltiv":
261  $ilCtrl->setParameterByClass($gui, "wsp_id", $a_node_id);
262  $ilCtrl->redirectByClass($gui, "deliver");
263  break;
264 
265  case "file":
266  case "webr":
267  $ilCtrl->setParameterByClass($gui, "wsp_id", $a_node_id);
268  $ilCtrl->redirectByClass($gui);
269  break;
270 
271  case "prtf":
272  $ilCtrl->setParameterByClass($gui, "prt_id", $a_node_id);
273  $ilCtrl->setParameterByClass($gui, "gtp", $this->request->getBlogGtp());
274  if ($this->request->getBackUrl()) {
275  $ilCtrl->setParameterByClass($gui, "back_url", rawurlencode($this->request->getBackUrl()));
276  }
277  $ilCtrl->redirectByClass($gui, "preview");
278  break;
279 
280  default:
281  exit("invalid object type");
282  }
283  }
exit
Definition: login.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilObjectDefinition $obj_definition
static getObjectDataFromNode(int $a_node_id)
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $ctrl

ilCtrl ilSharedResourceGUI::$ctrl
protected

◆ $lng

ilLanguage ilSharedResourceGUI::$lng
protected

◆ $locator

ilLocatorGUI ilSharedResourceGUI::$locator
protected

Definition at line 33 of file class.ilSharedResourceGUI.php.

Referenced by executeCommand().

◆ $node_id

int ilSharedResourceGUI::$node_id
protected

Definition at line 38 of file class.ilSharedResourceGUI.php.

◆ $obj_definition

ilObjectDefinition ilSharedResourceGUI::$obj_definition
protected

Definition at line 36 of file class.ilSharedResourceGUI.php.

Referenced by redirectToResource().

◆ $portfolio_id

int ilSharedResourceGUI::$portfolio_id
protected

Definition at line 39 of file class.ilSharedResourceGUI.php.

◆ $request

StandardGUIRequest ilSharedResourceGUI::$request
protected

Definition at line 40 of file class.ilSharedResourceGUI.php.

◆ $tabs

ilTabsGUI ilSharedResourceGUI::$tabs
protected

Definition at line 37 of file class.ilSharedResourceGUI.php.

Referenced by initPasswordForm().

◆ $tpl

ilGlobalTemplateInterface ilSharedResourceGUI::$tpl
protected

Definition at line 32 of file class.ilSharedResourceGUI.php.

Referenced by executeCommand(), and passwordForm().

◆ $user

ilObjUser ilSharedResourceGUI::$user
protected

Definition at line 34 of file class.ilSharedResourceGUI.php.

Referenced by cancelPassword(), executeCommand(), and initPasswordForm().


The documentation for this class was generated from the following file: