ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjCategoryGUI.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 
5 require_once "./Services/Container/classes/class.ilContainerGUI.php";
6 
21 {
22  var $ctrl;
23 
28  function ilObjCategoryGUI($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
29  {
30  //global $ilCtrl;
31 
32  // CONTROL OPTIONS
33  //$this->ctrl =& $ilCtrl;
34  //$this->ctrl->saveParameter($this,array("ref_id","cmdClass"));
35 
36  $this->type = "cat";
37  $this->ilContainerGUI($a_data,(int) $a_id,$a_call_by_reference,false);
38  }
39 
40  function &executeCommand()
41  {
42  global $rbacsystem, $ilNavigationHistory, $ilAccess, $ilCtrl,$ilTabs;
43 
44  $next_class = $this->ctrl->getNextClass($this);
45  $cmd = $this->ctrl->getCmd();
46  switch($next_class)
47  {
48  case "ilobjusergui":
49  include_once('./Services/User/classes/class.ilObjUserGUI.php');
50 
51  $this->tabs_gui->setTabActive('administrate_users');
52  if(!$_GET['obj_id'])
53  {
54  $this->gui_obj = new ilObjUserGUI("",$_GET['ref_id'],true, false);
55  $this->gui_obj->setCreationMode($this->creation_mode);
56  $ret =& $this->ctrl->forwardCommand($this->gui_obj);
57  }
58  else
59  {
60  $this->gui_obj = new ilObjUserGUI("", $_GET['obj_id'],false, false);
61  $this->gui_obj->setCreationMode($this->creation_mode);
62  $ret =& $this->ctrl->forwardCommand($this->gui_obj);
63  }
64 
65  $ilTabs->clearTargets();
66  $ilTabs->setBackTarget($this->lng->txt('backto_lua'), $this->ctrl->getLinkTarget($this,'listUsers'));
67  break;
68 
69  case "ilobjuserfoldergui":
70  include_once('./Services/User/classes/class.ilObjUserFolderGUI.php');
71 
72  $this->tabs_gui->setTabActive('administrate_users');
73  $this->gui_obj = new ilObjUserFolderGUI("",(int) $_GET['ref_id'],true, false);
74  $this->gui_obj->setUserOwnerId((int) $_GET['ref_id']);
75  $this->gui_obj->setCreationMode($this->creation_mode);
76  $ret =& $this->ctrl->forwardCommand($this->gui_obj);
77  break;
78 
79  case "ilcolumngui":
80  $this->checkPermission("read");
81  $this->prepareOutput();
82  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
83  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
84  ilObjStyleSheet::getContentStylePath($this->object->getStyleSheetId()));
85  $this->renderObject();
86  break;
87 
88  case 'ilpermissiongui':
89  $this->prepareOutput();
90  $this->tabs_gui->setTabActive('perm_settings');
91  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
92  $perm_gui =& new ilPermissionGUI($this);
93  $ret =& $this->ctrl->forwardCommand($perm_gui);
94  break;
95 
96  case 'ilinfoscreengui':
97  $this->prepareOutput();
98  $this->infoScreen();
99  break;
100 
101  case 'ilcontainerlinklistgui':
102  include_once("./classes/class.ilContainerLinkListGUI.php");
103  $link_list_gui =& new ilContainerLinkListGUI();
104  $ret =& $this->ctrl->forwardCommand($link_list_gui);
105  break;
106 
107  // container page editing
108  case "ilpageobjectgui":
109  $this->prepareOutput(false);
110  $ret = $this->forwardToPageObject();
111  if ($ret != "")
112  {
113  $this->tpl->setContent($ret);
114  }
115  break;
116 
117  case 'ilobjectcopygui':
118  $this->prepareOutput();
119 
120  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
121  $cp = new ilObjectCopyGUI($this);
122  $cp->setType('cat');
123  $this->ctrl->forwardCommand($cp);
124  break;
125 
126  case "ilobjstylesheetgui":
127  $this->forwardToStyleSheet();
128  break;
129 
130  case 'ilusertablegui':
131  include_once './Services/User/classes/class.ilUserTableGUI.php';
132  $u_table = new ilUserTableGUI($this, "listUsers");
133  $u_table->initFilter();
134  $this->ctrl->setReturn($this,'listUsers');
135  $this->ctrl->forwardCommand($u_table);
136  break;
137 
138  default:
139  if ($cmd == "infoScreen")
140  {
141  $this->checkPermission("visible");
142  }
143  else
144  {
145  $this->checkPermission("read");
146  }
147 
148  // add entry to navigation history
149  if (!$this->getCreationMode() &&
150  $ilAccess->checkAccess("read", "", $_GET["ref_id"]))
151  {
152  $ilNavigationHistory->addItem($_GET["ref_id"],
153  "repository.php?cmd=frameset&ref_id=".$_GET["ref_id"], "cat");
154  }
155 
156  $this->prepareOutput();
157  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
158  if (is_object($this->object))
159  {
160  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
161  ilObjStyleSheet::getContentStylePath($this->object->getStyleSheetId()));
162  }
163 
164 //echo "-".$this->object->getStyleSheetId()."-";
165  if(!$cmd)
166  {
167  $cmd = "render";
168  }
169  $cmd .= "Object";
170  $this->$cmd();
171 
172  break;
173  }
174  return true;
175  }
176 
180  function getTabs(&$tabs_gui)
181  {
182  global $rbacsystem, $lng;
183 
184  if ($this->ctrl->getCmd() == "editPageContent")
185  {
186  return;
187  }
188  #$this->ctrl->setParameter($this,"ref_id",$this->ref_id);
189 
190  if ($rbacsystem->checkAccess('read',$this->ref_id))
191  {
192  $force_active = ($_GET["cmd"] == "" || $_GET["cmd"] == "render")
193  ? true
194  : false;
195  $tabs_gui->addTab("view_content", $lng->txt("content"),
196  $this->ctrl->getLinkTarget($this, ""));
197 
198  //BEGIN ChangeEvent add info tab to category object
199  $force_active = ($this->ctrl->getNextClass() == "ilinfoscreengui"
200  || strtolower($_GET["cmdClass"]) == "ilnotegui")
201  ? true
202  : false;
203  $tabs_gui->addTarget("info_short",
204  $this->ctrl->getLinkTargetByClass(
205  array("ilobjcategorygui", "ilinfoscreengui"), "showSummary"),
206  array("showSummary","", "infoScreen"),
207  "", "", $force_active);
208  //END ChangeEvent add info tab to category object
209  }
210 
211  if ($rbacsystem->checkAccess('write',$this->ref_id))
212  {
213  $force_active = ($_GET["cmd"] == "edit")
214  ? true
215  : false;
216  $tabs_gui->addTarget("settings",
217  $this->ctrl->getLinkTarget($this, "edit"), "edit", get_class($this)
218  , "", $force_active);
219  }
220 
221  include_once './Services/User/classes/class.ilUserAccountSettings.php';
222  if(
223  ilUserAccountSettings::getInstance()->isLocalUserAdministrationEnabled() and
224  $rbacsystem->checkAccess('cat_administrate_users',$this->ref_id))
225  {
226  $tabs_gui->addTarget("administrate_users",
227  $this->ctrl->getLinkTarget($this, "listUsers"), "listUsers", get_class($this));
228  }
229 
230  // parent tabs (all container: edit_permission, clipboard, trash
231  parent::getTabs($tabs_gui);
232 
233  }
234 
238  function renderObject()
239  {
240  global $ilTabs;
241 
242  $ilTabs->activateTab("view_content");
244  return $ret;
245 
246  }
247 
253  function createObject()
254  {
255  global $rbacsystem;
256 
257  $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
258 
259  if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
260  {
261  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
262  }
263  else
264  {
265  //add template for buttons
266  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
267 
268  // only in administration
269  // to do: make this in repository work
270  if (false)
271  {
272  $this->tpl->setCurrentBlock("btn_cell");
273  $this->tpl->setVariable("BTN_LINK",
274  $this->ctrl->getLinkTarget($this, "importCategoriesForm"));
275  $this->tpl->setVariable("BTN_TXT", $this->lng->txt("import_categories"));
276  $this->tpl->parseCurrentBlock();
277  }
278 
279  $this->getTemplateFile("edit",$new_type);
280 
281  $array_push = true;
282 
283  if ($_SESSION["error_post_vars"])
284  {
285  $_SESSION["translation_post"] = $_SESSION["error_post_vars"];
286  $array_push = false;
287  }
288 
289  // clear session data if a fresh category should be created
290  if (($_GET["mode"] != "session"))
291  {
292  unset($_SESSION["translation_post"]);
293  } // remove a translation from session
294  elseif ($_GET["entry"] != 0)
295  {
296  array_splice($_SESSION["translation_post"]["Fobject"],$_GET["entry"],1,array());
297 
298  if ($_GET["entry"] == $_SESSION["translation_post"]["default_language"])
299  {
300  $_SESSION["translation_post"]["default_language"] = "";
301  }
302  }
303 
304  // stripslashes in form output?
305  $strip = isset($_SESSION["translation_post"]) ? true : false;
306 
307  $data = $_SESSION["translation_post"];
308 
309  if (!is_array($data["Fobject"]))
310  {
311  $data["Fobject"] = array();
312  }
313 
314  // add additional translation form
315  if (!$_GET["entry"] and $array_push)
316  {
317  $count = array_push($data["Fobject"],array("title" => "","desc" => ""));
318  }
319  else
320  {
321  $count = count($data["Fobject"]);
322  }
323 
324  foreach ($data["Fobject"] as $key => $val)
325  {
326  // add translation button
327  if ($key == $count -1)
328  {
329  $this->tpl->setCurrentBlock("addTranslation");
330  $this->tpl->setVariable("TXT_ADD_TRANSLATION",$this->lng->txt("add_translation")." >>");
331  $this->tpl->parseCurrentBlock();
332  }
333 
334  // remove translation button
335  if ($key != 0)
336  {
337  $this->tpl->setCurrentBlock("removeTranslation");
338  $this->tpl->setVariable("TXT_REMOVE_TRANSLATION",$this->lng->txt("remove_translation"));
339  $this->ctrl->setParameter($this, "entry", $key);
340  $this->ctrl->setParameter($this, "new_type", $new_type);
341  $this->ctrl->setParameter($this, "mode", "create");
342  $this->tpl->setVariable("LINK_REMOVE_TRANSLATION", $this->ctrl->getLinkTarget($this, "removeTranslation"));
343 
344  $this->tpl->parseCurrentBlock();
345  }
346 
347  // lang selection
348  $this->tpl->addBlockFile("SEL_LANGUAGE", "sel_language", "tpl.lang_selection.html", false);
349  $this->tpl->setVariable("SEL_NAME", "Fobject[".$key."][lang]");
350 
351  include_once('Services/MetaData/classes/class.ilMDLanguageItem.php');
352  $languages = ilMDLanguageItem::_getLanguages();
353 
354  foreach($languages as $code => $language)
355  {
356  $this->tpl->setCurrentBlock("lg_option");
357  $this->tpl->setVariable("VAL_LG", $code);
358  $this->tpl->setVariable("TXT_LG", $language);
359 
360  if ($count == 1 AND $code == $this->ilias->account->getPref("language") AND !isset($_SESSION["translation_post"]))
361  {
362  $this->tpl->setVariable("SELECTED", "selected=\"selected\"");
363  }
364  elseif ($code == $val["lang"])
365  {
366  $this->tpl->setVariable("SELECTED", "selected=\"selected\"");
367  }
368 
369  $this->tpl->parseCurrentBlock();
370  }
371 
372  if ($key == 0)
373  {
374  $this->tpl->setCurrentBlock("type_image");
375  $this->tpl->setVariable("TYPE_IMG",
376  ilUtil::getImagePath("icon_cat.gif"));
377  $this->tpl->parseCurrentBlock();
378  }
379 
380  // object data
381  $this->tpl->setCurrentBlock("obj_form");
382 
383  if ($key == 0)
384  {
385  $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($new_type."_new"));
386  }
387  else
388  {
389  $this->tpl->setVariable("TXT_HEADER", $this->lng->txt("translation")." ".$key);
390  }
391 
392  if ($key == $data["default_language"])
393  {
394  $this->tpl->setVariable("CHECKED", "checked=\"checked\"");
395  }
396 
397  $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
398  $this->tpl->setVariable("TXT_DESC", $this->lng->txt("desc"));
399  $this->tpl->setVariable("TXT_DEFAULT", $this->lng->txt("default"));
400  $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("language"));
401  $this->tpl->setVariable("TITLE", ilUtil::prepareFormOutput($val["title"],$strip));
402  $this->tpl->setVariable("DESC", ilUtil::stripSlashes($val["desc"]));
403  $this->tpl->setVariable("NUM", $key);
404  $this->tpl->parseCurrentBlock();
405  }
406 
407  // global
408  $this->ctrl->setParameter($this, "mode", "create");
409  $this->ctrl->setParameter($this, "new_type", $new_type);
410  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "save"));
411  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
412  $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($new_type."_add"));
413  $this->tpl->setVariable("CMD_SUBMIT", "save");
414  $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
415 
416  $this->showSortingSettings();
417  }
418 
419  $this->fillCloneTemplate('CLONE_WIZARD','cat');
420  }
421 
426  function saveObject()
427  {
428  global $ilErr;
429 
430  $data = $_POST;
431 
432  // default language set?
433  if (!isset($data["default_language"]))
434  {
435  $this->ilias->raiseError($this->lng->txt("msg_no_default_language"),$this->ilias->error_obj->MESSAGE);
436  }
437 
438  // check title
439  if(!$_POST['Fobject'][$_POST['default_language']]['title'])
440  {
441  ilUtil::sendFailure($this->lng->txt('please_enter_title'));
442  $this->createObject();
443  return false;
444  }
445 
446  // prepare array fro further checks
447  foreach ($data["Fobject"] as $key => $val)
448  {
449  $langs[$key] = $val["lang"];
450  }
451 
452  $langs = array_count_values($langs);
453 
454  // all languages set?
455  if (array_key_exists("",$langs))
456  {
457  $this->ilias->raiseError($this->lng->txt("msg_no_language_selected"),$this->ilias->error_obj->MESSAGE);
458  }
459 
460  // no single language is selected more than once?
461  if (array_sum($langs) > count($langs))
462  {
463  $this->ilias->raiseError($this->lng->txt("msg_multi_language_selected"),$this->ilias->error_obj->MESSAGE);
464  }
465 
466  // copy default translation to variable for object data entry
467  $_POST["Fobject"]["title"] = $_POST["Fobject"][$_POST["default_language"]]["title"];
468  $_POST["Fobject"]["desc"] = $_POST["Fobject"][$_POST["default_language"]]["desc"];
469 
470  // always call parent method first to create an object_data entry & a reference
471  $newObj = parent::saveObject();
472 
473  // write translations to object_translation
474  foreach ($data["Fobject"] as $key => $val)
475  {
476  if ($key == $data["default_language"])
477  {
478  $default = 1;
479  }
480  else
481  {
482  $default = 0;
483  }
484 
485  $newObj->addTranslation(ilUtil::stripSlashes($val["title"]),ilUtil::stripSlashes($val["desc"]),$val["lang"],$default);
486  }
487 
488  include_once('Services/Container/classes/class.ilContainerSortingSettings.php');
489  $settings = new ilContainerSortingSettings($newObj->getId());
490  $settings->setSortMode((int) $_POST['sorting']);
491  $settings->save();
492 
493 
494  // always send a message
495  ilUtil::sendSuccess($this->lng->txt("cat_added"),true);
496 
497  // BEGIN ChangeEvent: Record object creation
498  global $ilUser;
499  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
501  {
502  ilChangeEvent::_recordWriteEvent($newObj->getId(), $ilUser->getId(), 'create');
503  }
504  // END ChangeEvent: Record object creation
505 
506  $this->redirectToRefId($_GET["ref_id"]);
507  }
508 
514  function infoScreenObject()
515  {
516  $this->ctrl->setCmd("showSummary");
517  $this->ctrl->setCmdClass("ilinfoscreengui");
518  $this->infoScreen();
519  }
520 
524  function infoScreen()
525  {
526  global $ilAccess, $ilCtrl;
527 
528  if (!$ilAccess->checkAccess("visible", "", $this->ref_id))
529  {
530  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
531  }
532 
533  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
534  $info = new ilInfoScreenGUI($this);
535 
536  $info->enablePrivateNotes();
537 
538  if ($ilAccess->checkAccess("read", "", $_GET["ref_id"]))
539  {
540  $info->enableNews();
541  }
542 
543  // no news editing for files, just notifications
544  $info->enableNewsEditing(false);
545  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
546  {
547  $news_set = new ilSetting("news");
548  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
549 
550  if ($enable_internal_rss)
551  {
552  $info->setBlockProperty("news", "settings", true);
553  $info->setBlockProperty("news", "public_notifications_option", true);
554  }
555  }
556 
557  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordGUI.php');
558  $record_gui = new ilAdvancedMDRecordGUI(ilAdvancedMDRecordGUI::MODE_INFO,'cat',$this->object->getId());
559  $record_gui->setInfoObject($info);
560  $record_gui->parse();
561 
562 
563  // standard meta data
564  $info->addMetaDataSections($this->object->getId(),0, $this->object->getType());
565 
566  // forward the command
567  if ($ilCtrl->getNextClass() == "ilinfoscreengui")
568  {
569  $ilCtrl->forwardCommand($info);
570  }
571  else
572  {
573  return $ilCtrl->getHTML($info);
574  }
575  }
576 
582  protected function editInfoObject()
583  {
584  $this->checkPermission("write");
585  $this->getSubTabs('edit');
586  $this->tabs_gui->setTabActive('edit_properties');
587  $this->tabs_gui->setSubTabActive('edit_cat_settings');
588 
589  $this->initExtendedSettings();
590  $this->tpl->setContent($this->form->getHTML());
591  }
592 
598  protected function updateInfoObject()
599  {
600  $this->checkPermission("write");
601  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordGUI.php');
603  'crs',$this->object->getId());
604  $record_gui->loadFromPost();
605  $record_gui->saveValues();
606 
607  ilUtil::sendSuccess($this->lng->txt("settings_saved"));
608  $this->editInfoObject();
609  return true;
610  }
611 
612 
618  protected function initExtendedSettings()
619  {
620  if(is_object($this->form))
621  {
622  return true;
623  }
624 
625  include_once('Services/Form/classes/class.ilPropertyFormGUI.php');
626  $this->form = new ilPropertyFormGUI();
627  $this->form->setFormAction($this->ctrl->getFormAction($this));
628  $this->form->setTitle($this->lng->txt('ext_cat_settings'));
629  $this->form->addCommandButton('updateInfo',$this->lng->txt('save'));
630  $this->form->addCommandButton('editInfo',$this->lng->txt('cancel'));
631 
632  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordGUI.php');
633  $record_gui = new ilAdvancedMDRecordGUI(ilAdvancedMDRecordGUI::MODE_EDITOR,'cat',$this->object->getId());
634  $record_gui->setPropertyForm($this->form);
635  $record_gui->parse();
636 
637  return true;
638  }
639 
640 
646  function editObject()
647  {
648  global $rbacsystem;
649 
650  if (!$rbacsystem->checkAccess("write", $this->ref_id))
651  {
652  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
653  }
654 
655  $this->getSubTabs('edit');
656  $this->ctrl->setParameter($this,"mode","edit");
657 
658  // for lang selection include metadata class
659  include_once "./Services/MetaData/classes/class.ilMDLanguageItem.php";
660 
661  $this->getTemplateFile("edit",'');
662  $this->showSortingSettings();
663  $array_push = true;
664 
665  if ($_SESSION["error_post_vars"])
666  {
667  $_SESSION["translation_post"] = $_SESSION["error_post_vars"];
668  $_GET["mode"] = "session";
669  $array_push = false;
670  }
671 
672  // load from db if edit category is called the first time
673  if (($_GET["mode"] != "session"))
674  {
675  $data = $this->object->getTranslations();
676  $_SESSION["translation_post"] = $data;
677  $array_push = false;
678  } // remove a translation from session
679  elseif ($_GET["entry"] != 0)
680  {
681  array_splice($_SESSION["translation_post"]["Fobject"],$_GET["entry"],1,array());
682 
683  if ($_GET["entry"] == $_SESSION["translation_post"]["default_language"])
684  {
685  $_SESSION["translation_post"]["default_language"] = "";
686  }
687  }
688 
689  $data = $_SESSION["translation_post"];
690 
691  // add additional translation form
692  if (!$_GET["entry"] and $array_push)
693  {
694  $count = array_push($data["Fobject"],array("title" => "","desc" => ""));
695  }
696  else
697  {
698  $count = count($data["Fobject"]);
699  }
700 
701  // stripslashes in form?
702  $strip = isset($_SESSION["translation_post"]) ? true : false;
703 
704  foreach ((array) $data["Fobject"] as $key => $val)
705  {
706  // add translation button
707  if ($key == $count -1)
708  {
709  $this->tpl->setCurrentBlock("addTranslation");
710  $this->tpl->setVariable("TXT_ADD_TRANSLATION",$this->lng->txt("add_translation")." >>");
711  $this->tpl->parseCurrentBlock();
712  }
713 
714  // remove translation button
715  if ($key != 0)
716  {
717  $this->tpl->setCurrentBlock("removeTranslation");
718  $this->tpl->setVariable("TXT_REMOVE_TRANSLATION",$this->lng->txt("remove_translation"));
719  $this->ctrl->setParameter($this, "entry", $key);
720  $this->ctrl->setParameter($this, "mode", "edit");
721  $this->tpl->setVariable("LINK_REMOVE_TRANSLATION", $this->ctrl->getLinkTarget($this, "removeTranslation"));
722  $this->tpl->parseCurrentBlock();
723  }
724 
725  // lang selection
726  $this->tpl->addBlockFile("SEL_LANGUAGE", "sel_language", "tpl.lang_selection.html", false);
727  $this->tpl->setVariable("SEL_NAME", "Fobject[".$key."][lang]");
728 
729  $languages = ilMDLanguageItem::_getLanguages();
730 
731  foreach ($languages as $code => $language)
732  {
733  $this->tpl->setCurrentBlock("lg_option");
734  $this->tpl->setVariable("VAL_LG", $code);
735  $this->tpl->setVariable("TXT_LG", $language);
736 
737  if ($code == $val["lang"])
738  {
739  $this->tpl->setVariable("SELECTED", "selected=\"selected\"");
740  }
741 
742  $this->tpl->parseCurrentBlock();
743  }
744 
745  // object data
746  $this->tpl->setCurrentBlock("obj_form");
747 
748  if ($key == 0)
749  {
750  $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($this->object->getType()."_edit"));
751  }
752  else
753  {
754  $this->tpl->setVariable("TXT_HEADER", $this->lng->txt("translation")." ".$key);
755  }
756 
757  if ($key == $data["default_language"])
758  {
759  $this->tpl->setVariable("CHECKED", "checked=\"checked\"");
760  }
761 
762  $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
763  $this->tpl->setVariable("TXT_DESC", $this->lng->txt("desc"));
764  $this->tpl->setVariable("TXT_DEFAULT", $this->lng->txt("default"));
765  $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("language"));
766  $this->tpl->setVariable("TITLE", ilUtil::prepareFormOutput($val["title"],$strip));
767  $this->tpl->setVariable("DESC", ilUtil::stripSlashes($val["desc"]));
768  $this->tpl->setVariable("NUM", $key);
769  $this->tpl->parseCurrentBlock();
770  }
771 
772  $this->showCustomIconsEditing();
773 
774  // global
775  $this->tpl->setCurrentBlock("adm_content");
776  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "update"));
777  $this->tpl->setVariable("TARGET", $this->getTargetFrame("update"));
778  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
779  $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt("save"));
780  $this->tpl->setVariable("CMD_SUBMIT", "update");
781  $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
782  }
783 
789  function updateObject()
790  {
791  global $rbacsystem, $ilCtrl;
792 
793  if (!$rbacsystem->checkAccess("write", $this->object->getRefId()))
794  {
795  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
796  }
797  else
798  {
799  $data = $_POST;
800 
801  // default language set?
802  if (!isset($data["default_language"]))
803  {
804  $this->ilias->raiseError($this->lng->txt("msg_no_default_language"),$this->ilias->error_obj->MESSAGE);
805  }
806 
807  // prepare array fro further checks
808  foreach ($data["Fobject"] as $key => $val)
809  {
810  $langs[$key] = $val["lang"];
811  }
812 
813  $langs = array_count_values($langs);
814 
815  // all languages set?
816  if (array_key_exists("",$langs))
817  {
818  $this->ilias->raiseError($this->lng->txt("msg_no_language_selected"),$this->ilias->error_obj->MESSAGE);
819  }
820 
821  // no single language is selected more than once?
822  if (array_sum($langs) > count($langs))
823  {
824  $this->ilias->raiseError($this->lng->txt("msg_multi_language_selected"),$this->ilias->error_obj->MESSAGE);
825  }
826 
827  // copy default translation to variable for object data entry
828  $_POST["Fobject"]["title"] = $_POST["Fobject"][$_POST["default_language"]]["title"];
829  $_POST["Fobject"]["desc"] = $_POST["Fobject"][$_POST["default_language"]]["desc"];
830 
831  // check title
832  if (trim($_POST["Fobject"]["title"]) == "")
833  {
834  ilUtil::sendFailure($this->lng->txt("msg_no_title"), true);
835  $ilCtrl->redirect($this, "edit");
836  }
837 
838  // first delete all translation entries...
839  $this->object->removeTranslations();
840 
841  // ...and write new translations to object_translation
842  foreach ($data["Fobject"] as $key => $val)
843  {
844  if ($key == $data["default_language"])
845  {
846  $default = 1;
847  }
848  else
849  {
850  $default = 0;
851  }
852 
853  $this->object->addTranslation(ilUtil::stripSlashes($val["title"]),ilUtil::stripSlashes($val["desc"]),$val["lang"],$default);
854  }
855 
856  // update object data entry with default translation
857  $this->object->setTitle(ilUtil::stripSlashes($_POST["Fobject"]["title"]));
858  $this->object->setDescription(ilUtil::stripSlashes($_POST["Fobject"]["desc"]));
859 
860  //save custom icons
861  if ($this->ilias->getSetting("custom_icons"))
862  {
863  $this->object->saveIcons($_FILES["cont_big_icon"]['tmp_name'],
864  $_FILES["cont_small_icon"]['tmp_name'], $_FILES["cont_tiny_icon"]['tmp_name']);
865  }
866 
867  $this->update = $this->object->update();
868  }
869 
870  include_once('Services/Container/classes/class.ilContainerSortingSettings.php');
871  $settings = new ilContainerSortingSettings($this->object->getId());
872  $settings->setSortMode((int) $_POST['sorting']);
873  $settings->update();
874 
875  // BEGIN ChangeEvent: Record update
876  global $ilUser;
877  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
879  {
880  ilChangeEvent::_recordWriteEvent($this->object->getId(), $ilUser->getId(), 'update');
881  ilChangeEvent::_catchupWriteEvents($this->object->getId(), $ilUser->getId());
882  }
883  // END ChangeEvent: Record update
884 
885  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
886  ilUtil::redirect($this->getReturnLocation("update",$this->ctrl->getTargetScript()."?".$this->link_params));
887  }
888 
895  {
896 
897  $this->checkPermission("write");
898  if (!($_GET["mode"] != "create" or $_GET["mode"] != "edit"))
899  {
900  $message = get_class($this)."::addTranslationObject(): Missing or wrong parameter! mode: ".$_GET["mode"];
901  $this->ilias->raiseError($message,$this->ilias->error_obj->WARNING);
902  }
903  $_SESSION["translation_post"] = $_POST;
904  $this->ctrl->setParameter($this, "entry", 0);
905  $this->ctrl->setParameter($this, "mode", "session");
906  $this->ctrl->setParameter($this, "new_type", $_GET["new_type"]);
907 
908  ilUtil::redirect($this->ctrl->getLinkTarget($this, $_GET["mode"], "", false, false));
909  }
910 
917  {
918  $this->checkPermission("write");
919  if (!($_GET["mode"] != "create" or $_GET["mode"] != "edit"))
920  {
921  $message = get_class($this)."::removeTranslationObject(): Missing or wrong parameter! mode: ".$_GET["mode"];
922  $this->ilias->raiseError($message,$this->ilias->error_obj->WARNING);
923  }
924 
925  $this->ctrl->setParameter($this, "entry", $_GET["entry"]);
926  $this->ctrl->setParameter($this, "mode", "session");
927  $this->ctrl->setParameter($this, "new_type", $_GET["new_type"]);
928  ilUtil::redirect($this->ctrl->getLinkTarget($this, $_GET["mode"], "", false, false));
929 
930  }
931 
938  {
939  $this->checkPermission("write");
940  $_SESSION["translation_post"] = $_POST;
941  $this->object->removeBigIcon();
942  $this->ctrl->redirect($this, $_GET["mode"]);
943  }
944 
951  {
952  $this->checkPermission("write");
953  $_SESSION["translation_post"] = $_POST;
954  $this->object->removeSmallIcon();
955  $this->ctrl->redirect($this, $_GET["mode"]);
956  }
957 
964  {
965  $this->checkPermission("write");
966  $_SESSION["translation_post"] = $_POST;
967  $this->object->removeTinyIcon();
968  $this->ctrl->redirect($this, $_GET["mode"]);
969  }
970 
975  {
976  ilObjCategoryGUI::_importCategoriesForm($this->ref_id, $this->tpl);
977  }
978 
982  function _importCategoriesForm ($a_ref_id, &$a_tpl)
983  {
984  global $lng, $rbacreview;
985 
986  $a_tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.cat_import_form.html",
987  "Modules/Category");
988 
989  $a_tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
990 
991  $a_tpl->setVariable("TXT_IMPORT_CATEGORIES", $lng->txt("import_categories"));
992  $a_tpl->setVariable("TXT_HIERARCHY_OPTION", $lng->txt("import_cat_localrol"));
993  $a_tpl->setVariable("TXT_IMPORT_FILE", $lng->txt("import_file"));
994  $a_tpl->setVariable("TXT_IMPORT_TABLE", $lng->txt("import_cat_table"));
995 
996  $a_tpl->setVariable("BTN_IMPORT", $lng->txt("import"));
997  $a_tpl->setVariable("BTN_CANCEL", $lng->txt("cancel"));
998 
999  // NEED TO FILL ADOPT_PERMISSIONS HTML FORM....
1000  $parent_role_ids = $rbacreview->getParentRoleIds($a_ref_id,true);
1001 
1002  // sort output for correct color changing
1003  ksort($parent_role_ids);
1004 
1005  foreach ($parent_role_ids as $key => $par)
1006  {
1007  if ($par["obj_id"] != SYSTEM_ROLE_ID)
1008  {
1009  $check = ilUtil::formCheckbox(0,"adopt[]",$par["obj_id"],1);
1010  $output["adopt"][$key]["css_row_adopt"] = ilUtil::switchColor($key, "tblrow1", "tblrow2");
1011  $output["adopt"][$key]["check_adopt"] = $check;
1012  $output["adopt"][$key]["role_id"] = $par["obj_id"];
1013  $output["adopt"][$key]["type"] = ($par["type"] == 'role' ? 'Role' : 'Template');
1014  $output["adopt"][$key]["role_name"] = $par["title"];
1015  }
1016  }
1017 
1018  //var_dump($output);
1019 
1020  // BEGIN ADOPT PERMISSIONS
1021  foreach ($output["adopt"] as $key => $value)
1022  {
1023  $a_tpl->setCurrentBlock("ADOPT_PERM_ROW");
1024  $a_tpl->setVariable("CSS_ROW_ADOPT",$value["css_row_adopt"]);
1025  $a_tpl->setVariable("CHECK_ADOPT",$value["check_adopt"]);
1026  $a_tpl->setVariable("LABEL_ID",$value["role_id"]);
1027  $a_tpl->setVariable("TYPE",$value["type"]);
1028  $a_tpl->setVariable("ROLE_NAME",$value["role_name"]);
1029  $a_tpl->parseCurrentBlock();
1030  }
1031  }
1032 
1033 
1040  {
1041  $this->ctrl->redirect($this);
1042  }
1043 
1047  function _getImportDir()
1048  {
1049  return ilUtil::getDataDir()."/cat_import";
1050  }
1051 
1056  {
1058  // call to importCategories with $withrol = 0
1060  }
1061 
1066  {
1067 
1068  //echo "entra aqui";
1069  // call to importCategories with $withrol = 1
1071  }
1072 
1077  function _importCategories($a_ref_id, $withrol_tmp)
1078  {
1079  global $lng;
1080 
1081  require_once("./Modules/Category/classes/class.ilCategoryImportParser.php");
1082 
1083  $import_dir = ilObjCategoryGUI::_getImportDir();
1084 
1085  // create user import directory if necessary
1086  if (!@is_dir($import_dir))
1087  {
1088  ilUtil::createDirectory($import_dir);
1089  }
1090 
1091  // move uploaded file to user import directory
1092 
1093  $file_name = $_FILES["importFile"]["name"];
1094 
1095  // added to prevent empty file names
1096  if (!strcmp($file_name,"")) {
1097  ilUtil::sendFailure($lng->txt("no_import_file_found"), true);
1098  $this->ctrl->redirect($this);
1099  }
1100 
1101  $parts = pathinfo($file_name);
1102  $full_path = $import_dir."/".$file_name;
1103  //move_uploaded_file($_FILES["importFile"]["tmp_name"], $full_path);
1104  ilUtil::moveUploadedFile($_FILES["importFile"]["tmp_name"], $file_name, $full_path);
1105 
1106  // unzip file
1107  ilUtil::unzip($full_path);
1108 
1109  $subdir = basename($parts["basename"],".".$parts["extension"]);
1110  $xml_file = $import_dir."/".$subdir."/".$subdir.".xml";
1111  // CategoryImportParser
1112  //var_dump($_POST);
1113  $importParser = new ilCategoryImportParser($xml_file, $a_ref_id, $withrol_tmp);
1114  $importParser->startParsing();
1115 
1116  ilUtil::sendSuccess($lng->txt("categories_imported"), true);
1117  $this->ctrl->redirect($this);
1118  }
1119 
1124  protected function resetFilterObject()
1125  {
1126  include_once("./Services/User/classes/class.ilUserTableGUI.php");
1127  $utab = new ilUserTableGUI($this, "listUsers",ilUserTableGUI::MODE_LOCAL_USER);
1128  $utab->resetOffset();
1129  $utab->resetFilter();
1130 
1131  // from "old" implementation
1132  $this->listUsersObject();
1133  }
1134 
1139  protected function applyFilterObject()
1140  {
1141  global $ilTabs;
1142 
1143  include_once("./Services/User/classes/class.ilUserTableGUI.php");
1144  $utab = new ilUserTableGUI($this, "listUsers", ilUserTableGUI::MODE_LOCAL_USER);
1145  $utab->resetOffset();
1146  $utab->writeFilterToSession();
1147  $this->listUsersObject();
1148  }
1149 
1150  // METHODS for local user administration
1151  function listUsersObject($show_delete = false)
1152  {
1153  global $ilUser,$rbacreview, $ilToolbar;
1154 
1155  include_once './Services/User/classes/class.ilLocalUser.php';
1156  include_once './Services/User/classes/class.ilObjUserGUI.php';
1157 
1158  global $rbacsystem,$rbacreview;
1159 
1160  if(!$rbacsystem->checkAccess("cat_administrate_users",$this->object->getRefId()))
1161  {
1162  $this->ilias->raiseError($this->lng->txt("msg_no_perm_admin_users"),$this->ilias->error_obj->MESSAGE);
1163  }
1164  $this->tabs_gui->setTabActive('administrate_users');
1165 
1166 
1167 
1168  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.cat_admin_users.html',
1169  "Modules/Category");
1170 
1171  if(count($rbacreview->getGlobalAssignableRoles()) or in_array(SYSTEM_ROLE_ID,$rbacreview->assignedRoles($ilUser->getId())))
1172  {
1173  $ilToolbar->addButton(
1174  $this->lng->txt('add_user'),
1175  $this->ctrl->getLinkTargetByClass('ilobjusergui','create')
1176  );
1177 
1178  $ilToolbar->addButton(
1179  $this->lng->txt('import_users'),
1180  $this->ctrl->getLinkTargetByClass('ilobjuserfoldergui','importUserForm')
1181  );
1182  }
1183  else
1184  {
1185  ilUtil::sendInfo($this->lng->txt('no_roles_user_can_be_assigned_to'));
1186  }
1187 
1188  if($show_delete)
1189  {
1190  $this->tpl->setCurrentBlock("confirm_delete");
1191  $this->tpl->setVariable("CONFIRM_FORMACTION",$this->ctrl->getFormAction($this));
1192  $this->tpl->setVariable("TXT_CANCEL",$this->lng->txt('cancel'));
1193  $this->tpl->setVariable("CONFIRM_CMD",'performDeleteUsers');
1194  $this->tpl->setVariable("TXT_CONFIRM",$this->lng->txt('delete'));
1195  $this->tpl->parseCurrentBlock();
1196  }
1197 
1198  $this->lng->loadLanguageModule('user');
1199 
1200  include_once("./Services/User/classes/class.ilUserTableGUI.php");
1201  $utab = new ilUserTableGUI($this, 'listUsers',ilUserTableGUI::MODE_LOCAL_USER);
1202  $this->tpl->setVariable('USERS_TABLE',$utab->getHTML());
1203 
1204  return true;
1205  }
1206 
1208  {
1209  include_once './Services/User/classes/class.ilLocalUser.php';
1210  $this->checkPermission("cat_administrate_users");
1211 
1212  foreach($_POST['user_ids'] as $user_id)
1213  {
1214  if(!in_array($user_id,ilLocalUser::_getAllUserIds($this->object->getRefId())))
1215  {
1216  die('user id not valid');
1217  }
1218  if(!$tmp_obj =& ilObjectFactory::getInstanceByObjId($user_id,false))
1219  {
1220  continue;
1221  }
1222  $tmp_obj->delete();
1223  }
1224  ilUtil::sendSuccess($this->lng->txt('deleted_users'));
1225  $this->listUsersObject();
1226 
1227  return true;
1228  }
1229 
1231  {
1232  $this->checkPermission("cat_administrate_users");
1233  if(!count($_POST['id']))
1234  {
1235  ilUtil::sendFailure($this->lng->txt('no_users_selected'));
1236  $this->listUsersObject();
1237 
1238  return true;
1239  }
1240 
1241  include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
1242  $confirm = new ilConfirmationGUI();
1243  $confirm->setFormAction($this->ctrl->getFormAction($this));
1244  $confirm->setHeaderText($this->lng->txt('sure_delete_selected_users'));
1245  $confirm->setConfirm($this->lng->txt('delete'), 'performDeleteUsers');
1246  $confirm->setCancel($this->lng->txt('cancel'), 'listUsers');
1247 
1248  foreach($_POST['id'] as $user)
1249  {
1250  $name = ilObjUser::_lookupName($user);
1251 
1252  $confirm->addItem(
1253  'user_ids[]',
1254  $user,
1255  $name['lastname'].', '.$name['firstname'].' ['.$name['login'].']'
1256  );
1257  }
1258  $this->tpl->setContent($confirm->getHTML());
1259  }
1260 
1262  {
1263  global $rbacreview,$ilTabs;
1264 
1265  $this->checkPermission("cat_administrate_users");
1266 
1267  include_once './Services/User/classes/class.ilLocalUser.php';
1268 
1269  if(!isset($_GET['obj_id']))
1270  {
1271  ilUtil::sendFailure('no_user_selected');
1272  $this->listUsersObject();
1273 
1274  return true;
1275  }
1276 
1277  $ilTabs->clearTargets();
1278  $ilTabs->setBackTarget($this->lng->txt('backto_lua'), $this->ctrl->getLinkTarget($this,'listUsers'));
1279 
1280  $roles = $this->__getAssignableRoles();
1281 
1282  if(!count($roles))
1283  {
1284  #ilUtil::sendInfo($this->lng->txt('no_roles_user_can_be_assigned_to'));
1285  #$this->listUsersObject();
1286 
1287  #return true;
1288  }
1289 
1290  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.cat_role_assignment.html',
1291  "Modules/Category");
1292 
1293  $ass_roles = $rbacreview->assignedRoles($_GET['obj_id']);
1294 
1295  $counter = 0;
1296  foreach($roles as $role)
1297  {
1298  $role_obj =& ilObjectFactory::getInstanceByObjId($role['obj_id']);
1299 
1300  $disabled = false;
1301  $f_result[$counter][] = ilUtil::formCheckbox(in_array($role['obj_id'],$ass_roles) ? 1 : 0,
1302  'role_ids[]',
1303  $role['obj_id'],
1304  $disabled);
1305  $f_result[$counter][] = $role_obj->getTitle();
1306  $f_result[$counter][] = $role_obj->getDescription();
1307  $f_result[$counter][] = $role['role_type'] == 'global' ?
1308  $this->lng->txt('global') :
1309  $this->lng->txt('local');
1310 
1311  unset($role_obj);
1312  ++$counter;
1313  }
1314  $this->__showRolesTable($f_result,"assignRolesObject");
1315  }
1316 
1317  function assignSaveObject()
1318  {
1319  global $rbacreview,$rbacadmin;
1320  $this->checkPermission("cat_administrate_users");
1321 
1322  include_once './Services/User/classes/class.ilLocalUser.php';
1323  // check hack
1324  if(!isset($_GET['obj_id']) or !in_array($_REQUEST['obj_id'],ilLocalUser::_getAllUserIds()))
1325  {
1326  ilUtil::sendFailure('no_user_selected');
1327  $this->listUsersObject();
1328 
1329  return true;
1330  }
1331  $roles = $this->__getAssignableRoles();
1332 
1333  // check minimum one global role
1334  if(!$this->__checkGlobalRoles($_POST['role_ids']))
1335  {
1336  ilUtil::sendFailure($this->lng->txt('no_global_role_left'));
1337  $this->assignRolesObject();
1338 
1339  return false;
1340  }
1341 
1342  $new_role_ids = $_POST['role_ids'] ? $_POST['role_ids'] : array();
1343  $assigned_roles = $rbacreview->assignedRoles((int) $_REQUEST['obj_id']);
1344  foreach($roles as $role)
1345  {
1346  if(in_array($role['obj_id'],$new_role_ids) and !in_array($role['obj_id'],$assigned_roles))
1347  {
1348  $rbacadmin->assignUser($role['obj_id'],(int) $_REQUEST['obj_id']);
1349  }
1350  if(in_array($role['obj_id'],$assigned_roles) and !in_array($role['obj_id'],$new_role_ids))
1351  {
1352  $rbacadmin->deassignUser($role['obj_id'],(int) $_REQUEST['obj_id']);
1353  }
1354  }
1355  ilUtil::sendSuccess($this->lng->txt('role_assignment_updated'));
1356  $this->assignRolesObject();
1357 
1358  return true;
1359  }
1360 
1361  // PRIVATE
1363  {
1364  global $rbacreview,$ilUser;
1365 
1366  // check local user
1367  $tmp_obj =& ilObjectFactory::getInstanceByObjId($_REQUEST['obj_id']);
1368  // Admin => all roles
1369  if(in_array(SYSTEM_ROLE_ID,$rbacreview->assignedRoles($ilUser->getId())))
1370  {
1371  $global_roles = $rbacreview->getGlobalRolesArray();
1372  }
1373  elseif($tmp_obj->getTimeLimitOwner() == $this->object->getRefId())
1374  {
1375  $global_roles = $rbacreview->getGlobalAssignableRoles();
1376  }
1377  else
1378  {
1379  $global_roles = array();
1380  }
1381  return $roles = array_merge($global_roles,
1382  $rbacreview->getAssignableChildRoles($this->object->getRefId()));
1383  }
1384 
1385  function __checkGlobalRoles($new_assigned)
1386  {
1387  global $rbacreview,$ilUser;
1388 
1389  $this->checkPermission("cat_administrate_users");
1390 
1391  // return true if it's not a local user
1392  $tmp_obj =& ilObjectFactory::getInstanceByObjId($_REQUEST['obj_id']);
1393  if($tmp_obj->getTimeLimitOwner() != $this->object->getRefId() and
1394  !in_array(SYSTEM_ROLE_ID,$rbacreview->assignedRoles($ilUser->getId())))
1395  {
1396  return true;
1397  }
1398 
1399  // new assignment by form
1400  $new_assigned = $new_assigned ? $new_assigned : array();
1401  $assigned = $rbacreview->assignedRoles((int) $_GET['obj_id']);
1402 
1403  // all assignable globals
1404  if(!in_array(SYSTEM_ROLE_ID,$rbacreview->assignedRoles($ilUser->getId())))
1405  {
1406  $ga = $rbacreview->getGlobalAssignableRoles();
1407  }
1408  else
1409  {
1410  $ga = $rbacreview->getGlobalRolesArray();
1411  }
1412  $global_assignable = array();
1413  foreach($ga as $role)
1414  {
1415  $global_assignable[] = $role['obj_id'];
1416  }
1417 
1418  $new_visible_assigned_roles = array_intersect($new_assigned,$global_assignable);
1419  $all_assigned_roles = array_intersect($assigned,$rbacreview->getGlobalRoles());
1420  $main_assigned_roles = array_diff($all_assigned_roles,$global_assignable);
1421 
1422  if(!count($new_visible_assigned_roles) and !count($main_assigned_roles))
1423  {
1424  return false;
1425  }
1426  return true;
1427  }
1428 
1429 
1430  function __showRolesTable($a_result_set,$a_from = "")
1431  {
1432  $this->checkPermission("cat_administrate_users");
1433 
1434  $tbl =& $this->__initTableGUI();
1435  $tpl =& $tbl->getTemplateObject();
1436 
1437  // SET FORMAACTION
1438  $tpl->setCurrentBlock("tbl_form_header");
1439 
1440  $this->ctrl->setParameter($this,'obj_id',$_GET['obj_id']);
1441  $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
1442  $tpl->parseCurrentBlock();
1443 
1444  // SET FOOTER BUTTONS
1445  $tpl->setVariable("COLUMN_COUNTS",4);
1446  $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
1447 
1448  $tpl->setCurrentBlock("tbl_action_button");
1449  $tpl->setVariable("BTN_NAME","assignSave");
1450  $tpl->setVariable("BTN_VALUE",$this->lng->txt("change_assignment"));
1451  $tpl->parseCurrentBlock();
1452 
1453  $tpl->setCurrentBlock("tbl_action_row");
1454  $tpl->setVariable("TPLPATH",$this->tpl->tplPath);
1455  $tpl->parseCurrentBlock();
1456 
1457  $tmp_obj =& ilObjectFactory::getInstanceByObjId($_GET['obj_id']);
1458  $title = $this->lng->txt('role_assignment').' ('.$tmp_obj->getFullname().')';
1459 
1460  $tbl->setTitle($title,"icon_role.gif",$this->lng->txt("role_assignment"));
1461  $tbl->setHeaderNames(array('',
1462  $this->lng->txt("title"),
1463  $this->lng->txt('description'),
1464  $this->lng->txt("type")));
1465  $tbl->setHeaderVars(array("",
1466  "title",
1467  "description",
1468  "type"),
1469  array("ref_id" => $this->object->getRefId(),
1470  "cmd" => "assignRoles",
1471  "obj_id" => $_GET['obj_id'],
1472  "cmdClass" => "ilobjcategorygui",
1473  "cmdNode" => $_GET["cmdNode"]));
1474  $tbl->setColumnWidth(array("4%","35%","45%","16%"));
1475 
1476  $this->set_unlimited = true;
1477  $this->__setTableGUIBasicData($tbl,$a_result_set,$a_from,true);
1478  $tbl->render();
1479 
1480  $this->tpl->setVariable("ROLES_TABLE",$tbl->tpl->get());
1481 
1482  return true;
1483  }
1484 
1485  function __showUsersTable($a_result_set,$a_from = "",$a_footer = true)
1486  {
1487  $this->checkPermission("cat_administrate_users");
1488 
1489  $tbl =& $this->__initTableGUI();
1490  $tpl =& $tbl->getTemplateObject();
1491 
1492  // SET FORMAACTION
1493  $tpl->setCurrentBlock("tbl_form_header");
1494 
1495  $this->ctrl->setParameter($this,'sort_by',$_GET['sort_by']);
1496  $this->ctrl->setParameter($this,'sort_order',$_GET['sort_order']);
1497  $this->ctrl->setParameter($this,'offset',$_GET['offset']);
1498  $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
1499  $tpl->parseCurrentBlock();
1500 
1501 
1502  if($a_footer)
1503  {
1504  // SET FOOTER BUTTONS
1505  $tpl->setVariable("COLUMN_COUNTS",6);
1506  $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
1507 
1508  $tpl->setCurrentBlock("tbl_action_button");
1509  $tpl->setVariable("BTN_NAME","deleteUser");
1510  $tpl->setVariable("BTN_VALUE",$this->lng->txt("delete"));
1511  $tpl->parseCurrentBlock();
1512 
1513  $tpl->setCurrentBlock("tbl_action_row");
1514  $tpl->setVariable("TPLPATH",$this->tpl->tplPath);
1515  $tpl->parseCurrentBlock();
1516 
1517  $tbl->setFormName('cmd');
1518  $tbl->enable('select_all');
1519  }
1520 
1521  $tbl->setTitle($this->lng->txt("users"),"icon_usr.gif",$this->lng->txt("users"));
1522  $tbl->setHeaderNames(array('',
1523  $this->lng->txt("username"),
1524  $this->lng->txt("firstname"),
1525  $this->lng->txt("lastname"),
1526  $this->lng->txt('context'),
1527  $this->lng->txt('role_assignment')));
1528  $tbl->setHeaderVars(array("",
1529  "login",
1530  "firstname",
1531  "lastname",
1532  "context",
1533  "role_assignment"),
1534  array("ref_id" => $this->object->getRefId(),
1535  "cmd" => "listUsers",
1536  "cmdClass" => "ilobjcategorygui",
1537  "cmdNode" => $_GET["cmdNode"]));
1538  $tbl->setColumnWidth(array("1px","20%","20%","20%","20%","20%"));
1539  $tbl->setSelectAllCheckbox('user_ids');
1540 
1541  $this->__setTableGUIBasicData($tbl,$a_result_set,$a_from,true);
1542  $tbl->render();
1543 
1544  $this->tpl->setVariable("USERS_TABLE",$tbl->tpl->get());
1545 
1546  return true;
1547  }
1548 
1549  function __setTableGUIBasicData(&$tbl,&$result_set,$a_from = "",$a_footer = true)
1550  {
1551  global $ilUser;
1552 
1553  switch ($a_from)
1554  {
1555  case "listUsersObject":
1556  $tbl->setOrderColumn($_GET["sort_by"]);
1557  $tbl->setOrderDirection($_GET["sort_order"]);
1558  $tbl->setOffset($_GET["offset"]);
1559  $tbl->setMaxCount($this->all_users_count);
1560  $tbl->setLimit($ilUser->getPref('hits_per_page'));
1561  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
1562  $tbl->setData($result_set);
1563  $tbl->disable('auto_sort');
1564 
1565  return true;
1566 
1567 
1568  case "assignRolesObject":
1569  $offset = $_GET["offset"];
1570  // init sort_by (unfortunatly sort_by is preset with 'title'
1571  if ($_GET["sort_by"] == "title" or empty($_GET["sort_by"]))
1572  {
1573  $_GET["sort_by"] = "login";
1574  }
1575  $order = $_GET["sort_by"];
1576  $direction = $_GET["sort_order"];
1577  break;
1578 
1579  case "clipboardObject":
1580  $offset = $_GET["offset"];
1581  $order = $_GET["sort_by"];
1582  $direction = $_GET["sort_order"];
1583  $tbl->disable("footer");
1584  break;
1585 
1586  default:
1587  $offset = $_GET["offset"];
1588  $order = $_GET["sort_by"];
1589  $direction = $_GET["sort_order"];
1590  break;
1591  }
1592 
1593  $tbl->setOrderColumn($order);
1594  $tbl->setOrderDirection($direction);
1595  $tbl->setOffset($offset);
1596  if($this->set_unlimited)
1597  {
1598  $tbl->setLimit($_GET["limit"]*100);
1599  }
1600  else
1601  {
1602  $tbl->setLimit($_GET['limit']);
1603  }
1604  $tbl->setMaxCount(count($result_set));
1605 
1606  if($a_footer)
1607  {
1608  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
1609  }
1610  else
1611  {
1612  $tbl->disable('footer');
1613  }
1614  $tbl->setData($result_set);
1615  }
1616 
1617  function &__initTableGUI()
1618  {
1619  include_once "./Services/Table/classes/class.ilTableGUI.php";
1620 
1621  return new ilTableGUI(0,false);
1622  }
1623 
1624  function __buildFilterSelect($a_parent_ids)
1625  {
1626  $action[0] = $this->lng->txt('all_users');
1627  $action[$this->object->getRefId()] = $this->lng->txt('users').
1628  ' ('.ilObject::_lookupTitle(ilObject::_lookupObjId($this->object->getRefId())).')';
1629 
1630  foreach($a_parent_ids as $parent)
1631  {
1632  if($parent == $this->object->getRefId())
1633  {
1634  continue;
1635  }
1636  switch($parent)
1637  {
1639  $action[ilLocalUser::_getUserFolderId()] = $this->lng->txt('global_user');
1640 
1641  break;
1642 
1643  default:
1644  $action[$parent] = $this->lng->txt('users').' ('.ilObject::_lookupTitle(ilObject::_lookupObjId($parent)).')';
1645 
1646  break;
1647  }
1648  }
1649  return ilUtil::formSelect($_SESSION['filtered_users'][$this->object->getRefId()],"filter",$action,false,true);
1650  }
1651 
1652  function _goto($a_target)
1653  {
1654  global $ilAccess, $ilErr, $lng;
1655 
1656  if ($ilAccess->checkAccess("read", "", $a_target))
1657  {
1658  $_GET["cmd"] = "frameset";
1659  $_GET["ref_id"] = $a_target;
1660  include("repository.php");
1661  exit;
1662  }
1663  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
1664  {
1665  $_GET["cmd"] = "frameset";
1666  $_GET["target"] = "";
1667  $_GET["ref_id"] = ROOT_FOLDER_ID;
1668  ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
1669  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
1670  include("repository.php");
1671  exit;
1672  }
1673 
1674  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
1675 
1676  }
1677 
1683  protected function showSortingSettings()
1684  {
1685  $this->checkPermission("write");
1686 
1687  $this->tpl->setVariable('TXT_SORTING',$this->lng->txt('sorting_header'));
1688  $this->tpl->setVariable('TXT_SORT_TITLE',$this->lng->txt('sorting_title_header'));
1689  $this->tpl->setVariable('INFO_SORT_TITLE',$this->lng->txt('sorting_info_title'));
1690  $this->tpl->setVariable('TXT_SORT_MANUAL',$this->lng->txt('sorting_manual_header'));
1691  $this->tpl->setVariable('INFO_SORT_MANUAL',$this->lng->txt('sorting_info_manual'));
1692 
1693  include_once('Services/Container/classes/class.ilContainerSortingSettings.php');
1694  if($this->getCreationMode())
1695  {
1696  $settings = new ilContainerSortingSettings(0);
1697  }
1698  else
1699  {
1700  $settings = new ilContainerSortingSettings($this->object->getId());
1701  }
1702 
1703 
1704  $this->tpl->setVariable('RADIO_SORT_TITLE',ilUtil::formRadioButton(
1705  $settings->getSortMode() == ilContainer::SORT_TITLE,
1706  'sorting',
1708  $this->tpl->setVariable('RADIO_SORT_MANUAL',ilUtil::formRadioButton(
1709  $settings->getSortMode() == ilContainer::SORT_MANUAL,
1710  'sorting',
1712  }
1713 
1719  protected function getSubTabs($a_section)
1720  {
1721  switch($a_section)
1722  {
1723  case 'edit':
1724  $this->tabs_gui->addSubTabTarget("edit_properties",
1725  $this->ctrl->getLinkTarget($this,'edit'),
1726  "edit", get_class($this));
1727 
1728  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php');
1729  if(in_array('cat',ilAdvancedMDRecord::_getActivatedObjTypes()))
1730  {
1731  $this->tabs_gui->addSubTabTarget("edit_cat_settings",
1732  $this->ctrl->getLinkTarget($this,'editInfo'),
1733  "editInfo", get_class($this));
1734  }
1735  }
1736  }
1737 
1738 
1739 } // END class.ilObjCategoryGUI
1740 ?>