ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjOrgUnitGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 require_once("./Services/Container/classes/class.ilContainerGUI.php");
4 require_once("./Services/AccessControl/classes/class.ilObjRole.php");
5 require_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
6 require_once("./Services/AccessControl/classes/class.ilPermissionGUI.php");
7 require_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
8 require_once("./Services/User/classes/class.ilUserAccountSettings.php");
9 require_once("./Services/Tracking/classes/class.ilLearningProgressGUI.php");
10 require_once("./Services/User/classes/class.ilObjUserFolderGUI.php");
11 require_once("./Services/Tree/classes/class.ilTree.php");
12 require_once("./Modules/OrgUnit/classes/Staff/class.ilOrgUnitStaffGUI.php");
13 require_once("./Modules/OrgUnit/classes/LocalUser/class.ilLocalUserGUI.php");
14 require_once("./Modules/OrgUnit/classes/Translation/class.ilTranslationGUI.php");
15 require_once("./Modules/OrgUnit/classes/ExtId/class.ilExtIdGUI.php");
16 require_once("./Modules/OrgUnit/classes/SimpleImport/class.ilOrgUnitSimpleImportGUI.php");
17 require_once("./Modules/OrgUnit/classes/SimpleUserImport/class.ilOrgUnitSimpleUserImportGUI.php");
18 require_once("./Modules/OrgUnit/classes/class.ilOrgUnitImporter.php");
19 require_once("./Services/Object/classes/class.ilObjectAddNewItemGUI.php");
20 require_once("class.ilOrgUnitExplorerGUI.php");
21 require_once("class.ilOrgUnitExportGUI.php");
22 require_once("class.ilObjOrgUnitAccess.php");
23 require_once("class.ilObjOrgUnitTree.php");
40 
44  public $ctrl;
48  public $tpl;
52  public $tabs_gui;
56  protected $ilAccess;
60  protected $toolbar;
64  protected $ilLocator;
68  public $tree;
72  public $object;
76  protected $ilLog;
77 
78 
79  public function __construct() {
80  global $tpl, $ilCtrl, $ilAccess, $ilToolbar, $ilLocator, $tree, $lng, $ilLog;
81  parent::ilContainerGUI(array(), $_GET["ref_id"], true, false);
82 
83  $this->tpl = $tpl;
84  $this->ctrl = $ilCtrl;
85  $this->ilAccess = $ilAccess;
86  $this->ilLocator = $ilLocator;
87  $this->tree = $tree;
88  $this->toolbar = $ilToolbar;
89  $this->ilLog = $ilLog;
90 
91  $lng->loadLanguageModule("orgu");
92  }
93 
94 
95  public function executeCommand() {
96  $cmd = $this->ctrl->getCmd();
97  $next_class = $this->ctrl->getNextClass($this);
99 
100  //Otherwise move-Objects would not work
101  if($cmd != "cut")
102  {
103  $this->showTree();
104  }
105 
106 
107  switch ($next_class) {
108  case "illocalusergui":
109  $this->tabs_gui->setTabActive('administrate_users');
110  $ilLocalUserGUI = new ilLocalUserGUI($this);
111  $this->ctrl->forwardCommand($ilLocalUserGUI);
112  break;
113  case "ilextidgui":
114  $this->tabs_gui->setTabActive("settings");
115  $this->setSubTabsSettings();
116  $ilExtIdGUI = new ilExtIdGUI($this);
117  $this->ctrl->forwardCommand($ilExtIdGUI);
118  break;
119  case "ilorgunitsimpleimportgui":
120  $this->tabs_gui->setTabActive("view_content");
121  $ilOrgUnitSimpleImportGUI = new ilOrgUnitSimpleImportGUI($this);
122  $this->ctrl->forwardCommand($ilOrgUnitSimpleImportGUI);
123  $this->tabs_gui->clearTargets();
124  $this->tabs_gui->setBackTarget($this->lng->txt("back"),$this->ctrl->getLinkTarget($this));
125  break;
126  case "ilorgunitsimpleuserimportgui":
127  $this->tabs_gui->setTabActive("view_content");
128  $ilOrgUnitSimpleUserImportGUI = new ilOrgUnitSimpleUserImportGUI($this);
129  $this->ctrl->forwardCommand($ilOrgUnitSimpleUserImportGUI);
130  $this->tabs_gui->clearTargets();
131  $this->tabs_gui->setBackTarget($this->lng->txt("back"),$this->ctrl->getLinkTarget($this));
132  break;
133  case "ilorgunitstaffgui":
134  case "ilrepositorysearchgui":
135  $this->tabs_gui->setTabActive('orgu_staff');
136  $ilOrgUnitStaffGUI = new ilOrgUnitStaffGUI($this);
137  $this->ctrl->forwardCommand($ilOrgUnitStaffGUI);
138  break;
139  case "ilobjusergui":
140  switch ($cmd) {
141  case "create":
142  $ilObjUserGUI = new ilObjUserGUI("", (int)$_GET['ref_id'], true, false);
143  $ilObjUserGUI->setCreationMode(true);
144  $this->ctrl->forwardCommand($ilObjUserGUI);
145  $this->tabs_gui->setBackTarget($this->lng->txt("back"),$this->ctrl->getLinkTargetByClass("illocalusergui", 'index'));
146  break;
147  case "save":
148  $ilObjUserGUI = new ilObjUserGUI("",$_GET['ref_id'],true, false);
149  $ilObjUserGUI->setCreationMode(true);
150  $this->ctrl->forwardCommand($ilObjUserGUI);
151  $this->tabs_gui->clearTargets();
152  $this->tabs_gui->setBackTarget($this->lng->txt("back"),$this->ctrl->getLinkTargetByClass("illocalusergui", 'index'));
153  break;
154  case "view":
155  case "update":
156  $ilObjUserGUI = new ilObjUserGUI("", (int)$_GET['obj_id'], false, false);
157  $ilObjUserGUI->setCreationMode(false);
158  $this->ctrl->forwardCommand($ilObjUserGUI);
159  $this->tabs_gui->clearTargets();
160  $this->tabs_gui->setBackTarget($this->lng->txt("back"),$this->ctrl->getLinkTargetByClass("illocalusergui", 'index'));
161  break;
162  case "cancel":
163  $this->ctrl->redirectByClass("illocalusergui","index");
164  break;
165  }
166  break;
167  case "ilobjuserfoldergui":
168  switch ($cmd) {
169  case "view":
170  $this->ctrl->redirectByClass("illocalusergui","index");
171  break;
172  default:
173  $ilObjUserFolderGUI = new ilObjUserFolderGUI("", (int)$_GET['ref_id'], true, false);
174  $ilObjUserFolderGUI->setUserOwnerId((int)$_GET['ref_id']);
175  $ilObjUserFolderGUI->setCreationMode(true);
176  $this->ctrl->forwardCommand($ilObjUserFolderGUI);
177  $this->tabs_gui->clearTargets();
178  $this->tabs_gui->setBackTarget($this->lng->txt("back"),$this->ctrl->getLinkTargetByClass("illocalusergui", 'index'));
179  break;
180  }
181  break;
182  case "ilinfoscreengui":
183  $this->tabs_gui->setTabActive("info_short");
184  if (!$this->ilAccess->checkAccess("read", "", $this->ref_id) AND !$this->ilAccess->checkAccess("visible", "", $this->ref_id)) {
185  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"), $this->ilias->error_obj->MESSAGE);
186  }
187  $info = new ilInfoScreenGUI($this);
188  $this->ctrl->forwardCommand($info);
189  break;
190  case 'ilpermissiongui':
191  $this->tabs_gui->setTabActive('perm_settings');
192  $ilPermissionGUI = new ilPermissionGUI($this);
193  $this->ctrl->forwardCommand($ilPermissionGUI);
194  break;
195  case "ilcommonactiondispatchergui":
196  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
198  $this->ctrl->forwardCommand($gui);
199  break;
200  case 'illearningprogressgui':
201  case 'illplistofprogressgui':
202  $this->tabs_gui->clearTargets();
203  $this->tabs_gui->setBackTarget($this->lng->txt('backto_staff'), $this->ctrl->getLinkTargetByClass("ilOrgUnitStaffGUI", 'showStaff'));
204  if (!ilObjOrgUnitAccess::_checkAccessToUserLearningProgress($this->object->getRefid(),$_GET['obj_id'])) {
205  ilUtil::sendFailure($this->lng->txt("permission_denied"), true);
206  $this->ctrl->redirectByClass("ilOrgUnitStaffGUI", "showStaff");
207  }
208  $this->ctrl->saveParameterByClass("illearningprogressgui", "obj_id");
209  $this->ctrl->saveParameterByClass("illearningprogressgui", "recursive");
210  include_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
211  $new_gui =& new ilLearningProgressGUI(ilLearningProgressGUI::LP_CONTEXT_ORG_UNIT, $_GET["ref_id"], $_GET['obj_id']);
212  $this->ctrl->forwardCommand($new_gui);
213  break;
214  case 'ilorgunitexportgui':
215  $this->tabs_gui->setTabActive('export');;
216  $ilOrgUnitExportGUI = new ilOrgUnitExportGUI($this);
217  $ilOrgUnitExportGUI->addFormat('xml');
218  $this->ctrl->forwardCommand($ilOrgUnitExportGUI);
219  break;
220  case 'iltranslationgui':
221  $this->tabs_gui->setTabActive("settings");
222  $this->setSubTabsSettings();
223 
224  $ilTranslationGui = new ilTranslationGUI($this);
225  $this->ctrl->forwardCommand($ilTranslationGui);
226  break;
227  default:
228  switch ($cmd) {
229  case '':
230  case 'view':
231  case 'render':
232  case 'cancel':
233  $this->view();
234  break;
235  case 'cancelDelete':
236  $this->view();
237  break;
238  case 'performPaste':
239  $this->performPaste();
240  break;
241  case 'paste':
242  $this->performPaste();
243  break;
244  case 'create':
246  break;
247  case 'save':
249  break;
250  case 'delete':
251  $this->tabs_gui->clearTargets();
252  $this->tabs_gui->setBackTarget($this->lng->txt("back"),$this->ctrl->getLinkTarget($this));
254  break;
255  case 'confirmedDelete':
257  break;
258  case 'cut':
259  $this->tabs_gui->clearTargets();
260  $this->tabs_gui->setBackTarget($this->lng->txt("back"),$this->ctrl->getLinkTarget($this));
262  break;
263  case 'clear':
265  break;
266  case 'enableAdministrationPanel':
268  break;
269  case 'disableAdministrationPanel':
271  break;
272  case 'getAsynchItemList':
274  break;
275  }
276  break;
277  }
278 
279  }
280 
281 
282  public function view() {
283 
284  if (!$this->ilAccess->checkAccess("read", "", $_GET["ref_id"])) {
285  if($this->ilAccess->checkAccess("visible", "", $_GET["ref_id"])) {
286  ilUtil::sendFailure($this->lng->txt("msg_no_perm_read"));
287  $this->ctrl->redirectByClass('ilinfoscreengui', '');
288  }
289 
290  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->WARNING);
291  }
292 
294  $this->tabs_gui->setTabActive("view_content");
295  $this->tabs_gui->removeSubTab("page_editor");
296  if ($this->ilAccess->checkAccess("write", "", $_GET["ref_id"]) AND $this->object->getRefId() == ilObjOrgUnit::getRootOrgRefId()) {
297  $this->toolbar->addButton($this->lng->txt("simple_import"), $this->ctrl->getLinkTargetByClass("ilOrgUnitSimpleImportGUI", "importScreen"));
298  $this->toolbar->addButton($this->lng->txt("simple_user_import"), $this->ctrl->getLinkTargetByClass("ilOrgUnitSimpleUserImportGUI", "userImportScreen"));
299  }
300  }
301 
302 
313  protected function initCreationForms($a_new_type)
314  {
315  $forms = array(
316  self::CFORM_NEW => $this->initCreateForm($a_new_type),
317  self::CFORM_IMPORT => $this->initImportForm($a_new_type),
318  );
319 
320  return $forms;
321  }
322 
323 
324  public function showPossibleSubObjects() {
325  $gui = new ilObjectAddNewItemGUI($this->object->getRefId());
327  $gui->setCreationUrl("ilias.php?ref_id=" . $_GET["ref_id"]
328  . "&admin_mode=settings&cmd=create&baseClass=ilAdministrationGUI");
329  $gui->render();
330  }
331 
332 
333  public function showTree() {
334  $tree = new ilOrgUnitExplorerGUI("orgu_explorer", "ilObjOrgUnitGUI", "showTree", new ilTree(1));
335  $tree->setTypeWhiteList(array( "orgu" ));
336  if (! $tree->handleCommand()) {
337  $this->tpl->setLeftNavContent($tree->getHTML());
338  }
339  $this->ctrl->setParameterByClass("ilObjOrgUnitGUI", "ref_id", $_GET["ref_id"]);
340  }
341 
342 
346  public function setTitleAndDescription() {
347  # all possible create permissions
348  //$possible_ops_ids = $rbacreview->getOperationsByTypeAndClass('orgu', 'create');
350  if ($this->object->getTitle() == "__OrgUnitAdministration") {
351  $this->tpl->setTitle($this->lng->txt("objs_orgu"));
352  }
353  $this->tpl->setDescription($this->lng->txt("objs_orgu"));
354  }
355 
356 
357  protected function addAdminLocatorItems() {
358  $path = $this->tree->getPathFull($_GET["ref_id"], ilObjOrgUnit::getRootOrgRefId());
359  // add item for each node on path
360  foreach ((array)$path as $key => $row) {
361  if ($row["title"] == "__OrgUnitAdministration") {
362  $row["title"] = $this->lng->txt("objs_orgu");
363  }
364  $this->ctrl->setParameterByClass("ilobjorgunitgui", "ref_id", $row["child"]);
365  $this->ilLocator->addItem($row["title"], $this->ctrl->getLinkTargetByClass("ilobjorgunitgui", "view"), ilFrameTargetInfo::_getFrame("MainContent"), $row["child"]);
366  $this->ctrl->setParameterByClass("ilobjorgunitgui", "ref_id", $_GET["ref_id"]);
367  }
368  }
369 
370 
371  protected function redirectToRefId($a_ref_id, $a_cmd = "") {
372  $obj_type = ilObject::_lookupType($a_ref_id, true);
373  if ($obj_type != "orgu") {
374  parent::redirectToRefId($a_ref_id, $a_cmd);
375  } else {
376  $this->ctrl->setParameterByClass("ilObjOrgUnitGUI", "ref_id", $a_ref_id);
377  $this->ctrl->redirectByClass("ilObjOrgUnitGUI", $a_cmd);
378  }
379  }
380 
381 
382  public function getTabs(&$tabs_gui){
383  if ($this->ilAccess->checkAccess('read', '',$this->object->getRefId())) {
384  $this->tabs_gui->addTab("view_content", $this->lng->txt("content"), $this->ctrl->getLinkTarget($this, ""));
385  $this->tabs_gui->addTab("info_short", "Info", $this->ctrl->getLinkTargetByClass("ilinfoscreengui", "showSummary"));
386  }
387 
388  //Tabs for OrgUnits exclusive root!
389  if($this->object->getRefId() != ilObjOrgUnit::getRootOrgRefId())
390  {
391  if (ilObjOrgUnitAccess::_checkAccessStaff($this->object->getRefId())) {
392  $this->tabs_gui->addTab("orgu_staff", $this->lng->txt("orgu_staff"), $this->ctrl->getLinkTargetByClass("ilOrgUnitStaffGUI", "showStaff"));
393  }
394  if ($this->ilAccess->checkAccess('write', '',$this->object->getRefId())) {
395  $this->tabs_gui->addTab("settings", $this->lng->txt("settings"), $this->ctrl->getLinkTargetByClass("ilTranslationGUI", "editTranslations"));
396  }
397  if (ilObjOrgUnitAccess::_checkAccessAdministrateUsers($this->object->getRefId())) {
398  $this->tabs_gui->addTab("administrate_users", $this->lng->txt("administrate_users"), $this->ctrl->getLinkTargetByClass("ilLocalUserGUI", "index"));
399  }
400  }
401 
402  if ($this->ilAccess->checkAccess('write', '', $this->object->getRefId())) {
403  $this->tabs_gui->addTarget('export', $this->ctrl->getLinkTargetByClass('ilorgunitexportgui', ''), 'export', 'ilorgunitexportgui');
404  }
405 
407  }
408 
409  private function setSubTabsSettings()
410  {
411  $next_class = $this->ctrl->getNextClass($this);
412  $this->tabs_gui->addSubTab("edit_translations", $this->lng->txt("edit_translations"), $this->ctrl->getLinkTargetByClass("iltranslationgui", "editTranslations"));
413  $this->tabs_gui->addSubTab("edit_ext_id", $this->lng->txt("edit_ext_id"), $this->ctrl->getLinkTargetByClass("ilextidgui", "edit"));
414 
415  switch ($next_class) {
416  case 'iltranslationgui':
417  $this->tabs_gui->setSubTabActive("edit_translations");
418  break;
419  case 'ilextidgui':
420  $this->tabs_gui->setSubTabActive("edit_ext_id");
421  break;
422  }
423  return;
424  }
425 
426  public function showAdministrationPanel($tpl) {
428  //an ugly encapsulation violation in order to remove the "verknüpfen"/"link" and copy button.
430  if (! $toolbar = $tpl->admin_panel_commands_toolbar) {
431  return;
432  }
433  if (is_array($toolbar->items)) {
434  foreach ($toolbar->items as $key => $item) {
435  if ($item["cmd"] == "link" || $item["cmd"] == "copy") {
436  unset($toolbar->items[$key]);
437  }
438  }
439  }
440  }
441 
442  public function _goto($ref_id) {
443  global $ilCtrl;
444  $ilCtrl->initBaseClass("ilAdministrationGUI");
445  $ilCtrl->setTargetScript("ilias.php");
446  $ilCtrl->setParameterByClass("ilObjOrgUnitGUI", "ref_id", $ref_id);
447  $ilCtrl->setParameterByClass("ilObjOrgUnitGUI", "admin_mode", "settings");
448  $ilCtrl->redirectByClass(array( "ilAdministrationGUI", "ilObjOrgUnitGUI" ), "view");
449  }
450 
451  public function showPasteTreeObject() {
452 
453  $this->ctrl->setCmd('performPaste');
454 
455  $ilOrgUnitExplorerGUI = new ilOrgUnitExplorerGUI("orgu_explorer", "ilObjOrgUnitGUI", "showTree", new ilTree(1));
456  $ilOrgUnitExplorerGUI->setTypeWhiteList(array( "orgu" ));
457 
458  if (!$ilOrgUnitExplorerGUI->handleCommand()) {
459  $this->tpl->setContent($ilOrgUnitExplorerGUI->getHTML());
460  }
461  }
462 
463  public function getAdminTabs(&$tabs_gui) {
464  $this->getTabs($tabs_gui);
465  }
466 
470  public function performPaste() {
471  if (! in_array($_SESSION['clipboard']['cmd'], array( 'cut' ))) {
472  $message = __METHOD__ . ": cmd was not 'cut' ; may be a hack attempt!";
473  $this->ilias->raiseError($message, $this->ilias->error_obj->WARNING);
474  }
475  if ($_SESSION['clipboard']['cmd'] == 'cut') {
476  if (isset($_GET['ref_id']) && (int)$_GET['ref_id']) {
477  $_POST['nodes'] = array( $_GET['ref_id'] );
479  }
480  }
481  $this->ctrl->returnToParent($this);
482  }
483 
485  }
486 
487  //
488  // METHODS for local user administration.
489  //
494  public function __initTableGUI() {
495  return parent::__initTableGUI();
496  }
497 
502  public function __setTableGUIBasicData($tbl, $a_result_set, $a_from, $a_form) {
503  return parent::__setTableGUIBasicData($tbl, $a_result_set, $a_from, $a_form);
504  }
505 }
506 ?>