ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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  {
116  $objDefinition = $this->obj_definition;
117  $tpl = $this->tpl;
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 
167  if ($ilMainMenu->getMode() == ilMainMenuGUI::MODE_FULL) {
168  $this->renderBack();
169  }
170 
171  $tpl->setLocator();
172  }
173 
177  protected function initTree()
178  {
180 
181  $user_id = $ilUser->getId();
182 
183  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
184  $this->tree = new ilWorkspaceTree($user_id);
185  if (!$this->tree->getRootId()) {
186  $this->tree->createTreeForUser($user_id);
187  }
188  }
189 
190  protected function renderBack()
191  {
192  $lng = $this->lng;
193  $ilTabs = $this->tabs;
196 
197  $root = $this->tree->getNodeData($this->node_id);
198  if ($root["type"] != "wfld" && $root["type"] != "wsrt") {
199  // do not override existing back targets, e.g. public user profile gui
200  if (!$ilTabs->back_target) {
201  $owner = $this->tree->lookupOwner($this->node_id);
202  // workspace
203  if ($owner == $ilUser->getId()) {
204  $parent = $this->tree->getParentNodeData($this->node_id);
205  if ($parent["wsp_id"]) {
206  if ($parent["type"] == "wsrt") {
207  $class = "ilobjworkspacerootfoldergui";
208  } else {
209  $class = "ilobjworkspacefoldergui";
210  }
211  $ilCtrl->setParameterByClass($class, "wsp_id", $parent["wsp_id"]);
212  $ilTabs->setBackTarget(
213  $lng->txt("back"),
214  $ilCtrl->getLinkTargetByClass($class, "")
215  );
216  }
217  }
218  // "shared by others"
219  else {
220  $ilCtrl->setParameterByClass("ilobjworkspacerootfoldergui", "wsp_id", "");
221  $ilCtrl->setParameterByClass("ilobjworkspacerootfoldergui", "user", $owner);
222  $ilTabs->setBackTarget(
223  $lng->txt("back"),
224  $ilCtrl->getLinkTargetByClass("ilobjworkspacerootfoldergui", "share")
225  );
226  }
227  }
228  }
229  }
230 
234  protected function renderLocator()
235  {
236  $lng = $this->lng;
238  $ilLocator = $this->locator;
239  $tpl = $this->tpl;
240  $objDefinition = $this->obj_definition;
241 
242  $ilLocator->clearItems();
243 
244  // we have no path if shared item
245  $path = $this->tree->getPathFull($this->node_id);
246  if ($path) {
247  foreach ($path as $node) {
248  $obj_class = "ilObj" . $objDefinition->getClassName($node["type"]) . "GUI";
249 
250  $ilCtrl->setParameter($this, "wsp_id", $node["wsp_id"]);
251 
252  switch ($node["type"]) {
253  case "wsrt":
254  $ilLocator->addItem($lng->txt("personal_resources"), $ilCtrl->getLinkTargetByClass($obj_class, "render"));
255  break;
256 
257  case "blog":
258  case $objDefinition->isContainer($node["type"]):
259  $ilLocator->addItem($node["title"], $ilCtrl->getLinkTargetByClass($obj_class, "render"));
260  break;
261 
262  default:
263  $ilLocator->addItem($node["title"], $ilCtrl->getLinkTargetByClass($obj_class, "edit"));
264  break;
265  }
266  }
267  }
268 
269  $ilCtrl->setParameter($this, "wsp_id", $this->node_id);
270  }
271 }
GUI class for personal workspace.
settings()
Definition: settings.php:2
renderLocator()
Build locator for current node.
user()
Definition: user.php:4
Tree handler for personal workspace.
global $ilCtrl
Definition: ilias.php:18
help()
Definition: help.php:2
$ilUser
Definition: imgupload.php:18
$DIC
Definition: xapitoken.php:46