ILIAS  release_4-4 Revision
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  // fileupload support
308  require_once './Services/FileUpload/classes/class.ilFileUploadUtil.php';
309  if (ilFileUploadUtil::isUploadAllowed($this->ref_id, $this->object->getType()))
310  {
311  $this->enableDragDropFileUpload();
312  }
313  }
314 
315  return true;
316  }
317 
321  protected function setTitleAndDescription()
322  {
323  if (!is_object($this->object))
324  {
325  if ((int) $_REQUEST["crtptrefid"] > 0)
326  {
327  $cr_obj_id = ilObject::_lookupObjId((int) $_REQUEST["crtcb"]);
328  $this->tpl->setTitle(ilObject::_lookupTitle($cr_obj_id));
329  $this->tpl->setTitleIcon(ilObject::_getIcon($cr_obj_id));
330  }
331  return;
332  }
333  $this->tpl->setTitle($this->object->getPresentationTitle());
334  $this->tpl->setDescription($this->object->getLongDescription());
335 
336  if (strtolower($_GET["baseClass"]) == "iladministrationgui")
337  {
338  // alt text would be same as heading -> empty alt text
339  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_".$this->object->getType()."_b.png"),
340  "");
341  }
342  else
343  {
344  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_".$this->object->getType()."_b.png"),
345  $this->lng->txt("obj_" . $this->object->getType()));
346  }
347 
348  include_once './Services/Object/classes/class.ilObjectListGUIFactory.php';
349  $lgui = ilObjectListGUIFactory::_getListGUIByType($this->object->getType());
350  $lgui->initItem($this->object->getRefId(), $this->object->getId());
351  $this->tpl->setAlertProperties($lgui->getAlertProperties());
352  }
353 
361  protected function initHeaderAction($a_sub_type = null, $a_sub_id = null)
362  {
363  global $ilAccess;
364 
365  if(!$this->creation_mode && $this->object)
366  {
367  include_once "Services/Object/classes/class.ilCommonActionDispatcherGUI.php";
369  $ilAccess, $this->object->getType(), $this->ref_id, $this->object->getId());
370 
371  $dispatcher->setSubObject($a_sub_type, $a_sub_id);
372 
373  include_once "Services/Object/classes/class.ilObjectListGUI.php";
374  ilObjectListGUI::prepareJSLinks($this->ctrl->getLinkTarget($this, "redrawHeaderAction", "", true),
375  $this->ctrl->getLinkTargetByClass(array("ilcommonactiondispatchergui", "ilnotegui"), "", "", true, false),
376  $this->ctrl->getLinkTargetByClass(array("ilcommonactiondispatchergui", "iltagginggui"), "", "", true, false));
377 
378  $lg = $dispatcher->initHeaderAction();
379 
380  if (is_object($lg))
381  {
382  // to enable add to desktop / remove from desktop
383  if($this instanceof ilDesktopItemHandling)
384  {
385  $lg->setContainerObject($this);
386  }
387 
388  // enable multi download
389  $lg->enableMultiDownload(true);
390 
391  // comments settings are always on (for the repository)
392  // should only be shown if active or permission to toggle
393  include_once "Services/Notes/classes/class.ilNote.php";
394  if($ilAccess->checkAccess("write", "", $this->ref_id) ||
395  $ilAccess->checkAccess("edit_permissions", "", $this->ref_id) ||
396  ilNote::commentsActivated($this->object->getId(), 0, $this->object->getType()))
397  {
398  $lg->enableComments(true);
399  }
400 
401  $lg->enableNotes(true);
402  $lg->enableTags(true);
403  }
404 
405  return $lg;
406  }
407  }
408 
414  protected function insertHeaderAction($a_list_gui)
415  {
416  if(is_object($a_list_gui))
417  {
418  $this->tpl->setHeaderActionMenu($a_list_gui->getHeaderAction());
419  }
420  }
421 
425  protected function addHeaderAction()
426  {
427  $this->insertHeaderAction($this->initHeaderAction());
428  }
429 
433  protected function redrawHeaderActionObject()
434  {
435  global $tpl;
436 
437  $lg = $this->initHeaderAction();
438  echo $lg->getHeaderAction();
439 
440  // we need to add onload code manually (rating, comments, etc.)
441  echo $tpl->getOnLoadCodeForAsynch();
442 
443  exit;
444  }
445 
446  // BEGIN WebDAV: Show Mount Webfolder Icon.
447  protected function showMountWebfolderIcon()
448  {
449  global $tree, $tpl, $objDefinition;
450 
451  if ($this->object->getRefId() == "")
452  {
453  return;
454  }
455 
456  $tpl->setMountWebfolderIcon($this->object->getRefId());
457  }
458  // END WebDAV: Show Mount Webfolder Icon.
459 
460 
465  protected function setTabs()
466  {
467  $this->getTabs($this->tabs_gui);
468  }
469 
474  protected final function setAdminTabs()
475  {
476  $this->getAdminTabs($this->tabs_gui);
477  }
478 
482  function getAdminTabs(&$tabs_gui)
483  {
484  global $tree;
485 
486 /* if ($_GET["admin_mode"] == "repository")
487  {
488  $this->ctrl->setParameterByClass("iladministrationgui", "admin_mode", "settings");
489  $tabs_gui->setBackTarget($this->lng->txt("administration"),
490  $this->ctrl->getLinkTargetByClass("iladministrationgui", "frameset"),
491  ilFrameTargetInfo::_getFrame("MainContent"));
492  $this->ctrl->setParameterByClass("iladministrationgui", "admin_mode", "repository");
493  }*/
494 
495  if ($this->checkPermissionBool("visible,read"))
496  {
497  $tabs_gui->addTarget("view",
498  $this->ctrl->getLinkTarget($this, "view"), array("", "view"), get_class($this));
499 
500  }
501 
502  if ($this->checkPermissionBool("edit_permission"))
503  {
504  $tabs_gui->addTarget("perm_settings",
505  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), "", "ilpermissiongui");
506  }
507 
508  if ($tree->getSavedNodeData($this->object->getRefId()))
509  {
510  $tabs_gui->addTarget("trash",
511  $this->ctrl->getLinkTarget($this, "trash"), "trash", get_class($this));
512  }
513  }
514 
515 
516  function getHTML()
517  {
518  return $this->html;
519  }
520 
521 
528  final private function setActions($a_actions = "")
529  {
530  if (is_array($a_actions))
531  {
532  foreach ($a_actions as $name => $lng)
533  {
534  $this->actions[$name] = array("name" => $name, "lng" => $lng);
535  }
536  }
537  else
538  {
539  $this->actions = "";
540  }
541  }
542 
549  final private function setSubObjects($a_sub_objects = "")
550  {
551  if (is_array($a_sub_objects))
552  {
553  foreach ($a_sub_objects as $name => $options)
554  {
555  $this->sub_objects[$name] = array("name" => $name, "max" => $options["max"]);
556  }
557  }
558  else
559  {
560  $this->sub_objects = "";
561  }
562  }
563 
572  protected function setLocator()
573  {
574  global $ilLocator, $tpl;
575 
576  if ($this->omit_locator)
577  {
578  return;
579  }
580 
581  // repository vs. workspace
582  if($this->call_by_reference)
583  {
584  // todo: admin workaround
585  // in the future, objectgui classes should not be called in
586  // admin section anymore (rbac/trash handling in own classes)
587  $ref_id = ($_GET["ref_id"] != "")
588  ? $_GET["ref_id"]
589  : $this->object->getRefId();
590  $ilLocator->addRepositoryItems($ref_id);
591  }
592 
593  if(!$this->creation_mode)
594  {
595  $this->addLocatorItems();
596  }
597 
598  // not so nice workaround: todo: handle $ilLocator as tabs in ilTemplate
599  if ($_GET["admin_mode"] == "" &&
600  strtolower($this->ctrl->getCmdClass()) == "ilobjrolegui")
601  {
602  $this->ctrl->setParameterByClass("ilobjrolegui",
603  "rolf_ref_id", $_GET["rolf_ref_id"]);
604  $this->ctrl->setParameterByClass("ilobjrolegui",
605  "obj_id", $_GET["obj_id"]);
606  $ilLocator->addItem($this->lng->txt("role"),
607  $this->ctrl->getLinkTargetByClass(array("ilpermissiongui",
608  "ilobjrolegui"), "perm"));
609  }
610 
611  $tpl->setLocator();
612  }
613 
618  protected function addLocatorItems()
619  {
620  }
621 
622  protected function omitLocator($a_omit = true)
623  {
624  $this->omit_locator = $a_omit;
625  }
626 
633  protected function addAdminLocatorItems($a_do_not_add_object = false)
634  {
635  global $ilLocator;
636 
637  if ($_GET["admin_mode"] == "settings") // system settings
638  {
639  $this->ctrl->setParameterByClass("ilobjsystemfoldergui",
640  "ref_id", SYSTEM_FOLDER_ID);
641  $ilLocator->addItem($this->lng->txt("administration"),
642  $this->ctrl->getLinkTargetByClass(array("iladministrationgui", "ilobjsystemfoldergui"), "")
643  );
644  if ($this->object->getRefId() != SYSTEM_FOLDER_ID && !$a_do_not_add_object)
645  {
646  $ilLocator->addItem($this->object->getTitle(),
647  $this->ctrl->getLinkTarget($this, "view"));
648  }
649  }
650  else // repository administration
651  {
652  $this->ctrl->setParameterByClass("iladministrationgui",
653  "ref_id", "");
654  $this->ctrl->setParameterByClass("iladministrationgui",
655  "admin_mode", "settings");
656  //$ilLocator->addItem($this->lng->txt("administration"),
657  // $this->ctrl->getLinkTargetByClass("iladministrationgui", "frameset"),
658  // ilFrameTargetInfo::_getFrame("MainContent"));
659  $this->ctrl->clearParametersByClass("iladministrationgui");
660  $ilLocator->addAdministrationItems();
661  }
662 
663  }
664 
669  public function confirmedDeleteObject()
670  {
671  global $ilSetting, $lng;
672 
673  if(isset($_POST["mref_id"]))
674  {
675  $_SESSION["saved_post"] = array_unique(array_merge($_SESSION["saved_post"], $_POST["mref_id"]));
676  }
677 
678  include_once("./Services/Repository/classes/class.ilRepUtilGUI.php");
679  $ru = new ilRepUtilGUI($this);
680  $ru->deleteObjects($_GET["ref_id"], ilSession::get("saved_post"));
681  ilSession::clear("saved_post");
682  $this->ctrl->returnToParent($this);
683  }
684 
690  public function cancelDeleteObject()
691  {
692  ilSession::clear("saved_post");
693  $this->ctrl->returnToParent($this);
694  }
695 
696 
702  public function cancelObject($in_rep = false)
703  {
704  ilSession::clear("saved_post");
705  $this->ctrl->returnToParent($this);
706  }
707 
713  public function createObject()
714  {
715  global $tpl, $ilErr;
716 
717  $new_type = $_REQUEST["new_type"];
718 
719 
720  // add new object to custom parent container
721  $this->ctrl->saveParameter($this, "crtptrefid");
722  // use forced callback after object creation
723  $this->ctrl->saveParameter($this, "crtcb");
724 
725  if (!$this->checkPermissionBool("create", "", $new_type))
726  {
727  $ilErr->raiseError($this->lng->txt("permission_denied"),$ilErr->MESSAGE);
728  }
729  else
730  {
731  $this->lng->loadLanguageModule($new_type);
732  $this->ctrl->setParameter($this, "new_type", $new_type);
733 
734  $forms = $this->initCreationForms($new_type);
735 
736  // copy form validation error: do not show other creation forms
737  if($_GET["cpfl"] && isset($forms[self::CFORM_CLONE]))
738  {
739  $forms = array(self::CFORM_CLONE => $forms[self::CFORM_CLONE]);
740  }
741 
742  $tpl->setContent($this->getCreationFormsHTML($forms));
743  }
744  }
745 
754  protected function initCreationForms($a_new_type)
755  {
756  $forms = array(
757  self::CFORM_NEW => $this->initCreateForm($a_new_type),
758  self::CFORM_IMPORT => $this->initImportForm($a_new_type),
759  self::CFORM_CLONE => $this->fillCloneTemplate(null, $a_new_type)
760  );
761 
762  return $forms;
763  }
764 
770  final protected function getCreationFormsHTML(array $a_forms)
771  {
772  global $tpl;
773 
774  // #13168 - sanity check
775  foreach($a_forms as $id => $form)
776  {
777  if(!$form instanceof ilPropertyFormGUI)
778  {
779  unset($a_forms[$id]);
780  }
781  }
782 
783  // no accordion if there is just one form
784  if(sizeof($a_forms) == 1)
785  {
786  $a_forms = array_shift($a_forms);
787  return $a_forms->getHTML();
788  }
789  else
790  {
791  include_once("./Services/Accordion/classes/class.ilAccordionGUI.php");
792 
793  $acc = new ilAccordionGUI();
794  $acc->setBehaviour(ilAccordionGUI::FIRST_OPEN);
795  $cnt = 1;
796  foreach ($a_forms as $form_type => $cf)
797  {
798  $htpl = new ilTemplate("tpl.creation_acc_head.html", true, true, "Services/Object");
799 // $htpl->setVariable("IMG_ARROW", ilUtil::getImagePath("accordion_arrow.png"));
800 
801  // using custom form titles (used for repository plugins)
802  $form_title = "";
803  if(method_exists($this, "getCreationFormTitle"))
804  {
805  $form_title = $this->getCreationFormTitle($form_type);
806  }
807  if(!$form_title)
808  {
809  $form_title = $cf->getTitle();
810  }
811 
812  // move title from form to accordion
813  $htpl->setVariable("TITLE", $this->lng->txt("option")." ".$cnt.": ".
814  $form_title);
815  $cf->setTitle(null);
816  $cf->setTitleIcon(null);
817  $cf->setTableWidth("100%");
818 
819  $acc->addItem($htpl->get(), $cf->getHTML());
820 
821  $cnt++;
822  }
823 
824  return "<div class='ilCreationFormSection'>".$acc->getHTML()."</div>";
825  }
826  }
827 
834  protected function initCreateForm($a_new_type)
835  {
836  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
837  $form = new ilPropertyFormGUI();
838  $form->setTarget("_top");
839  $form->setFormAction($this->ctrl->getFormAction($this, "save"));
840  $form->setTitle($this->lng->txt($a_new_type."_new"));
841 
842  // title
843  $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
844  $ti->setSize(min(40, ilObject::TITLE_LENGTH));
845  $ti->setMaxLength(ilObject::TITLE_LENGTH);
846  $ti->setRequired(true);
847  $form->addItem($ti);
848 
849  // description
850  $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
851  $ta->setCols(40);
852  $ta->setRows(2);
853  $form->addItem($ta);
854 
855  $form = $this->initDidacticTemplate($form);
856 
857  $form->addCommandButton("save", $this->lng->txt($a_new_type."_add"));
858  $form->addCommandButton("cancel", $this->lng->txt("cancel"));
859 
860  return $form;
861  }
862 
868  protected function initDidacticTemplate(ilPropertyFormGUI $form)
869  {
870  global $lng;
871 
872  $lng->loadLanguageModule('didactic');
873 
874  $options = array();
875  $options['dtpl_0'] = array($this->lng->txt('didactic_default_type'),
876  sprintf(
877  $this->lng->txt('didactic_default_type_info'),
878  $this->lng->txt('objs_'.$this->type)
879  ));
880 
881  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateSettings.php';
882  $templates = ilDidacticTemplateSettings::getInstanceByObjectType($this->type)->getTemplates();
883  if($templates)
884  {
885  foreach($templates as $template)
886  {
887  $options["dtpl_".$template->getId()] = array($template->getTitle(),
888  $template->getDescription());
889  }
890  }
891 
893 
894  if(sizeof($options) > 1)
895  {
896  $type = new ilRadioGroupInputGUI(
897  $this->lng->txt('type'),
898  'didactic_type'
899  );
900  // workaround for containers in edit mode
901  if(!$this->getCreationMode())
902  {
903  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php';
904  $type->setValue(
905  'dtpl_'.ilDidacticTemplateObjSettings::lookupTemplateId($this->object->getRefId())
906  );
907  }
908  else
909  {
910  $type->setValue('dtpl_0');
911  }
912  $form->addItem($type);
913 
915  foreach($options as $id => $data)
916  {
917  $option = new ilRadioOption($data[0], $id, $data[1]);
918  $type->addOption($option);
919  }
920  }
921 
922  return $form;
923  }
924 
930  protected function addDidacticTemplateOptions(array &$a_options)
931  {
932 
933  }
934 
938  public function cancelCreation()
939  {
940  global $ilCtrl;
941 
942  $ilCtrl->redirectByClass("ilrepositorygui", "frameset");
943  }
944 
950  public function saveObject()
951  {
952  global $objDefinition, $tpl;
953 
954  $new_type = $_REQUEST["new_type"];
955 
956  // create permission is already checked in createObject. This check here is done to prevent hacking attempts
957  if (!$this->checkPermissionBool("create", "", $new_type))
958  {
959  $this->ilias->raiseError($this->lng->txt("no_create_permission"), $this->ilias->error_obj->MESSAGE);
960  }
961 
962  $this->lng->loadLanguageModule($new_type);
963  $this->ctrl->setParameter($this, "new_type", $new_type);
964 
965  $form = $this->initCreateForm($new_type);
966  if ($form->checkInput())
967  {
968  $this->ctrl->setParameter($this, "new_type", "");
969 
970  // create instance
971  $class_name = "ilObj".$objDefinition->getClassName($new_type);
972  $location = $objDefinition->getLocation($new_type);
973  include_once($location."/class.".$class_name.".php");
974  $newObj = new $class_name();
975  $newObj->setType($new_type);
976  $newObj->setTitle($form->getInput("title"));
977  $newObj->setDescription($form->getInput("desc"));
978  $newObj->create();
979 
980  $this->putObjectInTree($newObj);
981 
982  // apply didactic template?
983  $dtpl = $this->getDidacticTemplateVar("dtpl");
984  if($dtpl)
985  {
986  $newObj->applyDidacticTemplate($dtpl);
987  }
988 
989  // auto rating
990  $this->handleAutoRating($newObj);
991 
992  // additional paramters are added to afterSave()
993  $args = func_get_args();
994  if($args)
995  {
996  $this->afterSave($newObj, $args);
997  }
998  else
999  {
1000  $this->afterSave($newObj);
1001  }
1002  return;
1003  }
1004 
1005  // display only this form to correct input
1006  $form->setValuesByPost();
1007  $tpl->setContent($form->getHtml());
1008  }
1009 
1016  protected function getDidacticTemplateVar($a_type)
1017  {
1018  $tpl = $_POST["didactic_type"];
1019  if($tpl && substr($tpl, 0, strlen($a_type)+1) == $a_type."_")
1020  {
1021  return (int)substr($tpl, strlen($a_type)+1);
1022  }
1023  }
1024 
1031  protected function putObjectInTree(ilObject $a_obj, $a_parent_node_id = null)
1032  {
1033  global $rbacreview, $ilUser, $objDefinition;
1034 
1035  if(!$a_parent_node_id)
1036  {
1037  $a_parent_node_id = $_GET["ref_id"];
1038  }
1039 
1040  // add new object to custom parent container
1041  if((int)$_REQUEST["crtptrefid"])
1042  {
1043  $a_parent_node_id = (int)$_REQUEST["crtptrefid"];
1044  }
1045 
1046  $a_obj->createReference();
1047  $a_obj->putInTree($a_parent_node_id);
1048  $a_obj->setPermissions($a_parent_node_id);
1049 
1050  $this->obj_id = $a_obj->getId();
1051  $this->ref_id = $a_obj->getRefId();
1052 
1053  // BEGIN ChangeEvent: Record save object.
1054  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
1055  ilChangeEvent::_recordWriteEvent($this->obj_id, $ilUser->getId(), 'create');
1056  // END ChangeEvent: Record save object.
1057 
1058  // rbac log
1059  include_once "Services/AccessControl/classes/class.ilRbacLog.php";
1060  $rbac_log_roles = $rbacreview->getParentRoleIds($this->ref_id, false);
1061  $rbac_log = ilRbacLog::gatherFaPa($this->ref_id, array_keys($rbac_log_roles), true);
1062  ilRbacLog::add(ilRbacLog::CREATE_OBJECT, $this->ref_id, $rbac_log);
1063 
1064  // use forced callback after object creation
1065  if($_REQUEST["crtcb"])
1066  {
1067  $callback_type = ilObject::_lookupType((int)$_REQUEST["crtcb"], true);
1068  $class_name = "ilObj".$objDefinition->getClassName($callback_type)."GUI";
1069  $location = $objDefinition->getLocation($callback_type);
1070  include_once($location."/class.".$class_name.".php");
1071  if (in_array(strtolower($class_name), array("ilobjitemgroupgui")))
1072  {
1073  $callback_obj = new $class_name((int)$_REQUEST["crtcb"]);
1074  }
1075  else
1076  {
1077  // #10368
1078  $callback_obj = new $class_name(null, (int)$_REQUEST["crtcb"], true, false);
1079  }
1080  $callback_obj->afterSaveCallback($a_obj);
1081  }
1082  }
1083 
1089  protected function afterSave(ilObject $a_new_object)
1090  {
1091  ilUtil::sendSuccess($this->lng->txt("object_added"), true);
1092  $this->ctrl->returnToParent($this);
1093  }
1094 
1100  public function editObject()
1101  {
1102  global $tpl, $ilTabs;
1103 
1104  if (!$this->checkPermissionBool("write"))
1105  {
1106  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
1107  }
1108 
1109  $ilTabs->activateTab("settings");
1110 
1111  $form = $this->initEditForm();
1112  $values = $this->getEditFormValues();
1113  if($values)
1114  {
1115  $form->setValuesByArray($values);
1116  }
1117  $tpl->setContent($form->getHTML());
1118  }
1119 
1125  protected function initEditForm()
1126  {
1127  global $lng, $ilCtrl;
1128 
1129  $lng->loadLanguageModule($this->object->getType());
1130 
1131  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1132  $form = new ilPropertyFormGUI();
1133  $form->setFormAction($this->ctrl->getFormAction($this, "update"));
1134  $form->setTitle($this->lng->txt($this->object->getType()."_edit"));
1135 
1136  // title
1137  $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
1138  $ti->setSize(min(40, ilObject::TITLE_LENGTH));
1139  $ti->setMaxLength(ilObject::TITLE_LENGTH);
1140  $ti->setRequired(true);
1141  $form->addItem($ti);
1142 
1143  // description
1144  $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
1145  $ta->setCols(40);
1146  $ta->setRows(2);
1147  $form->addItem($ta);
1148 
1149  $this->initEditCustomForm($form);
1150 
1151  $form->addCommandButton("update", $this->lng->txt("save"));
1152  //$this->form->addCommandButton("cancelUpdate", $lng->txt("cancel"));
1153 
1154  return $form;
1155  }
1156 
1162  protected function initEditCustomForm(ilPropertyFormGUI $a_form)
1163  {
1164 
1165  }
1166 
1172  protected function getEditFormValues()
1173  {
1174  $values["title"] = $this->object->getTitle();
1175  $values["desc"] = $this->object->getLongDescription();
1176  $this->getEditFormCustomValues($values);
1177  return $values;
1178  }
1179 
1185  protected function getEditFormCustomValues(array &$a_values)
1186  {
1187 
1188  }
1189 
1193  public function updateObject()
1194  {
1195  global $ilTabs, $tpl;
1196 
1197  if (!$this->checkPermissionBool("write"))
1198  {
1199  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
1200  }
1201 
1202  $form = $this->initEditForm();
1203  if($form->checkInput())
1204  {
1205  $this->object->setTitle($form->getInput("title"));
1206  $this->object->setDescription($form->getInput("desc"));
1207  $this->updateCustom($form);
1208  $this->object->update();
1209 
1210  $this->afterUpdate();
1211  return;
1212  }
1213 
1214  // display form again to correct errors
1215  $ilTabs->activateTab("settings");
1216  $form->setValuesByPost();
1217  $tpl->setContent($form->getHtml());
1218  }
1219 
1225  protected function updateCustom(ilPropertyFormGUI $a_form)
1226  {
1227 
1228  }
1229 
1233  protected function afterUpdate()
1234  {
1235  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
1236  $this->ctrl->redirect($this, "edit");
1237  }
1238 
1245  protected function initImportForm($a_new_type)
1246  {
1247  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1248  $form = new ilPropertyFormGUI();
1249  $form->setTarget("_top");
1250  $form->setFormAction($this->ctrl->getFormAction($this, "importFile"));
1251  $form->setTitle($this->lng->txt($a_new_type."_import"));
1252 
1253  include_once("./Services/Form/classes/class.ilFileInputGUI.php");
1254  $fi = new ilFileInputGUI($this->lng->txt("import_file"), "importfile");
1255  $fi->setSuffixes(array("zip"));
1256  $fi->setRequired(true);
1257  $form->addItem($fi);
1258 
1259  $form->addCommandButton("importFile", $this->lng->txt("import"));
1260  $form->addCommandButton("cancel", $this->lng->txt("cancel"));
1261 
1262  return $form;
1263  }
1264 
1268  protected function importFileObject($parent_id = null)
1269  {
1270  global $objDefinition, $tpl, $ilErr;
1271 
1272  if(!$parent_id)
1273  {
1274  $parent_id = $_GET["ref_id"];
1275  }
1276  $new_type = $_REQUEST["new_type"];
1277 
1278  // create permission is already checked in createObject. This check here is done to prevent hacking attempts
1279  if (!$this->checkPermissionBool("create", "", $new_type))
1280  {
1281  $ilErr->raiseError($this->lng->txt("no_create_permission"));
1282  }
1283 
1284  $this->lng->loadLanguageModule($new_type);
1285  $this->ctrl->setParameter($this, "new_type", $new_type);
1286 
1287  $form = $this->initImportForm($new_type);
1288  if ($form->checkInput())
1289  {
1290  // :todo: make some check on manifest file
1291 
1292  if($objDefinition->isContainer($new_type))
1293  {
1294  include_once './Services/Export/classes/class.ilImportContainer.php';
1295  $imp = new ilImportContainer((int)$parent_id);
1296  }
1297  else
1298  {
1299  include_once("./Services/Export/classes/class.ilImport.php");
1300  $imp = new ilImport((int)$parent_id);
1301  }
1302 
1303  $new_id = $imp->importObject(null, $_FILES["importfile"]["tmp_name"],
1304  $_FILES["importfile"]["name"], $new_type);
1305 
1306  if ($new_id > 0)
1307  {
1308  $this->ctrl->setParameter($this, "new_type", "");
1309 
1310  $newObj = ilObjectFactory::getInstanceByObjId($new_id);
1311 
1312  // put new object id into tree - already done in import for containers
1313  if(!$objDefinition->isContainer($new_type))
1314  {
1315  $this->putObjectInTree($newObj);
1316  }
1317 
1318  $this->afterImport($newObj);
1319  }
1320  // import failed
1321  else
1322  {
1323  if($objDefinition->isContainer($new_type))
1324  {
1325  ilUtil::sendFailure($this->lng->txt("container_import_zip_file_invalid"));
1326  }
1327  else
1328  {
1329  // not enough information here...
1330  return;
1331  }
1332  }
1333  }
1334 
1335  // display form to correct errors
1336  $form->setValuesByPost();
1337  $tpl->setContent($form->getHtml());
1338  }
1339 
1345  protected function afterImport(ilObject $a_new_object)
1346  {
1347  ilUtil::sendSuccess($this->lng->txt("object_added"), true);
1348  $this->ctrl->returnToParent($this);
1349  }
1350 
1359  public function getFormAction($a_cmd, $a_formaction = "")
1360  {
1361  if ($this->formaction[$a_cmd] != "")
1362  {
1363  return $this->formaction[$a_cmd];
1364  }
1365  else
1366  {
1367  return $a_formaction;
1368  }
1369  }
1370 
1379  protected function setFormAction($a_cmd, $a_formaction)
1380  {
1381  $this->formaction[$a_cmd] = $a_formaction;
1382  }
1383 
1391  protected function getReturnLocation($a_cmd, $a_location ="")
1392  {
1393  if ($this->return_location[$a_cmd] != "")
1394  {
1395  return $this->return_location[$a_cmd];
1396  }
1397  else
1398  {
1399  return $a_location;
1400  }
1401  }
1402 
1410  protected function setReturnLocation($a_cmd, $a_location)
1411  {
1412 //echo "-".$a_cmd."-".$a_location."-";
1413  $this->return_location[$a_cmd] = $a_location;
1414  }
1415 
1423  protected function getTargetFrame($a_cmd, $a_target_frame = "")
1424  {
1425  if ($this->target_frame[$a_cmd] != "")
1426  {
1427  return $this->target_frame[$a_cmd];
1428  }
1429  elseif (!empty($a_target_frame))
1430  {
1431  return "target=\"".$a_target_frame."\"";
1432  }
1433  else
1434  {
1435  return;
1436  }
1437  }
1438 
1446  protected function setTargetFrame($a_cmd, $a_target_frame)
1447  {
1448  $this->target_frame[$a_cmd] = "target=\"".$a_target_frame."\"";
1449  }
1450 
1451  // BEGIN Security: Hide objects which aren't accessible by the user.
1452  public function isVisible($a_ref_id,$a_type)
1453  {
1454  global $ilBench;
1455 
1456  $ilBench->start("Explorer", "setOutput_isVisible");
1457  $visible = $this->checkPermissionBool("visible,read", "", "", $a_ref_id);
1458 
1459  if ($visible && $a_type == 'crs') {
1460  global $tree;
1461  if($crs_id = $tree->checkForParentType($a_ref_id,'crs'))
1462  {
1463  if(!$this->checkPermissionBool("write", "", "", $crs_id))
1464  {
1465  // Show only activated courses
1466  $tmp_obj =& ilObjectFactory::getInstanceByRefId($crs_id,false);
1467 
1468  if(!$tmp_obj->isActivated())
1469  {
1470  unset($tmp_obj);
1471  $visible = false;
1472  }
1473  if(($crs_id != $a_ref_id) and $tmp_obj->isArchived())
1474  {
1475  $visible = false;
1476  }
1477  }
1478  }
1479  }
1480 
1481  $ilBench->stop("Explorer", "setOutput_isVisible");
1482 
1483  return $visible;
1484  }
1485  // END Security: Hide objects which aren't accessible by the user.
1486 
1492  public function viewObject()
1493  {
1494  global$tpl;
1495 
1496  if (!$this->checkPermissionBool("visible,read"))
1497  {
1498  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
1499  }
1500 
1501  // BEGIN ChangeEvent: record read event.
1502  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
1503  global $ilUser;
1505  $this->object->getType(),
1506  $this->object->getRefId(),
1507  $this->object->getId(), $ilUser->getId());
1508  // END ChangeEvent: record read event.
1509 
1510  include_once("./Services/Repository/classes/class.ilAdminSubItemsTableGUI.php");
1511  if (!$this->call_by_reference)
1512  {
1513  $this->ctrl->setParameter($this, "obj_id", $this->obj_id);
1514  }
1515  $itab = new ilAdminSubItemsTableGUI($this, "view", $_GET["ref_id"]);
1516 
1517  $tpl->setContent($itab->getHTML());
1518  }
1519 
1527  public function deleteObject($a_error = false)
1528  {
1529  global $ilCtrl;
1530 
1531  if ($_GET["item_ref_id"] != "")
1532  {
1533  $_POST["id"] = array($_GET["item_ref_id"]);
1534  }
1535 
1536  if(is_array($_POST["id"]))
1537  {
1538  foreach($_POST["id"] as $idx => $id)
1539  {
1540  $_POST["id"][$idx] = (int)$id;
1541  }
1542  }
1543 
1544  // SAVE POST VALUES (get rid of this
1545  ilSession::set("saved_post", $_POST["id"]);
1546 
1547  include_once("./Services/Repository/classes/class.ilRepUtilGUI.php");
1548  $ru = new ilRepUtilGUI($this);
1549  if (!$ru->showDeleteConfirmation($_POST["id"], $a_error))
1550  {
1551  $ilCtrl->returnToParent($this);
1552  }
1553  }
1554 
1560  protected function showPossibleSubObjects()
1561  {
1562  if ($this->sub_objects == "")
1563  {
1564  $d = $this->objDefinition->getCreatableSubObjects($this->object->getType());
1565  }
1566  else
1567  {
1569  }
1570 
1571  $import = false;
1572 
1573  if (count($d) > 0)
1574  {
1575  foreach ($d as $row)
1576  {
1577  $count = 0;
1578 
1579  if ($row["max"] > 0)
1580  {
1581  //how many elements are present?
1582  for ($i=0; $i<count($this->data["ctrl"]); $i++)
1583  {
1584  if ($this->data["ctrl"][$i]["type"] == $row["name"])
1585  {
1586  $count++;
1587  }
1588  }
1589  }
1590 
1591  if ($row["max"] == "" || $count < $row["max"])
1592  {
1593  $subobj[] = $row["name"];
1594  }
1595  }
1596  }
1597 
1598  if (is_array($subobj))
1599  {
1600 
1601  //build form
1602  $opts = ilUtil::formSelect(12,"new_type",$subobj);
1603  $this->tpl->setCurrentBlock("add_object");
1604  $this->tpl->setVariable("SELECT_OBJTYPE", $opts);
1605  $this->tpl->setVariable("BTN_NAME", "create");
1606  $this->tpl->setVariable("TXT_ADD", $this->lng->txt("add"));
1607  $this->tpl->parseCurrentBlock();
1608  }
1609  }
1610 
1619  final protected function getTemplateFile($a_cmd,$a_type = "")
1620  {
1621  mk(); die("ilObjectGUI::getTemplateFile() is deprecated.");
1622  }
1623 
1632  protected function getTitlesByRefId($a_ref_ids)
1633  {
1634  foreach ($a_ref_ids as $id)
1635  {
1636  // GET OBJECT TITLE
1637  $tmp_obj =& $this->ilias->obj_factory->getInstanceByRefId($id);
1638  $title[] = $tmp_obj->getTitle();
1639  unset($tmp_obj);
1640  }
1641 
1642  return $title ? $title : array();
1643  }
1644 
1652  protected function getTabs(&$tabs_gui)
1653  {
1654  // please define your tabs here
1655 
1656  }
1657 
1658  // PROTECTED
1659  protected function __showButton($a_cmd,$a_text,$a_target = '')
1660  {
1661  global $ilToolbar;
1662 
1663  $ilToolbar->addButton($a_text, $this->ctrl->getLinkTarget($this, $a_cmd), $a_target);
1664  }
1665 
1666  protected function hitsperpageObject()
1667  {
1668  ilSession::set("tbl_limit", $_POST["hitsperpage"]);
1669  $_GET["limit"] = $_POST["hitsperpage"];
1670  }
1671 
1672 
1673  protected function &__initTableGUI()
1674  {
1675  include_once "./Services/Table/classes/class.ilTableGUI.php";
1676 
1677  return new ilTableGUI(0,false);
1678  }
1679 
1685  protected function __setTableGUIBasicData(&$tbl,&$result_set,$a_from = "")
1686  {
1687  switch ($a_from)
1688  {
1689  case "clipboardObject":
1690  $offset = $_GET["offset"];
1691  $order = $_GET["sort_by"];
1692  $direction = $_GET["sort_order"];
1693  $tbl->disable("footer");
1694  break;
1695 
1696  default:
1697  $offset = $_GET["offset"];
1698  $order = $_GET["sort_by"];
1699  $direction = $_GET["sort_order"];
1700  break;
1701  }
1702 
1703  $tbl->setOrderColumn($order);
1704  $tbl->setOrderDirection($direction);
1705  $tbl->setOffset($offset);
1706  $tbl->setLimit($_GET["limit"]);
1707  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
1708  $tbl->setData($result_set);
1709  }
1710 
1720  protected function redirectToRefId($a_ref_id, $a_cmd = "")
1721  {
1722  $obj_type = ilObject::_lookupType($a_ref_id,true);
1723  $class_name = $this->objDefinition->getClassName($obj_type);
1724  $class = strtolower("ilObj".$class_name."GUI");
1725  $this->ctrl->setParameterByClass("ilrepositorygui", "ref_id", $a_ref_id);
1726  $this->ctrl->redirectByClass(array("ilrepositorygui", $class), $a_cmd);
1727  }
1728 
1729  // Object Cloning
1739  protected function fillCloneTemplate($a_tpl_varname,$a_type)
1740  {
1741  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
1742  $cp = new ilObjectCopyGUI($this);
1743  $cp->setType($a_type);
1744  $cp->setTarget($_GET['ref_id']);
1745  if($a_tpl_varname)
1746  {
1747  $cp->showSourceSearch($a_tpl_varname);
1748  }
1749  else
1750  {
1751  return $cp->showSourceSearch(null);
1752  }
1753  }
1754 
1761  public function cloneAllObject()
1762  {
1763  include_once('./Services/Link/classes/class.ilLink.php');
1764  include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
1765 
1766  global $ilErr,$ilUser;
1767 
1768  $new_type = $_REQUEST['new_type'];
1769  if(!$this->checkPermissionBool("create", "", $new_type))
1770  {
1771  $ilErr->raiseError($this->lng->txt('permission_denied'));
1772  }
1773  if(!(int) $_REQUEST['clone_source'])
1774  {
1775  ilUtil::sendFailure($this->lng->txt('select_one'));
1776  $this->createObject();
1777  return false;
1778  }
1779  if(!$this->checkPermissionBool("write", "", $new_type, (int)$_REQUEST['clone_source']))
1780  {
1781  $ilErr->raiseError($this->lng->txt('permission_denied'));
1782  }
1783 
1784  // Save wizard options
1786  $wizard_options = ilCopyWizardOptions::_getInstance($copy_id);
1787  $wizard_options->saveOwner($ilUser->getId());
1788  $wizard_options->saveRoot((int) $_REQUEST['clone_source']);
1789 
1790  $options = $_POST['cp_options'] ? $_POST['cp_options'] : array();
1791  foreach($options as $source_id => $option)
1792  {
1793  $wizard_options->addEntry($source_id,$option);
1794  }
1795  $wizard_options->read();
1796 
1797  $orig = ilObjectFactory::getInstanceByRefId((int) $_REQUEST['clone_source']);
1798  $new_obj = $orig->cloneObject((int) $_GET['ref_id'],$copy_id);
1799 
1800  // Delete wizard options
1801  $wizard_options->deleteAll();
1802 
1803  ilUtil::sendSuccess($this->lng->txt("object_duplicated"),true);
1804  ilUtil::redirect(ilLink::_getLink($new_obj->getRefId()));
1805  }
1806 
1807 
1811  protected function getCenterColumnHTML()
1812  {
1813  global $ilCtrl;
1814 
1815  include_once("Services/Block/classes/class.ilColumnGUI.php");
1816 
1817  $obj_id = ilObject::_lookupObjId($this->object->getRefId());
1818  $obj_type = ilObject::_lookupType($obj_id);
1819 
1820  if ($ilCtrl->getNextClass() != "ilcolumngui")
1821  {
1822  // normal command processing
1823  return $this->getContent();
1824  }
1825  else
1826  {
1827  if (!$ilCtrl->isAsynch())
1828  {
1829  //if ($column_gui->getScreenMode() != IL_SCREEN_SIDE)
1831  {
1832  // right column wants center
1834  {
1835  $column_gui = new ilColumnGUI($obj_type, IL_COL_RIGHT);
1836  $this->setColumnSettings($column_gui);
1837  $this->html = $ilCtrl->forwardCommand($column_gui);
1838  }
1839  // left column wants center
1841  {
1842  $column_gui = new ilColumnGUI($obj_type, IL_COL_LEFT);
1843  $this->setColumnSettings($column_gui);
1844  $this->html = $ilCtrl->forwardCommand($column_gui);
1845  }
1846  }
1847  else
1848  {
1849  // normal command processing
1850  return $this->getContent();
1851  }
1852  }
1853  }
1854  }
1855 
1859  protected function getRightColumnHTML()
1860  {
1861  global $ilUser, $lng, $ilCtrl;
1862 
1863  $obj_id = ilObject::_lookupObjId($this->object->getRefId());
1864  $obj_type = ilObject::_lookupType($obj_id);
1865 
1866  include_once("Services/Block/classes/class.ilColumnGUI.php");
1867  $column_gui = new ilColumnGUI($obj_type, IL_COL_RIGHT);
1868 
1869  if ($column_gui->getScreenMode() == IL_SCREEN_FULL)
1870  {
1871  return "";
1872  }
1873 
1874  $this->setColumnSettings($column_gui);
1875 
1876  if ($ilCtrl->getNextClass() == "ilcolumngui" &&
1877  $column_gui->getCmdSide() == IL_COL_RIGHT &&
1878  $column_gui->getScreenMode() == IL_SCREEN_SIDE)
1879  {
1880  $html = $ilCtrl->forwardCommand($column_gui);
1881  }
1882  else
1883  {
1884  if (!$ilCtrl->isAsynch())
1885  {
1886  $html = $ilCtrl->getHTML($column_gui);
1887  }
1888  }
1889 
1890  return $html;
1891  }
1892 
1896  protected function setColumnSettings($column_gui)
1897  {
1898  $column_gui->setRepositoryMode(true);
1899  $column_gui->setEnableEdit(false);
1900  if ($this->checkPermissionBool("write"))
1901  {
1902  $column_gui->setEnableEdit(true);
1903  }
1904  }
1905 
1915  protected function checkPermission($a_perm, $a_cmd = "", $a_type = "", $a_ref_id = null)
1916  {
1917  if (!$this->checkPermissionBool($a_perm, $a_cmd, $a_type, $a_ref_id))
1918  {
1919  if (!is_int(strpos($_SERVER["PHP_SELF"], "goto.php")))
1920  {
1921  // create: redirect to parent
1922  if($a_perm == "create")
1923  {
1924  if(!$a_ref_id)
1925  {
1926  $a_ref_id = $_GET["ref_id"];
1927  }
1928  $type = ilObject::_lookupType($a_ref_id, true);
1929  }
1930  else
1931  {
1932  // does this make sense?
1933  if (!is_object($this->object))
1934  {
1935  return;
1936  }
1937  if (!$a_ref_id)
1938  {
1939  $a_ref_id = $this->object->getRefId();
1940  }
1941  $type = $this->object->getType();
1942  }
1943 
1944  ilSession::clear("il_rep_ref_id");
1945  ilUtil::sendFailure($this->lng->txt("permission_denied"), true);
1946  ilUtil::redirect("goto.php?target=".$type."_".$a_ref_id);
1947  }
1948  // we should never be here
1949  else
1950  {
1951  die("Permission Denied.");
1952  }
1953  }
1954  }
1955 
1965  protected function checkPermissionBool($a_perm, $a_cmd = "", $a_type = "", $a_ref_id = null)
1966  {
1967  global $ilAccess;
1968 
1969  if($a_perm == "create")
1970  {
1971  if(!$a_ref_id)
1972  {
1973  $a_ref_id = $_GET["ref_id"];
1974  }
1975  return $ilAccess->checkAccess($a_perm."_".$a_type, $a_cmd, $a_ref_id);
1976  }
1977  else
1978  {
1979  // does this make sense?
1980  if (!is_object($this->object))
1981  {
1982  return false;
1983  }
1984  if (!$a_ref_id)
1985  {
1986  $a_ref_id = $this->object->getRefId();
1987  }
1988  return $ilAccess->checkAccess($a_perm, $a_cmd, $a_ref_id);
1989  }
1990  }
1991 
1998  static function _gotoRepositoryRoot($a_raise_error = false)
1999  {
2000  global $ilAccess, $ilErr;
2001 
2002  if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
2003  {
2004  $_GET["cmd"] = "frameset";
2005  $_GET["target"] = "";
2006  $_GET["ref_id"] = ROOT_FOLDER_ID;
2007  $_GET["baseClass"] = "ilRepositoryGUI";
2008  include("ilias.php");
2009  exit;
2010  }
2011 
2012  if ($a_raise_error)
2013  {
2014  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
2015  }
2016  }
2017 
2024  static function _gotoRepositoryNode($a_ref_id, $a_cmd = "frameset")
2025  {
2026  global $ilAccess, $ilErr;
2027 
2028  $_GET["cmd"] = $a_cmd;
2029  $_GET["target"] = "";
2030  $_GET["ref_id"] = $a_ref_id;
2031  $_GET["baseClass"] = "ilRepositoryGUI";
2032  include("ilias.php");
2033  exit;
2034  }
2035 
2039  protected function enableDragDropFileUpload()
2040  {
2041  include_once("./Services/FileUpload/classes/class.ilFileUploadGUI.php");
2043 
2044  $this->tpl->enableDragDropFileUpload($this->ref_id);
2045  }
2046 
2052  protected function handleAutoRating(ilObject $a_new_obj)
2053  {
2054  if(ilObject::hasAutoRating($a_new_obj->getType(), $a_new_obj->getRefId()) &&
2055  method_exists($a_new_obj, "setRating"))
2056  {
2057  $a_new_obj->setRating(true);
2058  $a_new_obj->update();
2059  }
2060  }
2061 
2062 } // END class.ilObjectGUI (3.10: 2896 loc)
2063 
2064 ?>
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
redrawHeaderActionObject()
Ajax call: redraw action header only.
static lookupTemplateId($a_ref_id)
Lookup template id ilDB $ilDB.
setSubObjects($a_sub_objects="")
set possible subobjects for this object.
static initFileUpload()
Initializes the file upload and loads the needed javascripts and styles.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
This class represents an option in a radio group.
static _getIcon($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
addAdminLocatorItems($a_do_not_add_object=false)
should be overwritten to add object specific items (repository items are preloaded) ...
static getCmdSide()
Get Column Side of Current Command.
exit
Definition: login.php:54
$_POST['username']
Definition: cron.php:12
setTargetFrame($a_cmd, $a_target_frame)
set specific target frame for command
const PEAR_ERROR_CALLBACK
Definition: PEAR.php:35
getTitlesByRefId($a_ref_ids)
get Titles of objects this method is used for error messages in methods cut/copy/paste ...
getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
enableDragDropFileUpload()
Enables the file upload into this object by dropping files.
TableGUI class for sub items listed in repository administration.
cancelCreation()
cancel create action and go back to repository parent
This class represents a property form user interface.
GUI class for the workflow of copying objects.
initCreationForms($a_new_type)
Init creation froms.
const TITLE_LENGTH
max length of object title
$_GET["client_id"]
$location
Definition: buildRTE.php:44
This class represents a file property in a property form.
__setTableGUIBasicData(&$tbl, &$result_set, $a_from="")
standard implementation for tables use &#39;from&#39; variable use different initial setting of table ...
Class ilObject Basic functions for all objects.
initHeaderAction($a_sub_type=null, $a_sub_id=null)
Add header action menu.
__showButton($a_cmd, $a_text, $a_target='')
setReturnLocation($a_cmd, $a_location)
set specific return location for command
$cmd
Definition: sahs_server.php:35
static get($a_var)
Get a value.
static _gotoRepositoryRoot($a_raise_error=false)
Goto repository root.
setFormAction($a_cmd, $a_formaction)
set specific form action for command
static set($a_var, $a_val)
Set a value.
Import class.
static _isActive()
Static getter.
cancelObject($in_rep=false)
cancel action and go back to previous page public
ilObjectGUI($a_data, $a_id=0, $a_call_by_reference=true, $a_prepare_output=true)
Constructor public.
static _lookupTitle($a_id)
lookup object title
setActions($a_actions="")
set possible actions for objects in list.
setCreationMode($a_mode=true)
if true, a creation screen is displayed the current $_GET[ref_id] don&#39;t belong to the current class! ...
importFileObject($parent_id=null)
Import.
const IL_COL_RIGHT
confirmedDeleteObject()
confirmed deletion of object -> objects are moved to trash or deleted immediately, if trash is disabled
addItem($a_item)
Add Item (Property, SectionHeader).
viewObject()
list childs of current object
createObject()
create new object form
Class ilTableGUI.
afterSave(ilObject $a_new_object)
Post (successful) object creation hook.
cloneAllObject()
Clone single (not container object) Method is overwritten in ilContainerGUI.
fillCloneTemplate($a_tpl_varname, $a_type)
Fill object clone template This method can be called from any object GUI class that wants to offer ob...
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static gatherFaPa($a_ref_id, array $a_role_ids, $a_add_action=false)
cancelDeleteObject()
cancel deletion of object
global $ilCtrl
Definition: ilias.php:18
static hasAutoRating($a_type, $a_ref_id)
Check if auto rating is active for parent group/course.
getCenterColumnHTML()
Get center column.
updateCustom(ilPropertyFormGUI $a_form)
Insert custom update form values into object.
createReference()
creates reference for object
initImportForm($a_new_type)
Init object import form.
const CREATE_OBJECT
getCreationFormsHTML(array $a_forms)
Get HTML for creation forms (accordion)
isVisible($a_ref_id, $a_type)
const IL_SCREEN_FULL
This class represents a property in a property form.
static _getInstance($a_copy_id)
Get instance of copy wizard options.
if(!is_array($argv)) $options
& executeCommand()
execute command
getId()
get object id public
getTargetFrame($a_cmd, $a_target_frame="")
get target frame for command (command is method name without "Object", e.g.
static _gotoRepositoryNode($a_ref_id, $a_cmd="frameset")
Goto repository root.
Column user interface class.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static formSelect($selected, $varname, $options, $multiple=false, $direct_text=false, $size="0", $style_class="", $attribs="", $disabled=false)
Builds a select form field with options and shows the selected option first.
saveObject()
save object
getTabs(&$tabs_gui)
get tabs abstract method.
initDidacticTemplate(ilPropertyFormGUI $form)
Show didactic template types.
Class ilObjectGUI Basic methods of all Output classes.
static _lookupObjId($a_id)
getAdminTabs(&$tabs_gui)
administration tabs show only permissions and trash folder
special template class to simplify handling of ITX/PEAR
omitLocator($a_omit=true)
getTemplateFile($a_cmd, $a_type="")
get a template blockfile format: tpl.
Repository GUI Utilities.
setSize($a_size)
Set Size.
This class represents a text property in a property form.
static infoPanel($a_keep=true)
redirection script todo: (a better solution should control the processing via a xml file) ...
static _allocateCopyId()
Allocate a copy for further entries.
editObject()
edit object
static clear($a_var)
Unset a value.
getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
initCreateForm($a_new_type)
Init object creation form.
setTitleAndDescription()
called by prepare output
putInTree($a_parent_ref)
maybe this method should be in tree object!?
getType()
get object type public
initEditForm()
Init object edit form.
prepareOutput()
prepare output
static _lookupType($a_id, $a_reference=false)
lookup object type
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
const COPY_WIZARD_NEEDS_PAGE
getEditFormValues()
Get values for edit form.
getEditFormCustomValues(array &$a_values)
Add values to custom edit fields.
_recordReadEvent($a_type, $a_ref_id, $obj_id, $usr_id, $isCatchupWriteEvents=true, $a_ext_rc=false, $a_ext_time=false)
Records a read event and catches up with write events.
addDidacticTemplateOptions(array &$a_options)
Add custom templates.
withReferences()
determines wether objects are referenced or not (got ref ids or not)
static commentsActivated($a_rep_obj_id, $a_obj_id, $a_obj_type)
Are comments activated for object?
static getScreenMode()
Get Screen Mode for current command.
getRightColumnHTML()
Display right column.
Error Handling & global info handling uses PEAR error class.
global $ilUser
Definition: imgupload.php:15
static getInstanceByObjectType($a_obj_type)
Get instance by obj type.
setColumnSettings($column_gui)
May be overwritten in subclasses.
handleAutoRating(ilObject $a_new_obj)
Activate rating automatically if parent container setting.
Interface for gui classes (e.g ilLuceneSearchGUI) that offer add/remove to/from desktop.
static isUploadAllowed($a_ref_id, $a_type="")
Determines whether files can be uploaded to the object with the specified reference id...
redirectToRefId($a_ref_id, $a_cmd="")
redirects to (repository) view per ref id usually to a container and usually used at the end of a sav...
showPossibleSubObjects()
show possible subobjects (pulldown menu)
global $ilSetting
Definition: privfeed.php:40
This class represents a text area property in a property form.
static add($a_action, $a_ref_id, array $a_diff, $a_source_ref_id=false)
global $ilBench
Definition: ilias.php:18
insertHeaderAction($a_list_gui)
Insert header action into main template.
getCreationMode()
get creation mode
getRefId()
get reference id public
updateObject()
updates object entry in object_data
putObjectInTree(ilObject $a_obj, $a_parent_node_id=null)
Add object to tree at given position.
checkPermission($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission and redirect on error.
getDidacticTemplateVar($a_type)
Get didactic template setting from creation screen.
deleteObject($a_error=false)
Display deletion confirmation screen.
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
setTabs()
set admin tabs public
update()
update object in db
afterUpdate()
Post (successful) object update hook.
static redirect($a_script)
http redirect to other script
Accordion user interface class.
const IL_SCREEN_SIDE
getFormAction($a_cmd, $a_formaction="")
get form action for command (command is method name without "Object", e.g.
addHeaderAction()
Add header action menu.
setPermissions($a_parent_ref)
set permissions of object
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission.
setSuffixes($a_suffixes)
Set Accepted Suffixes.
getReturnLocation($a_cmd, $a_location="")
get return location for command (command is method name without "Object", e.g.
initEditCustomForm(ilPropertyFormGUI $a_form)
Add custom fields to update form.
Class ilCommonActionDispatcherGUI.
setSubObject($a_sub_obj_type, $a_sub_obj_id)
Set sub object attributes.
_recordWriteEvent($obj_id, $usr_id, $action, $parent_obj_id=null)
Records a write event.
setAdminTabs()
set admin tabs public
addLocatorItems()
should be overwritten to add object specific items (repository items are preloaded) ...
setLocator()
set Locator
afterImport(ilObject $a_new_object)
Post (successful) object import hook.
const IL_COL_LEFT