ILIAS  Release_4_2_x_branch Revision 61807
 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 
22  var $ilias;
23 
30 
36  var $tpl;
37 
43  var $tree;
44 
50  var $lng;
51 
57  var $data;
58 
64  var $object;
65  var $ref_id;
66  var $obj_id;
67  var $maxcount; // contains number of child objects
68  var $formaction; // special formation (array "cmd" => "formaction")
69  var $return_location; // special return location (array "cmd" => "location")
70  var $target_frame; // special target frame (array "cmd" => "location")
71 
73  var $actions;
75  var $omit_locator = false;
76 
77  const CFORM_NEW = 1;
78  const CFORM_IMPORT = 2;
79  const CFORM_CLONE = 3;
80 
88  function ilObjectGUI($a_data, $a_id = 0, $a_call_by_reference = true, $a_prepare_output = true)
89  {
90  global $ilias, $objDefinition, $tpl, $tree, $ilCtrl, $ilErr, $lng, $ilTabs;
91 
92  $this->tabs_gui =& $ilTabs;
93 
94  if (!isset($ilErr))
95  {
96  $ilErr = new ilErrorHandling();
97  $ilErr->setErrorHandling(PEAR_ERROR_CALLBACK,array($ilErr,'errorHandler'));
98  }
99  else
100  {
101  $this->ilErr =& $ilErr;
102  }
103 
104  $this->ilias =& $ilias;
105  $this->objDefinition =& $objDefinition;
106  $this->tpl =& $tpl;
107  $this->html = "";
108  $this->ctrl =& $ilCtrl;
109 
110  $params = array("ref_id");
111 
112  if (!$a_call_by_reference)
113  {
114  $params = array("ref_id","obj_id");
115  }
116 
117  $this->ctrl->saveParameter($this, $params);
118 
119  $this->lng =& $lng;
120  $this->tree =& $tree;
121  $this->formaction = array();
122  $this->return_location = array();
123  $this->target_frame = array();
124  $this->actions = "";
125  $this->sub_objects = "";
126 
127  $this->data = $a_data;
128  $this->id = $a_id;
129  $this->call_by_reference = $a_call_by_reference;
130  $this->prepare_output = $a_prepare_output;
131  $this->creation_mode = false;
132 
133  $this->ref_id = ($this->call_by_reference) ? $this->id : $_GET["ref_id"];
134  $this->obj_id = ($this->call_by_reference) ? $_GET["obj_id"] : $this->id;
135 
136  if ($this->id != 0)
137  {
138  $this->link_params = "ref_id=".$this->ref_id;
139  }
140 
141  // get the object
142  $this->assignObject();
143 
144  // set context
145  if (is_object($this->object))
146  {
147  if ($this->call_by_reference && $this->ref_id == $_GET["ref_id"])
148  {
149  $this->ctrl->setContext($this->object->getId(),
150  $this->object->getType());
151  }
152  }
153 
154  // use global $lng instead, when creating new objects object is not available
155  //$this->lng =& $this->object->lng;
156 
157  //prepare output
158  if ($a_prepare_output)
159  {
160  $this->prepareOutput();
161  }
162  }
163 
164 
168  function &executeCommand()
169  {
170  $next_class = $this->ctrl->getNextClass($this);
171  $cmd = $this->ctrl->getCmd();
172 
173  switch($next_class)
174  {
175  default:
176  $this->prepareOutput();
177  if(!$cmd)
178  {
179  $cmd = "view";
180  }
181  $cmd .= "Object";
182  $this->$cmd();
183 
184  break;
185  }
186 
187  return true;
188  }
189 
190 
194  public function withReferences()
195  {
196  return $this->call_by_reference;
197  }
198 
205  public function setCreationMode($a_mode = true)
206  {
207  $this->creation_mode = $a_mode;
208  }
209 
213  public function getCreationMode()
214  {
215  return $this->creation_mode;
216  }
217 
218  protected function assignObject()
219  {
220  // TODO: it seems that we always have to pass only the ref_id
221 //echo "<br>ilObjectGUIassign:".get_class($this).":".$this->id.":<br>";
222  if ($this->id != 0)
223  {
224  if ($this->call_by_reference)
225  {
226  $this->object = ilObjectFactory::getInstanceByRefId($this->id);
227  }
228  else
229  {
230  $this->object = ilObjectFactory::getInstanceByObjId($this->id);
231  }
232  }
233  }
234 
238  protected function prepareOutput()
239  {
240  global $ilLocator, $tpl, $ilUser;
241 
242  $this->tpl->getStandardTemplate();
243  // administration prepare output
244  if (strtolower($_GET["baseClass"]) == "iladministrationgui")
245  {
246  $this->addAdminLocatorItems();
247  $tpl->setLocator();
248 
249 // ilUtil::sendInfo();
251 
252  $this->setTitleAndDescription();
253 
254  if ($this->getCreationMode() != true)
255  {
256  $this->setAdminTabs();
257  $this->showUpperIcon();
258  }
259 
260  return false;
261  }
262  // set locator
263  $this->setLocator();
264  // catch feedback message
265 // ilUtil::sendInfo();
267 
268  // in creation mode (parent) object and gui object
269  // do not fit
270  if ($this->getCreationMode() == true)
271  {
272  // repository vs. workspace
273  if($this->call_by_reference)
274  {
275  // get gui class of parent and call their title and description method
276  $obj_type = ilObject::_lookupType($_GET["ref_id"],true);
277  $class_name = $this->objDefinition->getClassName($obj_type);
278  $class = strtolower("ilObj".$class_name."GUI");
279  $class_path = $this->ctrl->lookupClassPath($class);
280  include_once($class_path);
281  $class_name = $this->ctrl->getClassForClasspath($class_path);
282 //echo "<br>instantiating parent for title and description";
283  $this->parent_gui_obj = new $class_name("", $_GET["ref_id"], true, false);
284  // the next line prevents the header action menu being shown
285  $this->parent_gui_obj->setCreationMode(true);
286  $this->parent_gui_obj->setTitleAndDescription();
287  }
288  }
289  else
290  {
291  // set title and description and title icon
292  $this->setTitleAndDescription();
293 
294  // set tabs
295  $this->setTabs();
296  $this->showUpperIcon();
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  $this->tpl->setTitle($this->object->getPresentationTitle());
317  $this->tpl->setDescription($this->object->getLongDescription());
318  if (strtolower($_GET["baseClass"]) == "iladministrationgui")
319  {
320  // alt text would be same as heading -> empty alt text
321  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_".$this->object->getType()."_b.gif"),
322  "");
323  }
324  else
325  {
326  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_".$this->object->getType()."_b.gif"),
327  $this->lng->txt("obj_" . $this->object->getType()));
328  }
329 
330  include_once './Services/Object/classes/class.ilObjectListGUIFactory.php';
331  $lgui = ilObjectListGUIFactory::_getListGUIByType($this->object->getType());
332  $lgui->initItem($this->object->getRefId(), $this->object->getId());
333  $this->tpl->setAlertProperties($lgui->getAlertProperties());
334  }
335 
343  protected function initHeaderAction($a_sub_type = null, $a_sub_id = null)
344  {
345  global $ilAccess;
346 
347  if(!$this->creation_mode && $this->object)
348  {
349  include_once "Services/Object/classes/class.ilCommonActionDispatcherGUI.php";
351  $ilAccess, $this->object->getType(), $this->ref_id, $this->object->getId());
352 
353  $dispatcher->setSubObject($a_sub_type, $a_sub_id);
354 
355  include_once "Services/Object/classes/class.ilObjectListGUI.php";
356  ilObjectListGUI::prepareJSLinks($this->ctrl->getLinkTarget($this, "redrawHeaderAction", "", true),
357  $this->ctrl->getLinkTargetByClass(array("ilcommonactiondispatchergui", "ilnotegui"), "", "", true, false),
358  $this->ctrl->getLinkTargetByClass(array("ilcommonactiondispatchergui", "iltagginggui"), "", "", true, false));
359 
360  $lg = $dispatcher->initHeaderAction();
361 
362  if (is_object($lg))
363  {
364  // to enable add to desktop / remove from desktop
365  if($this instanceof ilDesktopItemHandling)
366  {
367  $lg->setContainerObject($this);
368  }
369 
370  // comments settings are always on (for the repository)
371  // should only be shown if active or permission to toggle
372  include_once "Services/Notes/classes/class.ilNote.php";
373  if($ilAccess->checkAccess("write", "", $this->ref_id) ||
374  $ilAccess->checkAccess("edit_permissions", "", $this->ref_id) ||
375  ilNote::commentsActivated($this->object->getId(), 0, $this->object->getType()))
376  {
377  $lg->enableComments(true);
378  }
379 
380  $lg->enableNotes(true);
381  $lg->enableTags(true);
382  }
383 
384  return $lg;
385  }
386  }
387 
393  protected function insertHeaderAction($a_list_gui)
394  {
395  if(is_object($a_list_gui))
396  {
397  $this->tpl->setHeaderActionMenu($a_list_gui->getHeaderAction());
398  }
399  }
400 
404  protected function addHeaderAction()
405  {
406  $this->insertHeaderAction($this->initHeaderAction());
407  }
408 
412  protected function redrawHeaderActionObject()
413  {
414  $lg = $this->initHeaderAction();
415  echo $lg->getHeaderAction();
416  exit;
417  }
418 
419  protected function showUpperIcon()
420  {
421  global $tree, $tpl, $objDefinition;
422 
423  if ($this->object->getRefId() == "")
424  {
425  return;
426  }
427 
428  if (strtolower($_GET["baseClass"]) == "iladministrationgui")
429  {
430  if ($this->object->getRefId() != ROOT_FOLDER_ID &&
431  $this->object->getRefId() != SYSTEM_FOLDER_ID)
432  {
433  $par_id = $tree->getParentId($this->object->getRefId());
434  $obj_type = ilObject::_lookupType($par_id,true);
435  $class_name = $objDefinition->getClassName($obj_type);
436  $class = strtolower("ilObj".$class_name."GUI");
437  $this->ctrl->setParameterByClass($class, "ref_id", $par_id);
438  $tpl->setUpperIcon($this->ctrl->getLinkTargetByClass($class, "view"));
439  $this->ctrl->clearParametersByClass($class);
440  }
441  // link repository admin to admin settings
442  else if ($this->object->getRefId() == ROOT_FOLDER_ID)
443  {
444  $this->ctrl->setParameterByClass("iladministrationgui", "ref_id", "");
445  $this->ctrl->setParameterByClass("iladministrationgui", "admin_mode", "settings");
446  $tpl->setUpperIcon($this->ctrl->getLinkTargetByClass("iladministrationgui", "frameset"),
447  ilFrameTargetInfo::_getFrame("MainContent"));
448  $this->ctrl->clearParametersByClass("iladministrationgui");
449  }
450  }
451  else
452  {
453  if ($this->object->getRefId() != ROOT_FOLDER_ID &&
454  $this->object->getRefId() != SYSTEM_FOLDER_ID &&
455  $_GET["obj_id"] == "")
456  {
457  if (defined("ILIAS_MODULE"))
458  {
459  $prefix = "../";
460  }
461  $par_id = $tree->getParentId($this->object->getRefId());
462  $tpl->setUpperIcon($prefix."repository.php?cmd=frameset&ref_id=".$par_id,
463  ilFrameTargetInfo::_getFrame("MainContent"));
464  }
465  }
466  }
467  // BEGIN WebDAV: Show Mount Webfolder Icon.
468  final private function showMountWebfolderIcon()
469  {
470  global $tree, $tpl, $objDefinition;
471 
472  if ($this->object->getRefId() == "")
473  {
474  return;
475  }
476 
477  $tpl->setMountWebfolderIcon($this->object->getRefId());
478  }
479  // END WebDAV: Show Mount Webfolder Icon.
480 
481 
486  protected function setTabs()
487  {
488  $this->getTabs($this->tabs_gui);
489  }
490 
495  protected final function setAdminTabs()
496  {
497  $this->getAdminTabs($this->tabs_gui);
498  }
499 
503  function getAdminTabs(&$tabs_gui)
504  {
505  global $tree;
506 
507  if ($_GET["admin_mode"] == "repository")
508  {
509  $this->ctrl->setParameterByClass("iladministrationgui", "admin_mode", "settings");
510  $tabs_gui->setBackTarget($this->lng->txt("administration"),
511  $this->ctrl->getLinkTargetByClass("iladministrationgui", "frameset"),
512  ilFrameTargetInfo::_getFrame("MainContent"));
513  $this->ctrl->setParameterByClass("iladministrationgui", "admin_mode", "repository");
514  }
515 
516  if ($this->checkPermissionBool("visible,read"))
517  {
518  $tabs_gui->addTarget("view",
519  $this->ctrl->getLinkTarget($this, "view"), array("", "view"), get_class($this));
520 
521  }
522 
523  if ($this->checkPermissionBool("edit_permission"))
524  {
525  $tabs_gui->addTarget("perm_settings",
526  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), "", "ilpermissiongui");
527  }
528 
529  if ($tree->getSavedNodeData($this->object->getRefId()))
530  {
531  $tabs_gui->addTarget("trash",
532  $this->ctrl->getLinkTarget($this, "trash"), "trash", get_class($this));
533  }
534  }
535 
536 
537  function getHTML()
538  {
539  return $this->html;
540  }
541 
542 
549  final private function setActions($a_actions = "")
550  {
551  if (is_array($a_actions))
552  {
553  foreach ($a_actions as $name => $lng)
554  {
555  $this->actions[$name] = array("name" => $name, "lng" => $lng);
556  }
557  }
558  else
559  {
560  $this->actions = "";
561  }
562  }
563 
570  final private function setSubObjects($a_sub_objects = "")
571  {
572  if (is_array($a_sub_objects))
573  {
574  foreach ($a_sub_objects as $name => $options)
575  {
576  $this->sub_objects[$name] = array("name" => $name, "max" => $options["max"]);
577  }
578  }
579  else
580  {
581  $this->sub_objects = "";
582  }
583  }
584 
593  protected function setLocator()
594  {
595  global $ilLocator, $tpl;
596 
597  if ($this->omit_locator)
598  {
599  return;
600  }
601 
602  // repository vs. workspace
603  if($this->call_by_reference)
604  {
605  // todo: admin workaround
606  // in the future, objectgui classes should not be called in
607  // admin section anymore (rbac/trash handling in own classes)
608  $ref_id = ($_GET["ref_id"] != "")
609  ? $_GET["ref_id"]
610  : $this->object->getRefId();
611  $ilLocator->addRepositoryItems($ref_id);
612  }
613 
614  if(!$this->creation_mode)
615  {
616  $this->addLocatorItems();
617  }
618 
619  // not so nice workaround: todo: handle $ilLocator as tabs in ilTemplate
620  if ($_GET["admin_mode"] == "" &&
621  strtolower($this->ctrl->getCmdClass()) == "ilobjrolegui")
622  {
623  $this->ctrl->setParameterByClass("ilobjrolegui",
624  "rolf_ref_id", $_GET["rolf_ref_id"]);
625  $this->ctrl->setParameterByClass("ilobjrolegui",
626  "obj_id", $_GET["obj_id"]);
627  $ilLocator->addItem($this->lng->txt("role"),
628  $this->ctrl->getLinkTargetByClass(array("ilpermissiongui",
629  "ilobjrolegui"), "perm"));
630  }
631 
632  $tpl->setLocator();
633  }
634 
639  protected function addLocatorItems()
640  {
641  }
642 
643  protected function omitLocator($a_omit = true)
644  {
645  $this->omit_locator = $a_omit;
646  }
647 
652  protected function addAdminLocatorItems()
653  {
654  global $ilLocator;
655 
656  if ($_GET["admin_mode"] == "settings") // system settings
657  {
658  $ilLocator->addItem($this->lng->txt("administration"),
659  $this->ctrl->getLinkTargetByClass("iladministrationgui", "frameset"),
660  ilFrameTargetInfo::_getFrame("MainContent"));
661  if ($this->object->getRefId() != SYSTEM_FOLDER_ID)
662  {
663  $ilLocator->addItem($this->object->getTitle(),
664  $this->ctrl->getLinkTarget($this, "view"));
665  }
666  }
667  else // repository administration
668  {
669  $this->ctrl->setParameterByClass("iladministrationgui",
670  "ref_id", "");
671  $this->ctrl->setParameterByClass("iladministrationgui",
672  "admin_mode", "settings");
673  //$ilLocator->addItem($this->lng->txt("administration"),
674  // $this->ctrl->getLinkTargetByClass("iladministrationgui", "frameset"),
675  // ilFrameTargetInfo::_getFrame("MainContent"));
676  $this->ctrl->clearParametersByClass("iladministrationgui");
677  $ilLocator->addAdministrationItems();
678  }
679 
680  }
681 
685  public function undeleteObject()
686  {
687  include_once("./Services/Repository/classes/class.ilRepUtilGUI.php");
688  $ru = new ilRepUtilGUI($this);
689  $ru->restoreObjects($_GET["ref_id"], $_POST["trash_id"]);
690  $this->ctrl->redirect($this, "trash");
691  }
692 
697  public function confirmedDeleteObject()
698  {
699  global $ilSetting, $lng;
700 
701  include_once("./Services/Repository/classes/class.ilRepUtilGUI.php");
702  $ru = new ilRepUtilGUI($this);
703  $ru->deleteObjects($_GET["ref_id"], $_SESSION["saved_post"]);
704  session_unregister("saved_post");
705  $this->ctrl->returnToParent($this);
706  }
707 
713  public function cancelDeleteObject()
714  {
715  session_unregister("saved_post");
716  $this->ctrl->returnToParent($this);
717  }
718 
724  public function removeFromSystemObject()
725  {
726  global $log, $ilAppEventHandler, $lng;
727 
728  include_once("./Services/Repository/classes/class.ilRepUtilGUI.php");
729  $ru = new ilRepUtilGUI($this);
730  $ru->removeObjectsFromSystem($_POST["trash_id"]);
731  $this->ctrl->redirect($this, "trash");
732  }
733 
739  public function cancelObject($in_rep = false)
740  {
741  session_unregister("saved_post");
742  $this->ctrl->returnToParent($this);
743  }
744 
750  public function createObject()
751  {
752  global $tpl, $ilErr;
753 
754  $new_type = $_REQUEST["new_type"];
755 
756  if (!$this->checkPermissionBool("create", "", $new_type))
757  {
758  $ilErr->raiseError($this->lng->txt("permission_denied"),$ilErr->MESSAGE);
759  }
760  else
761  {
762  $this->lng->loadLanguageModule($new_type);
763  $this->ctrl->setParameter($this, "new_type", $new_type);
764 
765  $forms = $this->initCreationForms($new_type);
766 
767  // copy form validation error: do not show other creation forms
768  if($_GET["cpfl"] && isset($forms[self::CFORM_CLONE]))
769  {
770  $forms = array(self::CFORM_CLONE => $forms[self::CFORM_CLONE]);
771  }
772 
773  $tpl->setContent($this->getCreationFormsHTML($forms));
774  }
775  }
776 
785  protected function initCreationForms($a_new_type)
786  {
787  $forms = array(
788  self::CFORM_NEW => $this->initCreateForm($a_new_type),
789  self::CFORM_IMPORT => $this->initImportForm($a_new_type),
790  self::CFORM_CLONE => $this->fillCloneTemplate(null, $a_new_type)
791  );
792 
793  return $forms;
794  }
795 
801  final protected function getCreationFormsHTML(array $a_forms)
802  {
803  global $tpl;
804 
805  // no accordion if there is just one form
806  if(sizeof($a_forms) == 1)
807  {
808  $a_forms = array_shift($a_forms);
809  if (is_object($a_forms) && get_class($a_forms) == "ilPropertyFormGUI")
810  {
811  return $a_forms->getHTML();
812  }
813  }
814  else
815  {
816  include_once("./Services/Accordion/classes/class.ilAccordionGUI.php");
817 
818  $acc = new ilAccordionGUI();
819  $acc->setBehaviour(ilAccordionGUI::FIRST_OPEN);
820  $cnt = 1;
821  foreach ($a_forms as $form_type => $cf)
822  {
823  if (is_object($cf) && get_class($cf) == "ilPropertyFormGUI")
824  {
825  $htpl = new ilTemplate("tpl.creation_acc_head.html", true, true, "Services/Object");
826 // $htpl->setVariable("IMG_ARROW", ilUtil::getImagePath("accordion_arrow.gif"));
827 
828  // using custom form titles (used for repository plugins)
829  $form_title = "";
830  if(method_exists($this, "getCreationFormTitle"))
831  {
832  $form_title = $this->getCreationFormTitle($form_type);
833  }
834  if(!$form_title)
835  {
836  $form_title = $cf->getTitle();
837  }
838 
839  // move title from form to accordion
840  $htpl->setVariable("TITLE", $this->lng->txt("option")." ".$cnt.": ".
841  $form_title);
842  $cf->setTitle(null);
843  $cf->setTitleIcon(null);
844  $cf->setTableWidth("100%");
845 
846  $acc->addItem($htpl->get(), $cf->getHTML());
847 
848  $cnt++;
849  }
850  }
851 
852  return "<div style='max-width:700px;'>".$acc->getHTML()."</div>";
853  }
854  }
855 
862  protected function initCreateForm($a_new_type)
863  {
864  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
865  $form = new ilPropertyFormGUI();
866  $form->setTarget("_top");
867  $form->setFormAction($this->ctrl->getFormAction($this, "save"));
868  $form->setTitle($this->lng->txt($a_new_type."_new"));
869 
870  // title
871  $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
872  $ti->setMaxLength(128);
873  $ti->setSize(40);
874  $ti->setRequired(true);
875  $form->addItem($ti);
876 
877  // description
878  $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
879  $ta->setCols(40);
880  $ta->setRows(2);
881  $form->addItem($ta);
882 
883  $form = $this->initDidacticTemplate($form);
884 
885  $form->addCommandButton("save", $this->lng->txt($a_new_type."_add"));
886  $form->addCommandButton("cancel", $this->lng->txt("cancel"));
887 
888  return $form;
889  }
890 
896  protected function initDidacticTemplate(ilPropertyFormGUI $form)
897  {
898  global $lng;
899 
900  $lng->loadLanguageModule('didactic');
901 
902  $options = array();
903  $options[0] = array($this->lng->txt('default'),
904  sprintf(
905  $this->lng->txt('didactic_default_type_info'),
906  $this->lng->txt('objs_'.$this->type)
907  ));
908 
909  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateSettings.php';
910  $templates = ilDidacticTemplateSettings::getInstanceByObjectType($this->type)->getTemplates();
911  if($templates)
912  {
913  foreach($templates as $template)
914  {
915  $options["dtpl_".$template->getId()] = array($template->getTitle(),
916  $template->getDescription());
917  }
918  }
919 
920  $this->addDidacticTemplateOptions($options);
921 
922  if(sizeof($options) > 1)
923  {
924  $type = new ilRadioGroupInputGUI(
925  $this->lng->txt('type'),
926  'didactic_type'
927  );
928  // workaround for containers in edit mode
929  if(!$this->getCreationMode())
930  {
931  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php';
932  $type->setValue(
933  'dtpl_'.ilDidacticTemplateObjSettings::lookupTemplateId($this->object->getRefId())
934  );
935  }
936  $form->addItem($type);
937 
938  ilUtil::sortArray($options, 0);
939  foreach($options as $id => $data)
940  {
941  $option = new ilRadioOption($data[0], $id, $data[1]);
942  $type->addOption($option);
943  }
944  }
945 
946  return $form;
947  }
948 
954  protected function addDidacticTemplateOptions(array &$a_options)
955  {
956 
957  }
958 
962  public function cancelCreation()
963  {
964  ilUtil::redirect("repository.php?cmd=frameset&ref_id=".$_GET["ref_id"]);
965  }
966 
972  public function saveObject()
973  {
974  global $objDefinition, $tpl;
975 
976  $new_type = $_REQUEST["new_type"];
977 
978  // create permission is already checked in createObject. This check here is done to prevent hacking attempts
979  if (!$this->checkPermissionBool("create", "", $new_type))
980  {
981  $this->ilias->raiseError($this->lng->txt("no_create_permission"), $this->ilias->error_obj->MESSAGE);
982  }
983 
984  $this->lng->loadLanguageModule($new_type);
985  $this->ctrl->setParameter($this, "new_type", $new_type);
986 
987  $form = $this->initCreateForm($new_type);
988  if ($form->checkInput())
989  {
990  $this->ctrl->setParameter($this, "new_type", "");
991 
992  // create instance
993  $class_name = "ilObj".$objDefinition->getClassName($new_type);
994  $location = $objDefinition->getLocation($new_type);
995  include_once($location."/class.".$class_name.".php");
996  $newObj = new $class_name();
997  $newObj->setType($new_type);
998  $newObj->setTitle($form->getInput("title"));
999  $newObj->setDescription($form->getInput("desc"));
1000  $newObj->create();
1001 
1002  $this->putObjectInTree($newObj);
1003 
1004  // apply didactic template?
1005  $dtpl = $this->getDidacticTemplateVar("dtpl");
1006  if($dtpl)
1007  {
1008  $newObj->applyDidacticTemplate($dtpl);
1009  }
1010 
1011  // additional paramters are added to afterSave()
1012  $args = func_get_args();
1013  if($args)
1014  {
1015  $this->afterSave($newObj, $args);
1016  }
1017  else
1018  {
1019  $this->afterSave($newObj);
1020  }
1021  return;
1022  }
1023 
1024  // display only this form to correct input
1025  $form->setValuesByPost();
1026  $tpl->setContent($form->getHtml());
1027  }
1028 
1035  protected function getDidacticTemplateVar($a_type)
1036  {
1037  $tpl = $_POST["didactic_type"];
1038  if($tpl && substr($tpl, 0, strlen($a_type)+1) == $a_type."_")
1039  {
1040  return (int)substr($tpl, strlen($a_type)+1);
1041  }
1042  }
1043 
1050  protected function putObjectInTree(ilObject $a_obj, $a_parent_node_id = null)
1051  {
1052  global $rbacreview, $ilUser;
1053 
1054  if(!$a_parent_node_id)
1055  {
1056  $a_parent_node_id = $_GET["ref_id"];
1057  }
1058 
1059  $a_obj->createReference();
1060  $a_obj->putInTree($a_parent_node_id);
1061  $a_obj->setPermissions($a_parent_node_id);
1062 
1063  $this->obj_id = $a_obj->getId();
1064  $this->ref_id = $a_obj->getRefId();
1065 
1066  // BEGIN ChangeEvent: Record save object.
1067  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
1068  ilChangeEvent::_recordWriteEvent($this->obj_id, $ilUser->getId(), 'create');
1069  // END ChangeEvent: Record save object.
1070 
1071  // rbac log
1072  include_once "Services/AccessControl/classes/class.ilRbacLog.php";
1073  $rbac_log_roles = $rbacreview->getParentRoleIds($this->ref_id, false);
1074  $rbac_log = ilRbacLog::gatherFaPa($this->ref_id, array_keys($rbac_log_roles), true);
1075  ilRbacLog::add(ilRbacLog::CREATE_OBJECT, $this->ref_id, $rbac_log);
1076  }
1077 
1083  protected function afterSave(ilObject $a_new_object)
1084  {
1085  ilUtil::sendSuccess($this->lng->txt("object_added"), true);
1086  $this->ctrl->returnToParent($this);
1087  }
1088 
1094  public function editObject()
1095  {
1096  global $tpl, $ilTabs;
1097 
1098  if (!$this->checkPermissionBool("write"))
1099  {
1100  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
1101  }
1102 
1103  $ilTabs->activateTab("settings");
1104 
1105  $form = $this->initEditForm();
1106  $values = $this->getEditFormValues();
1107  if($values)
1108  {
1109  $form->setValuesByArray($values);
1110  }
1111  $tpl->setContent($form->getHTML());
1112  }
1113 
1119  protected function initEditForm()
1120  {
1121  global $lng, $ilCtrl;
1122 
1123  $lng->loadLanguageModule($this->object->getType());
1124 
1125  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1126  $form = new ilPropertyFormGUI();
1127  $form->setFormAction($this->ctrl->getFormAction($this, "update"));
1128  $form->setTitle($this->lng->txt($this->object->getType()."_edit"));
1129 
1130  // title
1131  $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
1132  $ti->setMaxLength(128);
1133  $ti->setSize(40);
1134  $ti->setRequired(true);
1135  $form->addItem($ti);
1136 
1137  // description
1138  $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
1139  $ta->setCols(40);
1140  $ta->setRows(2);
1141  $form->addItem($ta);
1142 
1143  $this->initEditCustomForm($form);
1144 
1145  $form->addCommandButton("update", $this->lng->txt("save"));
1146  //$this->form->addCommandButton("cancelUpdate", $lng->txt("cancel"));
1147 
1148  return $form;
1149  }
1150 
1156  protected function initEditCustomForm(ilPropertyFormGUI $a_form)
1157  {
1158 
1159  }
1160 
1166  protected function getEditFormValues()
1167  {
1168  $values["title"] = $this->object->getTitle();
1169  $values["desc"] = $this->object->getDescription();
1170  $this->getEditFormCustomValues($values);
1171  return $values;
1172  }
1173 
1179  protected function getEditFormCustomValues(array &$a_values)
1180  {
1181 
1182  }
1183 
1187  public function updateObject()
1188  {
1189  global $ilTabs, $tpl;
1190 
1191  if (!$this->checkPermissionBool("write"))
1192  {
1193  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
1194  }
1195 
1196  $form = $this->initEditForm();
1197  if($form->checkInput())
1198  {
1199  $this->object->setTitle($form->getInput("title"));
1200  $this->object->setDescription($form->getInput("desc"));
1201  $this->updateCustom($form);
1202  $this->object->update();
1203 
1204  $this->afterUpdate();
1205  return;
1206  }
1207 
1208  // display form again to correct errors
1209  $ilTabs->activateTab("settings");
1210  $form->setValuesByPost();
1211  $tpl->setContent($form->getHtml());
1212  }
1213 
1219  protected function updateCustom(ilPropertyFormGUI $a_form)
1220  {
1221 
1222  }
1223 
1227  protected function afterUpdate()
1228  {
1229  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
1230  $this->ctrl->redirect($this, "edit");
1231  }
1232 
1239  protected function initImportForm($a_new_type)
1240  {
1241  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1242  $form = new ilPropertyFormGUI();
1243  $form->setTarget("_top");
1244  $form->setFormAction($this->ctrl->getFormAction($this, "importFile"));
1245  $form->setTitle($this->lng->txt($a_new_type."_import"));
1246 
1247  include_once("./Services/Form/classes/class.ilFileInputGUI.php");
1248  $fi = new ilFileInputGUI($this->lng->txt("import_file"), "importfile");
1249  $fi->setSuffixes(array("zip"));
1250  $fi->setRequired(true);
1251  $form->addItem($fi);
1252 
1253  $form->addCommandButton("importFile", $this->lng->txt("import"));
1254  $form->addCommandButton("cancel", $this->lng->txt("cancel"));
1255 
1256  return $form;
1257  }
1258 
1262  protected function importFileObject($parent_id = null)
1263  {
1264  global $objDefinition, $tpl, $ilErr;
1265 
1266  if(!$parent_id)
1267  {
1268  $parent_id = $_GET["ref_id"];
1269  }
1270  $new_type = $_REQUEST["new_type"];
1271 
1272  // create permission is already checked in createObject. This check here is done to prevent hacking attempts
1273  if (!$this->checkPermissionBool("create", "", $new_type))
1274  {
1275  $ilErr->raiseError($this->lng->txt("no_create_permission"));
1276  }
1277 
1278  $this->lng->loadLanguageModule($new_type);
1279  $this->ctrl->setParameter($this, "new_type", $new_type);
1280 
1281  $form = $this->initImportForm($new_type);
1282  if ($form->checkInput())
1283  {
1284  // :todo: make some check on manifest file
1285 
1286  if($objDefinition->isContainer($new_type))
1287  {
1288  include_once './Services/Export/classes/class.ilImportContainer.php';
1289  $imp = new ilImportContainer((int)$parent_id);
1290  }
1291  else
1292  {
1293  include_once("./Services/Export/classes/class.ilImport.php");
1294  $imp = new ilImport((int)$parent_id);
1295  }
1296 
1297  $new_id = $imp->importObject(null, $_FILES["importfile"]["tmp_name"],
1298  $_FILES["importfile"]["name"], $new_type);
1299 
1300  if ($new_id > 0)
1301  {
1302  $this->ctrl->setParameter($this, "new_type", "");
1303 
1304  $newObj = ilObjectFactory::getInstanceByObjId($new_id);
1305 
1306  // put new object id into tree - already done in import for containers
1307  if(!$objDefinition->isContainer($new_type))
1308  {
1309  $this->putObjectInTree($newObj);
1310  }
1311 
1312  $this->afterImport($newObj);
1313  }
1314  // import failed
1315  else
1316  {
1317  if($objDefinition->isContainer($new_type))
1318  {
1319  ilUtil::sendFailure($this->lng->txt("container_import_zip_file_invalid"));
1320  }
1321  else
1322  {
1323  // not enough information here...
1324  return;
1325  }
1326  }
1327  }
1328 
1329  // display form to correct errors
1330  $form->setValuesByPost();
1331  $tpl->setContent($form->getHtml());
1332  }
1333 
1339  protected function afterImport(ilObject $a_new_object)
1340  {
1341  ilUtil::sendSuccess($this->lng->txt("object_added"), true);
1342  $this->ctrl->returnToParent($this);
1343  }
1344 
1353  public function getFormAction($a_cmd, $a_formaction = "")
1354  {
1355  if ($this->formaction[$a_cmd] != "")
1356  {
1357  return $this->formaction[$a_cmd];
1358  }
1359  else
1360  {
1361  return $a_formaction;
1362  }
1363  }
1364 
1373  protected function setFormAction($a_cmd, $a_formaction)
1374  {
1375  $this->formaction[$a_cmd] = $a_formaction;
1376  }
1377 
1385  protected function getReturnLocation($a_cmd, $a_location ="")
1386  {
1387  if ($this->return_location[$a_cmd] != "")
1388  {
1389  return $this->return_location[$a_cmd];
1390  }
1391  else
1392  {
1393  return $a_location;
1394  }
1395  }
1396 
1404  protected function setReturnLocation($a_cmd, $a_location)
1405  {
1406 //echo "-".$a_cmd."-".$a_location."-";
1407  $this->return_location[$a_cmd] = $a_location;
1408  }
1409 
1417  protected function getTargetFrame($a_cmd, $a_target_frame = "")
1418  {
1419  if ($this->target_frame[$a_cmd] != "")
1420  {
1421  return $this->target_frame[$a_cmd];
1422  }
1423  elseif (!empty($a_target_frame))
1424  {
1425  return "target=\"".$a_target_frame."\"";
1426  }
1427  else
1428  {
1429  return;
1430  }
1431  }
1432 
1440  protected function setTargetFrame($a_cmd, $a_target_frame)
1441  {
1442  $this->target_frame[$a_cmd] = "target=\"".$a_target_frame."\"";
1443  }
1444 
1445  // BEGIN Security: Hide objects which aren't accessible by the user.
1446  public function isVisible($a_ref_id,$a_type)
1447  {
1448  global $ilBench;
1449 
1450  $ilBench->start("Explorer", "setOutput_isVisible");
1451  $visible = $this->checkPermissionBool("visible,read", "", "", $a_ref_id);
1452 
1453  if ($visible && $a_type == 'crs') {
1454  global $tree;
1455  if($crs_id = $tree->checkForParentType($a_ref_id,'crs'))
1456  {
1457  if(!$this->checkPermissionBool("write", "", "", $crs_id))
1458  {
1459  // Show only activated courses
1460  $tmp_obj =& ilObjectFactory::getInstanceByRefId($crs_id,false);
1461 
1462  if(!$tmp_obj->isActivated())
1463  {
1464  unset($tmp_obj);
1465  $visible = false;
1466  }
1467  if(($crs_id != $a_ref_id) and $tmp_obj->isArchived())
1468  {
1469  $visible = false;
1470  }
1471  // Show only activated course items
1472  include_once "./course/classes/class.ilCourseItems.php";
1473 
1474  if(($crs_id != $a_ref_id) and (!ilCourseItems::_isActivated($a_ref_id)))
1475  {
1476  $visible = false;
1477  }
1478  }
1479  }
1480  }
1481 
1482  $ilBench->stop("Explorer", "setOutput_isVisible");
1483 
1484  return $visible;
1485  }
1486  // END Security: Hide objects which aren't accessible by the user.
1487 
1493  public function viewObject()
1494  {
1495  global$tpl;
1496 
1497  if (!$this->checkPermissionBool("visible,read"))
1498  {
1499  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
1500  }
1501 
1502  // BEGIN ChangeEvent: record read event.
1503  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
1504  global $ilUser;
1506  $this->object->getType(),
1507  $this->object->getRefId(),
1508  $this->object->getId(), $ilUser->getId());
1509  // END ChangeEvent: record read event.
1510 
1511  include_once("./Services/Repository/classes/class.ilAdminSubItemsTableGUI.php");
1512  if (!$this->call_by_reference)
1513  {
1514  $this->ctrl->setParameter($this, "obj_id", $this->obj_id);
1515  }
1516  $itab = new ilAdminSubItemsTableGUI($this, "view", $_GET["ref_id"]);
1517 
1518  $tpl->setContent($itab->getHTML());
1519  }
1520 
1528  public function deleteObject($a_error = false)
1529  {
1530  global $tpl, $ilCtrl;
1531 
1532  if ($_GET["item_ref_id"] != "")
1533  {
1534  $_POST["id"] = array($_GET["item_ref_id"]);
1535  }
1536 
1537  // SAVE POST VALUES (get rid of this
1538  $_SESSION["saved_post"] = $_POST["id"];
1539 
1540  include_once("./Services/Repository/classes/class.ilRepUtilGUI.php");
1541  $ru = new ilRepUtilGUI($this);
1542  if (!$ru->showDeleteConfirmation($_POST["id"], $a_error))
1543  {
1544  $ilCtrl->returnToParent($this);
1545  }
1546  }
1547 
1553  public function trashObject()
1554  {
1555  global $tpl;
1556 
1557  include_once("./Services/Repository/classes/class.ilRepUtilGUI.php");
1558  $ru = new ilRepUtilGUI($this);
1559  $ru->showTrashTable($_GET["ref_id"]);
1560  }
1561 
1567  protected function showPossibleSubObjects()
1568  {
1569  if ($this->sub_objects == "")
1570  {
1571  $d = $this->objDefinition->getCreatableSubObjects($this->object->getType());
1572  }
1573  else
1574  {
1576  }
1577 
1578  $import = false;
1579 
1580  if (count($d) > 0)
1581  {
1582  foreach ($d as $row)
1583  {
1584  $count = 0;
1585 
1586  if ($row["max"] > 0)
1587  {
1588  //how many elements are present?
1589  for ($i=0; $i<count($this->data["ctrl"]); $i++)
1590  {
1591  if ($this->data["ctrl"][$i]["type"] == $row["name"])
1592  {
1593  $count++;
1594  }
1595  }
1596  }
1597 
1598  if ($row["max"] == "" || $count < $row["max"])
1599  {
1600  $subobj[] = $row["name"];
1601  }
1602  }
1603  }
1604 
1605  if (is_array($subobj))
1606  {
1607 
1608  //build form
1609  $opts = ilUtil::formSelect(12,"new_type",$subobj);
1610  $this->tpl->setCurrentBlock("add_object");
1611  $this->tpl->setVariable("SELECT_OBJTYPE", $opts);
1612  $this->tpl->setVariable("BTN_NAME", "create");
1613  $this->tpl->setVariable("TXT_ADD", $this->lng->txt("add"));
1614  $this->tpl->parseCurrentBlock();
1615  }
1616  }
1617 
1626  public function getTemplateFile($a_cmd,$a_type = "")
1627  {
1628  if (!$a_type)
1629  {
1630  $a_type = $this->type;
1631  }
1632 
1633  $template = "tpl.".$a_type."_".$a_cmd.".html";
1634 
1635  if (!$this->tpl->fileExists($template) &&
1636  !file_exists("./templates/default/".$template))
1637  {
1638  $template = "tpl.obj_".$a_cmd.".html";
1639  }
1640  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", $template,$a_in_module);
1641  }
1642 
1651  protected function getTitlesByRefId($a_ref_ids)
1652  {
1653  foreach ($a_ref_ids as $id)
1654  {
1655  // GET OBJECT TITLE
1656  $tmp_obj =& $this->ilias->obj_factory->getInstanceByRefId($id);
1657  $title[] = $tmp_obj->getTitle();
1658  unset($tmp_obj);
1659  }
1660 
1661  return $title ? $title : array();
1662  }
1663 
1671  protected function getTabs(&$tabs_gui)
1672  {
1673  // please define your tabs here
1674 
1675  }
1676 
1677  // PROTECTED
1678  protected function __showButton($a_cmd,$a_text,$a_target = '')
1679  {
1680  global $ilToolbar;
1681 
1682  $ilToolbar->addButton($a_text, $this->ctrl->getLinkTarget($this, $a_cmd), $a_target);
1683  }
1684 
1685  protected function hitsperpageObject()
1686  {
1687  $_SESSION["tbl_limit"] = $_POST["hitsperpage"];
1688  $_GET["limit"] = $_POST["hitsperpage"];
1689  }
1690 
1691 
1692  protected function &__initTableGUI()
1693  {
1694  include_once "./Services/Table/classes/class.ilTableGUI.php";
1695 
1696  return new ilTableGUI(0,false);
1697  }
1698 
1704  protected function __setTableGUIBasicData(&$tbl,&$result_set,$a_from = "")
1705  {
1706  switch ($a_from)
1707  {
1708  case "clipboardObject":
1709  $offset = $_GET["offset"];
1710  $order = $_GET["sort_by"];
1711  $direction = $_GET["sort_order"];
1712  $tbl->disable("footer");
1713  break;
1714 
1715  default:
1716  $offset = $_GET["offset"];
1717  $order = $_GET["sort_by"];
1718  $direction = $_GET["sort_order"];
1719  break;
1720  }
1721 
1722  $tbl->setOrderColumn($order);
1723  $tbl->setOrderDirection($direction);
1724  $tbl->setOffset($offset);
1725  $tbl->setLimit($_GET["limit"]);
1726  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
1727  $tbl->setData($result_set);
1728  }
1729 
1730  protected function __showClipboardTable($a_result_set,$a_from = "")
1731  {
1732  global $ilCtrl;
1733 
1734  $tbl =& $this->__initTableGUI();
1735  $tpl =& $tbl->getTemplateObject();
1736 
1737  $tpl->setCurrentBlock("tbl_form_header");
1738  $tpl->setVariable("FORMACTION", $ilCtrl->getFormAction($this));
1739  $tpl->parseCurrentBlock();
1740 
1741  $tpl->setCurrentBlock("tbl_action_btn");
1742  $tpl->setVariable("BTN_NAME","paste");
1743  $tpl->setVariable("BTN_VALUE",$this->lng->txt("insert_object_here"));
1744  $tpl->parseCurrentBlock();
1745 
1746  $tpl->setCurrentBlock("tbl_action_btn");
1747  $tpl->setVariable("BTN_NAME","clear");
1748  $tpl->setVariable("BTN_VALUE",$this->lng->txt("clear_clipboard"));
1749  $tpl->parseCurrentBlock();
1750 
1751  $tpl->setCurrentBlock("tbl_action_row");
1752  $tpl->setVariable("COLUMN_COUNTS",3);
1753  $tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("spacer.gif"));
1754  $tpl->parseCurrentBlock();
1755 
1756  $tbl->setTitle($this->lng->txt("clipboard"),"icon_typ_b.gif",$this->lng->txt("clipboard"));
1757  $tbl->setHeaderNames(array($this->lng->txt('obj_type'),
1758  $this->lng->txt('title'),
1759  $this->lng->txt('action')));
1760  $tbl->setHeaderVars(array('type',
1761  'title',
1762  'act'),
1763  array('ref_id' => $this->object->getRefId(),
1764  'cmd' => 'clipboard',
1765  'cmdClass' => $_GET['cmdClass'],
1766  'cmdNode' => $_GET['cmdNode']));
1767 
1768  $tbl->setColumnWidth(array("","80%","19%"));
1769 
1770 
1771  $this->__setTableGUIBasicData($tbl,$a_result_set,$a_from);
1772  $tbl->render();
1773 
1774  $this->tpl->setVariable("RESULT_TABLE",$tbl->tpl->get());
1775 
1776  return true;
1777  }
1778 
1788  protected function redirectToRefId($a_ref_id, $a_cmd = "")
1789  {
1790  $obj_type = ilObject::_lookupType($a_ref_id,true);
1791  $class_name = $this->objDefinition->getClassName($obj_type);
1792  $class = strtolower("ilObj".$class_name."GUI");
1793  $this->ctrl->redirectByClass(array("ilrepositorygui", $class), $a_cmd);
1794  }
1795 
1796  // Object Cloning
1806  protected function fillCloneTemplate($a_tpl_varname,$a_type)
1807  {
1808  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
1809  $cp = new ilObjectCopyGUI($this);
1810  $cp->setType($a_type);
1811  $cp->setTarget($_GET['ref_id']);
1812  if($a_tpl_varname)
1813  {
1814  $cp->showSourceSearch($a_tpl_varname);
1815  }
1816  else
1817  {
1818  return $cp->showSourceSearch(null);
1819  }
1820  }
1821 
1828  public function cloneAllObject()
1829  {
1830  include_once('classes/class.ilLink.php');
1831  include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
1832 
1833  global $ilErr,$ilUser;
1834 
1835  $new_type = $_REQUEST['new_type'];
1836  if(!$this->checkPermissionBool("create", "", $new_type))
1837  {
1838  $ilErr->raiseError($this->lng->txt('permission_denied'));
1839  }
1840  if(!(int) $_REQUEST['clone_source'])
1841  {
1842  ilUtil::sendFailure($this->lng->txt('select_one'));
1843  $this->createObject();
1844  return false;
1845  }
1846  if(!$this->checkPermissionBool("write", "", $new_type, (int)$_REQUEST['clone_source']))
1847  {
1848  $ilErr->raiseError($this->lng->txt('permission_denied'));
1849  }
1850 
1851  // Save wizard options
1853  $wizard_options = ilCopyWizardOptions::_getInstance($copy_id);
1854  $wizard_options->saveOwner($ilUser->getId());
1855  $wizard_options->saveRoot((int) $_REQUEST['clone_source']);
1856 
1857  $options = $_POST['cp_options'] ? $_POST['cp_options'] : array();
1858  foreach($options as $source_id => $option)
1859  {
1860  $wizard_options->addEntry($source_id,$option);
1861  }
1862  $wizard_options->read();
1863 
1864  $orig = ilObjectFactory::getInstanceByRefId((int) $_REQUEST['clone_source']);
1865  $new_obj = $orig->cloneObject((int) $_GET['ref_id'],$copy_id);
1866 
1867  // Delete wizard options
1868  $wizard_options->deleteAll();
1869 
1870  ilUtil::sendSuccess($this->lng->txt("object_duplicated"),true);
1871  ilUtil::redirect(ilLink::_getLink($new_obj->getRefId()));
1872  }
1873 
1881  public function copyWizardHasOptions($a_mode)
1882  {
1883  return false;
1884  }
1885 
1889  protected function getCenterColumnHTML()
1890  {
1891  global $ilCtrl;
1892 
1893  include_once("Services/Block/classes/class.ilColumnGUI.php");
1894 
1895  $obj_id = ilObject::_lookupObjId($this->object->getRefId());
1896  $obj_type = ilObject::_lookupType($obj_id);
1897 
1898  if ($ilCtrl->getNextClass() != "ilcolumngui")
1899  {
1900  // normal command processing
1901  return $this->getContent();
1902  }
1903  else
1904  {
1905  if (!$ilCtrl->isAsynch())
1906  {
1907  //if ($column_gui->getScreenMode() != IL_SCREEN_SIDE)
1909  {
1910  // right column wants center
1912  {
1913  $column_gui = new ilColumnGUI($obj_type, IL_COL_RIGHT);
1914  $this->setColumnSettings($column_gui);
1915  $this->html = $ilCtrl->forwardCommand($column_gui);
1916  }
1917  // left column wants center
1919  {
1920  $column_gui = new ilColumnGUI($obj_type, IL_COL_LEFT);
1921  $this->setColumnSettings($column_gui);
1922  $this->html = $ilCtrl->forwardCommand($column_gui);
1923  }
1924  }
1925  else
1926  {
1927  // normal command processing
1928  return $this->getContent();
1929  }
1930  }
1931  }
1932  }
1933 
1937  protected function getRightColumnHTML()
1938  {
1939  global $ilUser, $lng, $ilCtrl;
1940 
1941  $obj_id = ilObject::_lookupObjId($this->object->getRefId());
1942  $obj_type = ilObject::_lookupType($obj_id);
1943 
1944  include_once("Services/Block/classes/class.ilColumnGUI.php");
1945  $column_gui = new ilColumnGUI($obj_type, IL_COL_RIGHT);
1946 
1947  if ($column_gui->getScreenMode() == IL_SCREEN_FULL)
1948  {
1949  return "";
1950  }
1951 
1952  $this->setColumnSettings($column_gui);
1953 
1954  if ($ilCtrl->getNextClass() == "ilcolumngui" &&
1955  $column_gui->getCmdSide() == IL_COL_RIGHT &&
1956  $column_gui->getScreenMode() == IL_SCREEN_SIDE)
1957  {
1958  $html = $ilCtrl->forwardCommand($column_gui);
1959  }
1960  else
1961  {
1962  if (!$ilCtrl->isAsynch())
1963  {
1964  $html = $ilCtrl->getHTML($column_gui);
1965  }
1966  }
1967 
1968  return $html;
1969  }
1970 
1974  protected function setColumnSettings($column_gui)
1975  {
1976  $column_gui->setRepositoryMode(true);
1977  $column_gui->setEnableEdit(false);
1978  if ($this->checkPermissionBool("write"))
1979  {
1980  $column_gui->setEnableEdit(true);
1981  }
1982  }
1983 
1993  protected function checkPermission($a_perm, $a_cmd = "", $a_type = "", $a_ref_id = null)
1994  {
1995  if (!$this->checkPermissionBool($a_perm, $a_cmd, $a_type, $a_ref_id))
1996  {
1997  if (!is_int(strpos($_SERVER["PHP_SELF"], "goto.php")))
1998  {
1999  // create: redirect to parent
2000  if($a_perm == "create")
2001  {
2002  if(!$a_ref_id)
2003  {
2004  $a_ref_id = $_GET["ref_id"];
2005  }
2006  $type = ilObject::_lookupType($a_ref_id, true);
2007  }
2008  else
2009  {
2010  // does this make sense?
2011  if (!is_object($this->object))
2012  {
2013  return;
2014  }
2015  if (!$a_ref_id)
2016  {
2017  $a_ref_id = $this->object->getRefId();
2018  }
2019  $type = $this->object->getType();
2020  }
2021 
2022  $_SESSION["il_rep_ref_id"] = "";
2023  ilUtil::sendFailure($this->lng->txt("permission_denied"), true);
2024  ilUtil::redirect("goto.php?target=".$type."_".$a_ref_id);
2025  }
2026  // we should never be here
2027  else
2028  {
2029  die("Permission Denied.");
2030  }
2031  }
2032  }
2033 
2043  protected function checkPermissionBool($a_perm, $a_cmd = "", $a_type = "", $a_ref_id = null)
2044  {
2045  global $ilAccess;
2046 
2047  if($a_perm == "create")
2048  {
2049  if(!$a_ref_id)
2050  {
2051  $a_ref_id = $_GET["ref_id"];
2052  }
2053  return $ilAccess->checkAccess($a_perm."_".$a_type, $a_cmd, $a_ref_id);
2054  }
2055  else
2056  {
2057  // does this make sense?
2058  if (!is_object($this->object))
2059  {
2060  return false;
2061  }
2062  if (!$a_ref_id)
2063  {
2064  $a_ref_id = $this->object->getRefId();
2065  }
2066  return $ilAccess->checkAccess($a_perm, $a_cmd, $a_ref_id);
2067  }
2068  }
2069 } // END class.ilObjectGUI (3.10: 2896 loc)
2070 
2071 ?>