ILIAS  release_7 Revision v7.30-3-g800a261c036
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
4use Psr\Http\Message\ServerRequestInterface;
6use ILIAS\Object\CreationCallbackTrait;
7
17{
18 use CreationCallbackTrait;
19
21 '<b>',
22 '<i>',
23 '<strong>',
24 '<em>',
25 '<sub>',
26 '<sup>',
27 '<pre>',
28 '<strike>',
29 '<bdo>'
30 ];
31 protected const UPLOAD_TYPE_LOCAL = 1;
32 protected const UPLOAD_TYPE_UPLOAD_DIRECTORY = 2;
33
37 protected $ilErr;
38
42 protected $locator;
43
47 protected $user;
48
52 protected $access;
53
57 protected $rbacsystem;
58
62 protected $settings;
63
67 protected $rbacreview;
68
72 protected $toolbar;
73
75
76
83
89 public $tpl;
90
96 public $tree;
97
103 public $lng;
104
110 public $data;
111
117 public $object;
118 public $ref_id;
119 public $obj_id;
120 public $maxcount; // contains number of child objects
121 public $formaction; // special formation (array "cmd" => "formaction")
122 public $return_location; // special return location (array "cmd" => "location")
123 public $target_frame; // special target frame (array "cmd" => "location")
124 protected $tmp_import_dir; // directory used during import
125
127 public $actions;
129 public $omit_locator = false;
130
134 protected $tabs_gui = null;
135
139 protected $ctrl;
140
145
146 const CFORM_NEW = 1;
147 const CFORM_IMPORT = 2;
148 const CFORM_CLONE = 3;
149
153 protected $favourites;
154
158 protected $request;
159
167 public function __construct($a_data, $a_id = 0, $a_call_by_reference = true, $a_prepare_output = true)
168 {
169 global $DIC;
170
171 $this->request = $DIC->http()->request();
172 $this->locator = $DIC["ilLocator"];
173 $this->user = $DIC->user();
174 $this->access = $DIC->access();
175 $this->settings = $DIC->settings();
176 $this->rbacreview = $DIC->rbac()->review();
177 $this->toolbar = $DIC->toolbar();
178 $this->rbacsystem = $DIC->rbac()->system();
179 $this->object_service = $DIC->object();
180 $objDefinition = $DIC["objDefinition"];
181 $tpl = $DIC["tpl"];
182 $tree = $DIC->repositoryTree();
183 $ilCtrl = $DIC->ctrl();
184 $ilErr = $DIC["ilErr"];
185 $lng = $DIC->language();
186 $ilTabs = $DIC->tabs();
187
188 $this->favourites = new ilFavouritesManager();
189
190 $this->ilias = $DIC["ilias"];
191
195 $this->tabs_gui = $ilTabs;
196
197 if (!isset($ilErr)) {
198 $ilErr = new ilErrorHandling();
199 $ilErr->setErrorHandling(PEAR_ERROR_CALLBACK, array($ilErr,'errorHandler'));
200 } else {
201 $this->ilErr = $ilErr;
202 }
203
204 $this->objDefinition = $objDefinition;
205 $this->tpl = $tpl;
206 $this->html = "";
207 $this->ctrl = $ilCtrl;
208
209 $params = array("ref_id");
210
211 if (!$a_call_by_reference) {
212 $params = array("ref_id","obj_id");
213 }
214
215 $this->ctrl->saveParameter($this, $params);
216
217 $this->lng = $lng;
218 $this->tree = $tree;
219 $this->formaction = array();
220 $this->return_location = array();
221 $this->target_frame = array();
222 $this->actions = "";
223 $this->sub_objects = "";
224
225 $this->data = $a_data;
226 $this->id = $a_id;
227 $this->call_by_reference = $a_call_by_reference;
228 $this->prepare_output = $a_prepare_output;
229 $this->creation_mode = false;
230
231 $this->ref_id = ($this->call_by_reference) ? $this->id : $_GET["ref_id"];
232 $this->obj_id = ($this->call_by_reference) ? $_GET["obj_id"] : $this->id;
233
234 if ($this->id != 0) {
235 $this->link_params = "ref_id=" . $this->ref_id;
236 }
237
238 // get the object
239 $this->assignObject();
240
241 // set context
242 if (is_object($this->object)) {
243 if ($this->call_by_reference && $this->ref_id == $_GET["ref_id"]) {
244 $this->ctrl->setContext(
245 $this->object->getId(),
246 $this->object->getType()
247 );
248 }
249 }
250
251 //prepare output
252 if ($a_prepare_output) {
253 $this->prepareOutput();
254 }
255 }
256
262 protected function getObjectService()
263 {
265 }
266
270 public function executeCommand()
271 {
272 $next_class = $this->ctrl->getNextClass($this);
273 $cmd = $this->ctrl->getCmd();
274
275 switch ($next_class) {
276 default:
277 $this->prepareOutput();
278 if (!$cmd) {
279 $cmd = "view";
280 }
281 $cmd .= "Object";
282 $this->$cmd();
283
284 break;
285 }
286
287 return true;
288 }
289
290
294 public function withReferences()
295 {
296 return $this->call_by_reference;
297 }
298
305 public function setCreationMode($a_mode = true)
306 {
307 $this->creation_mode = $a_mode;
308 }
309
313 public function getCreationMode()
314 {
315 return $this->creation_mode;
316 }
317
318 protected function assignObject()
319 {
320 // TODO: it seems that we always have to pass only the ref_id
321 //echo "<br>ilObjectGUIassign:".get_class($this).":".$this->id.":<br>";
322 if ($this->id != 0) {
323 if ($this->call_by_reference) {
324 $this->object = ilObjectFactory::getInstanceByRefId($this->id);
325 } else {
326 $this->object = ilObjectFactory::getInstanceByObjId($this->id);
327 }
328 }
329 }
330
334 public function prepareOutput($a_show_subobjects = true)
335 {
336 $ilLocator = $this->locator;
339
340 $this->tpl->loadStandardTemplate();
341 // administration prepare output
342 if (strtolower($_GET["baseClass"]) == "iladministrationgui") {
343 $this->addAdminLocatorItems();
344 $tpl->setLocator();
345
346 // ilUtil::sendInfo();
348
349 $this->setTitleAndDescription();
350
351 if ($this->getCreationMode() != true) {
352 $this->setAdminTabs();
353 }
354
355 return false;
356 }
357 // set locator
358 $this->setLocator();
359 // catch feedback message
360 // ilUtil::sendInfo();
362
363 // in creation mode (parent) object and gui object
364 // do not fit
365 if ($this->getCreationMode() == true) {
366 // repository vs. workspace
367 if ($this->call_by_reference) {
368 // get gui class of parent and call their title and description method
369 $obj_type = ilObject::_lookupType($_GET["ref_id"], true);
370 $class_name = $this->objDefinition->getClassName($obj_type);
371 $class = strtolower("ilObj" . $class_name . "GUI");
372 $class_path = $this->ctrl->lookupClassPath($class);
373 include_once($class_path);
374 $class_name = $this->ctrl->getClassForClasspath($class_path);
375 //echo "<br>instantiating parent for title and description";
376 $this->parent_gui_obj = new $class_name("", $_GET["ref_id"], true, false);
377 // the next line prevents the header action menu being shown
378 $this->parent_gui_obj->setCreationMode(true);
379 $this->parent_gui_obj->setTitleAndDescription();
380 }
381 } else {
382 // set title and description and title icon
383 $this->setTitleAndDescription();
384
385 // set tabs
386 $this->setTabs();
387
388
389 // fileupload support
390 require_once './Services/FileUpload/classes/class.ilFileUploadUtil.php';
391 if (ilFileUploadUtil::isUploadAllowed($this->ref_id, $this->object->getType())) {
393 }
394 }
395
396 return true;
397 }
398
402 protected function setTitleAndDescription()
403 {
404 if (!is_object($this->object)) {
405 if ((int) $_REQUEST["crtptrefid"] > 0) {
406 $cr_obj_id = ilObject::_lookupObjId((int) $_REQUEST["crtcb"]);
407 $this->tpl->setTitle(
408 strip_tags(
409 ilObject::_lookupTitle($cr_obj_id),
410 self::ALLOWED_TAGS_IN_TITLE_AND_DESCRIPTION
411 )
412 );
413 $this->tpl->setTitleIcon(ilObject::_getIcon($cr_obj_id));
414 }
415 return;
416 }
417 $this->tpl->setTitle(
418 strip_tags(
419 $this->object->getPresentationTitle(),
420 self::ALLOWED_TAGS_IN_TITLE_AND_DESCRIPTION
421 )
422 );
423 $this->tpl->setDescription(
424 strip_tags(
425 $this->object->getLongDescription(),
426 self::ALLOWED_TAGS_IN_TITLE_AND_DESCRIPTION
427 )
428 );
429
430 if (strtolower($_GET["baseClass"]) == "iladministrationgui") {
431 // alt text would be same as heading -> empty alt text
432 $this->tpl->setTitleIcon(ilObject::_getIcon("", "big", $this->object->getType()));
433 } else {
434 $this->tpl->setTitleIcon(
435 ilObject::_getIcon("", "big", $this->object->getType()),
436 $this->lng->txt("obj_" . $this->object->getType())
437 );
438 }
439
440 include_once './Services/Object/classes/class.ilObjectListGUIFactory.php';
441 $lgui = ilObjectListGUIFactory::_getListGUIByType($this->object->getType());
442 $lgui->initItem($this->object->getRefId(), $this->object->getId(), $this->object->getType());
443 $this->tpl->setAlertProperties($lgui->getAlertProperties());
444 }
445
453 protected function initHeaderAction($a_sub_type = null, $a_sub_id = null)
454 {
455 $ilAccess = $this->access;
456
457 if (!$this->creation_mode && $this->object) {
458 include_once "Services/Object/classes/class.ilCommonActionDispatcherGUI.php";
459 $dispatcher = new ilCommonActionDispatcherGUI(
461 $ilAccess,
462 $this->object->getType(),
463 $this->ref_id,
464 $this->object->getId()
465 );
466
467 $dispatcher->setSubObject($a_sub_type, $a_sub_id);
468
469 include_once "Services/Object/classes/class.ilObjectListGUI.php";
470 ilObjectListGUI::prepareJSLinks(
471 $this->ctrl->getLinkTarget($this, "redrawHeaderAction", "", true),
472 $this->ctrl->getLinkTargetByClass(array("ilcommonactiondispatchergui", "ilnotegui"), "", "", true, false),
473 $this->ctrl->getLinkTargetByClass(array("ilcommonactiondispatchergui", "iltagginggui"), "", "", true, false)
474 );
475
476 $lg = $dispatcher->initHeaderAction();
477
478 if (is_object($lg)) {
479 // to enable add to desktop / remove from desktop
480 if ($this instanceof ilDesktopItemHandling) {
481 $lg->setContainerObject($this);
482 }
483
484 // enable multi download
485 $lg->enableMultiDownload(true);
486
487 // comments settings are always on (for the repository)
488 // should only be shown if active or permission to toggle
489 include_once "Services/Notes/classes/class.ilNote.php";
490 if ($ilAccess->checkAccess("write", "", $this->ref_id) ||
491 $ilAccess->checkAccess("edit_permissions", "", $this->ref_id) ||
492 ilNote::commentsActivated($this->object->getId(), 0, $this->object->getType())) {
493 $lg->enableComments(true);
494 }
495
496 $lg->enableNotes(true);
497 $lg->enableTags(true);
498 }
499
500 return $lg;
501 }
502 }
503
509 protected function insertHeaderAction($a_list_gui)
510 {
511 if (!is_object($this->object) || ilContainer::_lookupContainerSetting($this->object->getId(), "hide_top_actions")) {
512 return;
513 }
514
515 if (is_object($a_list_gui)) {
516 $this->tpl->setHeaderActionMenu($a_list_gui->getHeaderAction());
517 }
518 }
519
523 protected function addHeaderAction()
524 {
525 $this->insertHeaderAction($this->initHeaderAction());
526 }
527
531 protected function redrawHeaderActionObject()
532 {
534
535 $lg = $this->initHeaderAction();
536 echo $lg->getHeaderAction();
537
538 // we need to add onload code manually (rating, comments, etc.)
539 echo $tpl->getOnLoadCodeForAsynch();
540
541 exit;
542 }
543
544
545
550 protected function setTabs()
551 {
552 $this->getTabs();
553 }
554
559 final protected function setAdminTabs()
560 {
561 $this->getAdminTabs();
562 }
563
567 public function getAdminTabs()
568 {
570
571 if ($this->checkPermissionBool("visible,read")) {
572 $this->tabs_gui->addTarget(
573 "view",
574 $this->ctrl->getLinkTarget($this, "view"),
575 array("", "view"),
576 get_class($this)
577 );
578 }
579
580 if ($this->checkPermissionBool("edit_permission")) {
581 $this->tabs_gui->addTarget(
582 "perm_settings",
583 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"),
584 "",
585 "ilpermissiongui"
586 );
587 }
588 }
589
590
591 public function getHTML()
592 {
593 return $this->html;
594 }
595
596
603 private function setActions($a_actions = "")
604 {
605 if (is_array($a_actions)) {
606 foreach ($a_actions as $name => $lng) {
607 $this->actions[$name] = array("name" => $name, "lng" => $lng);
608 }
609 } else {
610 $this->actions = "";
611 }
612 }
613
620 private function setSubObjects($a_sub_objects = "")
621 {
622 if (is_array($a_sub_objects)) {
623 foreach ($a_sub_objects as $name => $options) {
624 $this->sub_objects[$name] = array("name" => $name, "max" => $options["max"]);
625 }
626 } else {
627 $this->sub_objects = "";
628 }
629 }
630
639 protected function setLocator()
640 {
641 $ilLocator = $this->locator;
643
644 if ($this->omit_locator) {
645 return;
646 }
647
648 // repository vs. workspace
649 if ($this->call_by_reference) {
650 // todo: admin workaround
651 // in the future, objectgui classes should not be called in
652 // admin section anymore (rbac/trash handling in own classes)
653 $ref_id = ($_GET["ref_id"] != "")
654 ? $_GET["ref_id"]
655 : $this->object->getRefId();
656 $ilLocator->addRepositoryItems($ref_id);
657 }
658
659 if (!$this->creation_mode) {
660 $this->addLocatorItems();
661 }
662
663 $tpl->setLocator();
664 }
665
670 protected function addLocatorItems()
671 {
672 }
673
674 protected function omitLocator($a_omit = true)
675 {
676 $this->omit_locator = $a_omit;
677 }
678
685 protected function addAdminLocatorItems($a_do_not_add_object = false)
686 {
687 $ilLocator = $this->locator;
688
689 if ($_GET["admin_mode"] == "settings") { // system settings
690 $this->ctrl->setParameterByClass(
691 "ilobjsystemfoldergui",
692 "ref_id",
694 );
695 $ilLocator->addItem(
696 $this->lng->txt("administration"),
697 $this->ctrl->getLinkTargetByClass(array("iladministrationgui", "ilobjsystemfoldergui"), "")
698 );
699 if ($this->object && ($this->object->getRefId() != SYSTEM_FOLDER_ID && !$a_do_not_add_object)) {
700 $ilLocator->addItem(
701 $this->object->getTitle(),
702 $this->ctrl->getLinkTarget($this, "view")
703 );
704 }
705 } else { // repository administration
706 $this->ctrl->setParameterByClass(
707 "iladministrationgui",
708 "ref_id",
709 ""
710 );
711 $this->ctrl->setParameterByClass(
712 "iladministrationgui",
713 "admin_mode",
714 "settings"
715 );
716 //$ilLocator->addItem($this->lng->txt("administration"),
717 // $this->ctrl->getLinkTargetByClass("iladministrationgui", "frameset"),
718 // ilFrameTargetInfo::_getFrame("MainContent"));
719 $this->ctrl->clearParametersByClass("iladministrationgui");
720 $ilLocator->addAdministrationItems();
721 }
722 }
723
728 public function confirmedDeleteObject()
729 {
730 if (isset($_POST["mref_id"])) {
731 $_SESSION["saved_post"] = array_unique(array_merge($_SESSION["saved_post"], $_POST["mref_id"]));
732 }
733
734 include_once("./Services/Repository/classes/class.ilRepUtilGUI.php");
735 $ru = new ilRepUtilGUI($this);
736 $ru->deleteObjects($_GET["ref_id"], ilSession::get("saved_post"));
737 ilSession::clear("saved_post");
738 $this->ctrl->returnToParent($this);
739 }
740
746 public function cancelDeleteObject()
747 {
748 ilSession::clear("saved_post");
749 $this->ctrl->returnToParent($this);
750 }
751
752
758 public function cancelObject()
759 {
760 ilSession::clear("saved_post");
761 $this->ctrl->returnToParent($this);
762 }
763
769 public function createObject()
770 {
773
774 $new_type = $_REQUEST["new_type"];
775
776
777 // add new object to custom parent container
778 $this->ctrl->saveParameter($this, "crtptrefid");
779 // use forced callback after object creation
780 $this->ctrl->saveParameter($this, "crtcb");
781
782 if (!$this->checkPermissionBool("create", "", $new_type)) {
783 $ilErr->raiseError($this->lng->txt("permission_denied"), $ilErr->MESSAGE);
784 } else {
785 $this->lng->loadLanguageModule($new_type);
786 $this->ctrl->setParameter($this, "new_type", $new_type);
787
788 $forms = $this->initCreationForms($new_type);
789
790 // copy form validation error: do not show other creation forms
791 if ($_GET["cpfl"] && isset($forms[self::CFORM_CLONE])) {
792 $forms = array(self::CFORM_CLONE => $forms[self::CFORM_CLONE]);
793 }
794 $tpl->setContent($this->getCreationFormsHTML($forms));
795 }
796 }
797
806 protected function initCreationForms($a_new_type)
807 {
808 $forms = array(
809 self::CFORM_NEW => $this->initCreateForm($a_new_type),
810 self::CFORM_IMPORT => $this->initImportForm($a_new_type),
811 self::CFORM_CLONE => $this->fillCloneTemplate(null, $a_new_type)
812 );
813
814 return $forms;
815 }
816
822 final protected function getCreationFormsHTML(array $a_forms)
823 {
825
826 // #13168- sanity check
827 foreach ($a_forms as $id => $form) {
828 if (!$form instanceof ilPropertyFormGUI) {
829 unset($a_forms[$id]);
830 }
831 }
832
833 // no accordion if there is just one form
834 if (sizeof($a_forms) == 1) {
835 $form_type = key($a_forms);
836 $a_forms = array_shift($a_forms);
837
838 // see bug #0016217
839 if (method_exists($this, "getCreationFormTitle")) {
840 $form_title = $this->getCreationFormTitle($form_type);
841 if ($form_title != "") {
842 $a_forms->setTitle($form_title);
843 }
844 }
845 return $a_forms->getHTML();
846 } else {
847 include_once("./Services/Accordion/classes/class.ilAccordionGUI.php");
848
849 $acc = new ilAccordionGUI();
850 $acc->setBehaviour(ilAccordionGUI::FIRST_OPEN);
851 $cnt = 1;
852 foreach ($a_forms as $form_type => $cf) {
853 $htpl = new ilTemplate("tpl.creation_acc_head.html", true, true, "Services/Object");
854
855 // using custom form titles (used for repository plugins)
856 $form_title = "";
857 if (method_exists($this, "getCreationFormTitle")) {
858 $form_title = $this->getCreationFormTitle($form_type);
859 }
860 if (!$form_title) {
861 $form_title = $cf->getTitle();
862 }
863
864 // move title from form to accordion
865 $htpl->setVariable("TITLE", $this->lng->txt("option") . " " . $cnt . ": " .
866 $form_title);
867 $cf->setTitle(null);
868 $cf->setTitleIcon(null);
869 $cf->setTableWidth("100%");
870
871 $acc->addItem($htpl->get(), $cf->getHTML());
872
873 $cnt++;
874 }
875
876 return "<div class='ilCreationFormSection'>" . $acc->getHTML() . "</div>";
877 }
878 }
879
886 protected function initCreateForm($a_new_type)
887 {
888 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
889 $form = new ilPropertyFormGUI();
890 $form->setTarget("_top");
891 $form->setFormAction($this->ctrl->getFormAction($this, "save"));
892 $form->setTitle($this->lng->txt($a_new_type . "_new"));
893
894 // title
895 $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
896 $ti->setSize(min(40, ilObject::TITLE_LENGTH));
897 $ti->setMaxLength(ilObject::TITLE_LENGTH);
898 $ti->setRequired(true);
899 $form->addItem($ti);
900
901 // description
902 $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
903 $ta->setCols(40);
904 $ta->setRows(2);
905 $form->addItem($ta);
906
907 $form = $this->initDidacticTemplate($form);
908
909 $form->addCommandButton("save", $this->lng->txt($a_new_type . "_add"));
910 $form->addCommandButton("cancel", $this->lng->txt("cancel"));
911
912 return $form;
913 }
914
920 protected function initDidacticTemplate(ilPropertyFormGUI $form)
921 {
923
924 $lng->loadLanguageModule('didactic');
925 $existing_exclusive = false;
926 $options = [];
927 $options['dtpl_0'] = array($this->lng->txt('didactic_default_type'),
928 sprintf(
929 $this->lng->txt('didactic_default_type_info'),
930 $this->lng->txt('objs_' . $this->type)
931 ));
932
933 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateSettings.php';
934 $templates = ilDidacticTemplateSettings::getInstanceByObjectType($this->type)->getTemplates();
935 if ($templates) {
936 foreach ($templates as $template) {
937 if ($template->isEffective($_GET["ref_id"])) {
938 $options["dtpl_" . $template->getId()] = array(
939 $template->getPresentationTitle(),
940 $template->getPresentationDescription()
941 );
942
943 if ($template->isExclusive()) {
944 $existing_exclusive = true;
945 }
946 }
947 }
948 }
949
950 $this->addDidacticTemplateOptions($options);
951
952 if (sizeof($options) > 1) {
954 $this->lng->txt('type'),
955 'didactic_type'
956 );
957 // workaround for containers in edit mode
958 if (!$this->getCreationMode()) {
959 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php';
960 $value = 'dtpl_' . ilDidacticTemplateObjSettings::lookupTemplateId($this->object->getRefId());
961
962 $type->setValue($value);
963
964 if (!in_array($value, array_keys($options)) || ($existing_exclusive && $value == "dtpl_0")) {
965 //add or rename actual value to not avaiable
966 $options[$value] = array($this->lng->txt('not_available'));
967 }
968 } else {
969 if ($existing_exclusive) {
970 //if an exclusive template exists use the second template as default value
971 $keys = array_keys($options);
972 $type->setValue($keys[1]);
973 } else {
974 $type->setValue('dtpl_0');
975 }
976 }
977 $form->addItem($type);
978
979 foreach ($options as $id => $data) {
980 $option = new ilRadioOption($data[0], $id, $data[1]);
981
982 if ($existing_exclusive && $id == 'dtpl_0') {
983 //set default disabled if an exclusive template exists
984 $option->setDisabled(true);
985 }
986
987 $type->addOption($option);
988 }
989 }
990
991 return $form;
992 }
993
999 protected function addDidacticTemplateOptions(array &$a_options)
1000 {
1001 }
1002
1006 public function cancelCreation()
1007 {
1008 $ilCtrl = $this->ctrl;
1009
1010 $ilCtrl->redirectByClass("ilrepositorygui", "frameset");
1011 }
1012
1018 public function saveObject()
1019 {
1021 $tpl = $this->tpl;
1023
1024 $new_type = $_REQUEST["new_type"];
1025
1026 // create permission is already checked in createObject. This check here is done to prevent hacking attempts
1027 if (!$this->checkPermissionBool("create", "", $new_type)) {
1028 $ilErr->raiseError($this->lng->txt("no_create_permission"), $ilErr->MESSAGE);
1029 }
1030
1031 $this->lng->loadLanguageModule($new_type);
1032 $this->ctrl->setParameter($this, "new_type", $new_type);
1033
1034 $form = $this->initCreateForm($new_type);
1035 if ($form->checkInput()) {
1036 $this->ctrl->setParameter($this, "new_type", "");
1037
1038 // create instance
1039 $class_name = "ilObj" . $objDefinition->getClassName($new_type);
1040 $location = $objDefinition->getLocation($new_type);
1041 include_once($location . "/class." . $class_name . ".php");
1042 $newObj = new $class_name();
1043 $newObj->setType($new_type);
1044 $newObj->setTitle($form->getInput("title"));
1045 $newObj->setDescription($form->getInput("desc"));
1046 $newObj->create();
1047
1048 $this->putObjectInTree($newObj);
1049
1050 // apply didactic template?
1051 $dtpl = $this->getDidacticTemplateVar("dtpl");
1052 if ($dtpl) {
1053 $newObj->applyDidacticTemplate($dtpl);
1054 }
1055
1056 // auto rating
1057 $this->handleAutoRating($newObj);
1058
1059 // additional paramters are added to afterSave()
1060 $args = func_get_args();
1061 if ($args) {
1062 $this->afterSave($newObj, $args);
1063 } else {
1064 $this->afterSave($newObj);
1065 }
1066 return;
1067 }
1068
1069 // display only this form to correct input
1070 $form->setValuesByPost();
1071 $tpl->setContent($form->getHtml());
1072 }
1073
1080 public function getDidacticTemplateVar($a_type)
1081 {
1082 $tpl = $_POST["didactic_type"];
1083 if ($tpl && substr($tpl, 0, strlen($a_type) + 1) == $a_type . "_") {
1084 return (int) substr($tpl, strlen($a_type) + 1);
1085 }
1086 return 0;
1087 }
1088
1095 public function putObjectInTree(ilObject $a_obj, $a_parent_node_id = null)
1096 {
1100
1101 if (!$a_parent_node_id) {
1102 $a_parent_node_id = $_GET["ref_id"];
1103 }
1104
1105 // add new object to custom parent container
1106 if ((int) $_REQUEST["crtptrefid"]) {
1107 $a_parent_node_id = (int) $_REQUEST["crtptrefid"];
1108 }
1109
1110 $a_obj->createReference();
1111 $a_obj->putInTree($a_parent_node_id);
1112 $a_obj->setPermissions($a_parent_node_id);
1113
1114 $this->obj_id = $a_obj->getId();
1115 $this->ref_id = $a_obj->getRefId();
1116
1117 // BEGIN ChangeEvent: Record save object.
1118 require_once('Services/Tracking/classes/class.ilChangeEvent.php');
1119 ilChangeEvent::_recordWriteEvent($this->obj_id, $ilUser->getId(), 'create');
1120 // END ChangeEvent: Record save object.
1121
1122 // rbac log
1123 include_once "Services/AccessControl/classes/class.ilRbacLog.php";
1124 $rbac_log_roles = $rbacreview->getParentRoleIds($this->ref_id, false);
1125 $rbac_log = ilRbacLog::gatherFaPa($this->ref_id, array_keys($rbac_log_roles), true);
1126 ilRbacLog::add(ilRbacLog::CREATE_OBJECT, $this->ref_id, $rbac_log);
1127
1128 // use forced callback after object creation
1129 $this->callCreationCallback($a_obj, $this->objDefinition, $_GET['crtcb'] ?? 0);
1130 }
1131
1137 protected function afterSave(ilObject $a_new_object)
1138 {
1139 ilUtil::sendSuccess($this->lng->txt("object_added"), true);
1140 $this->ctrl->returnToParent($this);
1141 }
1142
1148 public function editObject()
1149 {
1150 $tpl = $this->tpl;
1151 $ilTabs = $this->tabs_gui;
1153
1154 if (!$this->checkPermissionBool("write")) {
1155 $ilErr->raiseError($this->lng->txt("msg_no_perm_write"), $ilErr->MESSAGE);
1156 }
1157
1158 $ilTabs->activateTab("settings");
1159
1160 $form = $this->initEditForm();
1161 $values = $this->getEditFormValues();
1162 if ($values) {
1163 $form->setValuesByArray($values);
1164 }
1165
1166 $this->addExternalEditFormCustom($form);
1167
1168 $tpl->setContent($form->getHTML());
1169 }
1170
1172 {
1173 // has to be done AFTER setValuesByArray() ...
1174 }
1175
1181 protected function initEditForm()
1182 {
1183 $lng = $this->lng;
1184 $ilCtrl = $this->ctrl;
1185
1186 $lng->loadLanguageModule($this->object->getType());
1187
1188 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1189 $form = new ilPropertyFormGUI();
1190 $form->setFormAction($this->ctrl->getFormAction($this, "update"));
1191 $form->setTitle($this->lng->txt($this->object->getType() . "_edit"));
1192
1193 // title
1194 $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
1195 $ti->setSize(min(40, ilObject::TITLE_LENGTH));
1196 $ti->setMaxLength(ilObject::TITLE_LENGTH);
1197 $ti->setRequired(true);
1198 $form->addItem($ti);
1199
1200 // description
1201 $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
1202 $ta->setCols(40);
1203 $ta->setRows(2);
1204 $form->addItem($ta);
1205
1206 $this->initEditCustomForm($form);
1207
1208 $form->addCommandButton("update", $this->lng->txt("save"));
1209 //$this->form->addCommandButton("cancelUpdate", $lng->txt("cancel"));
1210
1211 return $form;
1212 }
1213
1219 protected function initEditCustomForm(ilPropertyFormGUI $a_form)
1220 {
1221 }
1222
1228 protected function getEditFormValues()
1229 {
1230 $values["title"] = $this->object->getTitle();
1231 $values["desc"] = $this->object->getLongDescription();
1232 $this->getEditFormCustomValues($values);
1233 return $values;
1234 }
1235
1241 protected function getEditFormCustomValues(array &$a_values)
1242 {
1243 }
1244
1248 public function updateObject()
1249 {
1250 $ilTabs = $this->tabs_gui;
1251 $tpl = $this->tpl;
1253
1254 if (!$this->checkPermissionBool("write")) {
1255 $ilErr->raiseError($this->lng->txt("permission_denied"), $ilErr->MESSAGE);
1256 }
1257
1258 $form = $this->initEditForm();
1259 if ($form->checkInput() &&
1260 $this->validateCustom($form)) {
1261 $this->object->setTitle($form->getInput("title"));
1262 $this->object->setDescription($form->getInput("desc"));
1263 $this->updateCustom($form);
1264 $this->object->update();
1265
1266 $this->afterUpdate();
1267 return;
1268 }
1269
1270 // display form again to correct errors
1271 $ilTabs->activateTab("settings");
1272 $form->setValuesByPost();
1273 $tpl->setContent($form->getHtml());
1274 }
1275
1282 protected function validateCustom(ilPropertyFormGUI $a_form)
1283 {
1284 return true;
1285 }
1286
1292 protected function updateCustom(ilPropertyFormGUI $a_form)
1293 {
1294 }
1295
1299 protected function afterUpdate()
1300 {
1301 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
1302 $this->ctrl->redirect($this, "edit");
1303 }
1304
1311 protected function initImportForm($a_new_type)
1312 {
1313 global $DIC;
1314
1315 $import_directory_factory = new ilImportDirectoryFactory();
1316 $export_directory = $import_directory_factory->getInstanceForComponent(ilImportDirectoryFactory::TYPE_EXPORT);
1317 $upload_files = $export_directory->getFilesFor((int) $DIC->user()->getId(), (string) $a_new_type);
1318 $has_upload_files = false;
1319 if (count($upload_files)) {
1320 $has_upload_files = true;
1321 }
1322
1323 $form = new ilPropertyFormGUI();
1324 $form->setTarget("_top");
1325 $form->setFormAction($this->ctrl->getFormAction($this, "importFile"));
1326 $form->setTitle($this->lng->txt($a_new_type . "_import"));
1327
1328 $fi = new ilFileInputGUI($this->lng->txt("import_file"), "importfile");
1329 $fi->setSuffixes(array("zip"));
1330 $fi->setRequired(true);
1331 if ($has_upload_files) {
1332 $this->lng->loadLanguageModule('content');
1333 $option = new ilRadioGroupInputGUI(
1334 $this->lng->txt('cont_choose_file_source'),
1335 'upload_type'
1336 );
1337 $option->setValue(self::UPLOAD_TYPE_LOCAL);
1338 $form->addItem($option);
1339
1340 $direct = new ilRadioOption(
1341 $this->lng->txt('cont_choose_local'),
1342 self::UPLOAD_TYPE_LOCAL
1343 );
1344 $option->addOption($direct);
1345
1346 $direct->addSubItem($fi);
1347 $upload = new ilRadioOption(
1348 $this->lng->txt('cont_choose_upload_dir'),
1349 self::UPLOAD_TYPE_UPLOAD_DIRECTORY
1350 );
1351 $option->addOption($upload);
1352 $files = new ilSelectInputGUI(
1353 $this->lng->txt('cont_choose_upload_dir'),
1354 'uploadFile'
1355 );
1356 $upload_files[''] = $this->lng->txt('cont_select_from_upload_dir');
1357 $files->setOptions($upload_files);
1358 $files->setRequired(true);
1359 $upload->addSubItem($files);
1360 }
1361
1362 if (!$has_upload_files) {
1363 $form->addItem($fi);
1364 }
1365
1366 $form->addCommandButton("importFile", $this->lng->txt("import"));
1367 $form->addCommandButton("cancel", $this->lng->txt("cancel"));
1368
1369 return $form;
1370 }
1371
1375 protected function importFileObject($parent_id = null, $a_catch_errors = true)
1376 {
1377 global $DIC;
1378
1379 $user = $DIC->user();
1380
1382 $tpl = $this->tpl;
1384
1385 if (!$parent_id) {
1386 $parent_id = $_GET["ref_id"];
1387 }
1388 $new_type = $_REQUEST["new_type"];
1389 $upload_type = $this->request->getParsedBody()['upload_type'] ?? self::UPLOAD_TYPE_LOCAL;
1390
1391 // create permission is already checked in createObject. This check here is done to prevent hacking attempts
1392 if (!$this->checkPermissionBool("create", "", $new_type)) {
1393 $ilErr->raiseError($this->lng->txt("no_create_permission"));
1394 }
1395
1396 $this->lng->loadLanguageModule($new_type);
1397 $this->ctrl->setParameter($this, "new_type", $new_type);
1398
1399 $form = $this->initImportForm($new_type);
1400 if ($form->checkInput()) {
1401 // :todo: make some check on manifest file
1402
1403 if ($objDefinition->isContainer($new_type)) {
1404 include_once './Services/Export/classes/class.ilImportContainer.php';
1405 $imp = new ilImportContainer((int) $parent_id);
1406 } else {
1407 include_once("./Services/Export/classes/class.ilImport.php");
1408 $imp = new ilImport((int) $parent_id);
1409 }
1410
1411 try {
1412 if ($upload_type == self::UPLOAD_TYPE_LOCAL) {
1413 $new_id = $imp->importObject(
1414 null,
1415 $_FILES["importfile"]["tmp_name"],
1416 $_FILES["importfile"]["name"],
1417 $new_type
1418 );
1419 } else {
1420 $hash = $this->request->getParsedBody()['uploadFile'] ?? '';
1421 $upload_factory = new ilImportDirectoryFactory();
1422 $export_upload = $upload_factory->getInstanceForComponent(ilImportDirectoryFactory::TYPE_EXPORT);
1423 $file = $export_upload->getAbsolutePathForHash($user->getId(), $new_type, $hash);
1424
1425 $new_id = $imp->importObject(
1426 null,
1427 $file,
1428 basename($file),
1429 $new_type,
1430 '',
1431 true
1432 );
1433 }
1434 } catch (ilException $e) {
1435 if (DEVMODE) {
1436 throw $e;
1437 }
1438 $this->tmp_import_dir = $imp->getTemporaryImportDir();
1439 if (!$a_catch_errors) {
1440 throw $e;
1441 }
1442 // display message and form again
1443 ilUtil::sendFailure($this->lng->txt("obj_import_file_error") . " <br />" . $e->getMessage());
1444 $form->setValuesByPost();
1445 $tpl->setContent($form->getHtml());
1446 return;
1447 }
1448
1449 if ($new_id > 0) {
1450 $this->ctrl->setParameter($this, "new_type", "");
1451
1452 $newObj = ilObjectFactory::getInstanceByObjId($new_id);
1453 // put new object id into tree - already done in import for containers
1454 if (!$objDefinition->isContainer($new_type)) {
1455 $this->putObjectInTree($newObj);
1456 } else {
1457 $ref_ids = ilObject::_getAllReferences($newObj->getId());
1458 if (count($ref_ids) === 1) {
1459 $newObj->setRefId((int) current($ref_ids));
1460 }
1461 $this->callCreationCallback($newObj, $this->objDefinition, $_GET['crtcb'] ?? 0); // see #24244
1462 }
1463
1464 $this->afterImport($newObj);
1465 }
1466 // import failed
1467 else {
1468 if ($objDefinition->isContainer($new_type)) {
1469 ilUtil::sendFailure($this->lng->txt("container_import_zip_file_invalid"));
1470 } else {
1471 // not enough information here...
1472 return;
1473 }
1474 }
1475 }
1476
1477 // display form to correct errors
1478 $form->setValuesByPost();
1479 $tpl->setContent($form->getHtml());
1480 }
1481
1487 protected function afterImport(ilObject $a_new_object)
1488 {
1489 ilUtil::sendSuccess($this->lng->txt("object_added"), true);
1490 $this->ctrl->returnToParent($this);
1491 }
1492
1501 public function getFormAction($a_cmd, $a_formaction = "")
1502 {
1503 if ($this->formaction[$a_cmd] != "") {
1504 return $this->formaction[$a_cmd];
1505 } else {
1506 return $a_formaction;
1507 }
1508 }
1509
1518 protected function setFormAction($a_cmd, $a_formaction)
1519 {
1520 $this->formaction[$a_cmd] = $a_formaction;
1521 }
1522
1530 protected function getReturnLocation($a_cmd, $a_location = "")
1531 {
1532 if ($this->return_location[$a_cmd] != "") {
1533 return $this->return_location[$a_cmd];
1534 } else {
1535 return $a_location;
1536 }
1537 }
1538
1546 protected function setReturnLocation($a_cmd, $a_location)
1547 {
1548 //echo "-".$a_cmd."-".$a_location."-";
1549 $this->return_location[$a_cmd] = $a_location;
1550 }
1551
1559 protected function getTargetFrame($a_cmd, $a_target_frame = "")
1560 {
1561 if ($this->target_frame[$a_cmd] != "") {
1562 return $this->target_frame[$a_cmd];
1563 } elseif (!empty($a_target_frame)) {
1564 return "target=\"" . $a_target_frame . "\"";
1565 } else {
1566 return;
1567 }
1568 }
1569
1577 protected function setTargetFrame($a_cmd, $a_target_frame)
1578 {
1579 $this->target_frame[$a_cmd] = "target=\"" . $a_target_frame . "\"";
1580 }
1581
1582 // BEGIN Security: Hide objects which aren't accessible by the user.
1583 public function isVisible($a_ref_id, $a_type)
1584 {
1585 $visible = $this->checkPermissionBool("visible,read", "", "", $a_ref_id);
1586
1587 if ($visible && $a_type == 'crs') {
1589 if ($crs_id = $tree->checkForParentType($a_ref_id, 'crs')) {
1590 if (!$this->checkPermissionBool("write", "", "", $crs_id)) {
1591 // Show only activated courses
1592 $tmp_obj = &ilObjectFactory::getInstanceByRefId($crs_id, false);
1593
1594 if (!$tmp_obj->isActivated()) {
1595 unset($tmp_obj);
1596 $visible = false;
1597 }
1598 }
1599 }
1600 }
1601
1602 return $visible;
1603 }
1604 // END Security: Hide objects which aren't accessible by the user.
1605
1610 public function viewObject()
1611 {
1612 global $DIC;
1613
1614 $tpl = $DIC->ui()->mainTemplate();
1615 $user = $DIC->user();
1616
1617 $this->checkPermission('visible') && $this->checkPermission('read');
1618
1619 $this->tabs_gui->activateTab('view');
1620
1622 $this->object->getType(),
1623 $this->object->getRefId(),
1624 $this->object->getId(),
1625 $user->getId()
1626 );
1627
1628 if (!$this->withReferences()) {
1629 $this->ctrl->setParameter($this, 'obj_id', $this->obj_id);
1630 }
1631 $itab = new ilAdminSubItemsTableGUI(
1632 $this,
1633 "view",
1634 $_GET["ref_id"],
1635 $this->checkPermissionBool('write')
1636 );
1637
1638 $tpl->setContent($itab->getHTML());
1639 }
1640
1648 public function deleteObject($a_error = false)
1649 {
1650 $ilCtrl = $this->ctrl;
1651
1652 if ($_GET["item_ref_id"] != "") {
1653 $_POST["id"] = array($_GET["item_ref_id"]);
1654 }
1655
1656 if (is_array($_POST["id"])) {
1657 foreach ($_POST["id"] as $idx => $id) {
1658 $_POST["id"][$idx] = (int) $id;
1659 }
1660 }
1661
1662 // SAVE POST VALUES (get rid of this
1663 ilSession::set("saved_post", $_POST["id"]);
1664
1665 include_once("./Services/Repository/classes/class.ilRepUtilGUI.php");
1666 $ru = new ilRepUtilGUI($this);
1667 if (!$ru->showDeleteConfirmation($_POST["id"], $a_error)) {
1668 $ilCtrl->returnToParent($this);
1669 }
1670 }
1671
1677 protected function showPossibleSubObjects()
1678 {
1679 if ($this->sub_objects == "") {
1680 $d = $this->objDefinition->getCreatableSubObjects($this->object->getType(), ilObjectDefinition::MODE_REPOSITORY, $this->ref_id);
1681 } else {
1683 }
1684
1685 $import = false;
1686
1687 if (count($d) > 0) {
1688 foreach ($d as $row) {
1689 $count = 0;
1690
1691 if ($row["max"] > 0) {
1692 //how many elements are present?
1693 for ($i = 0; $i < count($this->data["ctrl"]); $i++) {
1694 if ($this->data["ctrl"][$i]["type"] == $row["name"]) {
1695 $count++;
1696 }
1697 }
1698 }
1699
1700 if ($row["max"] == "" || $count < $row["max"]) {
1701 $subobj[] = $row["name"];
1702 }
1703 }
1704 }
1705
1706 if (is_array($subobj)) {
1707
1708 //build form
1709 $opts = ilUtil::formSelect(12, "new_type", $subobj);
1710 $this->tpl->setCurrentBlock("add_object");
1711 $this->tpl->setVariable("SELECT_OBJTYPE", $opts);
1712 $this->tpl->setVariable("BTN_NAME", "create");
1713 $this->tpl->setVariable("TXT_ADD", $this->lng->txt("add"));
1714 $this->tpl->parseCurrentBlock();
1715 }
1716 }
1717
1726 final protected function getTemplateFile($a_cmd, $a_type = "")
1727 {
1728 mk();
1729 die("ilObjectGUI::getTemplateFile() is deprecated.");
1730 }
1731
1739 protected function getTabs()
1740 {
1741 // please define your tabs here
1742 }
1743
1744 // PROTECTED
1745 protected function __showButton($a_cmd, $a_text, $a_target = '')
1746 {
1747 $ilToolbar = $this->toolbar;
1748
1749 $ilToolbar->addButton($a_text, $this->ctrl->getLinkTarget($this, $a_cmd), $a_target);
1750 }
1751
1752 protected function hitsperpageObject()
1753 {
1754 ilSession::set("tbl_limit", $_POST["hitsperpage"]);
1755 $_GET["limit"] = $_POST["hitsperpage"];
1756 }
1757
1758
1759 protected function &__initTableGUI()
1760 {
1761 include_once "./Services/Table/classes/class.ilTableGUI.php";
1762
1763 return new ilTableGUI(0, false);
1764 }
1765
1771 protected function __setTableGUIBasicData(&$tbl, &$result_set, $a_from = "")
1772 {
1773 switch ($a_from) {
1774 case "clipboardObject":
1775 $offset = $_GET["offset"];
1776 $order = $_GET["sort_by"];
1777 $direction = $_GET["sort_order"];
1778 $tbl->disable("footer");
1779 break;
1780
1781 default:
1782 $offset = $_GET["offset"];
1783 $order = $_GET["sort_by"];
1784 $direction = $_GET["sort_order"];
1785 break;
1786 }
1787
1788 $tbl->setOrderColumn($order);
1789 $tbl->setOrderDirection($direction);
1790 $tbl->setOffset($offset);
1791 $tbl->setLimit($_GET["limit"]);
1792 $tbl->setFooter("tblfooter", $this->lng->txt("previous"), $this->lng->txt("next"));
1793 $tbl->setData($result_set);
1794 }
1795
1805 protected function redirectToRefId($a_ref_id, $a_cmd = "")
1806 {
1807 $obj_type = ilObject::_lookupType($a_ref_id, true);
1808 $class_name = $this->objDefinition->getClassName($obj_type);
1809 $class = strtolower("ilObj" . $class_name . "GUI");
1810 $this->ctrl->setParameterByClass("ilrepositorygui", "ref_id", $a_ref_id);
1811 $this->ctrl->redirectByClass(array("ilrepositorygui", $class), $a_cmd);
1812 }
1813
1814 // Object Cloning
1824 protected function fillCloneTemplate($a_tpl_varname, $a_type)
1825 {
1826 include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
1827 $cp = new ilObjectCopyGUI($this);
1828 $cp->setType($a_type);
1829 $cp->setTarget($_GET['ref_id']);
1830 if ($a_tpl_varname) {
1831 $cp->showSourceSearch($a_tpl_varname);
1832 } else {
1833 return $cp->showSourceSearch(null);
1834 }
1835 }
1836
1843 public function cloneAllObject()
1844 {
1845 include_once('./Services/Link/classes/class.ilLink.php');
1846 include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
1847
1850
1851 $new_type = $_REQUEST['new_type'];
1852 if (!$this->checkPermissionBool("create", "", $new_type)) {
1853 $ilErr->raiseError($this->lng->txt('permission_denied'));
1854 }
1855 if (!(int) $_REQUEST['clone_source']) {
1856 ilUtil::sendFailure($this->lng->txt('select_one'));
1857 $this->createObject();
1858 return false;
1859 }
1860 if (!$this->checkPermissionBool("write", "", $new_type, (int) $_REQUEST['clone_source'])) {
1861 $ilErr->raiseError($this->lng->txt('permission_denied'));
1862 }
1863
1864 // Save wizard options
1866 $wizard_options = ilCopyWizardOptions::_getInstance($copy_id);
1867 $wizard_options->saveOwner($ilUser->getId());
1868 $wizard_options->saveRoot((int) $_REQUEST['clone_source']);
1869
1870 $options = $_POST['cp_options'] ? $_POST['cp_options'] : array();
1871 foreach ($options as $source_id => $option) {
1872 $wizard_options->addEntry($source_id, $option);
1873 }
1874 $wizard_options->read();
1875
1876 $orig = ilObjectFactory::getInstanceByRefId((int) $_REQUEST['clone_source']);
1877 $new_obj = $orig->cloneObject((int) $_GET['ref_id'], $copy_id);
1878
1879 // Delete wizard options
1880 $wizard_options->deleteAll();
1881
1882 ilUtil::sendSuccess($this->lng->txt("object_duplicated"), true);
1883 ilUtil::redirect(ilLink::_getLink($new_obj->getRefId()));
1884 }
1885
1886
1890 protected function getCenterColumnHTML()
1891 {
1892 $ilCtrl = $this->ctrl;
1893
1894 include_once("Services/Block/classes/class.ilColumnGUI.php");
1895
1896 $obj_id = ilObject::_lookupObjId($this->object->getRefId());
1897 $obj_type = ilObject::_lookupType($obj_id);
1898
1899 if ($ilCtrl->getNextClass() != "ilcolumngui") {
1900 // normal command processing
1901 return $this->getContent();
1902 } else {
1903 if (!$ilCtrl->isAsynch()) {
1904 //if ($column_gui->getScreenMode() != IL_SCREEN_SIDE)
1906 // right column wants center
1908 $column_gui = new ilColumnGUI($obj_type, IL_COL_RIGHT);
1909 $this->setColumnSettings($column_gui);
1910 $this->html = $ilCtrl->forwardCommand($column_gui);
1911 }
1912 // left column wants center
1914 $column_gui = new ilColumnGUI($obj_type, IL_COL_LEFT);
1915 $this->setColumnSettings($column_gui);
1916 $this->html = $ilCtrl->forwardCommand($column_gui);
1917 }
1918 } else {
1919 // normal command processing
1920 return $this->getContent();
1921 }
1922 }
1923 }
1924 }
1925
1929 protected function getRightColumnHTML()
1930 {
1932 $lng = $this->lng;
1933 $ilCtrl = $this->ctrl;
1934
1935 $obj_id = ilObject::_lookupObjId($this->object->getRefId());
1936 $obj_type = ilObject::_lookupType($obj_id);
1937
1938 include_once("Services/Block/classes/class.ilColumnGUI.php");
1939 $column_gui = new ilColumnGUI($obj_type, IL_COL_RIGHT);
1940
1941 if ($column_gui->getScreenMode() == IL_SCREEN_FULL) {
1942 return "";
1943 }
1944
1945 $this->setColumnSettings($column_gui);
1946
1947 if ($ilCtrl->getNextClass() == "ilcolumngui" &&
1948 $column_gui->getCmdSide() == IL_COL_RIGHT &&
1949 $column_gui->getScreenMode() == IL_SCREEN_SIDE) {
1950 $html = $ilCtrl->forwardCommand($column_gui);
1951 } else {
1952 if (!$ilCtrl->isAsynch()) {
1953 $html = $ilCtrl->getHTML($column_gui);
1954 }
1955 }
1956
1957 return $html;
1958 }
1959
1963 protected function setColumnSettings(ilColumnGUI $column_gui)
1964 {
1965 $column_gui->setRepositoryMode(true);
1966 $column_gui->setEnableEdit(false);
1967 if ($this->checkPermissionBool("write")) {
1968 $column_gui->setEnableEdit(true);
1969 }
1970 }
1971
1982 protected function checkPermission($a_perm, $a_cmd = "", $a_type = "", $a_ref_id = null)
1983 {
1984 if (!$this->checkPermissionBool($a_perm, $a_cmd, $a_type, $a_ref_id)) {
1985 if (!is_int(strpos($_SERVER["PHP_SELF"], "goto.php"))) {
1986 // create: redirect to parent
1987 if ($a_perm == "create") {
1988 if (!$a_ref_id) {
1989 $a_ref_id = $_GET["ref_id"];
1990 }
1991 $type = ilObject::_lookupType($a_ref_id, true);
1992 } else {
1993 // does this make sense?
1994 if (!is_object($this->object)) {
1995 return;
1996 }
1997 if (!$a_ref_id) {
1998 $a_ref_id = $this->object->getRefId();
1999 }
2000 $type = $this->object->getType();
2001 }
2002
2003 ilSession::clear("il_rep_ref_id");
2004
2005 include_once "Services/Object/exceptions/class.ilObjectException.php";
2006 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('msg_no_perm_read'), true);
2007 $parent_ref_id = $this->tree->getParentNodeData($this->object->getRefId())['ref_id'];
2008 $this->ctrl->redirectToURL(ilLink::_getLink($parent_ref_id));
2009 }
2010 // we should never be here
2011 else {
2012 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('msg_no_perm_read'), true);
2014 }
2015 }
2016 }
2017
2027 protected function checkPermissionBool($a_perm, $a_cmd = "", $a_type = "", $a_ref_id = null)
2028 {
2029 $ilAccess = $this->access;
2030
2031 if ($a_perm == "create") {
2032 if (!$a_ref_id) {
2033 $a_ref_id = $_GET["ref_id"];
2034 }
2035 return $ilAccess->checkAccess($a_perm . "_" . $a_type, $a_cmd, $a_ref_id);
2036 } else {
2037 // does this make sense?
2038 if (!is_object($this->object)) {
2039 return false;
2040 }
2041 if (!$a_ref_id) {
2042 $a_ref_id = $this->object->getRefId();
2043 }
2044 return $ilAccess->checkAccess($a_perm, $a_cmd, $a_ref_id);
2045 }
2046 }
2047
2054 public static function _gotoRepositoryRoot($a_raise_error = false)
2055 {
2056 global $DIC;
2057
2058 $ilAccess = $DIC->access();
2059 $ilErr = $DIC["ilErr"];
2060 $lng = $DIC->language();
2061
2062 if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
2063 $_GET["cmd"] = "frameset";
2064 $_GET["target"] = "";
2065 $_GET["ref_id"] = ROOT_FOLDER_ID;
2066 $_GET["baseClass"] = "ilRepositoryGUI";
2067 include("ilias.php");
2068 exit;
2069 }
2070
2071 if ($a_raise_error) {
2072 $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
2073 }
2074 }
2075
2082 public static function _gotoRepositoryNode($a_ref_id, $a_cmd = "frameset")
2083 {
2084 global $DIC;
2085
2086 $ilAccess = $DIC->access();
2087 $ilErr = $DIC["ilErr"];
2088
2089 $_GET["cmd"] = $a_cmd;
2090 $_GET["target"] = "";
2091 $_GET["ref_id"] = $a_ref_id;
2092 $_GET["baseClass"] = "ilRepositoryGUI";
2093 include("ilias.php");
2094 exit;
2095 }
2096
2100 protected function enableDragDropFileUpload()
2101 {
2102 include_once("./Services/FileUpload/classes/class.ilFileUploadGUI.php");
2104
2105 $this->tpl->enableDragDropFileUpload($this->ref_id);
2106 }
2107
2113 protected function handleAutoRating(ilObject $a_new_obj)
2114 {
2115 if (ilObject::hasAutoRating($a_new_obj->getType(), $a_new_obj->getRefId()) &&
2116 method_exists($a_new_obj, "setRating")) {
2117 $a_new_obj->setRating(true);
2118 $a_new_obj->update();
2119 }
2120 }
2121
2126 protected function showCustomIconsEditing($a_input_colspan = 1, ilPropertyFormGUI $a_form = null, $a_as_section = true)
2127 {
2128 if ($this->settings->get("custom_icons")) {
2129 if ($a_form) {
2130 global $DIC;
2132 $customIconFactory = $DIC['object.customicons.factory'];
2133
2134 $customIcon = $customIconFactory->getByObjId($this->object->getId(), $this->object->getType());
2135
2136 if ($a_as_section) {
2137 $title = new ilFormSectionHeaderGUI();
2138 $title->setTitle($this->lng->txt("icon_settings"));
2139 } else {
2140 $title = new ilCustomInputGUI($this->lng->txt("icon_settings"), "");
2141 }
2142 $a_form->addItem($title);
2143
2144 $caption = $this->lng->txt("cont_custom_icon");
2145 $icon = new ilImageFileInputGUI($caption, "cont_icon");
2146
2147 $icon->setSuffixes($customIcon->getSupportedFileExtensions());
2148 $icon->setUseCache(false);
2149 if ($customIcon->exists()) {
2150 $icon->setImage($customIcon->getFullPath());
2151 } else {
2152 $icon->setImage('');
2153 }
2154 if ($a_as_section) {
2155 $a_form->addItem($icon);
2156 } else {
2157 $title->addSubItem($icon);
2158 }
2159 }
2160 }
2161 }
2162
2168 public function redirectAfterCreation()
2169 {
2171 $link = ilLink::_getLink($this->object->getRefId());
2172 $ctrl->redirectToURL($link);
2173 }
2174
2178 public function addToDeskObject()
2179 {
2180 $lng = $this->lng;
2183 $this->favourites->add($user->getId(), (int) $_GET["item_ref_id"]);
2184 $lng->loadLanguageModule("rep");
2185 ilUtil::sendSuccess($lng->txt("rep_added_to_favourites"), true);
2186 $ctrl->redirectToURL(ilLink::_getLink((int) $_GET["ref_id"]));
2187 }
2188
2192 public function removeFromDeskObject()
2193 {
2194 $lng = $this->lng;
2197 $lng->loadLanguageModule("rep");
2198 $this->favourites->remove($user->getId(), (int) $_GET["item_ref_id"]);
2199 ilUtil::sendSuccess($lng->txt("rep_removed_from_favourites"), true);
2200 $ctrl->redirectToURL(ilLink::_getLink((int) $_GET["ref_id"]));
2201 }
2202}
user()
Definition: user.php:4
const PEAR_ERROR_CALLBACK
Definition: PEAR.php:35
$location
Definition: buildRTE.php:44
$_GET["client_id"]
$_POST["username"]
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
const IL_SCREEN_SIDE
const IL_COL_RIGHT
const IL_SCREEN_FULL
const IL_COL_LEFT
Accordion user interface class.
TableGUI class for sub items listed in repository administration.
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 _recordWriteEvent($obj_id, $usr_id, $action, $parent_obj_id=null)
Records a write event.
Column user interface class.
static getScreenMode()
Get Screen Mode for current command.
setRepositoryMode($a_repositorymode)
Set RepositoryMode.
setEnableEdit($a_enableedit)
Set EnableEdit.
static getCmdSide()
Get Column Side of Current Command.
Class ilCommonActionDispatcherGUI.
static _lookupContainerSetting($a_id, $a_keyword, $a_default_value=null)
Lookup a container setting.
static _allocateCopyId()
Allocate a copy for further entries.
static _getInstance($a_copy_id)
Get instance of copy wizard options.
This class represents a custom property in a property form.
static lookupTemplateId($a_ref_id)
Lookup template id @global ilDB $ilDB.
static getInstanceByObjectType($a_obj_type)
Get instance by obj type.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Manages favourites, currently the interface for other components, needs discussion.
This class represents a file property in a property form.
static initFileUpload()
Initializes the file upload and loads the needed javascripts and styles.
static isUploadAllowed($a_ref_id, $a_type="")
Determines whether files can be uploaded to the object with the specified reference id.
This class represents a section header in a property form.
This class represents an image file property in a property form.
Import class.
static commentsActivated($a_rep_obj_id, $a_obj_id, $a_obj_type, $a_news_id=0)
Are comments activated for object?
GUI class for the workflow of copying objects.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
Class ilObjectGUI Basic methods of all Output classes.
addDidacticTemplateOptions(array &$a_options)
Add custom templates.
__showButton($a_cmd, $a_text, $a_target='')
confirmedDeleteObject()
confirmed deletion of object -> objects are moved to trash or deleted immediately,...
validateCustom(ilPropertyFormGUI $a_form)
Validate custom values (if not possible with checkInput())
const UPLOAD_TYPE_UPLOAD_DIRECTORY
cancelCreation()
cancel create action and go back to repository parent
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.
initImportForm($a_new_type)
Init object import form.
afterImport(ilObject $a_new_object)
Post (successful) object import hook.
withReferences()
determines wether objects are referenced or not (got ref ids or not)
redirectAfterCreation()
Redirect after creation, see https://docu.ilias.de/goto_docu_wiki_wpage_5035_1357....
addToDeskObject()
@inheritDoc
importFileObject($parent_id=null, $a_catch_errors=true)
Import.
handleAutoRating(ilObject $a_new_obj)
Activate rating automatically if parent container setting.
getTabs()
get tabs abstract method.
putObjectInTree(ilObject $a_obj, $a_parent_node_id=null)
Add object to tree at given position.
prepareOutput($a_show_subobjects=true)
prepare output
initCreateForm($a_new_type)
Init object creation form.
getFormAction($a_cmd, $a_formaction="")
get form action for command (command is method name without "Object", e.g.
afterUpdate()
Post (successful) object update hook.
isVisible($a_ref_id, $a_type)
setColumnSettings(ilColumnGUI $column_gui)
May be overwritten in subclasses.
getRightColumnHTML()
Display right column.
static _gotoRepositoryNode($a_ref_id, $a_cmd="frameset")
Goto repository root.
omitLocator($a_omit=true)
addLocatorItems()
should be overwritten to add object specific items (repository items are preloaded)
removeFromDeskObject()
@inheritDoc
setSubObjects($a_sub_objects="")
set possible subobjects for this object.
enableDragDropFileUpload()
Enables the file upload into this object by dropping files.
const COPY_WIZARD_NEEDS_PAGE
updateCustom(ilPropertyFormGUI $a_form)
Insert custom update form values into object.
getAdminTabs()
administration tabs show only permissions and trash folder
getTemplateFile($a_cmd, $a_type="")
get a template blockfile format: tpl.
setAdminTabs()
set admin tabs @access public
viewObject()
viewObject container presentation for "administration -> repository, trash, permissions"
cancelObject()
cancel action and go back to previous page @access public
getReturnLocation($a_cmd, $a_location="")
get return location for command (command is method name without "Object", e.g.
getCenterColumnHTML()
Get center column.
editObject()
edit object
static _gotoRepositoryRoot($a_raise_error=false)
Goto repository root.
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...
getCreationMode()
get creation mode
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission.
insertHeaderAction($a_list_gui)
Insert header action into main template.
getEditFormValues()
Get values for edit form.
afterSave(ilObject $a_new_object)
Post (successful) object creation hook.
saveObject()
save object
setTargetFrame($a_cmd, $a_target_frame)
set specific target frame for command
initDidacticTemplate(ilPropertyFormGUI $form)
Show didactic template types.
addHeaderAction()
Add header action menu.
__setTableGUIBasicData(&$tbl, &$result_set, $a_from="")
standard implementation for tables use 'from' variable use different initial setting of table
createObject()
create new object form
getCreationFormsHTML(array $a_forms)
Get HTML for creation forms (accordion)
const ALLOWED_TAGS_IN_TITLE_AND_DESCRIPTION
setFormAction($a_cmd, $a_formaction)
set specific form action for command
getEditFormCustomValues(array &$a_values)
Add values to custom edit fields.
setTabs()
set admin tabs @access public
initEditForm()
Init object edit form.
setLocator()
set Locator
addAdminLocatorItems($a_do_not_add_object=false)
should be overwritten to add object specific items (repository items are preloaded)
addExternalEditFormCustom(ilPropertyFormGUI $a_form)
setTitleAndDescription()
called by prepare output
executeCommand()
execute command
getObjectService()
Get object service.
cancelDeleteObject()
cancel deletion of object
getTargetFrame($a_cmd, $a_target_frame="")
get target frame for command (command is method name without "Object", e.g.
initEditCustomForm(ilPropertyFormGUI $a_form)
Add custom fields to update form.
setReturnLocation($a_cmd, $a_location)
set specific return location for command
showPossibleSubObjects()
show possible subobjects (pulldown menu)
updateObject()
updates object entry in object_data
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...
setActions($a_actions="")
set possible actions for objects in list.
redrawHeaderActionObject()
Ajax call: redraw action header only.
setCreationMode($a_mode=true)
if true, a creation screen is displayed the current $_GET[ref_id] don't belong to the current class!...
initCreationForms($a_new_type)
Init creation froms.
deleteObject($a_error=false)
Display deletion confirmation screen.
cloneAllObject()
Clone single (not container object) Method is overwritten in ilContainerGUI.
initHeaderAction($a_sub_type=null, $a_sub_id=null)
Add header action menu.
static _getListGUIByType( $type, $context=ilObjectListGUI::CONTEXT_REPOSITORY)
Class ilObject Basic functions for all objects.
getType()
get object type @access public
static hasAutoRating($a_type, $a_ref_id)
Check if auto rating is active for parent group/course.
static _lookupObjId($a_id)
createReference()
creates reference for object
const TITLE_LENGTH
max length of object title
update()
update object in db
static _lookupTitle($a_id)
lookup object title
static _getIcon( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
setPermissions($a_parent_ref)
set permissions of object
getRefId()
get reference id @access public
static _getAllReferences($a_id)
get all reference ids of object
getId()
get object id @access public
putInTree($a_parent_ref)
maybe this method should be in tree object!?
static _lookupType($a_id, $a_reference=false)
lookup object type
This class represents a property form user interface.
addItem($a_item)
Add Item (Property, SectionHeader).
This class represents a property in a property form.
This class represents an option in a radio group.
static add($a_action, $a_ref_id, array $a_diff, $a_source_ref_id=false)
static gatherFaPa($a_ref_id, array $a_role_ids, $a_add_action=false)
const CREATE_OBJECT
Repository GUI Utilities.
This class represents a selection list property in a property form.
static set($a_var, $a_val)
Set a value.
static clear($a_var)
Unset a value.
static get($a_var)
Get a value.
Class ilTableGUI.
special template class to simplify handling of ITX/PEAR
This class represents a text area property in a property form.
This class represents a text property in a property form.
static redirect($a_script)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
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.
static infoPanel($a_keep=true)
const SYSTEM_FOLDER_ID
Definition: constants.php:33
const ROOT_FOLDER_ID
Definition: constants.php:30
for( $i=6;$i< 13;$i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296
global $DIC
Definition: goto.php:24
$ilUser
Definition: imgupload.php:18
callCreationCallback(\ilObject $object, \ilObjectDefinition $obj_definition, int $requested_crtcb)
Interface for gui classes (e.g ilLuceneSearchGUI) that offer add/remove to/from desktop.
exit
Definition: login.php:29
if($format !==null) $name
Definition: metadata.php:230
$i
Definition: metadata.php:24
$keys
Definition: metadata.php:187
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
redirection script todo: (a better solution should control the processing via a xml file)
$type
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
settings()
Definition: settings.php:2