ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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  protected $tmp_import_dir; // directory used during import
74 
76  var $actions;
78  var $omit_locator = false;
79 
83  protected $tabs_gui = null;
84 
88  protected $ctrl;
89 
90  const CFORM_NEW = 1;
91  const CFORM_IMPORT = 2;
92  const CFORM_CLONE = 3;
93 
101  function __construct($a_data, $a_id = 0, $a_call_by_reference = true, $a_prepare_output = true)
102  {
103  global $ilias, $objDefinition, $tpl, $tree, $ilCtrl, $ilErr, $lng, $ilTabs;
104 
108  $this->tabs_gui = $ilTabs;
109 
110  if (!isset($ilErr))
111  {
112  $ilErr = new ilErrorHandling();
113  $ilErr->setErrorHandling(PEAR_ERROR_CALLBACK,array($ilErr,'errorHandler'));
114  }
115  else
116  {
117  $this->ilErr = $ilErr;
118  }
119 
120  $this->ilias = $ilias;
121  $this->objDefinition = $objDefinition;
122  $this->tpl = $tpl;
123  $this->html = "";
124  $this->ctrl = $ilCtrl;
125 
126  $params = array("ref_id");
127 
128  if (!$a_call_by_reference)
129  {
130  $params = array("ref_id","obj_id");
131  }
132 
133  $this->ctrl->saveParameter($this, $params);
134 
135  $this->lng = $lng;
136  $this->tree = $tree;
137  $this->formaction = array();
138  $this->return_location = array();
139  $this->target_frame = array();
140  $this->actions = "";
141  $this->sub_objects = "";
142 
143  $this->data = $a_data;
144  $this->id = $a_id;
145  $this->call_by_reference = $a_call_by_reference;
146  $this->prepare_output = $a_prepare_output;
147  $this->creation_mode = false;
148 
149  $this->ref_id = ($this->call_by_reference) ? $this->id : $_GET["ref_id"];
150  $this->obj_id = ($this->call_by_reference) ? $_GET["obj_id"] : $this->id;
151 
152  if ($this->id != 0)
153  {
154  $this->link_params = "ref_id=".$this->ref_id;
155  }
156 
157  // get the object
158  $this->assignObject();
159 
160  // set context
161  if (is_object($this->object))
162  {
163  if ($this->call_by_reference && $this->ref_id == $_GET["ref_id"])
164  {
165  $this->ctrl->setContext($this->object->getId(),
166  $this->object->getType());
167  }
168  }
169 
170  // use global $lng instead, when creating new objects object is not available
171  //$this->lng =& $this->object->lng;
172 
173  //prepare output
174  if ($a_prepare_output)
175  {
176  $this->prepareOutput();
177  }
178  }
179 
180 
184  function executeCommand()
185  {
186  $next_class = $this->ctrl->getNextClass($this);
187  $cmd = $this->ctrl->getCmd();
188 
189  switch($next_class)
190  {
191  default:
192  $this->prepareOutput();
193  if(!$cmd)
194  {
195  $cmd = "view";
196  }
197  $cmd .= "Object";
198  $this->$cmd();
199 
200  break;
201  }
202 
203  return true;
204  }
205 
206 
210  public function withReferences()
211  {
212  return $this->call_by_reference;
213  }
214 
221  public function setCreationMode($a_mode = true)
222  {
223  $this->creation_mode = $a_mode;
224  }
225 
229  public function getCreationMode()
230  {
231  return $this->creation_mode;
232  }
233 
234  protected function assignObject()
235  {
236  // TODO: it seems that we always have to pass only the ref_id
237 //echo "<br>ilObjectGUIassign:".get_class($this).":".$this->id.":<br>";
238  if ($this->id != 0)
239  {
240  if ($this->call_by_reference)
241  {
242  $this->object = ilObjectFactory::getInstanceByRefId($this->id);
243  }
244  else
245  {
246  $this->object = ilObjectFactory::getInstanceByObjId($this->id);
247  }
248  }
249  }
250 
254  public function prepareOutput($a_show_subobjects = true)
255  {
256  global $ilLocator, $tpl, $ilUser;
257 
258  $this->tpl->getStandardTemplate();
259  // administration prepare output
260  if (strtolower($_GET["baseClass"]) == "iladministrationgui")
261  {
262  $this->addAdminLocatorItems();
263  $tpl->setLocator();
264 
265 // ilUtil::sendInfo();
267 
268  $this->setTitleAndDescription();
269 
270  if ($this->getCreationMode() != true)
271  {
272  $this->setAdminTabs();
273  }
274 
275  return false;
276  }
277  // set locator
278  $this->setLocator();
279  // catch feedback message
280 // ilUtil::sendInfo();
282 
283  // in creation mode (parent) object and gui object
284  // do not fit
285  if ($this->getCreationMode() == true)
286  {
287  // repository vs. workspace
288  if($this->call_by_reference)
289  {
290  // get gui class of parent and call their title and description method
291  $obj_type = ilObject::_lookupType($_GET["ref_id"],true);
292  $class_name = $this->objDefinition->getClassName($obj_type);
293  $class = strtolower("ilObj".$class_name."GUI");
294  $class_path = $this->ctrl->lookupClassPath($class);
295  include_once($class_path);
296  $class_name = $this->ctrl->getClassForClasspath($class_path);
297 //echo "<br>instantiating parent for title and description";
298  $this->parent_gui_obj = new $class_name("", $_GET["ref_id"], true, false);
299  // the next line prevents the header action menu being shown
300  $this->parent_gui_obj->setCreationMode(true);
301  $this->parent_gui_obj->setTitleAndDescription();
302  }
303  }
304  else
305  {
306  // set title and description and title icon
307  $this->setTitleAndDescription();
308 
309  // set tabs
310  $this->setTabs();
311 
312  // BEGIN WebDAV: Display Mount Webfolder icon.
313  if ($ilUser->getId() != ANONYMOUS_USER_ID)
314  {
315  require_once ('Services/WebDAV/classes/class.ilDAVActivationChecker.php');
317  {
318  $this->showMountWebfolderIcon();
319  }
320  }
321  // END WebDAV: Display Mount Webfolder icon.
322 
323  // fileupload support
324  require_once './Services/FileUpload/classes/class.ilFileUploadUtil.php';
325  if (ilFileUploadUtil::isUploadAllowed($this->ref_id, $this->object->getType()))
326  {
327  $this->enableDragDropFileUpload();
328  }
329  }
330 
331  return true;
332  }
333 
337  protected function setTitleAndDescription()
338  {
339  if (!is_object($this->object))
340  {
341  if ((int) $_REQUEST["crtptrefid"] > 0)
342  {
343  $cr_obj_id = ilObject::_lookupObjId((int) $_REQUEST["crtcb"]);
344  $this->tpl->setTitle(ilObject::_lookupTitle($cr_obj_id));
345  $this->tpl->setTitleIcon(ilObject::_getIcon($cr_obj_id));
346  }
347  return;
348  }
349  $this->tpl->setTitle($this->object->getPresentationTitle());
350  $this->tpl->setDescription($this->object->getLongDescription());
351 
352  if (strtolower($_GET["baseClass"]) == "iladministrationgui")
353  {
354  // alt text would be same as heading -> empty alt text
355  $this->tpl->setTitleIcon(ilObject::_getIcon("", "big", $this->object->getType()));
356  }
357  else
358  {
359  $this->tpl->setTitleIcon(ilObject::_getIcon("", "big", $this->object->getType()),
360  $this->lng->txt("obj_" . $this->object->getType()));
361  }
362 
363  include_once './Services/Object/classes/class.ilObjectListGUIFactory.php';
364  $lgui = ilObjectListGUIFactory::_getListGUIByType($this->object->getType());
365  $lgui->initItem($this->object->getRefId(), $this->object->getId());
366  $this->tpl->setAlertProperties($lgui->getAlertProperties());
367  }
368 
376  protected function initHeaderAction($a_sub_type = null, $a_sub_id = null)
377  {
378  global $ilAccess;
379 
380  if(!$this->creation_mode && $this->object)
381  {
382  include_once "Services/Object/classes/class.ilCommonActionDispatcherGUI.php";
384  $ilAccess, $this->object->getType(), $this->ref_id, $this->object->getId());
385 
386  $dispatcher->setSubObject($a_sub_type, $a_sub_id);
387 
388  include_once "Services/Object/classes/class.ilObjectListGUI.php";
389  ilObjectListGUI::prepareJSLinks($this->ctrl->getLinkTarget($this, "redrawHeaderAction", "", true),
390  $this->ctrl->getLinkTargetByClass(array("ilcommonactiondispatchergui", "ilnotegui"), "", "", true, false),
391  $this->ctrl->getLinkTargetByClass(array("ilcommonactiondispatchergui", "iltagginggui"), "", "", true, false));
392 
393  $lg = $dispatcher->initHeaderAction();
394 
395  if (is_object($lg))
396  {
397  // to enable add to desktop / remove from desktop
398  if($this instanceof ilDesktopItemHandling)
399  {
400  $lg->setContainerObject($this);
401  }
402 
403  // enable multi download
404  $lg->enableMultiDownload(true);
405 
406  // comments settings are always on (for the repository)
407  // should only be shown if active or permission to toggle
408  include_once "Services/Notes/classes/class.ilNote.php";
409  if($ilAccess->checkAccess("write", "", $this->ref_id) ||
410  $ilAccess->checkAccess("edit_permissions", "", $this->ref_id) ||
411  ilNote::commentsActivated($this->object->getId(), 0, $this->object->getType()))
412  {
413  $lg->enableComments(true);
414  }
415 
416  $lg->enableNotes(true);
417  $lg->enableTags(true);
418  }
419 
420  return $lg;
421  }
422  }
423 
429  protected function insertHeaderAction($a_list_gui)
430  {
431  if(is_object($a_list_gui))
432  {
433  $this->tpl->setHeaderActionMenu($a_list_gui->getHeaderAction());
434  }
435  }
436 
440  protected function addHeaderAction()
441  {
442  $this->insertHeaderAction($this->initHeaderAction());
443  }
444 
448  protected function redrawHeaderActionObject()
449  {
450  global $tpl;
451 
452  $lg = $this->initHeaderAction();
453  echo $lg->getHeaderAction();
454 
455  // we need to add onload code manually (rating, comments, etc.)
456  echo $tpl->getOnLoadCodeForAsynch();
457 
458  exit;
459  }
460 
461  // BEGIN WebDAV: Show Mount Webfolder Icon.
462  protected function showMountWebfolderIcon()
463  {
464  global $tree, $tpl, $objDefinition;
465 
466  if ($this->object->getRefId() == "")
467  {
468  return;
469  }
470 
471  $tpl->setMountWebfolderIcon($this->object->getRefId());
472  }
473  // END WebDAV: Show Mount Webfolder Icon.
474 
475 
480  protected function setTabs()
481  {
482  $this->getTabs();
483  }
484 
489  protected final function setAdminTabs()
490  {
491  $this->getAdminTabs();
492  }
493 
497  function getAdminTabs()
498  {
499  global $tree;
500 
501 /* if ($_GET["admin_mode"] == "repository")
502  {
503  $this->ctrl->setParameterByClass("iladministrationgui", "admin_mode", "settings");
504  $this->tabs_gui->setBackTarget($this->lng->txt("administration"),
505  $this->ctrl->getLinkTargetByClass("iladministrationgui", "frameset"),
506  ilFrameTargetInfo::_getFrame("MainContent"));
507  $this->ctrl->setParameterByClass("iladministrationgui", "admin_mode", "repository");
508  }*/
509 
510  if ($this->checkPermissionBool("visible,read"))
511  {
512  $this->tabs_gui->addTarget("view",
513  $this->ctrl->getLinkTarget($this, "view"), array("", "view"), get_class($this));
514 
515  }
516 
517  if ($this->checkPermissionBool("edit_permission"))
518  {
519  $this->tabs_gui->addTarget("perm_settings",
520  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), "", "ilpermissiongui");
521  }
522 
523  if ($tree->getSavedNodeData($this->object->getRefId()))
524  {
525  $this->tabs_gui->addTarget("trash",
526  $this->ctrl->getLinkTarget($this, "trash"), "trash", get_class($this));
527  }
528  }
529 
530 
531  function getHTML()
532  {
533  return $this->html;
534  }
535 
536 
543  final private function setActions($a_actions = "")
544  {
545  if (is_array($a_actions))
546  {
547  foreach ($a_actions as $name => $lng)
548  {
549  $this->actions[$name] = array("name" => $name, "lng" => $lng);
550  }
551  }
552  else
553  {
554  $this->actions = "";
555  }
556  }
557 
564  final private function setSubObjects($a_sub_objects = "")
565  {
566  if (is_array($a_sub_objects))
567  {
568  foreach ($a_sub_objects as $name => $options)
569  {
570  $this->sub_objects[$name] = array("name" => $name, "max" => $options["max"]);
571  }
572  }
573  else
574  {
575  $this->sub_objects = "";
576  }
577  }
578 
587  protected function setLocator()
588  {
589  global $ilLocator, $tpl;
590 
591  if ($this->omit_locator)
592  {
593  return;
594  }
595 
596  // repository vs. workspace
597  if($this->call_by_reference)
598  {
599  // todo: admin workaround
600  // in the future, objectgui classes should not be called in
601  // admin section anymore (rbac/trash handling in own classes)
602  $ref_id = ($_GET["ref_id"] != "")
603  ? $_GET["ref_id"]
604  : $this->object->getRefId();
605  $ilLocator->addRepositoryItems($ref_id);
606  }
607 
608  if(!$this->creation_mode)
609  {
610  $this->addLocatorItems();
611  }
612 
613  // not so nice workaround: todo: handle $ilLocator as tabs in ilTemplate
614  if ($_GET["admin_mode"] == "" &&
615  strtolower($this->ctrl->getCmdClass()) == "ilobjrolegui")
616  {
617  $this->ctrl->setParameterByClass("ilobjrolegui",
618  "rolf_ref_id", $_GET["rolf_ref_id"]);
619  $this->ctrl->setParameterByClass("ilobjrolegui",
620  "obj_id", $_GET["obj_id"]);
621  $ilLocator->addItem($this->lng->txt("role"),
622  $this->ctrl->getLinkTargetByClass(array("ilpermissiongui",
623  "ilobjrolegui"), "perm"));
624  }
625 
626  $tpl->setLocator();
627  }
628 
633  protected function addLocatorItems()
634  {
635  }
636 
637  protected function omitLocator($a_omit = true)
638  {
639  $this->omit_locator = $a_omit;
640  }
641 
648  protected function addAdminLocatorItems($a_do_not_add_object = false)
649  {
650  global $ilLocator;
651 
652  if ($_GET["admin_mode"] == "settings") // system settings
653  {
654  $this->ctrl->setParameterByClass("ilobjsystemfoldergui",
655  "ref_id", SYSTEM_FOLDER_ID);
656  $ilLocator->addItem($this->lng->txt("administration"),
657  $this->ctrl->getLinkTargetByClass(array("iladministrationgui", "ilobjsystemfoldergui"), "")
658  );
659  if ($this->object && ($this->object->getRefId() != SYSTEM_FOLDER_ID && !$a_do_not_add_object))
660  {
661  $ilLocator->addItem($this->object->getTitle(),
662  $this->ctrl->getLinkTarget($this, "view"));
663  }
664  }
665  else // repository administration
666  {
667  $this->ctrl->setParameterByClass("iladministrationgui",
668  "ref_id", "");
669  $this->ctrl->setParameterByClass("iladministrationgui",
670  "admin_mode", "settings");
671  //$ilLocator->addItem($this->lng->txt("administration"),
672  // $this->ctrl->getLinkTargetByClass("iladministrationgui", "frameset"),
673  // ilFrameTargetInfo::_getFrame("MainContent"));
674  $this->ctrl->clearParametersByClass("iladministrationgui");
675  $ilLocator->addAdministrationItems();
676  }
677 
678  }
679 
684  public function confirmedDeleteObject()
685  {
686  global $ilSetting, $lng;
687 
688  if(isset($_POST["mref_id"]))
689  {
690  $_SESSION["saved_post"] = array_unique(array_merge($_SESSION["saved_post"], $_POST["mref_id"]));
691  }
692 
693  include_once("./Services/Repository/classes/class.ilRepUtilGUI.php");
694  $ru = new ilRepUtilGUI($this);
695  $ru->deleteObjects($_GET["ref_id"], ilSession::get("saved_post"));
696  ilSession::clear("saved_post");
697  $this->ctrl->returnToParent($this);
698  }
699 
705  public function cancelDeleteObject()
706  {
707  ilSession::clear("saved_post");
708  $this->ctrl->returnToParent($this);
709  }
710 
711 
717  public function cancelObject()
718  {
719  ilSession::clear("saved_post");
720  $this->ctrl->returnToParent($this);
721  }
722 
728  public function createObject()
729  {
730  global $tpl, $ilErr;
731 
732  $new_type = $_REQUEST["new_type"];
733 
734 
735  // add new object to custom parent container
736  $this->ctrl->saveParameter($this, "crtptrefid");
737  // use forced callback after object creation
738  $this->ctrl->saveParameter($this, "crtcb");
739 
740  if (!$this->checkPermissionBool("create", "", $new_type))
741  {
742  $ilErr->raiseError($this->lng->txt("permission_denied"),$ilErr->MESSAGE);
743  }
744  else
745  {
746  $this->lng->loadLanguageModule($new_type);
747  $this->ctrl->setParameter($this, "new_type", $new_type);
748 
749  $forms = $this->initCreationForms($new_type);
750 
751  // copy form validation error: do not show other creation forms
752  if($_GET["cpfl"] && isset($forms[self::CFORM_CLONE]))
753  {
754  $forms = array(self::CFORM_CLONE => $forms[self::CFORM_CLONE]);
755  }
756  $tpl->setContent($this->getCreationFormsHTML($forms));
757  }
758  }
759 
768  protected function initCreationForms($a_new_type)
769  {
770  $forms = array(
771  self::CFORM_NEW => $this->initCreateForm($a_new_type),
772  self::CFORM_IMPORT => $this->initImportForm($a_new_type),
773  self::CFORM_CLONE => $this->fillCloneTemplate(null, $a_new_type)
774  );
775 
776  return $forms;
777  }
778 
784  final protected function getCreationFormsHTML(array $a_forms)
785  {
786  global $tpl;
787 
788  // #13168- sanity check
789  foreach($a_forms as $id => $form)
790  {
791  if(!$form instanceof ilPropertyFormGUI)
792  {
793  unset($a_forms[$id]);
794  }
795  }
796 
797  // no accordion if there is just one form
798  if(sizeof($a_forms) == 1)
799  {
800  $form_type = key($a_forms);
801  $a_forms = array_shift($a_forms);
802 
803  // see bug #0016217
804  if(method_exists($this, "getCreationFormTitle"))
805  {
806  $form_title = $this->getCreationFormTitle($form_type);
807  if ($form_title != "")
808  {
809  $a_forms->setTitle($form_title);
810  }
811  }
812  return $a_forms->getHTML();
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  $htpl = new ilTemplate("tpl.creation_acc_head.html", true, true, "Services/Object");
824 
825  // using custom form titles (used for repository plugins)
826  $form_title = "";
827  if(method_exists($this, "getCreationFormTitle"))
828  {
829  $form_title = $this->getCreationFormTitle($form_type);
830  }
831  if(!$form_title)
832  {
833  $form_title = $cf->getTitle();
834  }
835 
836  // move title from form to accordion
837  $htpl->setVariable("TITLE", $this->lng->txt("option")." ".$cnt.": ".
838  $form_title);
839  $cf->setTitle(null);
840  $cf->setTitleIcon(null);
841  $cf->setTableWidth("100%");
842 
843  $acc->addItem($htpl->get(), $cf->getHTML());
844 
845  $cnt++;
846  }
847 
848  return "<div class='ilCreationFormSection'>".$acc->getHTML()."</div>";
849  }
850  }
851 
858  protected function initCreateForm($a_new_type)
859  {
860  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
861  $form = new ilPropertyFormGUI();
862  $form->setTarget("_top");
863  $form->setFormAction($this->ctrl->getFormAction($this, "save"));
864  $form->setTitle($this->lng->txt($a_new_type."_new"));
865 
866  // title
867  $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
868  $ti->setSize(min(40, ilObject::TITLE_LENGTH));
869  $ti->setMaxLength(ilObject::TITLE_LENGTH);
870  $ti->setRequired(true);
871  $form->addItem($ti);
872 
873  // description
874  $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
875  $ta->setCols(40);
876  $ta->setRows(2);
877  $form->addItem($ta);
878 
879  $form = $this->initDidacticTemplate($form);
880 
881  $form->addCommandButton("save", $this->lng->txt($a_new_type."_add"));
882  $form->addCommandButton("cancel", $this->lng->txt("cancel"));
883 
884  return $form;
885  }
886 
892  protected function initDidacticTemplate(ilPropertyFormGUI $form)
893  {
894  global $lng;
895 
896  $lng->loadLanguageModule('didactic');
897  $existing_exclusive = false;
898  $options = array();
899  $options['dtpl_0'] = array($this->lng->txt('didactic_default_type'),
900  sprintf(
901  $this->lng->txt('didactic_default_type_info'),
902  $this->lng->txt('objs_'.$this->type)
903  ));
904 
905  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateSettings.php';
906  $templates = ilDidacticTemplateSettings::getInstanceByObjectType($this->type)->getTemplates();
907  if($templates)
908  {
909  foreach($templates as $template)
910  {
911  if($template->isEffective($_GET["ref_id"]))
912  {
913  $options["dtpl_".$template->getId()] = array(
914  $template->getPresentationTitle(),
915  $template->getPresentationDescription()
916  );
917 
918  if($template->isExclusive())
919  {
920  $existing_exclusive = true;
921  }
922  }
923 
924  }
925  }
926 
928 
929  if(sizeof($options) > 1)
930  {
931  $type = new ilRadioGroupInputGUI(
932  $this->lng->txt('type'),
933  'didactic_type'
934  );
935  // workaround for containers in edit mode
936  if(!$this->getCreationMode())
937  {
938  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php';
939  $value = 'dtpl_'.ilDidacticTemplateObjSettings::lookupTemplateId($this->object->getRefId());
940 
941  $type->setValue($value);
942 
943  if(!in_array($value, array_keys($options)) || ($existing_exclusive && $value == "dtpl_0"))
944  {
945  //add or rename actual value to not avaiable
946  $options[$value] = array($this->lng->txt('not_available'));
947  }
948  }
949  else
950  {
951  if($existing_exclusive)
952  {
953  //if an exclusive template exists use the second template as default value
954  $keys = array_keys($options);
955  $type->setValue($keys[1]);
956  }
957  else
958  {
959  $type->setValue('dtpl_0');
960  }
961 
962  }
963  $form->addItem($type);
964 
965  foreach($options as $id => $data)
966  {
967  $option = new ilRadioOption($data[0], $id, $data[1]);
968 
969  if($existing_exclusive && $id == "dtpl_0" && $this->getCreationMode())
970  {
971  //set default disabled if an exclusive template exists but just in creation screen
972  $option->setDisabled(true);
973  }
974 
975  $type->addOption($option);
976  }
977  }
978 
979  return $form;
980  }
981 
987  protected function addDidacticTemplateOptions(array &$a_options)
988  {
989 
990  }
991 
995  public function cancelCreation()
996  {
997  global $ilCtrl;
998 
999  $ilCtrl->redirectByClass("ilrepositorygui", "frameset");
1000  }
1001 
1007  public function saveObject()
1008  {
1009  global $objDefinition, $tpl;
1010 
1011  $new_type = $_REQUEST["new_type"];
1012 
1013  // create permission is already checked in createObject. This check here is done to prevent hacking attempts
1014  if (!$this->checkPermissionBool("create", "", $new_type))
1015  {
1016  $this->ilias->raiseError($this->lng->txt("no_create_permission"), $this->ilias->error_obj->MESSAGE);
1017  }
1018 
1019  $this->lng->loadLanguageModule($new_type);
1020  $this->ctrl->setParameter($this, "new_type", $new_type);
1021 
1022  $form = $this->initCreateForm($new_type);
1023  if ($form->checkInput())
1024  {
1025  $this->ctrl->setParameter($this, "new_type", "");
1026 
1027  // create instance
1028  $class_name = "ilObj".$objDefinition->getClassName($new_type);
1029  $location = $objDefinition->getLocation($new_type);
1030  include_once($location."/class.".$class_name.".php");
1031  $newObj = new $class_name();
1032  $newObj->setType($new_type);
1033  $newObj->setTitle($form->getInput("title"));
1034  $newObj->setDescription($form->getInput("desc"));
1035  $newObj->create();
1036 
1037  $this->putObjectInTree($newObj);
1038 
1039  // apply didactic template?
1040  $dtpl = $this->getDidacticTemplateVar("dtpl");
1041  if($dtpl)
1042  {
1043  $newObj->applyDidacticTemplate($dtpl);
1044  }
1045 
1046  // auto rating
1047  $this->handleAutoRating($newObj);
1048 
1049  // additional paramters are added to afterSave()
1050  $args = func_get_args();
1051  if($args)
1052  {
1053  $this->afterSave($newObj, $args);
1054  }
1055  else
1056  {
1057  $this->afterSave($newObj);
1058  }
1059  return;
1060  }
1061 
1062  // display only this form to correct input
1063  $form->setValuesByPost();
1064  $tpl->setContent($form->getHtml());
1065  }
1066 
1073  protected function getDidacticTemplateVar($a_type)
1074  {
1075  $tpl = $_POST["didactic_type"];
1076  if($tpl && substr($tpl, 0, strlen($a_type)+1) == $a_type."_")
1077  {
1078  return (int)substr($tpl, strlen($a_type)+1);
1079  }
1080  return 0;
1081  }
1082 
1089  protected function putObjectInTree(ilObject $a_obj, $a_parent_node_id = null)
1090  {
1091  global $rbacreview, $ilUser, $objDefinition;
1092 
1093  if(!$a_parent_node_id)
1094  {
1095  $a_parent_node_id = $_GET["ref_id"];
1096  }
1097 
1098  // add new object to custom parent container
1099  if((int)$_REQUEST["crtptrefid"])
1100  {
1101  $a_parent_node_id = (int)$_REQUEST["crtptrefid"];
1102  }
1103 
1104  $a_obj->createReference();
1105  $a_obj->putInTree($a_parent_node_id);
1106  $a_obj->setPermissions($a_parent_node_id);
1107 
1108  $this->obj_id = $a_obj->getId();
1109  $this->ref_id = $a_obj->getRefId();
1110 
1111  // BEGIN ChangeEvent: Record save object.
1112  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
1113  ilChangeEvent::_recordWriteEvent($this->obj_id, $ilUser->getId(), 'create');
1114  // END ChangeEvent: Record save object.
1115 
1116  // rbac log
1117  include_once "Services/AccessControl/classes/class.ilRbacLog.php";
1118  $rbac_log_roles = $rbacreview->getParentRoleIds($this->ref_id, false);
1119  $rbac_log = ilRbacLog::gatherFaPa($this->ref_id, array_keys($rbac_log_roles), true);
1120  ilRbacLog::add(ilRbacLog::CREATE_OBJECT, $this->ref_id, $rbac_log);
1121 
1122  // use forced callback after object creation
1123  if($_REQUEST["crtcb"])
1124  {
1125  $callback_type = ilObject::_lookupType((int)$_REQUEST["crtcb"], true);
1126  $class_name = "ilObj".$objDefinition->getClassName($callback_type)."GUI";
1127  $location = $objDefinition->getLocation($callback_type);
1128  include_once($location."/class.".$class_name.".php");
1129  if (in_array(strtolower($class_name), array("ilobjitemgroupgui")))
1130  {
1131  $callback_obj = new $class_name((int)$_REQUEST["crtcb"]);
1132  }
1133  else
1134  {
1135  // #10368
1136  $callback_obj = new $class_name(null, (int)$_REQUEST["crtcb"], true, false);
1137  }
1138  $callback_obj->afterSaveCallback($a_obj);
1139  }
1140  }
1141 
1147  protected function afterSave(ilObject $a_new_object)
1148  {
1149  ilUtil::sendSuccess($this->lng->txt("object_added"), true);
1150  $this->ctrl->returnToParent($this);
1151  }
1152 
1158  public function editObject()
1159  {
1160  global $tpl, $ilTabs;
1161 
1162  if (!$this->checkPermissionBool("write"))
1163  {
1164  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
1165  }
1166 
1167  $ilTabs->activateTab("settings");
1168 
1169  $form = $this->initEditForm();
1170  $values = $this->getEditFormValues();
1171  if($values)
1172  {
1173  $form->setValuesByArray($values);
1174  }
1175 
1176  $this->addExternalEditFormCustom($form);
1177 
1178  $tpl->setContent($form->getHTML());
1179  }
1180 
1182  {
1183  // has to be done AFTER setValuesByArray() ...
1184  }
1185 
1191  protected function initEditForm()
1192  {
1193  global $lng, $ilCtrl;
1194 
1195  $lng->loadLanguageModule($this->object->getType());
1196 
1197  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1198  $form = new ilPropertyFormGUI();
1199  $form->setFormAction($this->ctrl->getFormAction($this, "update"));
1200  $form->setTitle($this->lng->txt($this->object->getType()."_edit"));
1201 
1202  // title
1203  $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
1204  $ti->setSize(min(40, ilObject::TITLE_LENGTH));
1205  $ti->setMaxLength(ilObject::TITLE_LENGTH);
1206  $ti->setRequired(true);
1207  $form->addItem($ti);
1208 
1209  // description
1210  $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
1211  $ta->setCols(40);
1212  $ta->setRows(2);
1213  $form->addItem($ta);
1214 
1215  $this->initEditCustomForm($form);
1216 
1217  $form->addCommandButton("update", $this->lng->txt("save"));
1218  //$this->form->addCommandButton("cancelUpdate", $lng->txt("cancel"));
1219 
1220  return $form;
1221  }
1222 
1228  protected function initEditCustomForm(ilPropertyFormGUI $a_form)
1229  {
1230 
1231  }
1232 
1238  protected function getEditFormValues()
1239  {
1240  $values["title"] = $this->object->getTitle();
1241  $values["desc"] = $this->object->getLongDescription();
1242  $this->getEditFormCustomValues($values);
1243  return $values;
1244  }
1245 
1251  protected function getEditFormCustomValues(array &$a_values)
1252  {
1253 
1254  }
1255 
1259  public function updateObject()
1260  {
1261  global $ilTabs, $tpl;
1262 
1263  if (!$this->checkPermissionBool("write"))
1264  {
1265  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
1266  }
1267 
1268  $form = $this->initEditForm();
1269  if($form->checkInput() &&
1270  $this->validateCustom($form))
1271  {
1272  $this->object->setTitle($form->getInput("title"));
1273  $this->object->setDescription($form->getInput("desc"));
1274  $this->updateCustom($form);
1275  $this->object->update();
1276 
1277  $this->afterUpdate();
1278  return;
1279  }
1280 
1281  // display form again to correct errors
1282  $ilTabs->activateTab("settings");
1283  $form->setValuesByPost();
1284  $tpl->setContent($form->getHtml());
1285  }
1286 
1293  protected function validateCustom(ilPropertyFormGUI $a_form)
1294  {
1295  return true;
1296  }
1297 
1303  protected function updateCustom(ilPropertyFormGUI $a_form)
1304  {
1305 
1306  }
1307 
1311  protected function afterUpdate()
1312  {
1313  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
1314  $this->ctrl->redirect($this, "edit");
1315  }
1316 
1323  protected function initImportForm($a_new_type)
1324  {
1325  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1326  $form = new ilPropertyFormGUI();
1327  $form->setTarget("_top");
1328  $form->setFormAction($this->ctrl->getFormAction($this, "importFile"));
1329  $form->setTitle($this->lng->txt($a_new_type."_import"));
1330 
1331  include_once("./Services/Form/classes/class.ilFileInputGUI.php");
1332  $fi = new ilFileInputGUI($this->lng->txt("import_file"), "importfile");
1333  $fi->setSuffixes(array("zip"));
1334  $fi->setRequired(true);
1335  $form->addItem($fi);
1336 
1337  $form->addCommandButton("importFile", $this->lng->txt("import"));
1338  $form->addCommandButton("cancel", $this->lng->txt("cancel"));
1339 
1340  return $form;
1341  }
1342 
1346  protected function importFileObject($parent_id = null, $a_catch_errors = true)
1347  {
1348  global $objDefinition, $tpl, $ilErr;
1349 
1350  if(!$parent_id)
1351  {
1352  $parent_id = $_GET["ref_id"];
1353  }
1354  $new_type = $_REQUEST["new_type"];
1355 
1356  // create permission is already checked in createObject. This check here is done to prevent hacking attempts
1357  if (!$this->checkPermissionBool("create", "", $new_type))
1358  {
1359  $ilErr->raiseError($this->lng->txt("no_create_permission"));
1360  }
1361 
1362  $this->lng->loadLanguageModule($new_type);
1363  $this->ctrl->setParameter($this, "new_type", $new_type);
1364 
1365  $form = $this->initImportForm($new_type);
1366  if ($form->checkInput())
1367  {
1368  // :todo: make some check on manifest file
1369 
1370  if($objDefinition->isContainer($new_type))
1371  {
1372  include_once './Services/Export/classes/class.ilImportContainer.php';
1373  $imp = new ilImportContainer((int)$parent_id);
1374  }
1375  else
1376  {
1377  include_once("./Services/Export/classes/class.ilImport.php");
1378  $imp = new ilImport((int)$parent_id);
1379  }
1380 
1381  try
1382  {
1383  $new_id = $imp->importObject(null, $_FILES["importfile"]["tmp_name"],
1384  $_FILES["importfile"]["name"], $new_type);
1385  }
1386  catch (ilException $e)
1387  {
1388  $this->tmp_import_dir = $imp->getTemporaryImportDir();
1389  if (!$a_catch_errors)
1390  {
1391  throw $e;
1392  }
1393  // display message and form again
1394  ilUtil::sendFailure($this->lng->txt("obj_import_file_error")." <br />".$e->getMessage());
1395  $form->setValuesByPost();
1396  $tpl->setContent($form->getHtml());
1397  return;
1398  }
1399 
1400  if ($new_id > 0)
1401  {
1402  $this->ctrl->setParameter($this, "new_type", "");
1403 
1404  $newObj = ilObjectFactory::getInstanceByObjId($new_id);
1405 
1406  // put new object id into tree - already done in import for containers
1407  if(!$objDefinition->isContainer($new_type))
1408  {
1409  $this->putObjectInTree($newObj);
1410  }
1411 
1412  $this->afterImport($newObj);
1413  }
1414  // import failed
1415  else
1416  {
1417  if($objDefinition->isContainer($new_type))
1418  {
1419  ilUtil::sendFailure($this->lng->txt("container_import_zip_file_invalid"));
1420  }
1421  else
1422  {
1423  // not enough information here...
1424  return;
1425  }
1426  }
1427  }
1428 
1429  // display form to correct errors
1430  $form->setValuesByPost();
1431  $tpl->setContent($form->getHtml());
1432  }
1433 
1439  protected function afterImport(ilObject $a_new_object)
1440  {
1441  ilUtil::sendSuccess($this->lng->txt("object_added"), true);
1442  $this->ctrl->returnToParent($this);
1443  }
1444 
1453  public function getFormAction($a_cmd, $a_formaction = "")
1454  {
1455  if ($this->formaction[$a_cmd] != "")
1456  {
1457  return $this->formaction[$a_cmd];
1458  }
1459  else
1460  {
1461  return $a_formaction;
1462  }
1463  }
1464 
1473  protected function setFormAction($a_cmd, $a_formaction)
1474  {
1475  $this->formaction[$a_cmd] = $a_formaction;
1476  }
1477 
1485  protected function getReturnLocation($a_cmd, $a_location ="")
1486  {
1487  if ($this->return_location[$a_cmd] != "")
1488  {
1489  return $this->return_location[$a_cmd];
1490  }
1491  else
1492  {
1493  return $a_location;
1494  }
1495  }
1496 
1504  protected function setReturnLocation($a_cmd, $a_location)
1505  {
1506 //echo "-".$a_cmd."-".$a_location."-";
1507  $this->return_location[$a_cmd] = $a_location;
1508  }
1509 
1517  protected function getTargetFrame($a_cmd, $a_target_frame = "")
1518  {
1519  if ($this->target_frame[$a_cmd] != "")
1520  {
1521  return $this->target_frame[$a_cmd];
1522  }
1523  elseif (!empty($a_target_frame))
1524  {
1525  return "target=\"".$a_target_frame."\"";
1526  }
1527  else
1528  {
1529  return;
1530  }
1531  }
1532 
1540  protected function setTargetFrame($a_cmd, $a_target_frame)
1541  {
1542  $this->target_frame[$a_cmd] = "target=\"".$a_target_frame."\"";
1543  }
1544 
1545  // BEGIN Security: Hide objects which aren't accessible by the user.
1546  public function isVisible($a_ref_id,$a_type)
1547  {
1548  global $ilBench;
1549 
1550  $ilBench->start("Explorer", "setOutput_isVisible");
1551  $visible = $this->checkPermissionBool("visible,read", "", "", $a_ref_id);
1552 
1553  if ($visible && $a_type == 'crs') {
1554  global $tree;
1555  if($crs_id = $tree->checkForParentType($a_ref_id,'crs'))
1556  {
1557  if(!$this->checkPermissionBool("write", "", "", $crs_id))
1558  {
1559  // Show only activated courses
1560  $tmp_obj =& ilObjectFactory::getInstanceByRefId($crs_id,false);
1561 
1562  if(!$tmp_obj->isActivated())
1563  {
1564  unset($tmp_obj);
1565  $visible = false;
1566  }
1567  }
1568  }
1569  }
1570 
1571  $ilBench->stop("Explorer", "setOutput_isVisible");
1572 
1573  return $visible;
1574  }
1575  // END Security: Hide objects which aren't accessible by the user.
1576 
1582  public function viewObject()
1583  {
1584  global$tpl;
1585 
1586  if (!$this->checkPermissionBool("visible,read"))
1587  {
1588  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
1589  }
1590 
1591  // BEGIN ChangeEvent: record read event.
1592  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
1593  global $ilUser;
1595  $this->object->getType(),
1596  $this->object->getRefId(),
1597  $this->object->getId(), $ilUser->getId());
1598  // END ChangeEvent: record read event.
1599 
1600  include_once("./Services/Repository/classes/class.ilAdminSubItemsTableGUI.php");
1601  if (!$this->call_by_reference)
1602  {
1603  $this->ctrl->setParameter($this, "obj_id", $this->obj_id);
1604  }
1605  $itab = new ilAdminSubItemsTableGUI($this, "view", $_GET["ref_id"]);
1606 
1607  $tpl->setContent($itab->getHTML());
1608  }
1609 
1617  public function deleteObject($a_error = false)
1618  {
1619  global $ilCtrl;
1620 
1621  if ($_GET["item_ref_id"] != "")
1622  {
1623  $_POST["id"] = array($_GET["item_ref_id"]);
1624  }
1625 
1626  if(is_array($_POST["id"]))
1627  {
1628  foreach($_POST["id"] as $idx => $id)
1629  {
1630  $_POST["id"][$idx] = (int)$id;
1631  }
1632  }
1633 
1634  // SAVE POST VALUES (get rid of this
1635  ilSession::set("saved_post", $_POST["id"]);
1636 
1637  include_once("./Services/Repository/classes/class.ilRepUtilGUI.php");
1638  $ru = new ilRepUtilGUI($this);
1639  if (!$ru->showDeleteConfirmation($_POST["id"], $a_error))
1640  {
1641  $ilCtrl->returnToParent($this);
1642  }
1643  }
1644 
1650  protected function showPossibleSubObjects()
1651  {
1652  if ($this->sub_objects == "")
1653  {
1654  $d = $this->objDefinition->getCreatableSubObjects($this->object->getType(), ilObjectDefinition::MODE_REPOSITORY, $this->ref_id);
1655  }
1656  else
1657  {
1659  }
1660 
1661  $import = false;
1662 
1663  if (count($d) > 0)
1664  {
1665  foreach ($d as $row)
1666  {
1667  $count = 0;
1668 
1669  if ($row["max"] > 0)
1670  {
1671  //how many elements are present?
1672  for ($i=0; $i<count($this->data["ctrl"]); $i++)
1673  {
1674  if ($this->data["ctrl"][$i]["type"] == $row["name"])
1675  {
1676  $count++;
1677  }
1678  }
1679  }
1680 
1681  if ($row["max"] == "" || $count < $row["max"])
1682  {
1683  $subobj[] = $row["name"];
1684  }
1685  }
1686  }
1687 
1688  if (is_array($subobj))
1689  {
1690 
1691  //build form
1692  $opts = ilUtil::formSelect(12,"new_type",$subobj);
1693  $this->tpl->setCurrentBlock("add_object");
1694  $this->tpl->setVariable("SELECT_OBJTYPE", $opts);
1695  $this->tpl->setVariable("BTN_NAME", "create");
1696  $this->tpl->setVariable("TXT_ADD", $this->lng->txt("add"));
1697  $this->tpl->parseCurrentBlock();
1698  }
1699  }
1700 
1709  final protected function getTemplateFile($a_cmd,$a_type = "")
1710  {
1711  mk(); die("ilObjectGUI::getTemplateFile() is deprecated.");
1712  }
1713 
1721  protected function getTabs()
1722  {
1723  // please define your tabs here
1724 
1725  }
1726 
1727  // PROTECTED
1728  protected function __showButton($a_cmd,$a_text,$a_target = '')
1729  {
1730  global $ilToolbar;
1731 
1732  $ilToolbar->addButton($a_text, $this->ctrl->getLinkTarget($this, $a_cmd), $a_target);
1733  }
1734 
1735  protected function hitsperpageObject()
1736  {
1737  ilSession::set("tbl_limit", $_POST["hitsperpage"]);
1738  $_GET["limit"] = $_POST["hitsperpage"];
1739  }
1740 
1741 
1742  protected function &__initTableGUI()
1743  {
1744  include_once "./Services/Table/classes/class.ilTableGUI.php";
1745 
1746  return new ilTableGUI(0,false);
1747  }
1748 
1754  protected function __setTableGUIBasicData(&$tbl,&$result_set,$a_from = "")
1755  {
1756  switch ($a_from)
1757  {
1758  case "clipboardObject":
1759  $offset = $_GET["offset"];
1760  $order = $_GET["sort_by"];
1761  $direction = $_GET["sort_order"];
1762  $tbl->disable("footer");
1763  break;
1764 
1765  default:
1766  $offset = $_GET["offset"];
1767  $order = $_GET["sort_by"];
1768  $direction = $_GET["sort_order"];
1769  break;
1770  }
1771 
1772  $tbl->setOrderColumn($order);
1773  $tbl->setOrderDirection($direction);
1774  $tbl->setOffset($offset);
1775  $tbl->setLimit($_GET["limit"]);
1776  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
1777  $tbl->setData($result_set);
1778  }
1779 
1789  protected function redirectToRefId($a_ref_id, $a_cmd = "")
1790  {
1791  $obj_type = ilObject::_lookupType($a_ref_id,true);
1792  $class_name = $this->objDefinition->getClassName($obj_type);
1793  $class = strtolower("ilObj".$class_name."GUI");
1794  $this->ctrl->setParameterByClass("ilrepositorygui", "ref_id", $a_ref_id);
1795  $this->ctrl->redirectByClass(array("ilrepositorygui", $class), $a_cmd);
1796  }
1797 
1798  // Object Cloning
1808  protected function fillCloneTemplate($a_tpl_varname,$a_type)
1809  {
1810  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
1811  $cp = new ilObjectCopyGUI($this);
1812  $cp->setType($a_type);
1813  $cp->setTarget($_GET['ref_id']);
1814  if($a_tpl_varname)
1815  {
1816  $cp->showSourceSearch($a_tpl_varname);
1817  }
1818  else
1819  {
1820  return $cp->showSourceSearch(null);
1821  }
1822  }
1823 
1830  public function cloneAllObject()
1831  {
1832  include_once('./Services/Link/classes/class.ilLink.php');
1833  include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
1834 
1835  global $ilErr,$ilUser;
1836 
1837  $new_type = $_REQUEST['new_type'];
1838  if(!$this->checkPermissionBool("create", "", $new_type))
1839  {
1840  $ilErr->raiseError($this->lng->txt('permission_denied'));
1841  }
1842  if(!(int) $_REQUEST['clone_source'])
1843  {
1844  ilUtil::sendFailure($this->lng->txt('select_one'));
1845  $this->createObject();
1846  return false;
1847  }
1848  if(!$this->checkPermissionBool("write", "", $new_type, (int)$_REQUEST['clone_source']))
1849  {
1850  $ilErr->raiseError($this->lng->txt('permission_denied'));
1851  }
1852 
1853  // Save wizard options
1855  $wizard_options = ilCopyWizardOptions::_getInstance($copy_id);
1856  $wizard_options->saveOwner($ilUser->getId());
1857  $wizard_options->saveRoot((int) $_REQUEST['clone_source']);
1858 
1859  $options = $_POST['cp_options'] ? $_POST['cp_options'] : array();
1860  foreach($options as $source_id => $option)
1861  {
1862  $wizard_options->addEntry($source_id,$option);
1863  }
1864  $wizard_options->read();
1865 
1866  $orig = ilObjectFactory::getInstanceByRefId((int) $_REQUEST['clone_source']);
1867  $new_obj = $orig->cloneObject((int) $_GET['ref_id'],$copy_id);
1868 
1869  // Delete wizard options
1870  $wizard_options->deleteAll();
1871 
1872  ilUtil::sendSuccess($this->lng->txt("object_duplicated"),true);
1873  ilUtil::redirect(ilLink::_getLink($new_obj->getRefId()));
1874  }
1875 
1876 
1880  protected function getCenterColumnHTML()
1881  {
1882  global $ilCtrl;
1883 
1884  include_once("Services/Block/classes/class.ilColumnGUI.php");
1885 
1886  $obj_id = ilObject::_lookupObjId($this->object->getRefId());
1887  $obj_type = ilObject::_lookupType($obj_id);
1888 
1889  if ($ilCtrl->getNextClass() != "ilcolumngui")
1890  {
1891  // normal command processing
1892  return $this->getContent();
1893  }
1894  else
1895  {
1896  if (!$ilCtrl->isAsynch())
1897  {
1898  //if ($column_gui->getScreenMode() != IL_SCREEN_SIDE)
1900  {
1901  // right column wants center
1903  {
1904  $column_gui = new ilColumnGUI($obj_type, IL_COL_RIGHT);
1905  $this->setColumnSettings($column_gui);
1906  $this->html = $ilCtrl->forwardCommand($column_gui);
1907  }
1908  // left column wants center
1910  {
1911  $column_gui = new ilColumnGUI($obj_type, IL_COL_LEFT);
1912  $this->setColumnSettings($column_gui);
1913  $this->html = $ilCtrl->forwardCommand($column_gui);
1914  }
1915  }
1916  else
1917  {
1918  // normal command processing
1919  return $this->getContent();
1920  }
1921  }
1922  }
1923  }
1924 
1928  protected function getRightColumnHTML()
1929  {
1930  global $ilUser, $lng, $ilCtrl;
1931 
1932  $obj_id = ilObject::_lookupObjId($this->object->getRefId());
1933  $obj_type = ilObject::_lookupType($obj_id);
1934 
1935  include_once("Services/Block/classes/class.ilColumnGUI.php");
1936  $column_gui = new ilColumnGUI($obj_type, IL_COL_RIGHT);
1937 
1938  if ($column_gui->getScreenMode() == IL_SCREEN_FULL)
1939  {
1940  return "";
1941  }
1942 
1943  $this->setColumnSettings($column_gui);
1944 
1945  if ($ilCtrl->getNextClass() == "ilcolumngui" &&
1946  $column_gui->getCmdSide() == IL_COL_RIGHT &&
1947  $column_gui->getScreenMode() == IL_SCREEN_SIDE)
1948  {
1949  $html = $ilCtrl->forwardCommand($column_gui);
1950  }
1951  else
1952  {
1953  if (!$ilCtrl->isAsynch())
1954  {
1955  $html = $ilCtrl->getHTML($column_gui);
1956  }
1957  }
1958 
1959  return $html;
1960  }
1961 
1965  protected function setColumnSettings(ilColumnGUI $column_gui)
1966  {
1967  $column_gui->setRepositoryMode(true);
1968  $column_gui->setEnableEdit(false);
1969  if ($this->checkPermissionBool("write"))
1970  {
1971  $column_gui->setEnableEdit(true);
1972  }
1973  }
1974 
1985  protected function checkPermission($a_perm, $a_cmd = "", $a_type = "", $a_ref_id = null)
1986  {
1987  if (!$this->checkPermissionBool($a_perm, $a_cmd, $a_type, $a_ref_id))
1988  {
1989  if (!is_int(strpos($_SERVER["PHP_SELF"], "goto.php")))
1990  {
1991  // create: redirect to parent
1992  if($a_perm == "create")
1993  {
1994  if(!$a_ref_id)
1995  {
1996  $a_ref_id = $_GET["ref_id"];
1997  }
1998  $type = ilObject::_lookupType($a_ref_id, true);
1999  }
2000  else
2001  {
2002  // does this make sense?
2003  if (!is_object($this->object))
2004  {
2005  return;
2006  }
2007  if (!$a_ref_id)
2008  {
2009  $a_ref_id = $this->object->getRefId();
2010  }
2011  $type = $this->object->getType();
2012  }
2013 
2014  ilSession::clear("il_rep_ref_id");
2015 
2016  include_once "Services/Object/exceptions/class.ilObjectException.php";
2017  throw new ilObjectException($this->lng->txt("permission_denied"));
2018 
2019  /*
2020  ilUtil::sendFailure($this->lng->txt("permission_denied"), true);
2021  ilUtil::redirect("goto.php?target=".$type."_".$a_ref_id);
2022  */
2023  }
2024  // we should never be here
2025  else
2026  {
2027  die("Permission Denied.");
2028  }
2029  }
2030  }
2031 
2041  protected function checkPermissionBool($a_perm, $a_cmd = "", $a_type = "", $a_ref_id = null)
2042  {
2043  global $ilAccess;
2044 
2045  if($a_perm == "create")
2046  {
2047  if(!$a_ref_id)
2048  {
2049  $a_ref_id = $_GET["ref_id"];
2050  }
2051  return $ilAccess->checkAccess($a_perm."_".$a_type, $a_cmd, $a_ref_id);
2052  }
2053  else
2054  {
2055  // does this make sense?
2056  if (!is_object($this->object))
2057  {
2058  return false;
2059  }
2060  if (!$a_ref_id)
2061  {
2062  $a_ref_id = $this->object->getRefId();
2063  }
2064  return $ilAccess->checkAccess($a_perm, $a_cmd, $a_ref_id);
2065  }
2066  }
2067 
2074  static function _gotoRepositoryRoot($a_raise_error = false)
2075  {
2076  global $ilAccess, $ilErr, $lng;
2077 
2078  if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
2079  {
2080  $_GET["cmd"] = "frameset";
2081  $_GET["target"] = "";
2082  $_GET["ref_id"] = ROOT_FOLDER_ID;
2083  $_GET["baseClass"] = "ilRepositoryGUI";
2084  include("ilias.php");
2085  exit;
2086  }
2087 
2088  if ($a_raise_error)
2089  {
2090  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
2091  }
2092  }
2093 
2100  static function _gotoRepositoryNode($a_ref_id, $a_cmd = "frameset")
2101  {
2102  global $ilAccess, $ilErr;
2103 
2104  $_GET["cmd"] = $a_cmd;
2105  $_GET["target"] = "";
2106  $_GET["ref_id"] = $a_ref_id;
2107  $_GET["baseClass"] = "ilRepositoryGUI";
2108  include("ilias.php");
2109  exit;
2110  }
2111 
2115  protected function enableDragDropFileUpload()
2116  {
2117  include_once("./Services/FileUpload/classes/class.ilFileUploadGUI.php");
2119 
2120  $this->tpl->enableDragDropFileUpload($this->ref_id);
2121  }
2122 
2128  protected function handleAutoRating(ilObject $a_new_obj)
2129  {
2130  if(ilObject::hasAutoRating($a_new_obj->getType(), $a_new_obj->getRefId()) &&
2131  method_exists($a_new_obj, "setRating"))
2132  {
2133  $a_new_obj->setRating(true);
2134  $a_new_obj->update();
2135  }
2136  }
2137 } // END class.ilObjectGUI (3.10: 2896 loc)
2138 
2139 ?>
redrawHeaderActionObject()
Ajax call: redraw action header only.
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.
Add some data
global $ilErr
Definition: raiseError.php:16
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.
$lg
Definition: example_018.php:62
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.
Base class for ILIAS Exception handling.
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
getTabs()
get tabs abstract method.
setTargetFrame($a_cmd, $a_target_frame)
set specific target frame for command
const PEAR_ERROR_CALLBACK
Definition: PEAR.php:35
enableDragDropFileUpload()
Enables the file upload into this object by dropping files.
$_SESSION["AccountId"]
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.
cancelObject()
cancel action and go back to previous page public
initCreationForms($a_new_type)
Init creation froms.
const TITLE_LENGTH
max length of object title
$_GET["client_id"]
$tbl
Definition: example_048.php:81
$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.
static _recordWriteEvent($obj_id, $usr_id, $action, $parent_obj_id=null)
Records a write event.
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
Base exception class for object service.
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.
setEnableEdit($a_enableedit)
Set EnableEdit.
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! ...
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
static _isActive()
Static getter.
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 gatherFaPa($a_ref_id, array $a_role_ids, $a_add_action=false)
for($col=0; $col< 50; $col++) $d
addExternalEditFormCustom(ilPropertyFormGUI $a_form)
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.
$a_type
Definition: workflow.php:93
createReference()
creates reference for object
initImportForm($a_new_type)
Init object import form.
prepareOutput($a_show_subobjects=true)
prepare output
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
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 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
initDidacticTemplate(ilPropertyFormGUI $form)
Show didactic template types.
Class ilObjectGUI Basic methods of all Output classes.
static _lookupObjId($a_id)
setRepositoryMode($a_repositorymode)
Set RepositoryMode.
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)
$ilUser
Definition: imgupload.php:18
redirection script todo: (a better solution should control the processing via a xml file) ...
importFileObject($parent_id=null, $a_catch_errors=true)
Import.
static _allocateCopyId()
Allocate a copy for further entries.
editObject()
edit object
static _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.
static clear($a_var)
Unset a value.
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.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
Create styles array
The data for the language used.
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.
addDidacticTemplateOptions(array &$a_options)
Add custom templates.
validateCustom(ilPropertyFormGUI $a_form)
Validate custom values (if not possible with checkInput())
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.
static getInstanceByObjectType($a_obj_type)
Get instance by obj type.
handleAutoRating(ilObject $a_new_obj)
Activate rating automatically if parent container setting.
static _getListGUIByType($a_type, $a_context=ilObjectListGUI::CONTEXT_REPOSITORY)
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)
Create new PHPExcel object
obj_idprivate
global $ilSetting
Definition: privfeed.php:17
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.
setColumnSettings(ilColumnGUI $column_gui)
May be overwritten in subclasses.
getCreationMode()
get creation mode
getRefId()
get reference id public
updateObject()
updates object entry in object_data
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
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.
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.
getAdminTabs()
administration tabs show only permissions and trash folder
setSuffixes($a_suffixes)
Set Accepted Suffixes.
getReturnLocation($a_cmd, $a_location="")
get return location for command (command is method name without "Object", e.g.
$_POST["username"]
$html
Definition: example_001.php:87
$params
Definition: example_049.php:96
initEditCustomForm(ilPropertyFormGUI $a_form)
Add custom fields to update form.
Class ilCommonActionDispatcherGUI.
executeCommand()
execute command
setSubObject($a_sub_obj_type, $a_sub_obj_id)
Set sub object attributes.
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