ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjectGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 
14 {
16 
17 
18 
24  var $ilias;
25 
32 
38  var $tpl;
39 
45  var $tree;
46 
52  var $lng;
53 
59  var $data;
60 
66  var $object;
67  var $ref_id;
68  var $obj_id;
69  var $maxcount; // contains number of child objects
70  var $formaction; // special formation (array "cmd" => "formaction")
71  var $return_location; // special return location (array "cmd" => "location")
72  var $target_frame; // special target frame (array "cmd" => "location")
73 
75  var $actions;
77  var $omit_locator = false;
78 
79  const CFORM_NEW = 1;
80  const CFORM_IMPORT = 2;
81  const CFORM_CLONE = 3;
82 
90  function ilObjectGUI($a_data, $a_id = 0, $a_call_by_reference = true, $a_prepare_output = true)
91  {
92  global $ilias, $objDefinition, $tpl, $tree, $ilCtrl, $ilErr, $lng, $ilTabs;
93 
94  $this->tabs_gui =& $ilTabs;
95 
96  if (!isset($ilErr))
97  {
98  $ilErr = new ilErrorHandling();
99  $ilErr->setErrorHandling(PEAR_ERROR_CALLBACK,array($ilErr,'errorHandler'));
100  }
101  else
102  {
103  $this->ilErr =& $ilErr;
104  }
105 
106  $this->ilias =& $ilias;
107  $this->objDefinition =& $objDefinition;
108  $this->tpl =& $tpl;
109  $this->html = "";
110  $this->ctrl =& $ilCtrl;
111 
112  $params = array("ref_id");
113 
114  if (!$a_call_by_reference)
115  {
116  $params = array("ref_id","obj_id");
117  }
118 
119  $this->ctrl->saveParameter($this, $params);
120 
121  $this->lng =& $lng;
122  $this->tree =& $tree;
123  $this->formaction = array();
124  $this->return_location = array();
125  $this->target_frame = array();
126  $this->actions = "";
127  $this->sub_objects = "";
128 
129  $this->data = $a_data;
130  $this->id = $a_id;
131  $this->call_by_reference = $a_call_by_reference;
132  $this->prepare_output = $a_prepare_output;
133  $this->creation_mode = false;
134 
135  $this->ref_id = ($this->call_by_reference) ? $this->id : $_GET["ref_id"];
136  $this->obj_id = ($this->call_by_reference) ? $_GET["obj_id"] : $this->id;
137 
138  if ($this->id != 0)
139  {
140  $this->link_params = "ref_id=".$this->ref_id;
141  }
142 
143  // get the object
144  $this->assignObject();
145 
146  // set context
147  if (is_object($this->object))
148  {
149  if ($this->call_by_reference && $this->ref_id == $_GET["ref_id"])
150  {
151  $this->ctrl->setContext($this->object->getId(),
152  $this->object->getType());
153  }
154  }
155 
156  // use global $lng instead, when creating new objects object is not available
157  //$this->lng =& $this->object->lng;
158 
159  //prepare output
160  if ($a_prepare_output)
161  {
162  $this->prepareOutput();
163  }
164  }
165 
166 
170  function &executeCommand()
171  {
172  $next_class = $this->ctrl->getNextClass($this);
173  $cmd = $this->ctrl->getCmd();
174 
175  switch($next_class)
176  {
177  default:
178  $this->prepareOutput();
179  if(!$cmd)
180  {
181  $cmd = "view";
182  }
183  $cmd .= "Object";
184  $this->$cmd();
185 
186  break;
187  }
188 
189  return true;
190  }
191 
192 
196  public function withReferences()
197  {
198  return $this->call_by_reference;
199  }
200 
207  public function setCreationMode($a_mode = true)
208  {
209  $this->creation_mode = $a_mode;
210  }
211 
215  public function getCreationMode()
216  {
217  return $this->creation_mode;
218  }
219 
220  protected function assignObject()
221  {
222  // TODO: it seems that we always have to pass only the ref_id
223 //echo "<br>ilObjectGUIassign:".get_class($this).":".$this->id.":<br>";
224  if ($this->id != 0)
225  {
226  if ($this->call_by_reference)
227  {
228  $this->object = ilObjectFactory::getInstanceByRefId($this->id);
229  }
230  else
231  {
232  $this->object = ilObjectFactory::getInstanceByObjId($this->id);
233  }
234  }
235  }
236 
240  protected function prepareOutput()
241  {
242  global $ilLocator, $tpl, $ilUser;
243 
244  $this->tpl->getStandardTemplate();
245  // administration prepare output
246  if (strtolower($_GET["baseClass"]) == "iladministrationgui")
247  {
248  $this->addAdminLocatorItems();
249  $tpl->setLocator();
250 
251 // ilUtil::sendInfo();
253 
254  $this->setTitleAndDescription();
255 
256  if ($this->getCreationMode() != true)
257  {
258  $this->setAdminTabs();
259  }
260 
261  return false;
262  }
263  // set locator
264  $this->setLocator();
265  // catch feedback message
266 // ilUtil::sendInfo();
268 
269  // in creation mode (parent) object and gui object
270  // do not fit
271  if ($this->getCreationMode() == true)
272  {
273  // repository vs. workspace
274  if($this->call_by_reference)
275  {
276  // get gui class of parent and call their title and description method
277  $obj_type = ilObject::_lookupType($_GET["ref_id"],true);
278  $class_name = $this->objDefinition->getClassName($obj_type);
279  $class = strtolower("ilObj".$class_name."GUI");
280  $class_path = $this->ctrl->lookupClassPath($class);
281  include_once($class_path);
282  $class_name = $this->ctrl->getClassForClasspath($class_path);
283 //echo "<br>instantiating parent for title and description";
284  $this->parent_gui_obj = new $class_name("", $_GET["ref_id"], true, false);
285  // the next line prevents the header action menu being shown
286  $this->parent_gui_obj->setCreationMode(true);
287  $this->parent_gui_obj->setTitleAndDescription();
288  }
289  }
290  else
291  {
292  // set title and description and title icon
293  $this->setTitleAndDescription();
294 
295  // set tabs
296  $this->setTabs();
297 
298  // BEGIN WebDAV: Display Mount Webfolder icon.
299  require_once 'Services/WebDAV/classes/class.ilDAVServer.php';
300  if (ilDAVServer::_isActive() &&
301  $ilUser->getId() != ANONYMOUS_USER_ID)
302  {
303  $this->showMountWebfolderIcon();
304  }
305  // END WebDAV: Display Mount Webfolder icon.
306  }
307 
308  return true;
309  }
310 
314  protected function setTitleAndDescription()
315  {
316  if (!is_object($this->object))
317  {
318  if ((int) $_REQUEST["crtptrefid"] > 0)
319  {
320  $cr_obj_id = ilObject::_lookupObjId((int) $_REQUEST["crtcb"]);
321  $this->tpl->setTitle(ilObject::_lookupTitle($cr_obj_id));
322  $this->tpl->setTitleIcon(ilObject::_getIcon($cr_obj_id));
323  }
324  return;
325  }
326  $this->tpl->setTitle($this->object->getPresentationTitle());
327  $this->tpl->setDescription($this->object->getLongDescription());
328 
329  if (strtolower($_GET["baseClass"]) == "iladministrationgui")
330  {
331  // alt text would be same as heading -> empty alt text
332  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_".$this->object->getType()."_b.png"),
333  "");
334  }
335  else
336  {
337  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_".$this->object->getType()."_b.png"),
338  $this->lng->txt("obj_" . $this->object->getType()));
339  }
340 
341  include_once './Services/Object/classes/class.ilObjectListGUIFactory.php';
342  $lgui = ilObjectListGUIFactory::_getListGUIByType($this->object->getType());
343  $lgui->initItem($this->object->getRefId(), $this->object->getId());
344  $this->tpl->setAlertProperties($lgui->getAlertProperties());
345  }
346 
354  protected function initHeaderAction($a_sub_type = null, $a_sub_id = null)
355  {
356  global $ilAccess;
357 
358  if(!$this->creation_mode && $this->object)
359  {
360  include_once "Services/Object/classes/class.ilCommonActionDispatcherGUI.php";
362  $ilAccess, $this->object->getType(), $this->ref_id, $this->object->getId());
363 
364  $dispatcher->setSubObject($a_sub_type, $a_sub_id);
365 
366  include_once "Services/Object/classes/class.ilObjectListGUI.php";
367  ilObjectListGUI::prepareJSLinks($this->ctrl->getLinkTarget($this, "redrawHeaderAction", "", true),
368  $this->ctrl->getLinkTargetByClass(array("ilcommonactiondispatchergui", "ilnotegui"), "", "", true, false),
369  $this->ctrl->getLinkTargetByClass(array("ilcommonactiondispatchergui", "iltagginggui"), "", "", true, false));
370 
371  $lg = $dispatcher->initHeaderAction();
372 
373  if (is_object($lg))
374  {
375  // to enable add to desktop / remove from desktop
376  if($this instanceof ilDesktopItemHandling)
377  {
378  $lg->setContainerObject($this);
379  }
380 
381  // comments settings are always on (for the repository)
382  // should only be shown if active or permission to toggle
383  include_once "Services/Notes/classes/class.ilNote.php";
384  if($ilAccess->checkAccess("write", "", $this->ref_id) ||
385  $ilAccess->checkAccess("edit_permissions", "", $this->ref_id) ||
386  ilNote::commentsActivated($this->object->getId(), 0, $this->object->getType()))
387  {
388  $lg->enableComments(true);
389  }
390 
391  $lg->enableNotes(true);
392  $lg->enableTags(true);
393  }
394 
395  return $lg;
396  }
397  }
398 
404  protected function insertHeaderAction($a_list_gui)
405  {
406  if(is_object($a_list_gui))
407  {
408  $this->tpl->setHeaderActionMenu($a_list_gui->getHeaderAction());
409  }
410  }
411 
415  protected function addHeaderAction()
416  {
417  $this->insertHeaderAction($this->initHeaderAction());
418  }
419 
423  protected function redrawHeaderActionObject()
424  {
425  $lg = $this->initHeaderAction();
426  echo $lg->getHeaderAction();
427  exit;
428  }
429 
430  // BEGIN WebDAV: Show Mount Webfolder Icon.
431  final private function showMountWebfolderIcon()
432  {
433  global $tree, $tpl, $objDefinition;
434 
435  if ($this->object->getRefId() == "")
436  {
437  return;
438  }
439 
440  $tpl->setMountWebfolderIcon($this->object->getRefId());
441  }
442  // END WebDAV: Show Mount Webfolder Icon.
443 
444 
449  protected function setTabs()
450  {
451  $this->getTabs($this->tabs_gui);
452  }
453 
458  protected final function setAdminTabs()
459  {
460  $this->getAdminTabs($this->tabs_gui);
461  }
462 
466  function getAdminTabs(&$tabs_gui)
467  {
468  global $tree;
469 
470  if ($_GET["admin_mode"] == "repository")
471  {
472  $this->ctrl->setParameterByClass("iladministrationgui", "admin_mode", "settings");
473  $tabs_gui->setBackTarget($this->lng->txt("administration"),
474  $this->ctrl->getLinkTargetByClass("iladministrationgui", "frameset"),
475  ilFrameTargetInfo::_getFrame("MainContent"));
476  $this->ctrl->setParameterByClass("iladministrationgui", "admin_mode", "repository");
477  }
478 
479  if ($this->checkPermissionBool("visible,read"))
480  {
481  $tabs_gui->addTarget("view",
482  $this->ctrl->getLinkTarget($this, "view"), array("", "view"), get_class($this));
483 
484  }
485 
486  if ($this->checkPermissionBool("edit_permission"))
487  {
488  $tabs_gui->addTarget("perm_settings",
489  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), "", "ilpermissiongui");
490  }
491 
492  if ($tree->getSavedNodeData($this->object->getRefId()))
493  {
494  $tabs_gui->addTarget("trash",
495  $this->ctrl->getLinkTarget($this, "trash"), "trash", get_class($this));
496  }
497  }
498 
499 
500  function getHTML()
501  {
502  return $this->html;
503  }
504 
505 
512  final private function setActions($a_actions = "")
513  {
514  if (is_array($a_actions))
515  {
516  foreach ($a_actions as $name => $lng)
517  {
518  $this->actions[$name] = array("name" => $name, "lng" => $lng);
519  }
520  }
521  else
522  {
523  $this->actions = "";
524  }
525  }
526 
533  final private function setSubObjects($a_sub_objects = "")
534  {
535  if (is_array($a_sub_objects))
536  {
537  foreach ($a_sub_objects as $name => $options)
538  {
539  $this->sub_objects[$name] = array("name" => $name, "max" => $options["max"]);
540  }
541  }
542  else
543  {
544  $this->sub_objects = "";
545  }
546  }
547 
556  protected function setLocator()
557  {
558  global $ilLocator, $tpl;
559 
560  if ($this->omit_locator)
561  {
562  return;
563  }
564 
565  // repository vs. workspace
566  if($this->call_by_reference)
567  {
568  // todo: admin workaround
569  // in the future, objectgui classes should not be called in
570  // admin section anymore (rbac/trash handling in own classes)
571  $ref_id = ($_GET["ref_id"] != "")
572  ? $_GET["ref_id"]
573  : $this->object->getRefId();
574  $ilLocator->addRepositoryItems($ref_id);
575  }
576 
577  if(!$this->creation_mode)
578  {
579  $this->addLocatorItems();
580  }
581 
582  // not so nice workaround: todo: handle $ilLocator as tabs in ilTemplate
583  if ($_GET["admin_mode"] == "" &&
584  strtolower($this->ctrl->getCmdClass()) == "ilobjrolegui")
585  {
586  $this->ctrl->setParameterByClass("ilobjrolegui",
587  "rolf_ref_id", $_GET["rolf_ref_id"]);
588  $this->ctrl->setParameterByClass("ilobjrolegui",
589  "obj_id", $_GET["obj_id"]);
590  $ilLocator->addItem($this->lng->txt("role"),
591  $this->ctrl->getLinkTargetByClass(array("ilpermissiongui",
592  "ilobjrolegui"), "perm"));
593  }
594 
595  $tpl->setLocator();
596  }
597 
602  protected function addLocatorItems()
603  {
604  }
605 
606  protected function omitLocator($a_omit = true)
607  {
608  $this->omit_locator = $a_omit;
609  }
610 
615  protected function addAdminLocatorItems()
616  {
617  global $ilLocator;
618 
619  if ($_GET["admin_mode"] == "settings") // system settings
620  {
621  $this->ctrl->setParameterByClass("iladministrationgui",
622  "ref_id", SYSTEM_FOLDER_ID);
623  $ilLocator->addItem($this->lng->txt("administration"),
624  $this->ctrl->getLinkTargetByClass("iladministrationgui", "frameset"),
625  ilFrameTargetInfo::_getFrame("MainContent"));
626  if ($this->object->getRefId() != SYSTEM_FOLDER_ID)
627  {
628  $ilLocator->addItem($this->object->getTitle(),
629  $this->ctrl->getLinkTarget($this, "view"));
630  }
631  $this->ctrl->setParameterByClass("iladministrationgui",
632  "ref_id", $this->object->getRefId());
633  }
634  else // repository administration
635  {
636  $this->ctrl->setParameterByClass("iladministrationgui",
637  "ref_id", "");
638  $this->ctrl->setParameterByClass("iladministrationgui",
639  "admin_mode", "settings");
640  //$ilLocator->addItem($this->lng->txt("administration"),
641  // $this->ctrl->getLinkTargetByClass("iladministrationgui", "frameset"),
642  // ilFrameTargetInfo::_getFrame("MainContent"));
643  $this->ctrl->clearParametersByClass("iladministrationgui");
644  $ilLocator->addAdministrationItems();
645  }
646 
647  }
648 
653  public function confirmedDeleteObject()
654  {
655  global $ilSetting, $lng;
656 
657  if(isset($_POST["mref_id"]))
658  {
659  $_SESSION["saved_post"] = array_unique(array_merge($_SESSION["saved_post"], $_POST["mref_id"]));
660  }
661 
662  include_once("./Services/Repository/classes/class.ilRepUtilGUI.php");
663  $ru = new ilRepUtilGUI($this);
664  $ru->deleteObjects($_GET["ref_id"], ilSession::get("saved_post"));
665  ilSession::clear("saved_post");
666  $this->ctrl->returnToParent($this);
667  }
668 
674  public function cancelDeleteObject()
675  {
676  ilSession::clear("saved_post");
677  $this->ctrl->returnToParent($this);
678  }
679 
680 
686  public function cancelObject($in_rep = false)
687  {
688  ilSession::clear("saved_post");
689  $this->ctrl->returnToParent($this);
690  }
691 
697  public function createObject()
698  {
699  global $tpl, $ilErr;
700 
701  $new_type = $_REQUEST["new_type"];
702 
703 
704  // add new object to custom parent container
705  $this->ctrl->saveParameter($this, "crtptrefid");
706  // use forced callback after object creation
707  $this->ctrl->saveParameter($this, "crtcb");
708 
709  if (!$this->checkPermissionBool("create", "", $new_type))
710  {
711  $ilErr->raiseError($this->lng->txt("permission_denied"),$ilErr->MESSAGE);
712  }
713  else
714  {
715  $this->lng->loadLanguageModule($new_type);
716  $this->ctrl->setParameter($this, "new_type", $new_type);
717 
718  $forms = $this->initCreationForms($new_type);
719 
720  // copy form validation error: do not show other creation forms
721  if($_GET["cpfl"] && isset($forms[self::CFORM_CLONE]))
722  {
723  $forms = array(self::CFORM_CLONE => $forms[self::CFORM_CLONE]);
724  }
725 
726  $tpl->setContent($this->getCreationFormsHTML($forms));
727  }
728  }
729 
738  protected function initCreationForms($a_new_type)
739  {
740  $forms = array(
741  self::CFORM_NEW => $this->initCreateForm($a_new_type),
742  self::CFORM_IMPORT => $this->initImportForm($a_new_type),
743  self::CFORM_CLONE => $this->fillCloneTemplate(null, $a_new_type)
744  );
745 
746  return $forms;
747  }
748 
754  final protected function getCreationFormsHTML(array $a_forms)
755  {
756  global $tpl;
757 
758  // #13168 - sanity check
759  foreach($a_forms as $id => $form)
760  {
761  if(!$form instanceof ilPropertyFormGUI)
762  {
763  unset($a_forms[$id]);
764  }
765  }
766 
767  // no accordion if there is just one form
768  if(sizeof($a_forms) == 1)
769  {
770  $a_forms = array_shift($a_forms);
771  return $a_forms->getHTML();
772  }
773  else
774  {
775  include_once("./Services/Accordion/classes/class.ilAccordionGUI.php");
776 
777  $acc = new ilAccordionGUI();
778  $acc->setBehaviour(ilAccordionGUI::FIRST_OPEN);
779  $cnt = 1;
780  foreach ($a_forms as $form_type => $cf)
781  {
782  $htpl = new ilTemplate("tpl.creation_acc_head.html", true, true, "Services/Object");
783 // $htpl->setVariable("IMG_ARROW", ilUtil::getImagePath("accordion_arrow.png"));
784 
785  // using custom form titles (used for repository plugins)
786  $form_title = "";
787  if(method_exists($this, "getCreationFormTitle"))
788  {
789  $form_title = $this->getCreationFormTitle($form_type);
790  }
791  if(!$form_title)
792  {
793  $form_title = $cf->getTitle();
794  }
795 
796  // move title from form to accordion
797  $htpl->setVariable("TITLE", $this->lng->txt("option")." ".$cnt.": ".
798  $form_title);
799  $cf->setTitle(null);
800  $cf->setTitleIcon(null);
801  $cf->setTableWidth("100%");
802 
803  $acc->addItem($htpl->get(), $cf->getHTML());
804 
805  $cnt++;
806  }
807 
808  return "<div class='ilCreationFormSection'>".$acc->getHTML()."</div>";
809  }
810  }
811 
818  protected function initCreateForm($a_new_type)
819  {
820  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
821  $form = new ilPropertyFormGUI();
822  $form->setTarget("_top");
823  $form->setFormAction($this->ctrl->getFormAction($this, "save"));
824  $form->setTitle($this->lng->txt($a_new_type."_new"));
825 
826  // title
827  $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
828  $ti->setMaxLength(128);
829  $ti->setSize(40);
830  $ti->setRequired(true);
831  $form->addItem($ti);
832 
833  // description
834  $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
835  $ta->setCols(40);
836  $ta->setRows(2);
837  $form->addItem($ta);
838 
839  $form = $this->initDidacticTemplate($form);
840 
841  $form->addCommandButton("save", $this->lng->txt($a_new_type."_add"));
842  $form->addCommandButton("cancel", $this->lng->txt("cancel"));
843 
844  return $form;
845  }
846 
852  protected function initDidacticTemplate(ilPropertyFormGUI $form)
853  {
854  global $lng;
855 
856  $lng->loadLanguageModule('didactic');
857 
858  $options = array();
859  $options['dtpl_0'] = array($this->lng->txt('didactic_default_type'),
860  sprintf(
861  $this->lng->txt('didactic_default_type_info'),
862  $this->lng->txt('objs_'.$this->type)
863  ));
864 
865  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateSettings.php';
866  $templates = ilDidacticTemplateSettings::getInstanceByObjectType($this->type)->getTemplates();
867  if($templates)
868  {
869  foreach($templates as $template)
870  {
871  $options["dtpl_".$template->getId()] = array($template->getTitle(),
872  $template->getDescription());
873  }
874  }
875 
876  $this->addDidacticTemplateOptions($options);
877 
878  if(sizeof($options) > 1)
879  {
880  $type = new ilRadioGroupInputGUI(
881  $this->lng->txt('type'),
882  'didactic_type'
883  );
884  // workaround for containers in edit mode
885  if(!$this->getCreationMode())
886  {
887  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php';
888  $type->setValue(
889  'dtpl_'.ilDidacticTemplateObjSettings::lookupTemplateId($this->object->getRefId())
890  );
891  }
892  else
893  {
894  $type->setValue('dtpl_0');
895  }
896  $form->addItem($type);
897 
898  ilUtil::sortArray($options, 0);
899  foreach($options as $id => $data)
900  {
901  $option = new ilRadioOption($data[0], $id, $data[1]);
902  $type->addOption($option);
903  }
904  }
905 
906  return $form;
907  }
908 
914  protected function addDidacticTemplateOptions(array &$a_options)
915  {
916 
917  }
918 
922  public function cancelCreation()
923  {
924  global $ilCtrl;
925 
926  $ilCtrl->redirectByClass("ilrepositorygui", "frameset");
927  }
928 
934  public function saveObject()
935  {
936  global $objDefinition, $tpl;
937 
938  $new_type = $_REQUEST["new_type"];
939 
940  // create permission is already checked in createObject. This check here is done to prevent hacking attempts
941  if (!$this->checkPermissionBool("create", "", $new_type))
942  {
943  $this->ilias->raiseError($this->lng->txt("no_create_permission"), $this->ilias->error_obj->MESSAGE);
944  }
945 
946  $this->lng->loadLanguageModule($new_type);
947  $this->ctrl->setParameter($this, "new_type", $new_type);
948 
949  $form = $this->initCreateForm($new_type);
950  if ($form->checkInput())
951  {
952  $this->ctrl->setParameter($this, "new_type", "");
953 
954  // create instance
955  $class_name = "ilObj".$objDefinition->getClassName($new_type);
956  $location = $objDefinition->getLocation($new_type);
957  include_once($location."/class.".$class_name.".php");
958  $newObj = new $class_name();
959  $newObj->setType($new_type);
960  $newObj->setTitle($form->getInput("title"));
961  $newObj->setDescription($form->getInput("desc"));
962  $newObj->create();
963 
964  $this->putObjectInTree($newObj);
965 
966  // apply didactic template?
967  $dtpl = $this->getDidacticTemplateVar("dtpl");
968  if($dtpl)
969  {
970  $newObj->applyDidacticTemplate($dtpl);
971  }
972 
973  // additional paramters are added to afterSave()
974  $args = func_get_args();
975  if($args)
976  {
977  $this->afterSave($newObj, $args);
978  }
979  else
980  {
981  $this->afterSave($newObj);
982  }
983  return;
984  }
985 
986  // display only this form to correct input
987  $form->setValuesByPost();
988  $tpl->setContent($form->getHtml());
989  }
990 
997  protected function getDidacticTemplateVar($a_type)
998  {
999  $tpl = $_POST["didactic_type"];
1000  if($tpl && substr($tpl, 0, strlen($a_type)+1) == $a_type."_")
1001  {
1002  return (int)substr($tpl, strlen($a_type)+1);
1003  }
1004  }
1005 
1012  protected function putObjectInTree(ilObject $a_obj, $a_parent_node_id = null)
1013  {
1014  global $rbacreview, $ilUser, $objDefinition;
1015 
1016  if(!$a_parent_node_id)
1017  {
1018  $a_parent_node_id = $_GET["ref_id"];
1019  }
1020 
1021  // add new object to custom parent container
1022  if((int)$_REQUEST["crtptrefid"])
1023  {
1024  $a_parent_node_id = (int)$_REQUEST["crtptrefid"];
1025  }
1026 
1027  $a_obj->createReference();
1028  $a_obj->putInTree($a_parent_node_id);
1029  $a_obj->setPermissions($a_parent_node_id);
1030 
1031  $this->obj_id = $a_obj->getId();
1032  $this->ref_id = $a_obj->getRefId();
1033 
1034  // BEGIN ChangeEvent: Record save object.
1035  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
1036  ilChangeEvent::_recordWriteEvent($this->obj_id, $ilUser->getId(), 'create');
1037  // END ChangeEvent: Record save object.
1038 
1039  // rbac log
1040  include_once "Services/AccessControl/classes/class.ilRbacLog.php";
1041  $rbac_log_roles = $rbacreview->getParentRoleIds($this->ref_id, false);
1042  $rbac_log = ilRbacLog::gatherFaPa($this->ref_id, array_keys($rbac_log_roles), true);
1043  ilRbacLog::add(ilRbacLog::CREATE_OBJECT, $this->ref_id, $rbac_log);
1044 
1045  // use forced callback after object creation
1046  if($_REQUEST["crtcb"])
1047  {
1048  $callback_type = ilObject::_lookupType((int)$_REQUEST["crtcb"], true);
1049  $class_name = "ilObj".$objDefinition->getClassName($callback_type)."GUI";
1050  $location = $objDefinition->getLocation($callback_type);
1051  include_once($location."/class.".$class_name.".php");
1052  if (in_array(strtolower($class_name), array("ilobjitemgroupgui")))
1053  {
1054  $callback_obj = new $class_name((int)$_REQUEST["crtcb"]);
1055  }
1056  else
1057  {
1058  // #10368
1059  $callback_obj = new $class_name(null, (int)$_REQUEST["crtcb"], true, false);
1060  }
1061  $callback_obj->afterSaveCallback($a_obj);
1062  }
1063  }
1064 
1070  protected function afterSave(ilObject $a_new_object)
1071  {
1072  ilUtil::sendSuccess($this->lng->txt("object_added"), true);
1073  $this->ctrl->returnToParent($this);
1074  }
1075 
1081  public function editObject()
1082  {
1083  global $tpl, $ilTabs;
1084 
1085  if (!$this->checkPermissionBool("write"))
1086  {
1087  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
1088  }
1089 
1090  $ilTabs->activateTab("settings");
1091 
1092  $form = $this->initEditForm();
1093  $values = $this->getEditFormValues();
1094  if($values)
1095  {
1096  $form->setValuesByArray($values);
1097  }
1098  $tpl->setContent($form->getHTML());
1099  }
1100 
1106  protected function initEditForm()
1107  {
1108  global $lng, $ilCtrl;
1109 
1110  $lng->loadLanguageModule($this->object->getType());
1111 
1112  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1113  $form = new ilPropertyFormGUI();
1114  $form->setFormAction($this->ctrl->getFormAction($this, "update"));
1115  $form->setTitle($this->lng->txt($this->object->getType()."_edit"));
1116 
1117  // title
1118  $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
1119  $ti->setMaxLength(128);
1120  $ti->setSize(40);
1121  $ti->setRequired(true);
1122  $form->addItem($ti);
1123 
1124  // description
1125  $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
1126  $ta->setCols(40);
1127  $ta->setRows(2);
1128  $form->addItem($ta);
1129 
1130  $this->initEditCustomForm($form);
1131 
1132  $form->addCommandButton("update", $this->lng->txt("save"));
1133  //$this->form->addCommandButton("cancelUpdate", $lng->txt("cancel"));
1134 
1135  return $form;
1136  }
1137 
1143  protected function initEditCustomForm(ilPropertyFormGUI $a_form)
1144  {
1145 
1146  }
1147 
1153  protected function getEditFormValues()
1154  {
1155  $values["title"] = $this->object->getTitle();
1156  $values["desc"] = $this->object->getLongDescription();
1157  $this->getEditFormCustomValues($values);
1158  return $values;
1159  }
1160 
1166  protected function getEditFormCustomValues(array &$a_values)
1167  {
1168 
1169  }
1170 
1174  public function updateObject()
1175  {
1176  global $ilTabs, $tpl;
1177 
1178  if (!$this->checkPermissionBool("write"))
1179  {
1180  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
1181  }
1182 
1183  $form = $this->initEditForm();
1184  if($form->checkInput())
1185  {
1186  $this->object->setTitle($form->getInput("title"));
1187  $this->object->setDescription($form->getInput("desc"));
1188  $this->updateCustom($form);
1189  $this->object->update();
1190 
1191  $this->afterUpdate();
1192  return;
1193  }
1194 
1195  // display form again to correct errors
1196  $ilTabs->activateTab("settings");
1197  $form->setValuesByPost();
1198  $tpl->setContent($form->getHtml());
1199  }
1200 
1206  protected function updateCustom(ilPropertyFormGUI $a_form)
1207  {
1208 
1209  }
1210 
1214  protected function afterUpdate()
1215  {
1216  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
1217  $this->ctrl->redirect($this, "edit");
1218  }
1219 
1226  protected function initImportForm($a_new_type)
1227  {
1228  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1229  $form = new ilPropertyFormGUI();
1230  $form->setTarget("_top");
1231  $form->setFormAction($this->ctrl->getFormAction($this, "importFile"));
1232  $form->setTitle($this->lng->txt($a_new_type."_import"));
1233 
1234  include_once("./Services/Form/classes/class.ilFileInputGUI.php");
1235  $fi = new ilFileInputGUI($this->lng->txt("import_file"), "importfile");
1236  $fi->setSuffixes(array("zip"));
1237  $fi->setRequired(true);
1238  $form->addItem($fi);
1239 
1240  $form->addCommandButton("importFile", $this->lng->txt("import"));
1241  $form->addCommandButton("cancel", $this->lng->txt("cancel"));
1242 
1243  return $form;
1244  }
1245 
1249  protected function importFileObject($parent_id = null)
1250  {
1251  global $objDefinition, $tpl, $ilErr;
1252 
1253  if(!$parent_id)
1254  {
1255  $parent_id = $_GET["ref_id"];
1256  }
1257  $new_type = $_REQUEST["new_type"];
1258 
1259  // create permission is already checked in createObject. This check here is done to prevent hacking attempts
1260  if (!$this->checkPermissionBool("create", "", $new_type))
1261  {
1262  $ilErr->raiseError($this->lng->txt("no_create_permission"));
1263  }
1264 
1265  $this->lng->loadLanguageModule($new_type);
1266  $this->ctrl->setParameter($this, "new_type", $new_type);
1267 
1268  $form = $this->initImportForm($new_type);
1269  if ($form->checkInput())
1270  {
1271  // :todo: make some check on manifest file
1272 
1273  if($objDefinition->isContainer($new_type))
1274  {
1275  include_once './Services/Export/classes/class.ilImportContainer.php';
1276  $imp = new ilImportContainer((int)$parent_id);
1277  }
1278  else
1279  {
1280  include_once("./Services/Export/classes/class.ilImport.php");
1281  $imp = new ilImport((int)$parent_id);
1282  }
1283 
1284  $new_id = $imp->importObject(null, $_FILES["importfile"]["tmp_name"],
1285  $_FILES["importfile"]["name"], $new_type);
1286 
1287  if ($new_id > 0)
1288  {
1289  $this->ctrl->setParameter($this, "new_type", "");
1290 
1291  $newObj = ilObjectFactory::getInstanceByObjId($new_id);
1292 
1293  // put new object id into tree - already done in import for containers
1294  if(!$objDefinition->isContainer($new_type))
1295  {
1296  $this->putObjectInTree($newObj);
1297  }
1298 
1299  $this->afterImport($newObj);
1300  }
1301  // import failed
1302  else
1303  {
1304  if($objDefinition->isContainer($new_type))
1305  {
1306  ilUtil::sendFailure($this->lng->txt("container_import_zip_file_invalid"));
1307  }
1308  else
1309  {
1310  // not enough information here...
1311  return;
1312  }
1313  }
1314  }
1315 
1316  // display form to correct errors
1317  $form->setValuesByPost();
1318  $tpl->setContent($form->getHtml());
1319  }
1320 
1326  protected function afterImport(ilObject $a_new_object)
1327  {
1328  ilUtil::sendSuccess($this->lng->txt("object_added"), true);
1329  $this->ctrl->returnToParent($this);
1330  }
1331 
1340  public function getFormAction($a_cmd, $a_formaction = "")
1341  {
1342  if ($this->formaction[$a_cmd] != "")
1343  {
1344  return $this->formaction[$a_cmd];
1345  }
1346  else
1347  {
1348  return $a_formaction;
1349  }
1350  }
1351 
1360  protected function setFormAction($a_cmd, $a_formaction)
1361  {
1362  $this->formaction[$a_cmd] = $a_formaction;
1363  }
1364 
1372  protected function getReturnLocation($a_cmd, $a_location ="")
1373  {
1374  if ($this->return_location[$a_cmd] != "")
1375  {
1376  return $this->return_location[$a_cmd];
1377  }
1378  else
1379  {
1380  return $a_location;
1381  }
1382  }
1383 
1391  protected function setReturnLocation($a_cmd, $a_location)
1392  {
1393 //echo "-".$a_cmd."-".$a_location."-";
1394  $this->return_location[$a_cmd] = $a_location;
1395  }
1396 
1404  protected function getTargetFrame($a_cmd, $a_target_frame = "")
1405  {
1406  if ($this->target_frame[$a_cmd] != "")
1407  {
1408  return $this->target_frame[$a_cmd];
1409  }
1410  elseif (!empty($a_target_frame))
1411  {
1412  return "target=\"".$a_target_frame."\"";
1413  }
1414  else
1415  {
1416  return;
1417  }
1418  }
1419 
1427  protected function setTargetFrame($a_cmd, $a_target_frame)
1428  {
1429  $this->target_frame[$a_cmd] = "target=\"".$a_target_frame."\"";
1430  }
1431 
1432  // BEGIN Security: Hide objects which aren't accessible by the user.
1433  public function isVisible($a_ref_id,$a_type)
1434  {
1435  global $ilBench;
1436 
1437  $ilBench->start("Explorer", "setOutput_isVisible");
1438  $visible = $this->checkPermissionBool("visible,read", "", "", $a_ref_id);
1439 
1440  if ($visible && $a_type == 'crs') {
1441  global $tree;
1442  if($crs_id = $tree->checkForParentType($a_ref_id,'crs'))
1443  {
1444  if(!$this->checkPermissionBool("write", "", "", $crs_id))
1445  {
1446  // Show only activated courses
1447  $tmp_obj =& ilObjectFactory::getInstanceByRefId($crs_id,false);
1448 
1449  if(!$tmp_obj->isActivated())
1450  {
1451  unset($tmp_obj);
1452  $visible = false;
1453  }
1454  if(($crs_id != $a_ref_id) and $tmp_obj->isArchived())
1455  {
1456  $visible = false;
1457  }
1458  }
1459  }
1460  }
1461 
1462  $ilBench->stop("Explorer", "setOutput_isVisible");
1463 
1464  return $visible;
1465  }
1466  // END Security: Hide objects which aren't accessible by the user.
1467 
1473  public function viewObject()
1474  {
1475  global$tpl;
1476 
1477  if (!$this->checkPermissionBool("visible,read"))
1478  {
1479  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
1480  }
1481 
1482  // BEGIN ChangeEvent: record read event.
1483  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
1484  global $ilUser;
1486  $this->object->getType(),
1487  $this->object->getRefId(),
1488  $this->object->getId(), $ilUser->getId());
1489  // END ChangeEvent: record read event.
1490 
1491  include_once("./Services/Repository/classes/class.ilAdminSubItemsTableGUI.php");
1492  if (!$this->call_by_reference)
1493  {
1494  $this->ctrl->setParameter($this, "obj_id", $this->obj_id);
1495  }
1496  $itab = new ilAdminSubItemsTableGUI($this, "view", $_GET["ref_id"]);
1497 
1498  $tpl->setContent($itab->getHTML());
1499  }
1500 
1508  public function deleteObject($a_error = false)
1509  {
1510  global $tpl, $ilCtrl;
1511 
1512  if ($_GET["item_ref_id"] != "")
1513  {
1514  $_POST["id"] = array($_GET["item_ref_id"]);
1515  }
1516 
1517  if(is_array($_POST["id"]))
1518  {
1519  foreach($_POST["id"] as $idx => $id)
1520  {
1521  $_POST["id"][$idx] = (int)$id;
1522  }
1523  }
1524 
1525  // SAVE POST VALUES (get rid of this
1526  ilSession::set("saved_post", $_POST["id"]);
1527 
1528  include_once("./Services/Repository/classes/class.ilRepUtilGUI.php");
1529  $ru = new ilRepUtilGUI($this);
1530  if (!$ru->showDeleteConfirmation($_POST["id"], $a_error))
1531  {
1532  $ilCtrl->returnToParent($this);
1533  }
1534  }
1535 
1541  protected function showPossibleSubObjects()
1542  {
1543  if ($this->sub_objects == "")
1544  {
1545  $d = $this->objDefinition->getCreatableSubObjects($this->object->getType());
1546  }
1547  else
1548  {
1550  }
1551 
1552  $import = false;
1553 
1554  if (count($d) > 0)
1555  {
1556  foreach ($d as $row)
1557  {
1558  $count = 0;
1559 
1560  if ($row["max"] > 0)
1561  {
1562  //how many elements are present?
1563  for ($i=0; $i<count($this->data["ctrl"]); $i++)
1564  {
1565  if ($this->data["ctrl"][$i]["type"] == $row["name"])
1566  {
1567  $count++;
1568  }
1569  }
1570  }
1571 
1572  if ($row["max"] == "" || $count < $row["max"])
1573  {
1574  $subobj[] = $row["name"];
1575  }
1576  }
1577  }
1578 
1579  if (is_array($subobj))
1580  {
1581 
1582  //build form
1583  $opts = ilUtil::formSelect(12,"new_type",$subobj);
1584  $this->tpl->setCurrentBlock("add_object");
1585  $this->tpl->setVariable("SELECT_OBJTYPE", $opts);
1586  $this->tpl->setVariable("BTN_NAME", "create");
1587  $this->tpl->setVariable("TXT_ADD", $this->lng->txt("add"));
1588  $this->tpl->parseCurrentBlock();
1589  }
1590  }
1591 
1600  final protected function getTemplateFile($a_cmd,$a_type = "")
1601  {
1602  mk(); die("ilObjectGUI::getTemplateFile() is deprecated.");
1603  }
1604 
1613  protected function getTitlesByRefId($a_ref_ids)
1614  {
1615  foreach ($a_ref_ids as $id)
1616  {
1617  // GET OBJECT TITLE
1618  $tmp_obj =& $this->ilias->obj_factory->getInstanceByRefId($id);
1619  $title[] = $tmp_obj->getTitle();
1620  unset($tmp_obj);
1621  }
1622 
1623  return $title ? $title : array();
1624  }
1625 
1633  protected function getTabs(&$tabs_gui)
1634  {
1635  // please define your tabs here
1636 
1637  }
1638 
1639  // PROTECTED
1640  protected function __showButton($a_cmd,$a_text,$a_target = '')
1641  {
1642  global $ilToolbar;
1643 
1644  $ilToolbar->addButton($a_text, $this->ctrl->getLinkTarget($this, $a_cmd), $a_target);
1645  }
1646 
1647  protected function hitsperpageObject()
1648  {
1649  ilSession::set("tbl_limit", $_POST["hitsperpage"]);
1650  $_GET["limit"] = $_POST["hitsperpage"];
1651  }
1652 
1653 
1654  protected function &__initTableGUI()
1655  {
1656  include_once "./Services/Table/classes/class.ilTableGUI.php";
1657 
1658  return new ilTableGUI(0,false);
1659  }
1660 
1666  protected function __setTableGUIBasicData(&$tbl,&$result_set,$a_from = "")
1667  {
1668  switch ($a_from)
1669  {
1670  case "clipboardObject":
1671  $offset = $_GET["offset"];
1672  $order = $_GET["sort_by"];
1673  $direction = $_GET["sort_order"];
1674  $tbl->disable("footer");
1675  break;
1676 
1677  default:
1678  $offset = $_GET["offset"];
1679  $order = $_GET["sort_by"];
1680  $direction = $_GET["sort_order"];
1681  break;
1682  }
1683 
1684  $tbl->setOrderColumn($order);
1685  $tbl->setOrderDirection($direction);
1686  $tbl->setOffset($offset);
1687  $tbl->setLimit($_GET["limit"]);
1688  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
1689  $tbl->setData($result_set);
1690  }
1691 
1692  protected function __showClipboardTable($a_result_set,$a_from = "")
1693  {
1694  global $ilCtrl;
1695 
1696  $tbl =& $this->__initTableGUI();
1697  $tpl =& $tbl->getTemplateObject();
1698 
1699  $tpl->setCurrentBlock("tbl_form_header");
1700  $tpl->setVariable("FORMACTION", $ilCtrl->getFormAction($this));
1701  $tpl->parseCurrentBlock();
1702 
1703  $tpl->setCurrentBlock("tbl_action_btn");
1704  $tpl->setVariable("BTN_NAME","paste");
1705  $tpl->setVariable("BTN_VALUE",$this->lng->txt("insert_object_here"));
1706  $tpl->parseCurrentBlock();
1707 
1708  $tpl->setCurrentBlock("tbl_action_btn");
1709  $tpl->setVariable("BTN_NAME","clear");
1710  $tpl->setVariable("BTN_VALUE",$this->lng->txt("clear_clipboard"));
1711  $tpl->parseCurrentBlock();
1712 
1713  $tpl->setCurrentBlock("tbl_action_row");
1714  $tpl->setVariable("COLUMN_COUNTS",3);
1715  $tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("spacer.png"));
1716  $tpl->parseCurrentBlock();
1717 
1718  $tbl->setTitle($this->lng->txt("clipboard"),"icon_typ_b.png",$this->lng->txt("clipboard"));
1719  $tbl->setHeaderNames(array($this->lng->txt('obj_type'),
1720  $this->lng->txt('title'),
1721  $this->lng->txt('action')));
1722  $tbl->setHeaderVars(array('type',
1723  'title',
1724  'act'),
1725  array('ref_id' => $this->object->getRefId(),
1726  'cmd' => 'clipboard',
1727  'cmdClass' => $_GET['cmdClass'],
1728  'cmdNode' => $_GET['cmdNode']));
1729 
1730  $tbl->setColumnWidth(array("","80%","19%"));
1731 
1732 
1733  $this->__setTableGUIBasicData($tbl,$a_result_set,$a_from);
1734  $tbl->render();
1735 
1736  $this->tpl->setVariable("RESULT_TABLE",$tbl->tpl->get());
1737 
1738  return true;
1739  }
1740 
1750  protected function redirectToRefId($a_ref_id, $a_cmd = "")
1751  {
1752  $obj_type = ilObject::_lookupType($a_ref_id,true);
1753  $class_name = $this->objDefinition->getClassName($obj_type);
1754  $class = strtolower("ilObj".$class_name."GUI");
1755  $this->ctrl->setParameterByClass("ilrepositorygui", "ref_id", $a_ref_id);
1756  $this->ctrl->redirectByClass(array("ilrepositorygui", $class), $a_cmd);
1757  }
1758 
1759  // Object Cloning
1769  protected function fillCloneTemplate($a_tpl_varname,$a_type)
1770  {
1771  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
1772  $cp = new ilObjectCopyGUI($this);
1773  $cp->setType($a_type);
1774  $cp->setTarget($_GET['ref_id']);
1775  if($a_tpl_varname)
1776  {
1777  $cp->showSourceSearch($a_tpl_varname);
1778  }
1779  else
1780  {
1781  return $cp->showSourceSearch(null);
1782  }
1783  }
1784 
1791  public function cloneAllObject()
1792  {
1793  include_once('./Services/Link/classes/class.ilLink.php');
1794  include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
1795 
1796  global $ilErr,$ilUser;
1797 
1798  $new_type = $_REQUEST['new_type'];
1799  if(!$this->checkPermissionBool("create", "", $new_type))
1800  {
1801  $ilErr->raiseError($this->lng->txt('permission_denied'));
1802  }
1803  if(!(int) $_REQUEST['clone_source'])
1804  {
1805  ilUtil::sendFailure($this->lng->txt('select_one'));
1806  $this->createObject();
1807  return false;
1808  }
1809  if(!$this->checkPermissionBool("write", "", $new_type, (int)$_REQUEST['clone_source']))
1810  {
1811  $ilErr->raiseError($this->lng->txt('permission_denied'));
1812  }
1813 
1814  // Save wizard options
1816  $wizard_options = ilCopyWizardOptions::_getInstance($copy_id);
1817  $wizard_options->saveOwner($ilUser->getId());
1818  $wizard_options->saveRoot((int) $_REQUEST['clone_source']);
1819 
1820  $options = $_POST['cp_options'] ? $_POST['cp_options'] : array();
1821  foreach($options as $source_id => $option)
1822  {
1823  $wizard_options->addEntry($source_id,$option);
1824  }
1825  $wizard_options->read();
1826 
1827  $orig = ilObjectFactory::getInstanceByRefId((int) $_REQUEST['clone_source']);
1828  $new_obj = $orig->cloneObject((int) $_GET['ref_id'],$copy_id);
1829 
1830  // Delete wizard options
1831  $wizard_options->deleteAll();
1832 
1833  ilUtil::sendSuccess($this->lng->txt("object_duplicated"),true);
1834  ilUtil::redirect(ilLink::_getLink($new_obj->getRefId()));
1835  }
1836 
1837 
1841  protected function getCenterColumnHTML()
1842  {
1843  global $ilCtrl;
1844 
1845  include_once("Services/Block/classes/class.ilColumnGUI.php");
1846 
1847  $obj_id = ilObject::_lookupObjId($this->object->getRefId());
1848  $obj_type = ilObject::_lookupType($obj_id);
1849 
1850  if ($ilCtrl->getNextClass() != "ilcolumngui")
1851  {
1852  // normal command processing
1853  return $this->getContent();
1854  }
1855  else
1856  {
1857  if (!$ilCtrl->isAsynch())
1858  {
1859  //if ($column_gui->getScreenMode() != IL_SCREEN_SIDE)
1861  {
1862  // right column wants center
1864  {
1865  $column_gui = new ilColumnGUI($obj_type, IL_COL_RIGHT);
1866  $this->setColumnSettings($column_gui);
1867  $this->html = $ilCtrl->forwardCommand($column_gui);
1868  }
1869  // left column wants center
1871  {
1872  $column_gui = new ilColumnGUI($obj_type, IL_COL_LEFT);
1873  $this->setColumnSettings($column_gui);
1874  $this->html = $ilCtrl->forwardCommand($column_gui);
1875  }
1876  }
1877  else
1878  {
1879  // normal command processing
1880  return $this->getContent();
1881  }
1882  }
1883  }
1884  }
1885 
1889  protected function getRightColumnHTML()
1890  {
1891  global $ilUser, $lng, $ilCtrl;
1892 
1893  $obj_id = ilObject::_lookupObjId($this->object->getRefId());
1894  $obj_type = ilObject::_lookupType($obj_id);
1895 
1896  include_once("Services/Block/classes/class.ilColumnGUI.php");
1897  $column_gui = new ilColumnGUI($obj_type, IL_COL_RIGHT);
1898 
1899  if ($column_gui->getScreenMode() == IL_SCREEN_FULL)
1900  {
1901  return "";
1902  }
1903 
1904  $this->setColumnSettings($column_gui);
1905 
1906  if ($ilCtrl->getNextClass() == "ilcolumngui" &&
1907  $column_gui->getCmdSide() == IL_COL_RIGHT &&
1908  $column_gui->getScreenMode() == IL_SCREEN_SIDE)
1909  {
1910  $html = $ilCtrl->forwardCommand($column_gui);
1911  }
1912  else
1913  {
1914  if (!$ilCtrl->isAsynch())
1915  {
1916  $html = $ilCtrl->getHTML($column_gui);
1917  }
1918  }
1919 
1920  return $html;
1921  }
1922 
1926  protected function setColumnSettings($column_gui)
1927  {
1928  $column_gui->setRepositoryMode(true);
1929  $column_gui->setEnableEdit(false);
1930  if ($this->checkPermissionBool("write"))
1931  {
1932  $column_gui->setEnableEdit(true);
1933  }
1934  }
1935 
1945  protected function checkPermission($a_perm, $a_cmd = "", $a_type = "", $a_ref_id = null)
1946  {
1947  if (!$this->checkPermissionBool($a_perm, $a_cmd, $a_type, $a_ref_id))
1948  {
1949  if (!is_int(strpos($_SERVER["PHP_SELF"], "goto.php")))
1950  {
1951  // create: redirect to parent
1952  if($a_perm == "create")
1953  {
1954  if(!$a_ref_id)
1955  {
1956  $a_ref_id = $_GET["ref_id"];
1957  }
1958  $type = ilObject::_lookupType($a_ref_id, true);
1959  }
1960  else
1961  {
1962  // does this make sense?
1963  if (!is_object($this->object))
1964  {
1965  return;
1966  }
1967  if (!$a_ref_id)
1968  {
1969  $a_ref_id = $this->object->getRefId();
1970  }
1971  $type = $this->object->getType();
1972  }
1973 
1974  ilSession::clear("il_rep_ref_id");
1975  ilUtil::sendFailure($this->lng->txt("permission_denied"), true);
1976  ilUtil::redirect("goto.php?target=".$type."_".$a_ref_id);
1977  }
1978  // we should never be here
1979  else
1980  {
1981  die("Permission Denied.");
1982  }
1983  }
1984  }
1985 
1995  protected function checkPermissionBool($a_perm, $a_cmd = "", $a_type = "", $a_ref_id = null)
1996  {
1997  global $ilAccess;
1998 
1999  if($a_perm == "create")
2000  {
2001  if(!$a_ref_id)
2002  {
2003  $a_ref_id = $_GET["ref_id"];
2004  }
2005  return $ilAccess->checkAccess($a_perm."_".$a_type, $a_cmd, $a_ref_id);
2006  }
2007  else
2008  {
2009  // does this make sense?
2010  if (!is_object($this->object))
2011  {
2012  return false;
2013  }
2014  if (!$a_ref_id)
2015  {
2016  $a_ref_id = $this->object->getRefId();
2017  }
2018  return $ilAccess->checkAccess($a_perm, $a_cmd, $a_ref_id);
2019  }
2020  }
2021 
2028  static function _gotoRepositoryRoot($a_raise_error = false)
2029  {
2030  global $ilAccess, $ilErr;
2031 
2032  if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
2033  {
2034  $_GET["cmd"] = "frameset";
2035  $_GET["target"] = "";
2036  $_GET["ref_id"] = ROOT_FOLDER_ID;
2037  $_GET["baseClass"] = "ilRepositoryGUI";
2038  include("ilias.php");
2039  exit;
2040  }
2041 
2042  if ($a_raise_error)
2043  {
2044  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
2045  }
2046  }
2047 
2054  static function _gotoRepositoryNode($a_ref_id, $a_cmd = "frameset")
2055  {
2056  global $ilAccess, $ilErr;
2057 
2058  $_GET["cmd"] = $a_cmd;
2059  $_GET["target"] = "";
2060  $_GET["ref_id"] = $a_ref_id;
2061  $_GET["baseClass"] = "ilRepositoryGUI";
2062  include("ilias.php");
2063  exit;
2064  }
2065 
2066 
2067 
2068 
2069 } // END class.ilObjectGUI (3.10: 2896 loc)
2070 
2071 ?>