ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilPersonalWorkspaceGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4
19{
23 protected $ctrl;
24
28 protected $lng;
29
33 protected $help;
34
38 protected $obj_definition;
39
43 protected $tpl;
44
48 protected $main_menu;
49
53 protected $user;
54
58 protected $tabs;
59
63 protected $locator;
64
68 protected $tree;
69 protected $node_id; // [int]
70
74 protected $tool_context;
75
79 public function __construct()
80 {
81 global $DIC;
82
83 $this->ctrl = $DIC->ctrl();
84 $this->lng = $DIC->language();
85 $this->help = $DIC["ilHelp"];
86 $this->obj_definition = $DIC["objDefinition"];
87 $this->tpl = $DIC["tpl"];
88 $this->main_menu = $DIC["ilMainMenu"];
89 $this->user = $DIC->user();
90 $this->tabs = $DIC->tabs();
91 $this->locator = $DIC["ilLocator"];
92 $ilCtrl = $DIC->ctrl();
93 $lng = $DIC->language();
94 $ilHelp = $DIC["ilHelp"];
95 $this->settings = $DIC->settings();
96
97 $lng->loadLanguageModule("wsp");
98
99 $this->initTree();
100
101 $ilCtrl->saveParameter($this, "wsp_id");
102
103 $this->node_id = (int) $_REQUEST["wsp_id"];
104 if (!$this->node_id || !$this->tree->isInTree($this->node_id)) {
105 $this->node_id = $this->tree->getRootId();
106 }
107 $this->tool_context = $DIC->globalScreen()->tool()->context();
108 }
109
113 public function executeCommand()
114 {
115 $ilCtrl = $this->ctrl;
116 $objDefinition = $this->obj_definition;
118 $ilMainMenu = $this->main_menu;
119
120 if ($this->settings->get("disable_personal_workspace")) {
121 throw new ilException($this->lng->txt("no_permission"));
122 }
123
124 $ilCtrl->setReturn($this, "render");
125 $cmd = $ilCtrl->getCmd();
126
127 $this->tool_context->current()->addAdditionalData(ilWorkspaceGSToolProvider::SHOW_WS_TREE, true);
128
129 // new type
130 if ($_REQUEST["new_type"]) {
131 $class_name = $objDefinition->getClassName($_REQUEST["new_type"]);
132
133 // Only set the fixed cmdClass if the next class is different to
134 // the GUI class of the new object.
135 // An example:
136 // ilObjLinkResourceGUI tries to forward to ilLinkInputGUI (adding an internal link
137 // when creating a link resource)
138 // Without this fix, the cmdClass ilObjectCopyGUI would never be reached
139 if (strtolower($ilCtrl->getNextClass($this)) != strtolower("ilObj" . $class_name . "GUI")) {
140 $ilCtrl->setCmdClass("ilObj" . $class_name . "GUI");
141 }
142 }
143
144 // root node
145 $next_class = $ilCtrl->getNextClass();
146 if (!$next_class) {
147 $node = $this->tree->getNodeData($this->node_id);
148 $next_class = "ilObj" . $objDefinition->getClassName($node["type"]) . "GUI";
149 $ilCtrl->setCmdClass($next_class);
150 }
151
152 // if we do this here the object can still change the breadcrumb
153 $this->renderLocator();
154
155 // current node
156 $class_path = $ilCtrl->lookupClassPath($next_class);
157 include_once($class_path);
158 $class_name = $ilCtrl->getClassForClasspath($class_path);
159 if ($_REQUEST["new_type"]) {
160 $gui = new $class_name(null, ilObject2GUI::WORKSPACE_NODE_ID, $this->node_id);
161 $gui->setCreationMode();
162 } else {
163 $gui = new $class_name($this->node_id, ilObject2GUI::WORKSPACE_NODE_ID, false);
164 }
165 $ilCtrl->forwardCommand($gui);
166 if ($ilMainMenu->getMode() == ilMainMenuGUI::MODE_FULL) {
167 $this->renderBack();
168 }
169
170 $tpl->setLocator();
171 }
172
176 protected function initTree()
177 {
179
180 $user_id = $ilUser->getId();
181
182 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
183 $this->tree = new ilWorkspaceTree($user_id);
184 if (!$this->tree->getRootId()) {
185 $this->tree->createTreeForUser($user_id);
186 }
187 }
188
189 protected function renderBack()
190 {
192 $ilTabs = $this->tabs;
193 $ilCtrl = $this->ctrl;
195
196 $root = $this->tree->getNodeData($this->node_id);
197 if ($root["type"] != "wfld" && $root["type"] != "wsrt") {
198 // do not override existing back targets, e.g. public user profile gui
199 if (!$ilTabs->back_target) {
200 $owner = $this->tree->lookupOwner($this->node_id);
201 // workspace
202 if ($owner == $ilUser->getId()) {
203 $parent = $this->tree->getParentNodeData($this->node_id);
204 if ($parent["wsp_id"]) {
205 if ($parent["type"] == "wsrt") {
206 $class = "ilobjworkspacerootfoldergui";
207 } else {
208 $class = "ilobjworkspacefoldergui";
209 }
210 $ilCtrl->setParameterByClass($class, "wsp_id", $parent["wsp_id"]);
211 $ilTabs->setBackTarget(
212 $lng->txt("back"),
213 $ilCtrl->getLinkTargetByClass($class, "")
214 );
215 }
216 }
217 // "shared by others"
218 else {
219 $ilCtrl->setParameterByClass("ilobjworkspacerootfoldergui", "wsp_id", "");
220 $ilCtrl->setParameterByClass("ilobjworkspacerootfoldergui", "user", $owner);
221 $ilTabs->setBackTarget(
222 $lng->txt("back"),
223 $ilCtrl->getLinkTargetByClass("ilobjworkspacerootfoldergui", "share")
224 );
225 }
226 }
227 }
228 }
229
233 protected function renderLocator()
234 {
236 $ilCtrl = $this->ctrl;
237 $ilLocator = $this->locator;
239 $objDefinition = $this->obj_definition;
240
241 $ilLocator->clearItems();
242
243 // we have no path if shared item
244 $path = $this->tree->getPathFull($this->node_id);
245 if ($path) {
246 foreach ($path as $node) {
247 $obj_class = "ilObj" . $objDefinition->getClassName($node["type"]) . "GUI";
248
249 $ilCtrl->setParameter($this, "wsp_id", $node["wsp_id"]);
250
251 switch ($node["type"]) {
252 case "wsrt":
253 $ilLocator->addItem($lng->txt("mm_personal_and_shared_r"), $ilCtrl->getLinkTargetByClass($obj_class, "render"));
254 break;
255
256 case "blog":
257 case $objDefinition->isContainer($node["type"]):
258 $ilLocator->addItem($node["title"], $ilCtrl->getLinkTargetByClass($obj_class, "render"));
259 break;
260
261 default:
262 $ilLocator->addItem($node["title"], $ilCtrl->getLinkTargetByClass($obj_class, "edit"));
263 break;
264 }
265 }
266 }
267
268 $ilCtrl->setParameter($this, "wsp_id", $this->node_id);
269 }
270}
user()
Definition: user.php:4
An exception for terminatinating execution or to throw for unit testing.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
GUI class for personal workspace.
renderLocator()
Build locator for current node.
Tree handler for personal workspace.
global $DIC
Definition: goto.php:24
help()
Definition: help.php:2
$ilUser
Definition: imgupload.php:18
settings()
Definition: settings.php:2