ILIAS  release_8 Revision v8.24
class.ilObjectGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use Psr\Http\Message\ServerRequestInterface;
26use ILIAS\Object\CreationCallbackTrait;
27
35{
36 use CreationCallbackTrait;
37
39 '<b>',
40 '<i>',
41 '<strong>',
42 '<em>',
43 '<sub>',
44 '<sup>',
45 '<pre>',
46 '<strike>',
47 '<bdo>'
48 ];
49 public const ADMIN_MODE_NONE = "";
50 public const ADMIN_MODE_SETTINGS = "settings";
51 public const ADMIN_MODE_REPOSITORY = "repository";
52 public const UPLOAD_TYPE_LOCAL = 1;
54 public const CFORM_NEW = 1;
55 public const CFORM_IMPORT = 2;
56 public const CFORM_CLONE = 3;
57 protected \ILIAS\Notes\Service $notes_service;
58
59 protected ServerRequestInterface $request;
61 protected ilObjUser $user;
71 protected ilTree $tree;
72 protected ilCtrl $ctrl;
74 protected ilLanguage $lng;
76 protected ILIAS $ilias;
79 protected Factory $refinery;
83
84 protected ?ilObject $object = null;
85 protected bool $creation_mode = false;
86 protected $data;
87 protected int $id;
88 protected bool $call_by_reference = false;
89 protected bool $prepare_output;
90 protected int $ref_id;
91 protected int $obj_id;
92 protected int $maxcount; // contains number of child objects
93 protected array $form_action = []; // special formation (array "cmd" => "formaction")
94 protected array $return_location = []; // special return location (array "cmd" => "location")
95 protected array $target_frame = []; // special target frame (array "cmd" => "location")
96 protected string $tmp_import_dir; // directory used during import
97 protected string $sub_objects = "";
98 protected bool $omit_locator = false;
99 protected string $type = "";
101 protected int $requested_ref_id = 0;
102 protected int $requested_crtptrefid = 0;
103 protected int $requested_crtcb = 0;
104 protected string $requested_new_type = "";
105 protected string $link_params;
106 protected string $html = "";
107
115 public function __construct($data, int $id = 0, bool $call_by_reference = true, bool $prepare_output = true)
116 {
117 global $DIC;
118
119 $this->request = $DIC->http()->request();
120 $this->locator = $DIC["ilLocator"];
121 $this->user = $DIC->user();
122 $this->access = $DIC->access();
123 $this->settings = $DIC->settings();
124 $this->toolbar = $DIC->toolbar();
125 $this->rbac_admin = $DIC->rbac()->admin();
126 $this->rbac_system = $DIC->rbac()->system();
127 $this->rbac_review = $DIC->rbac()->review();
128 $this->object_service = $DIC->object();
129 $this->obj_definition = $DIC["objDefinition"];
130 $this->tpl = $DIC["tpl"];
131 $this->tree = $DIC->repositoryTree();
132 $this->ctrl = $DIC->ctrl();
133 $this->error = $DIC["ilErr"];
134 $this->lng = $DIC->language();
135 $this->tabs_gui = $DIC->tabs();
136 $this->ilias = $DIC["ilias"];
137 $this->post_wrapper = $DIC->http()->wrapper()->post();
138 $this->request_wrapper = $DIC->http()->wrapper()->query();
139 $this->refinery = $DIC->refinery();
140 $this->retriever = new ilObjectRequestRetriever($DIC->http()->wrapper(), $this->refinery);
141 $this->favourites = new ilFavouritesManager();
142 $this->custom_icon_factory = $DIC['object.customicons.factory'];
143
144 $this->data = $data;
145 $this->id = $id;
146 $this->call_by_reference = $call_by_reference;
147 $this->prepare_output = $prepare_output;
148
149 $params = array("ref_id");
150 if (!$call_by_reference) {
151 $params = array("ref_id","obj_id");
152 }
153 $this->ctrl->saveParameter($this, $params);
154
155 if ($this->request_wrapper->has("ref_id")) {
156 $this->requested_ref_id = $this->request_wrapper->retrieve("ref_id", $this->refinery->kindlyTo()->int());
157 }
158
159 $this->obj_id = $this->id;
160 $this->ref_id = $this->requested_ref_id;
161
162 if ($call_by_reference) {
163 $this->ref_id = $this->id;
164 $this->obj_id = 0;
165 if ($this->request_wrapper->has("obj_id")) {
166 $this->obj_id = $this->request_wrapper->retrieve("obj_id", $this->refinery->kindlyTo()->int());
167 }
168 }
169
170 // TODO: refactor this with post_wrapper or request_wrapper
171 // callback after creation
172 $this->requested_crtptrefid = $this->retriever->getMaybeInt('crtptrefid', 0);
173 $this->requested_crtcb = $this->retriever->getMaybeInt('crtcb', 0);
174 $this->requested_new_type = $this->retriever->getMaybeString('new_type', '');
175
176
177 if ($this->id != 0) {
178 $this->link_params = "ref_id=" . $this->ref_id;
179 }
180
181 $this->assignObject();
182
183 if (is_object($this->object)) {
184 if ($this->call_by_reference && $this->ref_id == $this->requested_ref_id) {
185 $this->ctrl->setContextObject(
186 $this->object->getId(),
187 $this->object->getType()
188 );
189 }
190 }
191
192 if ($prepare_output) {
193 $this->prepareOutput();
194 }
195
196 $this->notes_service = $DIC->notes();
197 }
198
199 public function getRefId(): int
200 {
201 return $this->ref_id;
202 }
203
204 public function setAdminMode(string $mode): void
205 {
206 if (!in_array($mode, [
207 self::ADMIN_MODE_NONE,
208 self::ADMIN_MODE_REPOSITORY,
209 self::ADMIN_MODE_SETTINGS
210 ])) {
211 throw new ilObjectException("Unknown Admin Mode $mode.");
212 }
213 $this->admin_mode = $mode;
214 }
215
216 public function getAdminMode(): string
217 {
218 return $this->admin_mode;
219 }
220
221 protected function getObjectService(): ilObjectService
222 {
224 }
225
226 public function getObject(): ?ilObject
227 {
228 return $this->object;
229 }
230
231 public function executeCommand(): void
232 {
233 $cmd = $this->ctrl->getCmd();
234
235 $this->prepareOutput();
236 if (!$cmd) {
237 $cmd = "view";
238 }
239 $cmd .= "Object";
240 $this->$cmd();
241 }
242
246 public function withReferences(): bool
247 {
249 }
250
257 public function setCreationMode(bool $mode = true): void
258 {
259 $this->creation_mode = $mode;
260 }
261
262 public function getCreationMode(): bool
263 {
265 }
266
267 protected function assignObject(): void
268 {
269 // TODO: it seems that we always have to pass only the ref_id
270 if ($this->id != 0) {
271 if ($this->call_by_reference) {
272 $this->object = ilObjectFactory::getInstanceByRefId($this->id);
273 } else {
274 $this->object = ilObjectFactory::getInstanceByObjId($this->id);
275 }
276 }
277 }
278
279 public function prepareOutput(bool $show_sub_objects = true): bool
280 {
281 $this->tpl->loadStandardTemplate();
282 // administration prepare output
283 $base_class = $this->request_wrapper->retrieve("baseClass", $this->refinery->kindlyTo()->string());
284 if (strtolower($base_class) == "iladministrationgui") {
285 $this->addAdminLocatorItems();
286 $this->tpl->setLocator();
287
288 $this->setTitleAndDescription();
289
290 if ($this->getCreationMode() != true) {
291 $this->setAdminTabs();
292 }
293
294 return false;
295 }
296 $this->setLocator();
297
298 // in creation mode (parent) object and gui object do not fit
299 if ($this->getCreationMode() === true) {
300 // repository vs. workspace
301 if ($this->call_by_reference) {
302 // get gui class of parent and call their title and description method
303 $obj_type = ilObject::_lookupType($this->requested_ref_id, true);
304 $class_name = $this->obj_definition->getClassName($obj_type);
305 $class = strtolower("ilObj" . $class_name . "GUI");
306 $class_path = $this->ctrl->lookupClassPath($class);
307 $class_name = $this->ctrl->getClassForClasspath($class_path);
308
309 // $parent_gui_obj = new $class_name($this->requested_ref_id, true, false); // TODO: this fails in many cases since the parameters of the constructor are not known
310 // the next line prevents the header action menu being shown
311 // $parent_gui_obj->setCreationMode(true);
312 // $parent_gui_obj->setTitleAndDescription();
313 }
314 } else {
315 $this->setTitleAndDescription();
316
317 // set tabs
318 $this->setTabs();
319
320 $file_upload_dropzone = new ilObjFileUploadDropzone($this->ref_id);
321 if ($file_upload_dropzone->isUploadAllowed($this->object->getType())) {
323 }
324 }
325
326 return true;
327 }
328
329 protected function setTitleAndDescription(): void
330 {
331 if (!is_object($this->object)) {
332 if ($this->requested_crtptrefid > 0) {
333 $cr_obj_id = ilObject::_lookupObjId($this->requested_crtcb);
334 $this->tpl->setTitle(
335 strip_tags(
336 ilObject::_lookupTitle($cr_obj_id),
337 self::ALLOWED_TAGS_IN_TITLE_AND_DESCRIPTION
338 )
339 );
340 $this->tpl->setTitleIcon(ilObject::_getIcon($cr_obj_id));
341 }
342 return;
343 }
344 $this->tpl->setTitle(
345 strip_tags(
346 $this->object->getPresentationTitle(),
347 self::ALLOWED_TAGS_IN_TITLE_AND_DESCRIPTION
348 )
349 );
350 $this->tpl->setDescription(
351 strip_tags(
352 $this->object->getLongDescription(),
353 self::ALLOWED_TAGS_IN_TITLE_AND_DESCRIPTION
354 )
355 );
356
357 $base_class = $this->request_wrapper->retrieve("baseClass", $this->refinery->kindlyTo()->string());
358 if (strtolower($base_class) == "iladministrationgui") {
359 // alt text would be same as heading -> empty alt text
360 $this->tpl->setTitleIcon(ilObject::_getIcon(0, "big", $this->object->getType()));
361 } else {
362 $this->tpl->setTitleIcon(
363 ilObject::_getIcon(0, "big", $this->object->getType()),
364 $this->lng->txt("obj_" . $this->object->getType())
365 );
366 }
367 if (!$this->obj_definition->isAdministrationObject($this->object->getType())) {
368 $lgui = ilObjectListGUIFactory::_getListGUIByType($this->object->getType());
369 $lgui->initItem($this->object->getRefId(), $this->object->getId(), $this->object->getType());
370 $this->tpl->setAlertProperties($lgui->getAlertProperties());
371 }
372 }
373
377 protected function initHeaderAction(?string $sub_type = null, ?int $sub_id = null): ?ilObjectListGUI
378 {
379 if (!$this->creation_mode && $this->object) {
380 $dispatcher = new ilCommonActionDispatcherGUI(
382 $this->access,
383 $this->object->getType(),
384 $this->ref_id,
385 $this->object->getId()
386 );
387
388 $dispatcher->setSubObject($sub_type, $sub_id);
389
391 $this->ctrl->getLinkTarget($this, "redrawHeaderAction", "", true),
392 "",
393 $this->ctrl->getLinkTargetByClass(["ilcommonactiondispatchergui", "iltagginggui"], "", "", true)
394 );
395
396 $lg = $dispatcher->initHeaderAction();
397
398 if (is_object($lg)) {
399 // to enable add to desktop / remove from desktop
400 if ($this instanceof ilDesktopItemHandling) {
401 $lg->setContainerObject($this);
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 if (
409 $this->access->checkAccess("write", "", $this->ref_id) ||
410 $this->access->checkAccess("edit_permissions", "", $this->ref_id) ||
411 $this->notes_service->domain()->commentsActive($this->object->getId())
412 ) {
413 $lg->enableComments(true);
414 }
415
416 $lg->enableNotes(true);
417 $lg->enableTags(true);
418 }
419
420 return $lg;
421 }
422 return null;
423 }
424
428 protected function insertHeaderAction(?ilObjectListGUI $list_gui = null): void
429 {
430 if (
431 !is_object($this->object) ||
432 ilContainer::_lookupContainerSetting($this->object->getId(), "hide_top_actions")
433 ) {
434 return;
435 }
436
437 if (is_object($list_gui)) {
438 $this->tpl->setHeaderActionMenu($list_gui->getHeaderAction());
439 }
440 }
441
445 protected function addHeaderAction(): void
446 {
447 $this->insertHeaderAction($this->initHeaderAction());
448 }
449
453 protected function redrawHeaderActionObject(): void
454 {
455 $lg = $this->initHeaderAction();
456 echo $lg->getHeaderAction();
457
458 // we need to add onload code manually (rating, comments, etc.)
459 echo $this->tpl->getOnLoadCodeForAsynch();
460 exit;
461 }
462
466 protected function setTabs(): void
467 {
468 $this->getTabs();
469 }
470
474 final protected function setAdminTabs(): void
475 {
476 $this->getAdminTabs();
477 }
478
482 public function getAdminTabs(): void
483 {
484 if ($this->checkPermissionBool("visible,read")) {
485 $this->tabs_gui->addTarget(
486 "view",
487 $this->ctrl->getLinkTarget($this, "view"),
488 array("", "view"),
489 get_class($this)
490 );
491 }
492
493 if ($this->checkPermissionBool("edit_permission")) {
494 $this->tabs_gui->addTarget(
495 "perm_settings",
496 $this->ctrl->getLinkTargetByClass(array(get_class($this), 'ilpermissiongui'), "perm"),
497 "",
498 "ilpermissiongui"
499 );
500 }
501 }
502
503 public function getHTML(): string
504 {
505 return $this->html;
506 }
507
508 protected function setLocator(): void
509 {
510 $ilLocator = $this->locator;
512
513 if ($this->omit_locator) {
514 return;
515 }
516
517 // repository vs. workspace
518 if ($this->call_by_reference) {
519 // todo: admin workaround
520 // in the future, object gui classes should not be called in
521 // admin section anymore (rbac/trash handling in own classes)
523 if ($this->requested_ref_id === 0) {
524 $ref_id = $this->object->getRefId();
525 }
526 $ilLocator->addRepositoryItems($ref_id);
527 }
528
529 if (!$this->creation_mode) {
530 $this->addLocatorItems();
531 }
532
533 $tpl->setLocator();
534 }
535
540 protected function addLocatorItems(): void
541 {
542 }
543
544 protected function omitLocator(bool $omit = true): void
545 {
546 $this->omit_locator = $omit;
547 }
548
553 protected function addAdminLocatorItems(bool $do_not_add_object = false): void
554 {
555 if ($this->admin_mode == self::ADMIN_MODE_SETTINGS) {
556 $this->ctrl->setParameterByClass(
557 "ilobjsystemfoldergui",
558 "ref_id",
560 );
561 $this->locator->addItem(
562 $this->lng->txt("administration"),
563 $this->ctrl->getLinkTargetByClass(["iladministrationgui", "ilobjsystemfoldergui"], "")
564 );
565 if ($this->object && ($this->object->getRefId() != SYSTEM_FOLDER_ID && !$do_not_add_object)) {
566 $this->locator->addItem(
567 $this->object->getTitle(),
568 $this->ctrl->getLinkTarget($this, "view")
569 );
570 }
571 } else {
572 $this->ctrl->setParameterByClass(
573 "iladministrationgui",
574 "ref_id",
575 ""
576 );
577 $this->ctrl->setParameterByClass(
578 "iladministrationgui",
579 "admin_mode",
580 "settings"
581 );
582 $this->ctrl->clearParametersByClass("iladministrationgui");
583 $this->locator->addAdministrationItems();
584 }
585 }
586
591 public function confirmedDeleteObject(): void
592 {
593 if ($this->post_wrapper->has("mref_id")) {
594 $mref_id = $this->post_wrapper->retrieve(
595 "mref_id",
596 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
597 );
598 $_SESSION["saved_post"] = array_unique(array_merge($_SESSION["saved_post"], $mref_id));
599 }
600
601 $ru = new ilRepositoryTrashGUI($this);
602 $ru->deleteObjects($this->requested_ref_id, ilSession::get("saved_post") ?? []);
603 ilSession::clear("saved_post");
604 $this->ctrl->returnToParent($this);
605 }
606
610 public function cancelDeleteObject(): void
611 {
612 ilSession::clear("saved_post");
613 $this->ctrl->returnToParent($this);
614 }
615
616
620 public function cancelObject(): void
621 {
622 ilSession::clear("saved_post");
623 $this->ctrl->returnToParent($this);
624 }
625
629 public function createObject(): void
630 {
631 $new_type = $this->requested_new_type;
632
633 // add new object to custom parent container
634 $this->ctrl->saveParameter($this, "crtptrefid");
635 // use forced callback after object creation
636 $this->ctrl->saveParameter($this, "crtcb");
637
638 if (!$this->checkPermissionBool("create", "", $new_type)) {
639 $this->error->raiseError($this->lng->txt("permission_denied"), $this->error->MESSAGE);
640 } else {
641 $this->lng->loadLanguageModule($new_type);
642 $this->ctrl->setParameter($this, "new_type", $new_type);
643
644 $forms = $this->initCreationForms($new_type);
645
646 // copy form validation error: do not show other creation forms
647 if ($this->request_wrapper->has("cpfl") && isset($forms[self::CFORM_CLONE])) {
648 $forms = array(self::CFORM_CLONE => $forms[self::CFORM_CLONE]);
649 }
650 $this->tpl->setContent($this->getCreationFormsHTML($forms));
651 }
652 }
653
659 protected function initCreationForms(string $new_type): array
660 {
661 $forms = [
662 self::CFORM_NEW => $this->initCreateForm($new_type),
663 self::CFORM_IMPORT => $this->initImportForm($new_type),
664 self::CFORM_CLONE => $this->fillCloneTemplate(null, $new_type)
665 ];
666
667 return $forms;
668 }
669
674 protected function getCreationFormsHTML(array $forms): string
675 {
676 // #13168- sanity check
677 foreach ($forms as $id => $form) {
678 if (!$form instanceof ilPropertyFormGUI) {
679 unset($forms[$id]);
680 }
681 }
682
683 // no accordion if there is just one form
684 if (sizeof($forms) == 1) {
685 $form_type = key($forms);
686 $forms = array_shift($forms);
687
688 // see bug #0016217
689 if (method_exists($this, "getCreationFormTitle")) {
690 $form_title = $this->getCreationFormTitle($form_type);
691 if ($form_title != "") {
692 $forms->setTitle($form_title);
693 }
694 }
695 return $forms->getHTML();
696 } else {
697 $acc = new ilAccordionGUI();
698 $acc->setBehaviour(ilAccordionGUI::FIRST_OPEN);
699 $cnt = 1;
700 foreach ($forms as $form_type => $cf) {
701 $htpl = new ilTemplate("tpl.creation_acc_head.html", true, true, "Services/Object");
702
703 // using custom form titles (used for repository plugins)
704 $form_title = "";
705 if (method_exists($this, "getCreationFormTitle")) {
706 $form_title = $this->getCreationFormTitle($form_type);
707 }
708 if (!$form_title) {
709 $form_title = $cf->getTitle();
710 }
711
712 // move title from form to accordion
713 $htpl->setVariable("TITLE", $this->lng->txt("option") . " " . $cnt . ": " . $form_title);
714 $cf->setTitle('');
715 $cf->setTitleIcon('');
716 $cf->setTableWidth("100%");
717
718 $acc->addItem($htpl->get(), $cf->getHTML());
719
720 $cnt++;
721 }
722
723 return "<div class='ilCreationFormSection'>" . $acc->getHTML() . "</div>";
724 }
725 }
726
727 protected function initCreateForm(string $new_type): ilPropertyFormGUI
728 {
729 $form = new ilPropertyFormGUI();
730 $form->setTarget("_top");
731 $form->setFormAction($this->ctrl->getFormAction($this, "save"));
732 $form->setTitle($this->lng->txt($new_type . "_new"));
733
734 $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
735 $ti->setSize(min(40, ilObject::TITLE_LENGTH));
736 $ti->setMaxLength(ilObject::TITLE_LENGTH);
737 $ti->setRequired(true);
738 $form->addItem($ti);
739
740 $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
741 $ta->setCols(40);
742 $ta->setRows(2);
743 $ta->setMaxNumOfChars(ilObject::LONG_DESC_LENGTH);
744 $form->addItem($ta);
745
746 $form = $this->initDidacticTemplate($form);
747
748 $form->addCommandButton("save", $this->lng->txt($new_type . "_add"));
749 $form->addCommandButton("cancel", $this->lng->txt("cancel"));
750
751 return $form;
752 }
753
755 {
756 $this->lng->loadLanguageModule('didactic');
757 $existing_exclusive = false;
758 $options = [];
759 $options['dtpl_0'] = [
760 $this->lng->txt('didactic_default_type'),
761 sprintf(
762 $this->lng->txt('didactic_default_type_info'),
763 $this->lng->txt('objs_' . $this->type)
764 )
765 ];
766
767 $templates = ilDidacticTemplateSettings::getInstanceByObjectType($this->type)->getTemplates();
768 if ($templates) {
769 foreach ($templates as $template) {
770 if ($template->isEffective((int) $this->requested_ref_id)) {
771 $options["dtpl_" . $template->getId()] = array(
772 $template->getPresentationTitle(),
773 $template->getPresentationDescription()
774 );
775
776 if ($template->isExclusive()) {
777 $existing_exclusive = true;
778 }
779 }
780 }
781 }
782
783 $this->addDidacticTemplateOptions($options);
784
785 if (sizeof($options) > 1) {
787 $this->lng->txt('type'),
788 'didactic_type'
789 );
790 // workaround for containers in edit mode
791 if (!$this->getCreationMode()) {
792 $value = 'dtpl_' . ilDidacticTemplateObjSettings::lookupTemplateId($this->object->getRefId());
793
794 $type->setValue($value);
795
796 if (!in_array($value, array_keys($options)) || ($existing_exclusive && $value == "dtpl_0")) {
797 //add or rename actual value to not available
798 $options[$value] = [$this->lng->txt('not_available')];
799 }
800 } else {
801 if ($existing_exclusive) {
802 //if an exclusive template exists use the second template as default value
803 $keys = array_keys($options);
804 $type->setValue($keys[1]);
805 } else {
806 $type->setValue('dtpl_0');
807 }
808 }
809 $form->addItem($type);
810
811 foreach ($options as $id => $data) {
812 $option = new ilRadioOption($data[0] ?? '', (string) $id, $data[1] ?? '');
813 if ($existing_exclusive && $id == 'dtpl_0') {
814 //set default disabled if an exclusive template exists
815 $option->setDisabled(true);
816 }
817
818 $type->addOption($option);
819 }
820 }
821
822 return $form;
823 }
824
828 protected function addDidacticTemplateOptions(array &$a_options): void
829 {
830 }
831
835 public function cancelCreation(): void
836 {
837 $this->ctrl->redirectByClass("ilrepositorygui", "");
838 }
839
840 public function saveObject(): void
841 {
842 // create permission is already checked in createObject. This check here is done to prevent hacking attempts
843 if (!$this->checkPermissionBool("create", "", $this->requested_new_type)) {
844 $this->error->raiseError($this->lng->txt("no_create_permission"), $this->error->MESSAGE);
845 }
846
847 $this->lng->loadLanguageModule($this->requested_new_type);
848 $this->ctrl->setParameter($this, "new_type", $this->requested_new_type);
849
850 $form = $this->initCreateForm($this->requested_new_type);
851 if ($form->checkInput()) {
852 $this->ctrl->setParameter($this, "new_type", "");
853
854 $class_name = "ilObj" . $this->obj_definition->getClassName($this->requested_new_type);
855 $newObj = new $class_name();
856 $newObj->setType($this->requested_new_type);
857 $newObj->setTitle($form->getInput("title"));
858 $newObj->setDescription($form->getInput("desc"));
859 $newObj->processAutoRating();
860 $newObj->create();
861
862 $this->putObjectInTree($newObj);
863
864 $dtpl = $this->getDidacticTemplateVar("dtpl");
865 if ($dtpl) {
866 $newObj->applyDidacticTemplate($dtpl);
867 }
868
869 $this->afterSave($newObj);
870 }
871
872 $form->setValuesByPost();
873 $this->tpl->setContent($form->getHTML());
874 }
875
879 public function getDidacticTemplateVar(string $type): int
880 {
881 if (!$this->post_wrapper->has("didactic_type")) {
882 return 0;
883 }
884
885 $tpl = $this->post_wrapper->retrieve("didactic_type", $this->refinery->kindlyTo()->string());
886 if (substr($tpl, 0, strlen($type) + 1) != $type . "_") {
887 return 0;
888 }
889
890 return (int) substr($tpl, strlen($type) + 1);
891 }
892
896 public function putObjectInTree(ilObject $obj, int $parent_node_id = null): void
897 {
898 if (!$parent_node_id) {
899 $parent_node_id = $this->requested_ref_id;
900 }
901
902 // add new object to custom parent container
903 if ($this->requested_crtptrefid > 0) {
904 $parent_node_id = $this->requested_crtptrefid;
905 }
906
907 $obj->createReference();
908 $obj->putInTree($parent_node_id);
909 $obj->setPermissions($parent_node_id);
910
911 $this->obj_id = $obj->getId();
912 $this->ref_id = $obj->getRefId();
913
914 // BEGIN ChangeEvent: Record save object.
915 ilChangeEvent::_recordWriteEvent($this->obj_id, $this->user->getId(), 'create');
916 // END ChangeEvent: Record save object.
917
918 // rbac log
919 $rbac_log_roles = $this->rbac_review->getParentRoleIds($this->ref_id, false);
920 $rbac_log = ilRbacLog::gatherFaPa($this->ref_id, array_keys($rbac_log_roles), true);
921 ilRbacLog::add(ilRbacLog::CREATE_OBJECT, $this->ref_id, $rbac_log);
922
923 // use forced callback after object creation
924 $this->callCreationCallback($obj, $this->obj_definition, $this->requested_crtcb);
925 }
926
930 protected function afterSave(ilObject $new_object): void
931 {
932 $this->tpl->setOnScreenMessage("success", $this->lng->txt("object_added"), true);
933 $this->ctrl->returnToParent($this);
934 }
935
936 public function editObject(): void
937 {
938 if (!$this->checkPermissionBool("write")) {
939 $this->error->raiseError($this->lng->txt("msg_no_perm_write"), $this->error->MESSAGE);
940 }
941
942 $this->tabs_gui->activateTab("settings");
943
944 $form = $this->initEditForm();
945 $values = $this->getEditFormValues();
946 if ($values) {
947 $form->setValuesByArray($values);
948 }
949
950 $this->addExternalEditFormCustom($form);
951
952 $this->tpl->setContent($form->getHTML());
953 }
954
955 public function addExternalEditFormCustom(ilPropertyFormGUI $form): void
956 {
957 // has to be done AFTER setValuesByArray() ...
958 }
959
960 protected function initEditForm(): ilPropertyFormGUI
961 {
963
964 $lng->loadLanguageModule($this->object->getType());
965
966 $form = new ilPropertyFormGUI();
967 $form->setFormAction($this->ctrl->getFormAction($this, "update"));
968 $form->setTitle($this->lng->txt($this->object->getType() . "_edit"));
969
970 $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
971 $ti->setSize(min(40, ilObject::TITLE_LENGTH));
972 $ti->setMaxLength(ilObject::TITLE_LENGTH);
973 $ti->setRequired(true);
974 $form->addItem($ti);
975
976 $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
977 $ta->setCols(40);
978 $ta->setRows(2);
979 $ta->setMaxNumOfChars(ilObject::LONG_DESC_LENGTH);
980 $form->addItem($ta);
981
982 $this->initEditCustomForm($form);
983
984 $form->addCommandButton("update", $this->lng->txt("save"));
985
986 return $form;
987 }
988
992 protected function initEditCustomForm(ilPropertyFormGUI $a_form): void
993 {
994 }
995
996 protected function getEditFormValues(): array
997 {
998 $values["title"] = $this->object->getTitle();
999 $values["desc"] = $this->object->getLongDescription();
1000 $this->getEditFormCustomValues($values);
1001 return $values;
1002 }
1003
1007 protected function getEditFormCustomValues(array &$a_values): void
1008 {
1009 }
1010
1014 public function updateObject(): void
1015 {
1016 if (!$this->checkPermissionBool("write")) {
1017 $this->error->raiseError($this->lng->txt("permission_denied"), $this->error->MESSAGE);
1018 }
1019
1020 $form = $this->initEditForm();
1021 if ($form->checkInput() && $this->validateCustom($form)) {
1022 $this->object->setTitle($form->getInput("title"));
1023 $this->object->setDescription($form->getInput("desc"));
1024 $this->updateCustom($form);
1025 $this->object->update();
1026
1027 $this->afterUpdate();
1028 return;
1029 }
1030
1031 // display form again to correct errors
1032 $this->tabs_gui->activateTab("settings");
1033 $form->setValuesByPost();
1034 $this->tpl->setContent($form->getHTML());
1035 }
1036
1040 protected function validateCustom(ilPropertyFormGUI $form): bool
1041 {
1042 return true;
1043 }
1044
1048 protected function updateCustom(ilPropertyFormGUI $form): void
1049 {
1050 }
1051
1055 protected function afterUpdate(): void
1056 {
1057 $this->tpl->setOnScreenMessage("success", $this->lng->txt("msg_obj_modified"), true);
1058 $this->ctrl->redirect($this, "edit");
1059 }
1060
1061 protected function initImportForm(string $new_type): ilPropertyFormGUI
1062 {
1063 $import_directory_factory = new ilImportDirectoryFactory();
1064 $export_directory = $import_directory_factory->getInstanceForComponent(ilImportDirectoryFactory::TYPE_EXPORT);
1065 $upload_files = $export_directory->getFilesFor($this->user->getId(), $new_type);
1066 $has_upload_files = false;
1067 if (count($upload_files)) {
1068 $has_upload_files = true;
1069 }
1070
1071 $form = new ilPropertyFormGUI();
1072 $form->setTarget("_top");
1073 $form->setFormAction($this->ctrl->getFormAction($this, "importFile"));
1074 $form->setTitle($this->lng->txt($new_type . "_import"));
1075
1076 $fi = new ilFileInputGUI($this->lng->txt("import_file"), "importfile");
1077 $fi->setSuffixes(array("zip"));
1078 $fi->setRequired(true);
1079 if ($has_upload_files) {
1080 $this->lng->loadLanguageModule('content');
1081 $option = new ilRadioGroupInputGUI(
1082 $this->lng->txt('cont_choose_file_source'),
1083 'upload_type'
1084 );
1085 $option->setValue((string) self::UPLOAD_TYPE_LOCAL);
1086 $form->addItem($option);
1087
1088 $direct = new ilRadioOption($this->lng->txt('cont_choose_local'), (string) self::UPLOAD_TYPE_LOCAL);
1089 $option->addOption($direct);
1090
1091 $direct->addSubItem($fi);
1092 $upload = new ilRadioOption(
1093 $this->lng->txt('cont_choose_upload_dir'),
1094 (string) self::UPLOAD_TYPE_UPLOAD_DIRECTORY
1095 );
1096 $option->addOption($upload);
1097 $files = new ilSelectInputGUI(
1098 $this->lng->txt('cont_choose_upload_dir'),
1099 'uploadFile'
1100 );
1101 $upload_files[''] = $this->lng->txt('cont_select_from_upload_dir');
1102 $files->setOptions($upload_files);
1103 $files->setRequired(true);
1104 $upload->addSubItem($files);
1105 }
1106
1107 if (!$has_upload_files) {
1108 $form->addItem($fi);
1109 }
1110
1111 $form->addCommandButton("importFile", $this->lng->txt("import"));
1112 $form->addCommandButton("cancel", $this->lng->txt("cancel"));
1113
1114 return $form;
1115 }
1116
1117 protected function importFileObject(int $parent_id = null): void
1118 {
1119 if (!$parent_id) {
1120 $parent_id = $this->requested_ref_id;
1121 }
1122 $new_type = $this->requested_new_type;
1123 $upload_type = self::UPLOAD_TYPE_LOCAL;
1124 if ($this->post_wrapper->has("upload_type")) {
1125 $upload_type = $this->post_wrapper->retrieve("upload_type", $this->refinery->kindlyTo()->int());
1126 }
1127
1128 // create permission is already checked in createObject. This check here is done to prevent hacking attempts
1129 if (!$this->checkPermissionBool("create", "", $new_type)) {
1130 $this->error->raiseError($this->lng->txt("no_create_permission"));
1131 }
1132
1133 $this->lng->loadLanguageModule($new_type);
1134 $this->ctrl->setParameter($this, "new_type", $new_type);
1135
1136 $form = $this->initImportForm($new_type);
1137 if ($form->checkInput()) {
1138 // :todo: make some check on manifest file
1139 if ($this->obj_definition->isContainer($new_type)) {
1140 $imp = new ilImportContainer((int) $parent_id);
1141 } else {
1142 $imp = new ilImport((int) $parent_id);
1143 }
1144
1145 try {
1146 if ($upload_type == self::UPLOAD_TYPE_LOCAL) {
1147 $new_id = $imp->importObject(
1148 null,
1149 $_FILES["importfile"]["tmp_name"],
1150 $_FILES["importfile"]["name"],
1151 $new_type
1152 );
1153 } else {
1154 $hash = $this->request->getParsedBody()['uploadFile'] ?? '';
1155 $upload_factory = new ilImportDirectoryFactory();
1156 $export_upload = $upload_factory->getInstanceForComponent(ilImportDirectoryFactory::TYPE_EXPORT);
1157 $file = $export_upload->getAbsolutePathForHash($this->user->getId(), $new_type, $hash);
1158
1159 $new_id = $imp->importObject(
1160 null,
1161 $file,
1162 basename($file),
1163 $new_type,
1164 '',
1165 true
1166 );
1167 }
1168 } catch (ilException $e) {
1169 $this->tmp_import_dir = $imp->getTemporaryImportDir();
1170 $this->lng->loadLanguageModule('obj');
1171
1172 $this->tpl->setOnScreenMessage(
1173 "failure",
1174 $this->lng->txt("obj_import_file_error") . " <br />" . $e->getMessage()
1175 );
1176 $form->setValuesByPost();
1177 $this->tpl->setContent($form->getHTML());
1178 return;
1179 }
1180
1181 if ($new_id > 0) {
1182 $this->ctrl->setParameter($this, "new_type", "");
1183
1184 $newObj = ilObjectFactory::getInstanceByObjId($new_id);
1185 // put new object id into tree - already done in import for containers
1186 if (!$this->obj_definition->isContainer($new_type)) {
1187 $this->putObjectInTree($newObj);
1188 } else {
1189 $ref_ids = ilObject::_getAllReferences($newObj->getId());
1190 if (count($ref_ids) === 1) {
1191 $newObj->setRefId((int) current($ref_ids));
1192 }
1193 $this->callCreationCallback($newObj, $this->obj_definition, $this->requested_crtcb); // see #24244
1194 }
1195
1196 $this->afterImport($newObj);
1197 } else {
1198 if ($this->obj_definition->isContainer($new_type)) {
1199 $this->tpl->setOnScreenMessage("failure", $this->lng->txt("container_import_zip_file_invalid"));
1200 } else {
1201 // not enough information here...
1202 return;
1203 }
1204 }
1205 }
1206
1207 $form->setValuesByPost();
1208 $this->tpl->setContent($form->getHTML());
1209 }
1210
1214 protected function afterImport(ilObject $new_object): void
1215 {
1216 $this->tpl->setOnScreenMessage("success", $this->lng->txt("object_added"), true);
1217 $this->ctrl->returnToParent($this);
1218 }
1219
1223 public function getFormAction(string $cmd, string $default_form_action = ""): string
1224 {
1225 if ($this->form_action[$cmd] != "") {
1226 return $this->form_action[$cmd];
1227 }
1228
1229 return $default_form_action;
1230 }
1231
1232 protected function setFormAction(string $cmd, string $form_action): void
1233 {
1234 $this->form_action[$cmd] = $form_action;
1235 }
1236
1240 protected function getReturnLocation(string $cmd, string $default_location = ""): string
1241 {
1242 if (($this->return_location[$cmd] ?? "") !== "") {
1243 return $this->return_location[$cmd];
1244 } else {
1245 return $default_location;
1246 }
1247 }
1248
1252 protected function setReturnLocation(string $cmd, string $location): void
1253 {
1254 $this->return_location[$cmd] = $location;
1255 }
1256
1260 protected function getTargetFrame(string $cmd, string $default_target_frame = ""): string
1261 {
1262 if (isset($this->target_frame[$cmd]) && $this->target_frame[$cmd] != "") {
1263 return $this->target_frame[$cmd];
1264 }
1265
1266 if (!empty($default_target_frame)) {
1267 return "target=\"" . $default_target_frame . "\"";
1268 }
1269
1270 return "";
1271 }
1272
1276 protected function setTargetFrame(string $cmd, string $target_frame): void
1277 {
1278 $this->target_frame[$cmd] = "target=\"" . $target_frame . "\"";
1279 }
1280
1281 public function isVisible(int $ref_id, string $type): bool
1282 {
1283 $visible = $this->checkPermissionBool("visible,read", "", "", $ref_id);
1284
1285 if ($visible && $type == 'crs') {
1287 if ($crs_id = $tree->checkForParentType($ref_id, 'crs')) {
1288 if (!$this->checkPermissionBool("write", "", "", $crs_id)) {
1289 // Show only activated courses
1290 $tmp_obj = ilObjectFactory::getInstanceByRefId($crs_id, false);
1291
1292 if (!$tmp_obj->isActivated()) {
1293 unset($tmp_obj);
1294 $visible = false;
1295 }
1296 }
1297 }
1298 }
1299
1300 return $visible;
1301 }
1302
1306 public function viewObject(): void
1307 {
1308 $this->checkPermission('visible') && $this->checkPermission('read');
1309
1310 $this->tabs_gui->activateTab('view');
1311
1313 $this->object->getType(),
1314 $this->object->getRefId(),
1315 $this->object->getId(),
1316 $this->user->getId()
1317 );
1318
1319 if (!$this->withReferences()) {
1320 $this->ctrl->setParameter($this, 'obj_id', $this->obj_id);
1321 }
1322
1323 $itab = new ilAdminSubItemsTableGUI(
1324 $this,
1325 "view",
1326 $this->requested_ref_id,
1327 $this->checkPermissionBool('write')
1328 );
1329
1330 $this->tpl->setContent($itab->getHTML());
1331 }
1332
1338 public function deleteObject(bool $error = false): void
1339 {
1340 $request_ids = [];
1341 if ($this->post_wrapper->has("id")) {
1342 $request_ids = $this->post_wrapper->retrieve(
1343 "id",
1344 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
1345 );
1346 }
1347
1348 if (
1349 $this->request_wrapper->has("item_ref_id") &&
1350 $this->request_wrapper->retrieve("item_ref_id", $this->refinery->kindlyTo()->string()) != ""
1351 ) {
1352 $request_ids = [$this->request_wrapper->retrieve("item_ref_id", $this->refinery->kindlyTo()->int())];
1353 }
1354
1355 $ids = [];
1356 if (count($request_ids) > 0) {
1357 foreach ($request_ids as $idx => $id) {
1358 $ids["id"][$idx] = $id;
1359 }
1360 }
1361
1362 // SAVE POST VALUES (get rid of this
1363 ilSession::set("saved_post", $ids["id"] ?? []);
1364
1365 $ru = new ilRepositoryTrashGUI($this);
1366 if (!$ru->showDeleteConfirmation($ids["id"] ?? [], $error)) {
1367 $this->ctrl->returnToParent($this);
1368 }
1369 }
1370
1374 protected function showPossibleSubObjects(): void
1375 {
1376 if ($this->sub_objects == "") {
1377 $sub_objects = $this->obj_definition->getCreatableSubObjects(
1378 $this->object->getType(),
1380 $this->ref_id
1381 );
1382 } else {
1384 }
1385
1386 $subobj = [];
1387 if (count($sub_objects) > 0) {
1388 foreach ($sub_objects as $row) {
1389 $count = 0;
1390 if ($row["max"] > 0) {
1391 //how many elements are present?
1392 for ($i = 0; $i < count($this->data["ctrl"]); $i++) {
1393 if ($this->data["ctrl"][$i]["type"] == $row["name"]) {
1394 $count++;
1395 }
1396 }
1397 }
1398
1399 if ($row["max"] == "" || $count < $row["max"]) {
1400 $subobj[] = $row["name"];
1401 }
1402 }
1403 }
1404
1405 if (count($subobj) > 0) {
1406 $opts = ilLegacyFormElementsUtil::formSelect(12, "new_type", $subobj);
1407 $this->tpl->setCurrentBlock("add_object");
1408 $this->tpl->setVariable("SELECT_OBJTYPE", $opts);
1409 $this->tpl->setVariable("BTN_NAME", "create");
1410 $this->tpl->setVariable("TXT_ADD", $this->lng->txt("add"));
1411 $this->tpl->parseCurrentBlock();
1412 }
1413 }
1414
1418 protected function getTabs(): void
1419 {
1420 }
1421
1429 protected function redirectToRefId(int $ref_id, string $cmd = ""): void
1430 {
1431 $obj_type = ilObject::_lookupType($ref_id, true);
1432 $class_name = $this->obj_definition->getClassName($obj_type);
1433 $class = strtolower("ilObj" . $class_name . "GUI");
1434 $this->ctrl->setParameterByClass("ilrepositorygui", "ref_id", $ref_id);
1435 $this->ctrl->redirectByClass(array("ilrepositorygui", $class), $cmd);
1436 }
1437
1446 protected function fillCloneTemplate(?string $tpl_name, string $type): ?ilPropertyFormGUI
1447 {
1448 $cp = new ilObjectCopyGUI($this);
1449 $cp->setType($type);
1450 $target = $this->request_wrapper->has("ref_id")
1451 ? $this->request_wrapper->retrieve("ref_id", $this->refinery->kindlyTo()->int())
1452 : 0;
1453 $cp->setTarget($target);
1454 if ($tpl_name) {
1455 $cp->showSourceSearch($tpl_name);
1456 }
1457
1458 return $cp->showSourceSearch(null);
1459 }
1460
1464 protected function getCenterColumnHTML(): string
1465 {
1466 $obj_id = ilObject::_lookupObjId($this->object->getRefId());
1467 $obj_type = ilObject::_lookupType($obj_id);
1468
1469 if ($this->ctrl->getNextClass() != "ilcolumngui") {
1470 // normal command processing
1471 return $this->getContent();
1472 } else {
1473 if (!$this->ctrl->isAsynch()) {
1474 //if ($column_gui->getScreenMode() != IL_SCREEN_SIDE)
1476 // right column wants center
1478 $column_gui = new ilColumnGUI($obj_type, IL_COL_RIGHT);
1479 $this->setColumnSettings($column_gui);
1480 $this->html = $this->ctrl->forwardCommand($column_gui);
1481 }
1482 // left column wants center
1484 $column_gui = new ilColumnGUI($obj_type, IL_COL_LEFT);
1485 $this->setColumnSettings($column_gui);
1486 $this->html = $this->ctrl->forwardCommand($column_gui);
1487 }
1488 } else {
1489 // normal command processing
1490 return $this->getContent();
1491 }
1492 }
1493 }
1494 return "";
1495 }
1496
1500 protected function getRightColumnHTML(): string
1501 {
1502 $obj_id = ilObject::_lookupObjId($this->object->getRefId());
1503 $obj_type = ilObject::_lookupType($obj_id);
1504
1505 $column_gui = new ilColumnGUI($obj_type, IL_COL_RIGHT);
1506
1507 if ($column_gui->getScreenMode() == IL_SCREEN_FULL) {
1508 return "";
1509 }
1510
1511 $this->setColumnSettings($column_gui);
1512
1513 $html = "";
1514 if (
1515 $this->ctrl->getNextClass() == "ilcolumngui" &&
1516 $column_gui->getCmdSide() == IL_COL_RIGHT &&
1517 $column_gui->getScreenMode() == IL_SCREEN_SIDE
1518 ) {
1519 return $this->ctrl->forwardCommand($column_gui);
1520 }
1521
1522 if (!$this->ctrl->isAsynch()) {
1523 return $this->ctrl->getHTML($column_gui);
1524 }
1525
1526 return $html;
1527 }
1528
1529 public function setColumnSettings(ilColumnGUI $column_gui): void
1530 {
1531 $column_gui->setRepositoryMode(true);
1532 $column_gui->setEnableEdit(false);
1533 if ($this->checkPermissionBool("write")) {
1534 $column_gui->setEnableEdit(true);
1535 }
1536 }
1537
1538 protected function checkPermission(string $perm, string $cmd = "", string $type = "", ?int $ref_id = null): void
1539 {
1540 if (!$this->checkPermissionBool($perm, $cmd, $type, $ref_id)) {
1541 if (!is_int(strpos($_SERVER["PHP_SELF"], "goto.php"))) {
1542 if ($perm != "create" && !is_object($this->object)) {
1543 return;
1544 }
1545
1546 ilSession::clear("il_rep_ref_id");
1547
1548 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('msg_no_perm_read'), true);
1549 $parent_ref_id = (int) $this->tree->getParentNodeData($this->object->getRefId())['ref_id'];
1550 $this->ctrl->redirectToURL(ilLink::_getLink($parent_ref_id));
1551 }
1552
1553 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('msg_no_perm_read'), true);
1555 }
1556 }
1557
1558 protected function checkPermissionBool(string $perm, string $cmd = "", string $type = "", ?int $ref_id = null): bool
1559 {
1560 if ($perm == "create") {
1561 if (!$ref_id) {
1563 }
1564 return $this->access->checkAccess($perm . "_" . $type, $cmd, $ref_id);
1565 }
1566
1567 if (!is_object($this->object)) {
1568 return false;
1569 }
1570
1571 if (!$ref_id) {
1572 $ref_id = $this->object->getRefId();
1573 }
1574
1575 return $this->access->checkAccess($perm, $cmd, $ref_id);
1576 }
1577
1584 public static function _gotoRepositoryRoot(bool $raise_error = false): void
1585 {
1586 global $DIC;
1587
1588 $ilAccess = $DIC->access();
1589 $ilErr = $DIC["ilErr"];
1590 $lng = $DIC->language();
1591 $ctrl = $DIC->ctrl();
1592
1593 if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
1594 $ctrl->setParameterByClass("ilRepositoryGUI", "ref_id", ROOT_FOLDER_ID);
1595 $ctrl->redirectByClass("ilRepositoryGUI");
1596 }
1597
1598 if ($raise_error) {
1599 $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
1600 }
1601 }
1602
1603 public static function _gotoRepositoryNode(int $ref_id, string $cmd = ""): void
1604 {
1605 global $DIC;
1606
1607 $ctrl = $DIC->ctrl();
1608 $ctrl->setParameterByClass("ilRepositoryGUI", "ref_id", $ref_id);
1609 $ctrl->redirectByClass("ilRepositoryGUI", $cmd);
1610 }
1611
1612 public static function _gotoSharedWorkspaceNode(int $wsp_id): void
1613 {
1614 global $DIC;
1615
1616 $ctrl = $DIC->ctrl();
1617 $ctrl->setParameterByClass(ilSharedResourceGUI::class, "wsp_id", $wsp_id);
1618 $ctrl->redirectByClass(ilSharedResourceGUI::class, "");
1619 }
1620
1624 protected function enableDragDropFileUpload(): void
1625 {
1626 $this->tpl->setFileUploadRefId($this->ref_id);
1627 }
1628
1632 protected function showCustomIconsEditing(
1633 $input_colspan = 1,
1634 ilPropertyFormGUI $form = null,
1635 $as_section = true
1636 ): void {
1637 if ($this->settings->get("custom_icons")) {
1638 if ($form) {
1639 $customIcon = $this->custom_icon_factory->getByObjId($this->object->getId(), $this->object->getType());
1640
1641 if ($as_section) {
1642 $title = new ilFormSectionHeaderGUI();
1643 $title->setTitle($this->lng->txt("icon_settings"));
1644 } else {
1645 $title = new ilCustomInputGUI($this->lng->txt("icon_settings"), "");
1646 }
1647 $form->addItem($title);
1648
1649 $caption = $this->lng->txt("cont_custom_icon");
1650 $icon = new ilImageFileInputGUI($caption, "cont_icon");
1651
1652 $icon->setSuffixes($customIcon->getSupportedFileExtensions());
1653 $icon->setUseCache(false);
1654 if ($customIcon->exists()) {
1655 $icon->setImage($customIcon->getFullPath());
1656 } else {
1657 $icon->setImage('');
1658 }
1659 if ($as_section) {
1660 $form->addItem($icon);
1661 } else {
1662 $title->addSubItem($icon);
1663 }
1664 }
1665 }
1666 }
1667
1672 public function redirectAfterCreation(): void
1673 {
1674 $link = ilLink::_getLink($this->object->getRefId());
1675 $this->ctrl->redirectToURL($link);
1676 }
1677
1678 public function addToDeskObject(): void
1679 {
1680 $this->favourites->add(
1681 $this->user->getId(),
1682 $this->request_wrapper->retrieve("item_ref_id", $this->refinery->kindlyTo()->int())
1683 );
1684 $this->lng->loadLanguageModule("rep");
1685 $this->tpl->setOnScreenMessage("success", $this->lng->txt("rep_added_to_favourites"), true);
1686 $this->ctrl->redirectToURL(ilLink::_getLink($this->requested_ref_id));
1687 }
1688
1689 public function removeFromDeskObject(): void
1690 {
1691 $this->lng->loadLanguageModule("rep");
1692 $item_ref_id = $this->request_wrapper->retrieve("item_ref_id", $this->refinery->kindlyTo()->int());
1693 $this->favourites->remove($this->user->getId(), $item_ref_id);
1694 $this->tpl->setOnScreenMessage("success", $this->lng->txt("rep_removed_from_favourites"), true);
1695 $this->ctrl->redirectToURL(ilLink::_getLink($this->requested_ref_id));
1696 }
1697}
$location
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: buildRTE.php:22
Builds data types.
Definition: Factory.php:21
const IL_SCREEN_SIDE
const IL_COL_RIGHT
const IL_SCREEN_FULL
const IL_COL_LEFT
error(string $a_errmsg)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
TableGUI class for sub items listed in repository administration.
static _recordReadEvent(string $a_type, int $a_ref_id, int $obj_id, int $usr_id, bool $isCatchupWriteEvents=true, $a_ext_rc=null, $a_ext_time=null)
static _recordWriteEvent(int $obj_id, int $usr_id, string $action, ?int $parent_obj_id=null)
Records a write event.
Column user interface class.
static getScreenMode()
setEnableEdit(bool $a_enableedit)
setRepositoryMode(bool $a_repositorymode)
static getCmdSide()
Get Column Side of Current Command.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupContainerSetting(int $a_id, string $a_keyword, string $a_default_value=null)
Class ilCtrl provides processing control methods.
redirectByClass( $a_class, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
@inheritDoc
setParameterByClass(string $a_class, string $a_parameter, $a_value)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstanceByObjectType(string $a_obj_type)
Error Handling & global info handling uses PEAR error class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a file property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
language handling
loadLanguageModule(string $a_module)
Load language module.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static formSelect( $selected, string $varname, array $options, bool $multiple=false, bool $direct_text=false, int $size=0, string $style_class="", array $attribs=[], bool $disabled=false)
Builds a select form field with options and shows the selected option first.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
User class.
GUI class for the workflow of copying objects.
parses the objects.xml it handles the xml-description of all ilias objects
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
Class ilObjectGUI Basic methods of all Output classes.
ArrayBasedRequestWrapper $post_wrapper
ilObjectCustomIconFactory $custom_icon_factory
addDidacticTemplateOptions(array &$a_options)
Add custom templates.
static _gotoSharedWorkspaceNode(int $wsp_id)
confirmedDeleteObject()
confirmed deletion of object -> objects are moved to trash or deleted immediately,...
const UPLOAD_TYPE_UPLOAD_DIRECTORY
cancelCreation()
cancel create action and go back to repository parent
ilAccessHandler $access
initImportForm(string $new_type)
importFileObject(int $parent_id=null)
ilGlobalTemplateInterface $tpl
setReturnLocation(string $cmd, string $location)
set specific return location for command
__construct($data, int $id=0, bool $call_by_reference=true, bool $prepare_output=true)
withReferences()
determines whether objects are referenced or not (got ref ids or not)
insertHeaderAction(?ilObjectListGUI $list_gui=null)
Insert header action into main template.
redirectAfterCreation()
Redirect after creation, see https://docu.ilias.de/goto_docu_wiki_wpage_5035_1357....
static _gotoRepositoryRoot(bool $raise_error=false)
Goto repository root.
addExternalEditFormCustom(ilPropertyFormGUI $form)
getTabs()
@abstract overwrite in derived GUI class of your object type
ilRbacReview $rbac_review
deleteObject(bool $error=false)
Display deletion confirmation screen.
afterUpdate()
Post (successful) object update hook.
setColumnSettings(ilColumnGUI $column_gui)
checkPermission(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
getRightColumnHTML()
Display right column.
initHeaderAction(?string $sub_type=null, ?int $sub_id=null)
Add header action menu.
addLocatorItems()
should be overwritten to add object specific items (repository items are preloaded)
enableDragDropFileUpload()
Enables the file upload into this object by dropping files.
setFormAction(string $cmd, string $form_action)
setCreationMode(bool $mode=true)
if true, a creation screen is displayed the current [ref_id] don't belong to the current class!...
const ADMIN_MODE_SETTINGS
getAdminTabs()
administration tabs show only permissions and trash folder
setAdminTabs()
set admin tabs
viewObject()
viewObject container presentation for "administration -> repository, trash, permissions"
getFormAction(string $cmd, string $default_form_action="")
Get form action for command (command is method name without "Object", e.g.
ilObjectService $object_service
cancelObject()
cancel action and go back to previous page
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
ilRbacSystem $rbac_system
afterSave(ilObject $new_object)
Post (successful) object creation hook.
ilErrorHandling $error
getCenterColumnHTML()
Get center column.
setTargetFrame(string $cmd, string $target_frame)
Set specific target frame for command.
setAdminMode(string $mode)
updateCustom(ilPropertyFormGUI $form)
Insert custom update form values into object.
isVisible(int $ref_id, string $type)
RequestWrapper $request_wrapper
initDidacticTemplate(ilPropertyFormGUI $form)
showCustomIconsEditing( $input_colspan=1, ilPropertyFormGUI $form=null, $as_section=true)
show edit section of custom icons for container
ilSetting $settings
addHeaderAction()
Add header action menu.
ILIAS Notes Service $notes_service
createObject()
create new object form
getCreationFormsHTML(array $forms)
Get HTML for creation forms (accordion)
addAdminLocatorItems(bool $do_not_add_object=false)
should be overwritten to add object specific items (repository items are preloaded)
fillCloneTemplate(?string $tpl_name, string $type)
Fill object clone template This method can be called from any object GUI class that wants to offer ob...
omitLocator(bool $omit=true)
const ALLOWED_TAGS_IN_TITLE_AND_DESCRIPTION
ilObjectDefinition $obj_definition
string $tmp_import_dir
getEditFormCustomValues(array &$a_values)
Add values to custom edit fields.
setTabs()
set admin tabs
validateCustom(ilPropertyFormGUI $form)
Validate custom values (if not possible with checkInput())
afterImport(ilObject $new_object)
Post (successful) object import hook.
getDidacticTemplateVar(string $type)
Get didactic template setting from creation screen.
ilTabsGUI $tabs_gui
static _gotoRepositoryNode(int $ref_id, string $cmd="")
ilToolbarGUI $toolbar
ilObjectRequestRetriever $retriever
ilLocatorGUI $locator
redirectToRefId(int $ref_id, string $cmd="")
redirects to (repository) view per ref id usually to a container and usually used at the end of a sav...
prepareOutput(bool $show_sub_objects=true)
cancelDeleteObject()
cancel deletion of object
string $requested_new_type
ilFavouritesManager $favourites
initEditCustomForm(ilPropertyFormGUI $a_form)
Add custom fields to update form.
ServerRequestInterface $request
ilRbacAdmin $rbac_admin
getReturnLocation(string $cmd, string $default_location="")
Get return location for command (command is method name without "Object", e.g.
showPossibleSubObjects()
show possible sub objects (pull down menu)
ilLanguage $lng
initCreateForm(string $new_type)
updateObject()
updates object entry in object_data
const ADMIN_MODE_REPOSITORY
getTargetFrame(string $cmd, string $default_target_frame="")
get target frame for command (command is method name without "Object", e.g.
redrawHeaderActionObject()
Ajax call: redraw action header only.
putObjectInTree(ilObject $obj, int $parent_node_id=null)
Add object to tree at given position.
initCreationForms(string $new_type)
Init creation forms.
static _getListGUIByType(string $type, int $context=ilObjectListGUI::CONTEXT_REPOSITORY)
static prepareJsLinks(string $redraw_url, string $notes_url, string $tags_url, ilGlobalTemplateInterface $tpl=null)
Insert js/ajax links into template.
Base class for all sub item list gui's.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupType(int $id, bool $reference=false)
setPermissions(int $parent_ref_id)
createReference()
creates reference for object
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
const TITLE_LENGTH
putInTree(int $parent_ref_id)
maybe this method should be in tree object!?
static _getAllReferences(int $id)
get all reference ids for object ID
const LONG_DESC_LENGTH
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
This class represents a property form user interface.
This class represents a property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilRbacAdmin Core functions for role based access control.
static add(int $a_action, int $a_ref_id, array $a_diff, bool $a_source_ref_id=false)
static gatherFaPa(int $a_ref_id, array $a_role_ids, bool $a_add_action=false)
const CREATE_OBJECT
class ilRbacReview Contains Review functions of core Rbac.
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
Repository GUI Utilities.
This class represents a selection list property in a property form.
static get(string $a_var)
static clear(string $a_var)
static set(string $a_var, $a_val)
Set a value.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
checkForParentType(int $a_ref_id, string $a_type, bool $a_exclude_source_check=false)
Check for parent type e.g check if a folder (ref_id 3) is in a parent course obj => checkForParentTyp...
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: confirmReg.php:20
const SYSTEM_FOLDER_ID
Definition: constants.php:35
const ROOT_FOLDER_ID
Definition: constants.php:32
global $DIC
Definition: feed.php:28
Interface RequestWrapper.
callCreationCallback(\ilObject $object, \ilObjectDefinition $obj_definition, int $requested_crtcb)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setLocator()
Insert locator.
exit
Definition: login.php:28
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:33
$i
Definition: metadata.php:41
$keys
Definition: metadata.php:204
get(string $key, Refinery\Transformation $t)
Get passed parameter, if not data passed, get key from http request.
Class ChatMainBarProvider \MainMenu\Provider.
header include for all ilias files.
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
$ilErr
Definition: raiseError.php:17