ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilPersonalWorkspaceGUI.php
Go to the documentation of this file.
1<?php
2
21
36{
38 protected ilCtrl $ctrl;
39 protected ilLanguage $lng;
40 protected ilHelpGUI $help;
43 protected ilObjUser $user;
44 protected ilTabsGUI $tabs;
46 protected ilTree $tree;
47 protected int $node_id; // [int]
50
51 public function __construct()
52 {
54 global $DIC;
55
56 $this->ctrl = $DIC->ctrl();
57 $this->lng = $DIC->language();
58 $this->help = $DIC["ilHelp"];
59 $this->obj_definition = $DIC["objDefinition"];
60 $this->tpl = $DIC->ui()->mainTemplate();
61 $this->user = $DIC->user();
62 $this->tabs = $DIC->tabs();
63 $this->locator = $DIC["ilLocator"];
64 $ilCtrl = $DIC->ctrl();
65 $lng = $DIC->language();
66 $this->settings = $DIC->settings();
67
69
70 $this->std_request = new StandardGUIRequest(
71 $DIC->http(),
72 $DIC->refinery()
73 );
74
75 $this->initTree();
76
77 $ilCtrl->saveParameter($this, "wsp_id");
78
79 $this->node_id = $this->std_request->getWspId();
80 if (!$this->node_id || !$this->tree->isInTree($this->node_id)) {
81 $this->node_id = $this->tree->getRootId();
82 }
83 $this->tool_context = $DIC->globalScreen()->tool()->context();
84 }
85
86 public function executeCommand(): void
87 {
88 $ilCtrl = $this->ctrl;
89 $objDefinition = $this->obj_definition;
91
92 if ($this->settings->get("disable_personal_workspace")) {
93 throw new ilException($this->lng->txt("no_permission"));
94 }
95
96 $ilCtrl->setReturn($this, "render");
97
98 if (!in_array($ilCtrl->getCmd(), ["shareFilter"]) &&
99 !in_array(strtolower($ilCtrl->getCmdClass()), ["ilobjectownershipmanagementgui"])
100 ) {
101 $this->tool_context->current()->addAdditionalData(ilWorkspaceGSToolProvider::SHOW_WS_TREE, true);
102 }
103
104 // new type
105 if ($this->std_request->getNewType()) {
106 $class_name = $objDefinition->getClassName(
107 $this->std_request->getNewType()
108 );
109
110 // Only set the fixed cmdClass if the next class is different to
111 // the GUI class of the new object.
112 // An example:
113 // ilObjLinkResourceGUI tries to forward to ilLinkInputGUI (adding an internal link
114 // when creating a link resource)
115 // Without this fix, the cmdClass ilObjectCopyGUI would never be reached
116 if (strtolower($ilCtrl->getNextClass($this)) !== strtolower("ilObj" . $class_name . "GUI")) {
117 $this->ctrl->setParameterByClass("ilObj" . $class_name . "GUI", "new_type", $this->std_request->getNewType());
118 $ilCtrl->redirectByClass("ilObj" . $class_name . "GUI", $ilCtrl->getCmd());
119 }
120 }
121
122 // root node
123 $next_class = $ilCtrl->getNextClass();
124 if (!$next_class) {
125 $node = $this->tree->getNodeData($this->node_id);
126 if (isset($node["type"])) {
127 $next_class = "ilObj" . $objDefinition->getClassName($node["type"]) . "GUI";
128 } else {
129 $next_class = "ilObjWorkspaceRootFolderGUI";
130 }
131 $ilCtrl->redirectByClass($next_class, $ilCtrl->getCmd());
132 }
133
134 // if we do this here the object can still change the breadcrumb
135 $this->renderLocator();
136
137 // current node
138 $class_path = $ilCtrl->lookupClassPath($next_class);
139 $class_name = $ilCtrl->getClassForClasspath($class_path);
140 if ($this->std_request->getNewType()) {
141 $gui = new $class_name(0, ilObject2GUI::WORKSPACE_NODE_ID, $this->node_id);
142 $gui->setCreationMode();
143 } else {
144 $gui = new $class_name($this->node_id, ilObject2GUI::WORKSPACE_NODE_ID, false);
145 }
146 $ilCtrl->forwardCommand($gui);
147
148 //$this->renderBack();
149
150 $tpl->setLocator();
151 }
152
153 protected function initTree(): void
154 {
155 $ilUser = $this->user;
156
157 $user_id = $ilUser->getId();
158
159 $this->tree = new ilWorkspaceTree($user_id);
160 if (!$this->tree->getRootId()) {
161 $this->tree->createTreeForUser($user_id);
162 }
163 }
164
165 protected function renderBack(): void
166 {
168 $ilTabs = $this->tabs;
169 $ilCtrl = $this->ctrl;
170 $ilUser = $this->user;
171
172 $root = $this->tree->getNodeData($this->node_id);
173 if ($root["type"] != "wfld" && $root["type"] != "wsrt") {
174 // do not override existing back targets, e.g. public user profile gui
175 if (!$ilTabs->back_target) {
176 $owner = $this->tree->lookupOwner($this->node_id);
177 // workspace
178 if ($owner == $ilUser->getId()) {
179 $parent = $this->tree->getParentNodeData($this->node_id);
180 if ($parent["wsp_id"]) {
181 if ($parent["type"] == "wsrt") {
182 $class = "ilobjworkspacerootfoldergui";
183 } else {
184 $class = "ilobjworkspacefoldergui";
185 }
186 $ilCtrl->setParameterByClass($class, "wsp_id", $parent["wsp_id"]);
187 $ilTabs->setBackTarget(
188 $lng->txt("back"),
189 $ilCtrl->getLinkTargetByClass($class, "")
190 );
191 }
192 }
193 // "shared by others"
194 else {
195 $ilCtrl->setParameterByClass("ilobjworkspacerootfoldergui", "wsp_id", "");
196 $ilCtrl->setParameterByClass("ilobjworkspacerootfoldergui", "user", $owner);
197 $ilTabs->setBackTarget(
198 $lng->txt("back"),
199 $ilCtrl->getLinkTargetByClass("ilobjworkspacerootfoldergui", "share")
200 );
201 }
202 }
203 }
204 }
205
209 protected function renderLocator(): void
210 {
212 $ilCtrl = $this->ctrl;
213 $ilLocator = $this->locator;
214 $objDefinition = $this->obj_definition;
215
216 $ilLocator->clearItems();
217
218 // we have no path if shared item
219 $path = $this->tree->getPathFull($this->node_id);
220 if ($path) {
221 foreach ($path as $node) {
222 $obj_class = "ilObj" . $objDefinition->getClassName($node["type"]) . "GUI";
223
224 $ilCtrl->setParameter($this, "wsp_id", $node["wsp_id"]);
225
226 switch ($node["type"]) {
227 case "wsrt":
228 $ilLocator->addItem($lng->txt("mm_personal_and_shared_r"), $ilCtrl->getLinkTargetByClass($obj_class, "render"));
229 break;
230
231 case "blog":
232 case $objDefinition->isContainer($node["type"]):
233 $ilLocator->addItem($node["title"], $ilCtrl->getLinkTargetByClass($obj_class, "render"));
234 break;
235
236 default:
237 $ilLocator->addItem($node["title"], $ilCtrl->getLinkTargetByClass($obj_class, "edit"));
238 break;
239 }
240 }
241 }
242
243 $ilCtrl->setParameter($this, "wsp_id", $this->node_id);
244 }
245}
Class ilCtrl provides processing control methods.
Base class for ILIAS Exception handling.
Help GUI class.
language handling
loadLanguageModule(string $a_module)
Load language module.
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
User class.
parses the objects.xml it handles the xml-description of all ilias objects
GUI class for personal workspace.
renderLocator()
Build locator for current node.
ilGlobalTemplateInterface $tpl
ILIAS Setting Class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setLocator()
Insert locator.
$path
Definition: ltiservices.php:30
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26