ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
class.ilObjectGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use Psr\Http\Message\ServerRequestInterface;
25use ILIAS\Refinery\Factory as Refinery;
27use ILIAS\UI\Factory as UIFactory;
28use ILIAS\UI\Renderer as UIRenderer;
33use ILIAS\ILIASObject\Creation\CreationCallbackTrait;
41
49{
50 use CreationCallbackTrait;
51
52 public const ADMIN_MODE_NONE = "";
53 public const ADMIN_MODE_SETTINGS = "settings";
54 public const ADMIN_MODE_REPOSITORY = "repository";
55 public const UPLOAD_TYPE_LOCAL = 1;
57 public const CFORM_NEW = 1;
58 public const CFORM_IMPORT = 2;
59 public const CFORM_CLONE = 3;
60 public const SUPPORTED_IMPORT_MIME_TYPES = [MimeType::APPLICATION__ZIP, MimeType::APPLICATION__X_ZIP_COMPRESSED];
61 protected \ILIAS\Notes\Service $notes_service;
62
64 protected ServerRequestInterface $request;
66 protected ilObjUser $user;
76 protected ilTree $tree;
77 protected ilCtrl $ctrl;
79 protected ilLanguage $lng;
81 protected ILIAS $ilias;
84 protected Refinery $refinery;
86 protected CustomIconFactory $custom_icon_factory;
87 protected UIFactory $ui_factory;
88 protected UIRenderer $ui_renderer;
92
93 protected ?ilObject $object = null;
94 protected bool $creation_mode = false;
95 protected $data;
96 protected int $id;
97 protected bool $call_by_reference = false;
98 protected bool $prepare_output;
99 protected int $ref_id;
100 protected int $obj_id;
101 protected int $maxcount; // contains number of child objects
102 protected array $form_action = []; // special formation (array "cmd" => "formaction")
103 protected array $return_location = []; // special return location (array "cmd" => "location")
104 protected array $target_frame = []; // special target frame (array "cmd" => "location")
105 protected string $tmp_import_dir; // directory used during import$this->ui_factory = $DIC['ui.factory'];
106 protected string $sub_objects = "";
107 protected bool $omit_locator = false;
108 protected string $type = "";
110 protected int $requested_ref_id = 0;
111 protected int $requested_crtptrefid = 0;
112 protected int $requested_crtcb = 0;
113 protected string $requested_new_type = "";
114 protected string $link_params;
115 protected string $html = "";
116
117 private ?RoundTrip $import_modal = null;
119
127 public function __construct($data, int $id = 0, bool $call_by_reference = true, bool $prepare_output = true)
128 {
130 global $DIC;
131
132 $this->http = $DIC['http'];
133 $this->locator = $DIC['ilLocator'];
134 $this->user = $DIC['user']->getLoggedInUser();
135 $this->access = $DIC['ilAccess'];
136 $this->settings = $DIC['ilSetting'];
137 $this->toolbar = $DIC['ilToolbar'];
138 $this->rbac_admin = $DIC['rbacadmin'];
139 $this->rbac_system = $DIC['rbacsystem'];
140 $this->rbac_review = $DIC['rbacreview'];
141 $this->obj_definition = $DIC['objDefinition'];
142 $this->tpl = $DIC['tpl'];
143 $this->tree = $DIC['tree'];
144 $this->ctrl = $DIC['ilCtrl'];
145 $this->error = $DIC['ilErr'];
146 $this->lng = $DIC['lng'];
147 $this->tabs_gui = $DIC['ilTabs'];
148 $this->ilias = $DIC['ilias'];
149 $this->refinery = $DIC['refinery'];
150 $this->custom_icon_factory = $DIC['object.customicons.factory'];
151 $this->ui_factory = $DIC['ui.factory'];
152 $this->ui_renderer = $DIC['ui.renderer'];
153 $this->object_service = $DIC->object();
154 $this->temp_file_system = $DIC->filesystem()->temp();
155
156 $this->request = $this->http->request();
157 $this->post_wrapper = $this->http->wrapper()->post();
158 $this->request_wrapper = $this->http->wrapper()->query();
159
160 $this->retriever = new ilObjectRequestRetriever($DIC->http()->wrapper(), $this->refinery);
161 $this->favourites = new ilFavouritesManager();
162
163 $this->data = $data;
164 $this->id = $id;
165 $this->call_by_reference = $call_by_reference;
166 $this->prepare_output = $prepare_output;
167
168 $this->lng->loadLanguageModule('obj');
169
170 $params = ['ref_id'];
171 if (!$call_by_reference) {
172 $params = ['ref_id','obj_id'];
173 }
174 $this->ctrl->saveParameter($this, $params);
175
176 if ($this->request_wrapper->has('ref_id')) {
177 $this->requested_ref_id = $this->request_wrapper->retrieve('ref_id', $this->refinery->kindlyTo()->int());
178 }
179
180 $this->obj_id = $this->id;
181 $this->ref_id = $this->requested_ref_id;
182
183 if ($call_by_reference) {
184 $this->ref_id = $this->id;
185 $this->obj_id = 0;
186 if ($this->request_wrapper->has('obj_id')) {
187 $this->obj_id = $this->request_wrapper->retrieve('obj_id', $this->refinery->kindlyTo()->int());
188 }
189 }
190
191 // TODO: refactor this with post_wrapper or request_wrapper
192 // callback after creation
193 $this->requested_crtptrefid = $this->retriever->getMaybeInt('crtptrefid', 0);
194 $this->requested_crtcb = $this->retriever->getMaybeInt('crtcb', 0);
195 $this->requested_new_type = $this->retriever->getMaybeString('new_type', '');
196
197
198 if ($this->id != 0) {
199 $this->link_params = "ref_id=" . $this->ref_id;
200 }
201
202 $this->assignObject();
203
204 if (is_object($this->object)) {
205 if ($this->call_by_reference && $this->ref_id == $this->requested_ref_id) {
206 $this->ctrl->setContextObject(
207 $this->object->getId(),
208 $this->object->getType()
209 );
210 }
211 }
212
213 if ($prepare_output) {
214 $this->prepareOutput();
215 }
216
217 $this->notes_service = $DIC->notes();
218 }
219
221 {
222 if (!isset($this->multi_object_manipulator)) {
223 $this->multi_object_manipulator = LocalDIC::dic()['properties.multi_manipulator'];
224 }
226 }
227
228 public function getRefId(): int
229 {
230 return $this->ref_id;
231 }
232
233 public function setAdminMode(string $mode): void
234 {
235 if (!in_array($mode, [
236 self::ADMIN_MODE_NONE,
237 self::ADMIN_MODE_REPOSITORY,
238 self::ADMIN_MODE_SETTINGS
239 ])) {
240 throw new ilObjectException("Unknown Admin Mode $mode.");
241 }
242 $this->admin_mode = $mode;
243 }
244
245 public function getAdminMode(): string
246 {
247 return $this->admin_mode;
248 }
249
250 protected function getObjectService(): ilObjectService
251 {
253 }
254
255 public function getObject(): ?ilObject
256 {
257 return $this->object;
258 }
259
260 public function executeCommand(): void
261 {
262 $cmd = $this->ctrl->getCmd();
263
264 $this->prepareOutput();
265 if (!$cmd) {
266 $cmd = "view";
267 }
268 $cmd .= "Object";
269 $this->$cmd();
270 }
271
275 public function withReferences(): bool
276 {
278 }
279
285 public function setCreationMode(bool $mode = true): void
286 {
287 $this->creation_mode = $mode;
288 }
289
290 public function getCreationMode(): bool
291 {
293 }
294
295 protected function assignObject(): void
296 {
297 // TODO: it seems that we always have to pass only the ref_id
298 if ($this->id != 0) {
299 if ($this->call_by_reference) {
300 $this->object = ilObjectFactory::getInstanceByRefId($this->id);
301 } else {
302 $this->object = ilObjectFactory::getInstanceByObjId($this->id);
303 }
304 }
305 }
306
307 public function prepareOutput(bool $show_sub_objects = true): bool
308 {
309 $this->tpl->loadStandardTemplate();
310 $base_class = $this->request_wrapper->retrieve("baseClass", $this->refinery->kindlyTo()->string());
311 if (strtolower($base_class) == "iladministrationgui") {
312 $this->addAdminLocatorItems();
313 $this->tpl->setLocator();
314
315 $this->setTitleAndDescription();
316
317 if ($this->getCreationMode() != true) {
318 $this->setAdminTabs();
319 }
320
321 return false;
322 }
323 $this->setLocator();
324
325 // in creation mode (parent) object and gui object do not fit
326 if ($this->getCreationMode() === true) {
327 // repository vs. workspace
328 if ($this->call_by_reference) {
329 // get gui class of parent and call their title and description method
330 $obj_type = ilObject::_lookupType($this->requested_ref_id, true);
331 $class_name = $this->obj_definition->getClassName($obj_type);
332 $class = strtolower("ilObj" . $class_name . "GUI");
333 $class_path = $this->ctrl->lookupClassPath($class);
334 $class_name = $this->ctrl->getClassForClasspath($class_path);
335 }
336 } else {
337 $this->setTitleAndDescription();
338
339 // set tabs
340 $this->setTabs();
341
342 $file_upload_dropzone = new ilObjFileUploadDropzone($this->ref_id);
343 if ($file_upload_dropzone->isUploadAllowed($this->object->getType())) {
345 }
346 }
347
348 return true;
349 }
350
351 protected function setTitleAndDescription(): void
352 {
353 if (!is_object($this->object)) {
354 if ($this->requested_crtptrefid > 0) {
355 $cr_obj_id = ilObject::_lookupObjId($this->requested_crtcb);
356 $this->tpl->setTitle(
357 $this->refinery->encode()->htmlSpecialCharsAsEntities()->transform(
358 ilObject::_lookupTitle($cr_obj_id)
359 )
360 );
361 $this->tpl->setTitleIcon(ilObject::_getIcon($cr_obj_id));
362 }
363 return;
364 }
365 $this->tpl->setTitle(
366 $this->refinery->encode()->htmlSpecialCharsAsEntities()->transform(
367 $this->object->getPresentationTitle()
368 )
369 );
370 $this->tpl->setDescription(
371 $this->refinery->encode()->htmlSpecialCharsAsEntities()->transform(
372 $this->object->getLongDescription()
373 )
374 );
375
376 $base_class = $this->request_wrapper->retrieve("baseClass", $this->refinery->kindlyTo()->string());
377 if (strtolower($base_class) === "iladministrationgui") {
378 // alt text would be same as heading -> empty alt text
379 $this->tpl->setTitleIcon(ilObject::_getIcon(0, "big", $this->object->getType()));
380 } else {
381 $this->tpl->setTitleIcon(
382 ilObject::_getIcon($this->object->getId(), "big", $this->object->getType()),
383 $this->lng->txt("obj_" . $this->object->getType())
384 );
385 }
386 if (!$this->obj_definition->isAdministrationObject($this->object->getType())) {
387 $lgui = ilObjectListGUIFactory::_getListGUIByType($this->object->getType());
388 $lgui->initItem($this->object->getRefId(), $this->object->getId(), $this->object->getType());
389 $this->tpl->setAlertProperties($lgui->getAlertProperties());
390 }
391 }
392
394 {
397 $this->access,
398 $this->object->getType(),
399 $this->ref_id,
400 $this->object->getId()
401 );
402 }
403
407 protected function initHeaderAction(?string $sub_type = null, ?int $sub_id = null): ?ilObjectListGUI
408 {
409 if (!$this->creation_mode && $this->object) {
410 $dispatcher = $this->createActionDispatcherGUI();
411
412 $dispatcher->setSubObject($sub_type, $sub_id);
413
415 $this->ctrl->getLinkTarget($this, 'redrawHeaderAction', '', true),
416 "",
417 $this->ctrl->getLinkTargetByClass([ilCommonActionDispatcherGUI::class, ilTaggingGUI::class], '', '', true)
418 );
419
420 $lg = $dispatcher->initHeaderAction();
421
422 if (is_object($lg)) {
423 // to enable add to desktop / remove from desktop
424 if ($this instanceof ilDesktopItemHandling) {
425 $lg->setContainerObject($this);
426 }
427 // enable multi download
428 $lg->enableMultiDownload(true);
429
430 // comments settings are always on (for the repository)
431 // should only be shown if active or permission to toggle
432 if (
433 $this->access->checkAccess("write", "", $this->ref_id) ||
434 $this->access->checkAccess("edit_permissions", "", $this->ref_id) ||
435 $this->notes_service->domain()->commentsActive($this->object->getId())
436 ) {
437 $lg->enableComments(true);
438 }
439
440 $lg->enableNotes(true);
441 $lg->enableTags(true);
442 }
443
444 return $lg;
445 }
446 return null;
447 }
448
452 protected function insertHeaderAction(?ilObjectListGUI $list_gui = null): void
453 {
454 if (
455 !is_object($this->object) ||
456 ilContainer::_lookupContainerSetting($this->object->getId(), "hide_top_actions")
457 ) {
458 return;
459 }
460
461 if (is_object($list_gui)) {
462 $this->tpl->setHeaderActionMenu($list_gui->getHeaderAction());
463 }
464 }
465
469 protected function addHeaderAction(): void
470 {
471 $this->insertHeaderAction($this->initHeaderAction());
472 }
473
477 protected function redrawHeaderActionObject(): void
478 {
479 $lg = $this->initHeaderAction();
480 echo $lg->getHeaderAction();
481
482 // we need to add onload code manually (rating, comments, etc.)
483 echo $this->tpl->getOnLoadCodeForAsynch();
484 exit;
485 }
486
490 protected function setTabs(): void
491 {
492 $this->getTabs();
493 }
494
498 final protected function setAdminTabs(): void
499 {
500 $this->getAdminTabs();
501 }
502
506 public function getAdminTabs(): void
507 {
508 if ($this->checkPermissionBool("visible,read")) {
509 $this->tabs_gui->addTarget(
510 "view",
511 $this->ctrl->getLinkTarget($this, "view"),
512 ["", "view"],
513 get_class($this)
514 );
515 }
516
517 if ($this->checkPermissionBool("edit_permission")) {
518 $this->tabs_gui->addTarget(
519 "perm_settings",
520 $this->ctrl->getLinkTargetByClass([get_class($this), 'ilpermissiongui'], "perm"),
521 "",
522 "ilpermissiongui"
523 );
524 }
525 }
526
527 public function getHTML(): string
528 {
529 return $this->html;
530 }
531
532 protected function setLocator(): void
533 {
534 $ilLocator = $this->locator;
536
537 if ($this->omit_locator) {
538 return;
539 }
540
541 // repository vs. workspace
542 if ($this->call_by_reference) {
543 // todo: admin workaround
544 // in the future, object gui classes should not be called in
545 // admin section anymore (rbac/trash handling in own classes)
547 if ($this->requested_ref_id === 0) {
548 $ref_id = $this->object->getRefId();
549 }
550 $ilLocator->addRepositoryItems($ref_id);
551 }
552
553 if (!$this->creation_mode) {
554 $this->addLocatorItems();
555 }
556
557 $tpl->setLocator();
558 }
559
564 protected function addLocatorItems(): void
565 {
566 }
567
568 protected function omitLocator(bool $omit = true): void
569 {
570 $this->omit_locator = $omit;
571 }
572
577 protected function addAdminLocatorItems(bool $do_not_add_object = false): void
578 {
579 if ($this->admin_mode == self::ADMIN_MODE_SETTINGS) {
580 $this->ctrl->setParameterByClass(
581 "ilobjsystemfoldergui",
582 "ref_id",
584 );
585 $this->locator->addItem(
586 $this->lng->txt("administration"),
587 $this->ctrl->getLinkTargetByClass(["iladministrationgui", "ilobjsystemfoldergui"], "")
588 );
589 if ($this->object && ($this->object->getRefId() != SYSTEM_FOLDER_ID && !$do_not_add_object)) {
590 $this->locator->addItem(
591 $this->object->getTitle(),
592 $this->ctrl->getLinkTarget($this, "view")
593 );
594 }
595 } else {
596 $this->ctrl->setParameterByClass(
597 "iladministrationgui",
598 "ref_id",
599 ""
600 );
601 $this->ctrl->setParameterByClass(
602 "iladministrationgui",
603 "admin_mode",
604 "settings"
605 );
606 $this->ctrl->clearParametersByClass("iladministrationgui");
607 $this->locator->addAdministrationItems();
608 }
609 }
610
615 public function confirmedDeleteObject(): void
616 {
617 if (!$this->request_wrapper->has('id')) {
618 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('no_checkbox'), true);
619 $this->ctrl->returnToParent($this);
620 }
621
623 explode(
624 ',',
625 $this->request_wrapper->retrieve(
626 'id',
627 $this->refinery->kindlyTo()->string()
628 )
629 )
630 )->withRequest($this->request)->getData();
631
632 if ($data === null) {
633 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('no_checkbox'), true);
634 $this->ctrl->returnToParent($this);
635 }
636
637 $ru = new ilRepositoryTrashGUI($this);
638 $ru->deleteObjects($this->requested_ref_id, $this->buildRefIdsFromData($data));
639
640 $this->ctrl->redirectByClass(static::class);
641 }
642
643 private function buildRefIdsFromData(array $data): array
644 {
645 return array_reduce(
646 $data,
647 function (array $c, array|int|null $v): array {
648 if ($v === null) {
649 return $c;
650 }
651
652 if (is_array($v)) {
653 return array_merge(
654 $c,
655 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())->transform($v)
656 );
657 }
658
659 $c[] = $this->refinery->kindlyTo()->int()->transform($v);
660 return $c;
661 },
662 []
663 );
664 }
665
669 public function cancelObject(): void
670 {
671 ilSession::clear("saved_post");
672 $this->ctrl->returnToParent($this);
673 }
674
678 public function createObject(): void
679 {
680 $new_type = $this->requested_new_type;
681
682 // add new object to custom parent container
683 $this->ctrl->saveParameter($this, "crtptrefid");
684 // use forced callback after object creation
685 $this->ctrl->saveParameter($this, "crtcb");
686
687 if (!$this->checkPermissionBool('create', '', $new_type)) {
688 $this->error->raiseError($this->lng->txt("permission_denied"), $this->error->MESSAGE);
689 }
690
691 $this->lng->loadLanguageModule($new_type);
692 $this->ctrl->setParameter($this, 'new_type', $new_type);
693
694 $this->tpl->setTitleIcon(ilObject::getIconForType($this->requested_new_type));
695 $this->tpl->setTitle($this->getTitleForCreationFormPage());
696 $create_form = $this->initCreateForm($new_type);
697 $this->tabs_gui->setBackTarget($this->lng->txt('cancel'), $this->ctrl->getLinkTargetByClass(static::class, 'cancel'));
698 $this->tpl->setContent($this->getCreationFormsHTML($create_form));
699 }
700
704 protected function getCreationFormsHTML(StandardForm|ilPropertyFormGUI|array $form): string
705 {
706 $title = $this->getCreationFormTitle();
707
708 if (is_array($form)) {
709 throw new Exception('We do not deal with arrays here.');
710 }
711
712 $content = $form;
713 if ($form instanceof ilPropertyFormGUI) {
714 $form->setTitle('');
715 $form->setTitleIcon('');
716 $form->setTableWidth('100%');
717 $content = $this->ui_factory->legacy()->content($form->getHTML());
718 }
719
720 return $this->ui_renderer->render(
721 $this->ui_factory->panel()->standard($title, $content)
722 );
723 }
724
725 protected function getTitleForCreationFormPage(): string
726 {
727 if (!$this->obj_definition->isPlugin($this->requested_new_type)) {
728 return $this->lng->txt("obj_{$this->requested_new_type}");
729 }
731 $this->requested_new_type,
732 "obj_{$this->requested_new_type}"
733 );
734 }
735
736 protected function getCreationFormTitle(): string
737 {
738 if (!$this->obj_definition->isPlugin($this->requested_new_type)) {
739 return $this->lng->txt("{$this->requested_new_type}_new");
740 }
742 $this->requested_new_type,
743 "{$this->requested_new_type}_new"
744 );
745 }
746
747 protected function initCreateForm(string $new_type): StandardForm|ilPropertyFormGUI|array
748 {
749 $form_fields['title_and_description'] = (new ilObject())->getObjectProperties()->getPropertyTitleAndDescription()->toForm(
750 $this->lng,
751 $this->ui_factory->input()->field(),
753 );
754
755 $didactic_templates = $this->didacticTemplatesToForm();
756
757 if ($didactic_templates !== null) {
758 $form_fields['didactic_templates'] = $didactic_templates;
759 }
760
761 return $this->ui_factory->input()->container()->form()->standard(
762 $this->ctrl->getFormAction($this, 'save'),
763 $form_fields
764 )->withSubmitLabel(
765 !$this->obj_definition->isPlugin($new_type)
766 ? $this->lng->txt($new_type . '_add')
768 $this->requested_new_type,
769 "{$this->requested_new_type}_add"
770 )
771 );
772 }
773
774 protected function didacticTemplatesToForm(): ?Radio
775 {
776 $this->lng->loadLanguageModule('didactic');
777
778 list($existing_exclusive, $options) = $this->buildDidacticTemplateOptions();
779
780 if (sizeof($options) < 2) {
781 return null;
782 }
783
784 $didactic_templates_radio = $this->ui_factory->input()->field()->radio($this->lng->txt('type'));
785
786 $values = [];
787 foreach ($options as $value => $option) {
788 if ($existing_exclusive && $value == 'dtpl_0') {
789 //Skip default disabled if an exclusive template exists - Whatever the f*** that means!
790 continue;
791 }
792 $values[] = $value;
793 $didactic_templates_radio = $didactic_templates_radio->withOption($value, $option[0], $option[1] ?? '');
794 }
795
796 if (!$this->getCreationMode()) {
797 $current_value = 'dtpl_' . ilDidacticTemplateObjSettings::lookupTemplateId($this->object->getRefId());
798
799 if (in_array($current_value, $values)) {
800 $didactic_templates_radio = $didactic_templates_radio->withValue($current_value);
801 }
802
803 if (!in_array($value, array_keys($options)) || ($existing_exclusive && $value == "dtpl_0")) {
804 //add or rename actual value to not available
805 $options[$value] = [$this->lng->txt('not_available')];
806 }
807 } else {
808 if ($existing_exclusive) {
809 //if an exclusive template exists use the second template as default value
810 $keys = array_keys($options);
811 $didactic_templates_radio = $didactic_templates_radio->withValue($keys[1]);
812 } else {
813 $didactic_templates_radio = $didactic_templates_radio->withValue('dtpl_0');
814 }
815 }
816
817 return $didactic_templates_radio;
818 }
819
824 {
825 list($existing_exclusive, $options) = $this->buildDidacticTemplateOptions();
826
827 if (sizeof($options) < 2) {
828 return $form;
829 }
830
832 $this->lng->txt('type'),
833 'didactic_type'
834 );
835 // workaround for containers in edit mode
836 if (!$this->getCreationMode()) {
837 $value = 'dtpl_' . ilDidacticTemplateObjSettings::lookupTemplateId($this->object->getRefId());
838
839 $type->setValue($value);
840
841 if (!in_array($value, array_keys($options)) || ($existing_exclusive && $value == "dtpl_0")) {
842 //add or rename actual value to not available
843 $options[$value] = [$this->lng->txt('not_available')];
844 }
845 } else {
846 if ($existing_exclusive) {
847 //if an exclusive template exists use the second template as default value - Whatever the f*** that means!
848 $keys = array_keys($options);
849 $type->setValue($keys[1]);
850 } else {
851 $type->setValue('dtpl_0');
852 }
853 }
854 $form->addItem($type);
855
856 foreach ($options as $id => $data) {
857 $option = new ilRadioOption($data[0] ?? '', (string) $id, $data[1] ?? '');
858 if ($existing_exclusive && $id == 'dtpl_0') {
859 //set default disabled if an exclusive template exists
860 $option->setDisabled(true);
861 }
862
863 $type->addOption($option);
864 }
865
866 return $form;
867 }
868
869 private function buildDidacticTemplateOptions(): array
870 {
871 $this->lng->loadLanguageModule('didactic');
872 $existing_exclusive = false;
873 $options = [];
874 $options['dtpl_0'] = [
875 $this->lng->txt('didactic_default_type'),
876 sprintf(
877 $this->lng->txt('didactic_default_type_info'),
878 $this->lng->txt('objs_' . $this->type)
879 )
880 ];
881
882 $templates = ilDidacticTemplateSettings::getInstanceByObjectType($this->type)->getTemplates();
883 if ($templates) {
884 foreach ($templates as $template) {
885 if ($template->isEffective((int) $this->requested_ref_id)) {
886 $options["dtpl_" . $template->getId()] = [
887 $template->getPresentationTitle(),
888 $template->getPresentationDescription()
889 ];
890
891 if ($template->isExclusive()) {
892 $existing_exclusive = true;
893 }
894 }
895 }
896 }
897
898 return [$existing_exclusive, array_merge($options, $this->retrieveAdditionalDidacticTemplateOptions())];
899 }
900
905 {
906 return [];
907 }
908
909 protected function addAdoptContentLinkToToolbar(): void
910 {
911 $this->toolbar->addComponent(
912 $this->ui_factory->link()->standard(
913 $this->lng->txt('cntr_adopt_content'),
914 $this->ctrl->getLinkTargetByClass(
915 'ilObjectCopyGUI',
916 'adoptContent'
917 )
918 )
919 );
920 }
921
922 protected function addImportButtonToToolbar(): void
923 {
924 $modal = $this->import_modal ?? $this->buildImportModal();
925 $this->toolbar->addComponent(
926 $this->ui_factory->button()->standard(
927 $this->lng->txt('import'),
928 $modal->getShowSignal()
929 )
930 );
931
932 $this->tpl->setVariable(
933 'IL_OBJECT_IMPORT_MODAL',
934 $this->ui_renderer->render(
935 $this->import_type_selector_modal === null
936 ? $modal
937 : [$modal, $this->import_type_selector_modal]
938 )
939 );
940 }
941
942 private function buildImportModal(): RoundTrip
943 {
944 return $this->ui_factory->modal()
945 ->roundtrip(
946 $this->lng->txt('import'),
947 [],
948 $this->buildImportFormInputs(),
949 $this->ctrl->getFormAction($this, 'routeImportCmd')
950 )->withSubmitLabel($this->lng->txt('import'));
951 }
952
954 ?string $file_to_import = null,
955 ?string $upload_file_name = null
956 ): Roundtrip {
957 return $this->ui_factory->modal()
958 ->roundtrip(
959 $this->lng->txt('select_object_type'),
960 [
961 $this->ui_factory->messageBox()->info(
962 $this->lng->txt('select_import_type_info')
963 )
964 ],
966 $file_to_import,
967 $upload_file_name
968 ),
969 $this->ctrl->getFormActionByClass(static::class, 'routeImportCmd')
970 )->withCloseWithKeyboard(false)
971 ->withSubmitLabel($this->lng->txt('import'));
972 }
973
975 {
976 $toolbar->addSeparator();
977
978 $toolbar->addComponent(
979 $this->getMultiObjectPropertiesManipulator()->getAvailabilityPeriodButton()
980 );
981 return $toolbar;
982 }
983
984 public function editAvailabilityPeriodObject(): void
985 {
986 $item_ref_ids = $this->retriever->getSelectedIdsFromObjectList();
987 if (!$this->checkPermissionBool('write')
988 && !$this->checkWritePermissionOnRefIdArray($item_ref_ids)) {
989 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('msg_no_perm_write'));
990 return;
991 }
992
993 $availability_period_modal = $this->getMultiObjectPropertiesManipulator()->getEditAvailabilityPeriodPropertiesModal(
994 $item_ref_ids,
995 $this
996 );
997 if ($availability_period_modal !== null) {
998 $this->tpl->setVariable(
999 'IL_OBJECT_EPHEMRAL_MODALS',
1000 $this->ui_renderer->render(
1001 $availability_period_modal->withOnLoad(
1002 $availability_period_modal->getShowSignal()
1003 )
1004 )
1005 );
1006 }
1007 $this->renderObject();
1008 }
1009
1010 public function saveAvailabilityPeriodObject(): void
1011 {
1012 $availability_period_modal = $this->getMultiObjectPropertiesManipulator()->saveEditAvailabilityPeriodPropertiesModal(
1013 $this,
1014 fn($ref_ids): bool => $this->checkPermissionBool('write') || $this->checkWritePermissionOnRefIdArray($ref_ids),
1015 $this->request
1016 );
1017 if ($availability_period_modal === true) {
1018 $this->tpl->setOnScreenMessage('success', $this->lng->txt('availability_period_changed'));
1019 } elseif ($availability_period_modal === false) {
1020 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('msg_no_perm_write'));
1021 } else {
1022 $this->tpl->setVariable(
1023 'IL_OBJECT_EPHEMRAL_MODALS',
1024 $this->ui_renderer->render(
1025 $availability_period_modal->withOnLoad(
1026 $availability_period_modal->getShowSignal()
1027 )
1028 )
1029 );
1030 }
1031 $this->renderObject();
1032 }
1033
1037 public function cancelCreation(): void
1038 {
1039 $this->ctrl->redirectByClass("ilrepositorygui", "");
1040 }
1041
1042 public function saveObject(): void
1043 {
1044 // create permission is already checked in createObject. This check here is done to prevent hacking attempts
1045 if (!$this->checkPermissionBool("create", "", $this->requested_new_type)) {
1046 $this->error->raiseError($this->lng->txt("no_create_permission"), $this->error->MESSAGE);
1047 }
1048
1049 $this->lng->loadLanguageModule($this->requested_new_type);
1050 $this->ctrl->setParameter($this, "new_type", $this->requested_new_type);
1051
1052 $form = $this->initCreateForm($this->requested_new_type)
1053 ->withRequest($this->request);
1054 $data = $form->getData();
1055 if ($data === null) {
1056 $this->tpl->setContent($this->getCreationFormsHTML($form));
1057 return;
1058 }
1059
1060 $this->ctrl->setParameter($this, 'new_type', '');
1061
1062 $class_name = 'ilObj' . $this->obj_definition->getClassName($this->requested_new_type);
1063
1064 $new_obj = new $class_name();
1065 $new_obj->setType($this->requested_new_type);
1066 $new_obj->processAutoRating();
1067 $new_obj->setTitle($data['title_and_description']->getTitle());
1068 $new_obj->setDescription($data['title_and_description']->getDescription());
1069 $new_obj->create();
1070
1071 $new_obj->getObjectProperties()->storePropertyTitleAndDescription(
1072 $data['title_and_description']
1073 );
1074
1075 $this->putObjectInTree($new_obj);
1076
1077 $dtpl = $data['didactic_templates'] ?? null;
1078 if ($dtpl !== null) {
1079 $dtpl_id = $this->parseDidacticTemplateVar($dtpl, 'dtpl');
1080 $new_obj->applyDidacticTemplate($dtpl_id);
1081 }
1082
1083 $this->afterSave($new_obj);
1084 }
1085
1091 public function getDidacticTemplateVar(string $type): int
1092 {
1093 $create_form = $this->initCreateForm($this->type);
1094 if ($create_form instanceof StandardForm) {
1095 try {
1096 $data = $create_form->withRequest($this->request)->getData();
1097 return isset($data['didactic_templates'])
1098 ? $this->parseDidacticTemplateVar($data['didactic_templates'], $type)
1099 : 0;
1100 } catch (InvalidArgumentException $e) {
1101 }
1102 }
1103
1104 if (!$this->post_wrapper->has('didactic_type')) {
1105 return 0;
1106 }
1107
1108 $tpl = $this->post_wrapper->retrieve('didactic_type', $this->refinery->kindlyTo()->string());
1109 return $this->parseDidacticTemplateVar($tpl, $type);
1110 }
1111
1112 protected function parseDidacticTemplateVar(string $var, string $type): int
1113 {
1114 if (substr($var, 0, strlen($type) + 1) != $type . "_") {
1115 return 0;
1116 }
1117
1118 return (int) substr($var, strlen($type) + 1);
1119 }
1120
1124 public function putObjectInTree(ilObject $obj, ?int $parent_node_id = null): void
1125 {
1126 if (!$parent_node_id) {
1127 $parent_node_id = $this->requested_ref_id;
1128 }
1129
1130 // add new object to custom parent container
1131 if ($this->requested_crtptrefid > 0) {
1132 $parent_node_id = $this->requested_crtptrefid;
1133 }
1134
1135 $obj->createReference();
1136 $obj->putInTree($parent_node_id);
1137 $obj->setPermissions($parent_node_id);
1138
1139 $this->obj_id = $obj->getId();
1140 $this->ref_id = $obj->getRefId();
1141
1142 // BEGIN ChangeEvent: Record save object.
1143 ilChangeEvent::_recordWriteEvent($this->obj_id, $this->user->getId(), 'create');
1144 // END ChangeEvent: Record save object.
1145
1146 // rbac log
1147 $rbac_log_roles = $this->rbac_review->getParentRoleIds($this->ref_id, false);
1148 $rbac_log = ilRbacLog::gatherFaPa($this->ref_id, array_keys($rbac_log_roles), true);
1149 ilRbacLog::add(ilRbacLog::CREATE_OBJECT, $this->ref_id, $rbac_log);
1150
1151 // use forced callback after object creation
1152 $this->callCreationCallback($obj, $this->obj_definition, $this->requested_crtcb);
1153 }
1154
1158 protected function afterSave(ilObject $new_object): void
1159 {
1160 $this->tpl->setOnScreenMessage("success", $this->lng->txt("object_added"), true);
1161 $this->ctrl->returnToParent($this);
1162 }
1163
1164 public function editObject(): void
1165 {
1166 if (!$this->checkPermissionBool("write")) {
1167 $this->error->raiseError($this->lng->txt("msg_no_perm_write"), $this->error->MESSAGE);
1168 }
1169
1170 $this->tabs_gui->activateTab("settings");
1171
1172 $form = $this->initEditForm();
1173 $values = $this->getEditFormValues();
1174 if ($values) {
1175 $form->setValuesByArray($values);
1176 }
1177
1178 $this->addExternalEditFormCustom($form);
1179
1180 $this->tpl->setContent($form->getHTML());
1181 }
1182
1184 {
1185 // has to be done AFTER setValuesByArray() ...
1186 }
1187
1188 protected function initEditForm(): ilPropertyFormGUI
1189 {
1190 $lng = $this->lng;
1191
1192 $lng->loadLanguageModule($this->object->getType());
1193
1194 $form = new ilPropertyFormGUI();
1195 $form->setFormAction($this->ctrl->getFormAction($this, "update"));
1196 $form->setTitle($this->lng->txt($this->object->getType() . "_edit"));
1197
1198 $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
1199 $ti->setSize(min(40, ilObject::TITLE_LENGTH));
1200 $ti->setMaxLength(ilObject::TITLE_LENGTH);
1201 $ti->setRequired(true);
1202 $form->addItem($ti);
1203
1204 $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
1205 $ta->setCols(40);
1206 $ta->setRows(2);
1207 $ta->setMaxNumOfChars(ilObject::LONG_DESC_LENGTH);
1208 $form->addItem($ta);
1209
1210 $this->initEditCustomForm($form);
1211
1212 $form->addCommandButton("update", $this->lng->txt("save"));
1213
1214 return $form;
1215 }
1216
1220 protected function initEditCustomForm(ilPropertyFormGUI $a_form): void
1221 {
1222 }
1223
1224 protected function getEditFormValues(): array
1225 {
1226 $values["title"] = $this->object->getTitle();
1227 $values["desc"] = $this->object->getLongDescription();
1228 $this->getEditFormCustomValues($values);
1229 return $values;
1230 }
1231
1235 protected function getEditFormCustomValues(array &$a_values): void
1236 {
1237 }
1238
1242 public function updateObject(): void
1243 {
1244 if (!$this->checkPermissionBool("write")) {
1245 $this->error->raiseError($this->lng->txt("permission_denied"), $this->error->MESSAGE);
1246 }
1247
1248 $form = $this->initEditForm();
1249 if ($form->checkInput() && $this->validateCustom($form)) {
1250 $this->updateCustom($form);
1251 $this->object->setTitle($form->getInput('title'));
1252 $this->object->setDescription($form->getInput('desc'));
1253 $this->object->update();
1254
1255 $this->afterUpdate();
1256 return;
1257 }
1258
1259 // display form again to correct errors
1260 $this->tabs_gui->activateTab("settings");
1261 $form->setValuesByPost();
1262 $this->tpl->setContent($form->getHTML());
1263 }
1264
1268 protected function validateCustom(ilPropertyFormGUI $form): bool
1269 {
1270 return true;
1271 }
1272
1276 protected function updateCustom(ilPropertyFormGUI $form): void
1277 {
1278 }
1279
1283 protected function afterUpdate(): void
1284 {
1285 $this->tpl->setOnScreenMessage("success", $this->lng->txt("msg_obj_modified"), true);
1286 $this->ctrl->redirect($this, "edit");
1287 }
1288
1289 private function buildImportFormInputs(): array
1290 {
1291 $trafo = $this->refinery->custom()->transformation(
1292 function ($vs): array {
1293 if ($vs === null) {
1294 return null;
1295 }
1296 if (!isset($vs[1])) {
1297 return [self::UPLOAD_TYPE_LOCAL => $vs[0]];
1298 } elseif ((int) $vs[1][0] === self::UPLOAD_TYPE_LOCAL) {
1299 return [self::UPLOAD_TYPE_LOCAL => $vs[1][0][0]];
1300 } else {
1301 $upload_factory = new ilImportDirectoryFactory();
1302 $export_upload = $upload_factory->getInstanceForComponent(ilImportDirectoryFactory::TYPE_EXPORT);
1303 $type = $this->extractFileTypeFromImportFilename($vs[1][0]) ?? '';
1304 $file = $export_upload->getAbsolutePathForHash($this->user->getId(), $type, $vs[1][0]);
1305 return [
1306 self::UPLOAD_TYPE_UPLOAD_DIRECTORY => $file
1307 ];
1308 }
1309 }
1310 );
1311
1312 $import_directory_factory = new ilImportDirectoryFactory();
1313 $upload_files = $import_directory_factory->getInstanceForComponent(ilImportDirectoryFactory::TYPE_EXPORT)
1314 ->getFilesFor($this->user->getId());
1315
1316 $field_factory = $this->ui_factory->input()->field();
1317
1318 $file_upload_input = $field_factory->file(new \ImportUploadHandlerGUI(), $this->lng->txt('import_file'))
1319 ->withAcceptedMimeTypes(self::SUPPORTED_IMPORT_MIME_TYPES)
1320 ->withRequired(true)
1321 ->withMaxFiles(1);
1322
1323 if ($upload_files !== []) {
1324 $this->lng->loadLanguageModule('content');
1325
1326 $file_upload_input = $field_factory->switchableGroup(
1327 [
1328 self::UPLOAD_TYPE_LOCAL => $field_factory->group(
1329 [$file_upload_input],
1330 $this->lng->txt('cont_choose_local')
1331 ),
1332 self::UPLOAD_TYPE_UPLOAD_DIRECTORY => $field_factory->group(
1333 [$field_factory->select($this->lng->txt('cont_uploaded_file'), $upload_files)->withRequired(true)],
1334 $this->lng->txt('cont_choose_upload_dir'),
1335 )
1336 ],
1337 $this->lng->txt('cont_choose_file_source')
1338 );
1339 }
1340
1341 return [
1342 'upload' => $file_upload_input->withAdditionalTransformation($trafo)
1343 ];
1344 }
1345
1347 ?string $file_to_import = null,
1348 ?string $file_name_in_temp_dir = null
1349 ): array {
1350 $ff = $this->ui_factory->input()->field();
1351
1352 $possible_sub_objects = array_map(
1353 fn(array $v): string => $this->getTranslatedObjectTypeNameFromItemArray($v),
1354 $this->object->getPossibleSubObjects()
1355 );
1356
1357 asort($possible_sub_objects);
1358
1359 return [
1360 'type' => $ff->select(
1361 $this->lng->txt('select_object_type'),
1362 $possible_sub_objects
1363 )->withRequired(true),
1364 'file_to_import' => $ff->hidden()->withValue($file_to_import),
1365 'temp_file' => $ff->hidden()->withValue($file_name_in_temp_dir)
1366 ];
1367 }
1368
1369 protected function routeImportCmdObject(): void
1370 {
1371 if ($this->request_wrapper->has('step')) {
1372 $data = $this->retrieveAndCheckImportTypeData();
1373 } else {
1374 $data = $this->retrieveAndCheckImportData();
1375 }
1376
1377 if ($data === null) {
1378 $this->viewObject();
1379 return;
1380 }
1381
1382 [$new_type, $file_to_import, $path_to_uploaded_file_in_temp_dir] = $this
1383 ->retrieveFilesAndUploadTypeFromData($data);
1384
1385 if ($new_type === null) {
1386 $this->showImportTypeSelectorModal(
1387 basename($file_to_import),
1388 $path_to_uploaded_file_in_temp_dir
1389 );
1390 return;
1391 }
1392
1393 // create permission is already checked in createObject. This check here is done to prevent hacking attempts
1394 if (!$this->checkPermissionBool('create', '', $new_type)
1395 || !in_array($new_type, $this->obj_definition->getAllObjects())
1396 || !array_key_exists($new_type, $this->object->getPossibleSubObjects())) {
1397 $this->deleteUploadedImportFile($path_to_uploaded_file_in_temp_dir);
1398 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('no_create_permission'));
1399 $this->viewObject();
1400 return;
1401 }
1402
1403 $this->lng->loadLanguageModule($new_type);
1404 $this->ctrl->setParameter($this, 'new_type', $new_type);
1405
1406 $target_class = 'ilObj' . $this->obj_definition->getClassName($new_type) . 'GUI';
1407 try {
1408 $target = new $target_class('', 0, false, false);
1409 } catch (TypeError $e) {
1410 $target = new $target_class(0, ilObject2GUI::REPOSITORY_NODE_ID, $this->getRefId());
1411 }
1412 $target->importFile($file_to_import, $path_to_uploaded_file_in_temp_dir);
1413 $this->ctrl->clearParameterByClass(get_class($this), 'new_type');
1414 $this->viewObject();
1415 }
1416
1417 protected function importFile(string $file_to_import, string $path_to_uploaded_file_in_temp_dir): void
1418 {
1419 if ($this instanceof ilContainerGUI) {
1420 $imp = new ilImportContainer($this->requested_ref_id);
1421 } else {
1422 $imp = new ilImport($this->requested_ref_id);
1423 }
1424
1425 try {
1426 $new_id = $imp->importObject(
1427 null,
1428 $file_to_import,
1429 basename($file_to_import),
1430 $this->type,
1431 '',
1432 true
1433 );
1434 } catch (ilException $e) {
1435 $this->tmp_import_dir = $imp->getTemporaryImportDir();
1436 $this->tpl->setOnScreenMessage(
1437 'failure',
1438 $this->lng->txt('obj_import_file_error') . ' <br />' . $e->getMessage()
1439 );
1440 $this->deleteUploadedImportFile($path_to_uploaded_file_in_temp_dir);
1441 return;
1442 }
1443
1444 if ($new_id === null
1445 || $new_id === 0) {
1446 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('import_file_not_valid_here'));
1447 $this->deleteUploadedImportFile($path_to_uploaded_file_in_temp_dir);
1448 return;
1449 }
1450
1451 $this->ctrl->setParameter($this, 'new_type', '');
1452
1453 $new_obj = ilObjectFactory::getInstanceByObjId($new_id);
1454 // put new object id into tree - already done in import for containers
1455 if (!$this->obj_definition->isContainer($this->type)) {
1456 $this->putObjectInTree($new_obj);
1457 } else {
1458 $ref_ids = ilObject::_getAllReferences($new_obj->getId());
1459 if (count($ref_ids) === 1) {
1460 $new_obj->setRefId((int) current($ref_ids));
1461 }
1462 $this->callCreationCallback($new_obj, $this->obj_definition, $this->requested_crtcb); // see #24244
1463 }
1464
1465 if ($path_to_uploaded_file_in_temp_dir !== ''
1466 && $this->temp_file_system->hasDir($path_to_uploaded_file_in_temp_dir)) {
1467 $this->temp_file_system->deleteDir($path_to_uploaded_file_in_temp_dir);
1468 }
1469
1470 $this->afterImport($new_obj);
1471 $this->ctrl->setParameterByClass(get_class($new_obj), 'ref_id', $new_obj->getRefId());
1472 $this->ctrl->redirectByClass(get_class($new_obj));
1473 }
1474
1475 protected function deleteUploadedImportFile(string $path_to_uploaded_file_in_temp_dir): void
1476 {
1477 if ($path_to_uploaded_file_in_temp_dir !== ''
1478 && $this->temp_file_system->hasDir($path_to_uploaded_file_in_temp_dir)) {
1479 $this->temp_file_system->deleteDir($path_to_uploaded_file_in_temp_dir);
1480 }
1481 }
1482
1483 private function retrieveAndCheckImportData(): ?array
1484 {
1485 $modal = $this->buildImportModal()->withRequest($this->request);
1486 $data = $modal->getData();
1487
1488 if ($data !== null) {
1489 return $data;
1490 }
1491
1492 $this->import_modal = $modal->withOnLoad($modal->getShowSignal());
1493 return null;
1494 }
1495
1496 private function retrieveAndCheckImportTypeData(): ?array
1497 {
1498 $modal = $this->buildImportTypeSelectorModal()->withRequest($this->request);
1499 $data = $modal->getData();
1500
1501 if ($data !== null) {
1502 return $data;
1503 }
1504
1505 $this->import_type_selector_modal = $modal->withOnLoad($modal->getShowSignal());
1506 return null;
1507 }
1508
1510 ?string $file_to_import = null,
1511 ?string $path_to_uploaded_file_in_temp_dir = null
1512 ): void {
1513 $this->ctrl->setParameterByClass(static::class, 'step', 'select_type');
1514 $modal = $this->buildImportTypeSelectorModal(
1515 $file_to_import,
1516 $path_to_uploaded_file_in_temp_dir
1517 );
1518 $this->ctrl->clearParameterByClass(static::class, 'step');
1519 $this->import_type_selector_modal = $modal->withOnLoad($modal->getShowSignal());
1520 $this->viewObject();
1521 return;
1522 }
1523
1524 private function retrieveFilesAndUploadTypeFromData(array $data): array
1525 {
1526 if (isset($data['type']) && isset($data['file_to_import']) && isset($data['temp_file'])) {
1527 return [
1528 $data['type'],
1529 implode(
1530 DIRECTORY_SEPARATOR,
1531 [CLIENT_DATA_DIR, 'temp', $data['temp_file'], $data['file_to_import']]
1532 ),
1533 $data['temp_file']
1534 ];
1535 }
1536 $file_to_import = $this->getFileToImportFromImportFormData($data);
1537 $path_to_uploaded_file_in_temp_dir = '';
1538 if (array_key_first($data['upload']) === self::UPLOAD_TYPE_LOCAL) {
1539 $path_to_uploaded_file_in_temp_dir = $data['upload'][self::UPLOAD_TYPE_LOCAL];
1540 }
1541
1542 return [
1543 $this->extractFileTypeFromImportFilename(basename($file_to_import)),
1544 $file_to_import,
1545 $path_to_uploaded_file_in_temp_dir
1546 ];
1547 }
1548
1549 private function extractFileTypeFromImportFilename(string $filename): ?string
1550 {
1551 $matches = [];
1552 $result = preg_match('/[0-9]{10}__[0-9]{1,6}__([a-z]{1,4})_[0-9]{2,9}.zip/', $filename, $matches);
1553 if ($result === false
1554 || $result === 0
1555 || !isset($matches[1])) {
1556 return null;
1557 }
1558 return $matches[1];
1559 }
1560
1562 {
1563 $upload_data = $data['upload'];
1564 if (array_key_first($upload_data) === self::UPLOAD_TYPE_LOCAL
1565 && $this->temp_file_system->hasDir($upload_data[self::UPLOAD_TYPE_LOCAL])) {
1566 $files = $this->temp_file_system->listContents($upload_data[self::UPLOAD_TYPE_LOCAL]);
1567 return CLIENT_DATA_DIR . DIRECTORY_SEPARATOR
1568 . 'temp' . DIRECTORY_SEPARATOR
1569 . $files[0]->getPath();
1570 }
1571 return $upload_data[self::UPLOAD_TYPE_UPLOAD_DIRECTORY];
1572 }
1573
1577 protected function afterImport(ilObject $new_object): void
1578 {
1579 $this->tpl->setOnScreenMessage("success", $this->lng->txt("object_added"), true);
1580 $this->ctrl->returnToParent($this);
1581 }
1582
1586 public function getFormAction(string $cmd, string $default_form_action = ""): string
1587 {
1588 if ($this->form_action[$cmd] != "") {
1589 return $this->form_action[$cmd];
1590 }
1591
1592 return $default_form_action;
1593 }
1594
1595 protected function setFormAction(string $cmd, string $form_action): void
1596 {
1597 $this->form_action[$cmd] = $form_action;
1598 }
1599
1603 protected function getReturnLocation(string $cmd, string $default_location = ""): string
1604 {
1605 if (($this->return_location[$cmd] ?? "") !== "") {
1606 return $this->return_location[$cmd];
1607 } else {
1608 return $default_location;
1609 }
1610 }
1611
1615 protected function setReturnLocation(string $cmd, string $location): void
1616 {
1617 $this->return_location[$cmd] = $location;
1618 }
1619
1623 protected function getTargetFrame(string $cmd, string $default_target_frame = ""): string
1624 {
1625 if (isset($this->target_frame[$cmd]) && $this->target_frame[$cmd] != "") {
1626 return $this->target_frame[$cmd];
1627 }
1628
1629 if (!empty($default_target_frame)) {
1630 return "target=\"" . $default_target_frame . "\"";
1631 }
1632
1633 return "";
1634 }
1635
1639 protected function setTargetFrame(string $cmd, string $target_frame): void
1640 {
1641 $this->target_frame[$cmd] = "target=\"" . $target_frame . "\"";
1642 }
1643
1644 public function isVisible(int $ref_id, string $type): bool
1645 {
1646 $visible = $this->checkPermissionBool("visible,read", "", "", $ref_id);
1647
1648 if ($visible && $type == 'crs') {
1649 $tree = $this->tree;
1650 if ($crs_id = $tree->checkForParentType($ref_id, 'crs')) {
1651 if (!$this->checkPermissionBool("write", "", "", $crs_id)) {
1652 // Show only activated courses
1653 $tmp_obj = ilObjectFactory::getInstanceByRefId($crs_id, false);
1654
1655 if (!$tmp_obj->isActivated()) {
1656 unset($tmp_obj);
1657 $visible = false;
1658 }
1659 }
1660 }
1661 }
1662
1663 return $visible;
1664 }
1665
1669 public function viewObject(): void
1670 {
1671 $this->checkPermission('visible') && $this->checkPermission('read');
1672
1673 $this->tabs_gui->activateTab('view');
1674
1676 $this->object->getType(),
1677 $this->object->getRefId(),
1678 $this->object->getId(),
1679 $this->user->getId()
1680 );
1681
1682 if (!$this->withReferences()) {
1683 $this->ctrl->setParameter($this, 'obj_id', $this->obj_id);
1684 }
1685
1686 $itab = new ilAdminSubItemsTableGUI(
1687 $this,
1688 "view",
1689 $this->requested_ref_id,
1690 $this->checkPermissionBool('write')
1691 );
1692
1693 $this->tpl->setContent($itab->getHTML());
1694 }
1695
1701 public function deleteObject(bool $error = false): void
1702 {
1703 $request_ids = [];
1704 if ($this->post_wrapper->has('id')) {
1705 $request_ids = $this->post_wrapper->retrieve(
1706 'id',
1707 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
1708 );
1709 }
1710
1711 if (
1712 $this->request_wrapper->has('item_ref_id')
1713 && $this->request_wrapper->retrieve('item_ref_id', $this->refinery->kindlyTo()->string()) !== ""
1714 ) {
1715 $request_ids = [$this->request_wrapper->retrieve('item_ref_id', $this->refinery->kindlyTo()->int())];
1716 }
1717
1718 if ($request_ids === []) {
1719 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('no_checkbox'), true);
1720 $this->ctrl->returnToParent($this);
1721 }
1722
1723 $modal = $this->buildDeleletionModal(array_unique($request_ids));
1724 $this->tpl->setVariable(
1725 'IL_OBJECT_EPHEMRAL_MODALS',
1726 $this->ui_renderer->render(
1727 $modal->withOnLoad($modal->getShowSignal())
1728 )
1729 );
1730 $this->renderObject();
1731 }
1732
1733 private function buildDeleletionModal(array $request_ids): \ILIAS\UI\Component\Modal\RoundTrip
1734 {
1735 [$listing_items, $inputs, $has_additional_references] = $this->buildDeletionModalItems($request_ids);
1736
1737 $msg = $this->lng->txt('info_delete_sure');
1738 if (!$this->settings->get('enable_trash')) {
1739 $msg .= "<br/>" . $this->lng->txt('info_delete_warning_no_trash');
1740 }
1741
1742 $content = [
1743 $this->ui_factory->messageBox()->confirmation($msg),
1744 $this->ui_factory->listing()->unordered($listing_items)
1745 ];
1746
1747 if ($has_additional_references) {
1748 $content[] = $this->ui_factory->messageBox()->confirmation(
1749 $this->lng->txt('multiple_reference_deletion_info') . ' '
1750 . $this->lng->txt('rep_multiple_reference_deletion_instruction')
1751 );
1752 }
1753
1754 $this->ctrl->setParameterByClass(static::class, 'id', implode(',', $request_ids));
1755 $target_url = $this->ctrl->getFormActionByClass(static::class, 'confirmedDelete');
1756 $this->ctrl->clearParameterByClass(static::class, 'id');
1757
1758 return $this->ui_factory->modal()->roundtrip(
1759 $this->lng->txt('confirm'),
1760 $content,
1761 $inputs,
1762 $target_url
1763 )->withSubmitLabel($this->lng->txt('delete'));
1764 }
1765
1766 private function buildDeletionModalItems(array $ref_ids): array
1767 {
1768 $path_gui = new ilPathGUI();
1769 $path_gui->enableTextOnly(true);
1770 $path_gui->enableHideLeaf(false);
1771 return array_reduce(
1772 $ref_ids,
1773 function (array $c, int $v) use ($path_gui): array {
1776 );
1777 $c[1][] = $this->ui_factory->input()->field()->hidden()->withValue($v);
1778
1779 $other_references = $this->buildInputsForAdditionalDeletionReferences($v, $path_gui);
1780 if ($other_references !== []) {
1781 $c[1][] = $this->ui_factory->input()->field()->multiSelect(
1784 ),
1785 $other_references
1786 );
1787 $c[2] = true;
1788 }
1789 return $c;
1790 },
1791 [[], [], false]
1792 );
1793 }
1794
1795 private function buildInputsForAdditionalDeletionReferences(int $ref_id, ilPathGUI $path_gui): array
1796 {
1797 return array_reduce(
1799 function (array $c, int $v) use ($ref_id, $path_gui): array {
1800 if ($v !== $ref_id
1801 && !$this->tree->isDeleted($v)
1802 && $this->access->checkAccess('delete', '', $v)) {
1803 $c[$v] = $path_gui->getPath(ROOT_FOLDER_ID, $v);
1804 }
1805 return $c;
1806 },
1807 []
1808 );
1809 }
1810
1814 protected function showPossibleSubObjects(): void
1815 {
1816 if ($this->sub_objects == "") {
1817 $sub_objects = $this->obj_definition->getCreatableSubObjects(
1818 $this->object->getType(),
1820 $this->ref_id
1821 );
1822 } else {
1823 $sub_objects = $this->sub_objects;
1824 }
1825
1826 $subobj = [];
1827 if (count($sub_objects) > 0) {
1828 foreach ($sub_objects as $row) {
1829 $count = 0;
1830 if ($row["max"] > 0) {
1831 //how many elements are present?
1832 for ($i = 0; $i < count($this->data["ctrl"]); $i++) {
1833 if ($this->data["ctrl"][$i]["type"] == $row["name"]) {
1834 $count++;
1835 }
1836 }
1837 }
1838
1839 if ($row["max"] == "" || $count < $row["max"]) {
1840 $subobj[] = $row["name"];
1841 }
1842 }
1843 }
1844
1845 if (count($subobj) > 0) {
1846 $opts = ilLegacyFormElementsUtil::formSelect(12, "new_type", $subobj);
1847 $this->tpl->setCurrentBlock("add_object");
1848 $this->tpl->setVariable("SELECT_OBJTYPE", $opts);
1849 $this->tpl->setVariable("BTN_NAME", "create");
1850 $this->tpl->setVariable("TXT_ADD", $this->lng->txt("add"));
1851 $this->tpl->parseCurrentBlock();
1852 }
1853 }
1854
1858 protected function getTabs(): void
1859 {
1860 }
1861
1869 protected function redirectToRefId(int $ref_id, string $cmd = ""): void
1870 {
1871 $obj_type = ilObject::_lookupType($ref_id, true);
1872 $class_name = $this->obj_definition->getClassName($obj_type);
1873 $class = strtolower("ilObj" . $class_name . "GUI");
1874 $this->ctrl->setParameterByClass("ilrepositorygui", "ref_id", $ref_id);
1875 $this->ctrl->redirectByClass(["ilrepositorygui", $class], $cmd);
1876 }
1877
1881 protected function getCenterColumnHTML(): string
1882 {
1883 $obj_id = ilObject::_lookupObjId($this->object->getRefId());
1884 $obj_type = ilObject::_lookupType($obj_id);
1885
1886 if ($this->ctrl->getNextClass() != "ilcolumngui") {
1887 // normal command processing
1888 return $this->getContent();
1889 } else {
1890 if (!$this->ctrl->isAsynch()) {
1891 //if ($column_gui->getScreenMode() != IL_SCREEN_SIDE)
1893 // right column wants center
1895 $column_gui = new ilColumnGUI($obj_type, IL_COL_RIGHT);
1896 $this->setColumnSettings($column_gui);
1897 $this->html = $this->ctrl->forwardCommand($column_gui);
1898 }
1899 // left column wants center
1901 $column_gui = new ilColumnGUI($obj_type, IL_COL_LEFT);
1902 $this->setColumnSettings($column_gui);
1903 $this->html = $this->ctrl->forwardCommand($column_gui);
1904 }
1905 } else {
1906 // normal command processing
1907 return $this->getContent();
1908 }
1909 }
1910 }
1911 return "";
1912 }
1913
1917 protected function getRightColumnHTML(): string
1918 {
1919 $obj_id = ilObject::_lookupObjId($this->object->getRefId());
1920 $obj_type = ilObject::_lookupType($obj_id);
1921
1922 $column_gui = new ilColumnGUI($obj_type, IL_COL_RIGHT);
1923
1924 if ($column_gui->getScreenMode() == IL_SCREEN_FULL) {
1925 return "";
1926 }
1927
1928 $this->setColumnSettings($column_gui);
1929
1930 $html = "";
1931 if (
1932 $this->ctrl->getNextClass() == "ilcolumngui" &&
1933 $column_gui->getCmdSide() == IL_COL_RIGHT &&
1934 $column_gui->getScreenMode() == IL_SCREEN_SIDE
1935 ) {
1936 return $this->ctrl->forwardCommand($column_gui);
1937 }
1938
1939 if (!$this->ctrl->isAsynch()) {
1940 return $this->ctrl->getHTML($column_gui);
1941 }
1942
1943 return $html;
1944 }
1945
1946 public function setColumnSettings(ilColumnGUI $column_gui): void
1947 {
1948 $column_gui->setRepositoryMode(true);
1949 $column_gui->setEnableEdit(false);
1950 if ($this->checkPermissionBool("write")) {
1951 $column_gui->setEnableEdit(true);
1952 }
1953 }
1954
1955 protected function checkPermission(string $perm, string $cmd = "", string $type = "", ?int $ref_id = null): void
1956 {
1957 if (!$this->checkPermissionBool($perm, $cmd, $type, $ref_id)) {
1958 if (!is_int(strpos($_SERVER['PHP_SELF'], 'goto.php'))) {
1959 if ($perm != 'create' && !is_object($this->object)) {
1960 return;
1961 }
1962
1963 ilSession::clear('il_rep_ref_id');
1964
1965 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('msg_no_perm_read'), true);
1966 $parent_ref_id = $this->tree->getParentId($this->object->getRefId());
1967 if ($parent_ref_id > 0) {
1968 $this->ctrl->redirectToURL(ilLink::_getLink($parent_ref_id));
1969 } else {
1970 $this->ctrl->redirectToURL('login.php?cmd=force_login');
1971 }
1972 }
1973
1974 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('msg_no_perm_read'), true);
1975 self::_gotoRepositoryRoot();
1976 }
1977 }
1978
1979 protected function checkPermissionBool(string $perm, string $cmd = "", string $type = "", ?int $ref_id = null): bool
1980 {
1981 if ($perm === "create") {
1982 if (!$ref_id) {
1984 }
1985 return $this->access->checkAccess($perm . "_" . $type, $cmd, $ref_id);
1986 }
1987
1988 if (!is_object($this->object)) {
1989 return false;
1990 }
1991
1992 if (!$ref_id) {
1993 $ref_id = $this->object->getRefId();
1994 }
1995
1996 return $this->access->checkAccess($perm, $cmd, $ref_id);
1997 }
1998
2005 public static function _gotoRepositoryRoot(bool $raise_error = false): void
2006 {
2007 global $DIC;
2008
2009 $ilAccess = $DIC->access();
2010 $ilErr = $DIC["ilErr"];
2011 $lng = $DIC->language();
2012 $ctrl = $DIC->ctrl();
2013
2014 if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
2015 $ctrl->setParameterByClass("ilRepositoryGUI", "ref_id", ROOT_FOLDER_ID);
2016 $ctrl->redirectByClass("ilRepositoryGUI");
2017 }
2018
2019 if ($raise_error) {
2020 $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
2021 }
2022 }
2023
2024 public static function _gotoRepositoryNode(int $ref_id, string $cmd = ""): void
2025 {
2026 global $DIC;
2027
2028 $ctrl = $DIC->ctrl();
2029 $ctrl->setParameterByClass("ilRepositoryGUI", "ref_id", $ref_id);
2030 $ctrl->redirectByClass("ilRepositoryGUI", $cmd);
2031 }
2032
2033 public static function _gotoSharedWorkspaceNode(int $wsp_id): void
2034 {
2035 global $DIC;
2036
2037 $ctrl = $DIC->ctrl();
2038 $ctrl->setParameterByClass(ilSharedResourceGUI::class, "wsp_id", $wsp_id);
2039 $ctrl->redirectByClass(ilSharedResourceGUI::class, "");
2040 }
2041
2045 protected function enableDragDropFileUpload(): void
2046 {
2047 $this->tpl->setFileUploadRefId($this->ref_id);
2048 }
2049
2050 public function addToDeskObject(): void
2051 {
2052 $this->favourites->add(
2053 $this->user->getId(),
2054 $this->request_wrapper->retrieve("item_ref_id", $this->refinery->kindlyTo()->int())
2055 );
2056 $this->lng->loadLanguageModule("rep");
2057 $this->tpl->setOnScreenMessage("success", $this->lng->txt("rep_added_to_favourites"), true);
2058 $this->ctrl->redirectToURL(ilLink::_getLink($this->requested_ref_id));
2059 }
2060
2061 public function removeFromDeskObject(): void
2062 {
2063 $this->lng->loadLanguageModule("rep");
2064 $item_ref_id = $this->request_wrapper->retrieve("item_ref_id", $this->refinery->kindlyTo()->int());
2065 $this->favourites->remove($this->user->getId(), $item_ref_id);
2066 $this->tpl->setOnScreenMessage("success", $this->lng->txt("rep_removed_from_favourites"), true);
2067 $this->ctrl->redirectToURL(ilLink::_getLink($this->requested_ref_id));
2068 }
2069
2070 protected function getCreatableObjectTypes(): array
2071 {
2072 $subtypes = $this->obj_definition->getCreatableSubObjects(
2073 $this->object->getType(),
2075 $this->object->getRefId()
2076 );
2077
2078 return array_filter(
2079 $subtypes,
2080 fn($key) => $this->access->checkAccess('create_' . $key, '', $this->ref_id, $this->type),
2081 ARRAY_FILTER_USE_KEY
2082 );
2083 }
2084
2085 protected function buildAddNewItemElements(
2086 array $subtypes,
2087 string $create_target_class = ilRepositoryGUI::class,
2088 ?int $redirect_target_ref_id = null,
2089 ): array {
2090 if ($subtypes === []) {
2091 return [];
2092 }
2093 if ($redirect_target_ref_id !== null) {
2094 $this->ctrl->setParameterByClass($create_target_class, 'crtcb', (string) $redirect_target_ref_id);
2095 }
2096
2097 $this->lng->loadLanguageModule('wsp');
2098 $this->lng->loadLanguageModule('rep');
2099 $this->lng->loadLanguageModule('cntr');
2100
2101 $elements = $this->initAddNewItemElementsFromNewItemGroups(
2102 $create_target_class,
2105 $subtypes
2106 );
2107 if ($elements === []) {
2108 $elements = $this->initAddnewItemElementsFromDefaultGroups(
2109 $create_target_class,
2111 $subtypes
2112 );
2113 }
2114
2115 $this->ctrl->clearParameterByClass(self::class, 'crtcb');
2116 return $elements;
2117 }
2118
2120 string $create_target_class,
2121 array $new_item_groups,
2122 array $new_item_groups_subitems,
2123 array $subtypes
2124 ): array {
2125 if ($new_item_groups === []) {
2126 return [];
2127 }
2128
2129 $new_item_groups[0] = $this->lng->txt('rep_new_item_group_other');
2130 $add_new_item_elements = [];
2131 foreach ($new_item_groups as $group_id => $group) {
2132 if (empty($new_item_groups_subitems[$group_id])) {
2133 continue;
2134 }
2135 $group_element = $this->buildGroup(
2136 $create_target_class,
2137 $new_item_groups_subitems[$group_id],
2138 $group['title'] ?? $group,
2139 $subtypes
2140 );
2141
2142 if ($group_element !== null) {
2143 $add_new_item_elements[] = $group_element;
2144 }
2145 }
2146
2147 return $add_new_item_elements;
2148 }
2149
2151 string $create_target_class,
2152 array $default_groups,
2153 array $subtypes
2154 ): array {
2155 $add_new_item_elements = [];
2156 $grouped_types = [];
2157
2158 foreach ($default_groups['groups'] as $group_id => $group) {
2159 $obj_types_in_group = array_keys(
2160 array_filter(
2161 $default_groups['items'],
2162 fn($item_group_id) => $item_group_id === $group_id
2163 )
2164 );
2165 $grouped_types = array_merge($grouped_types, $obj_types_in_group);
2166
2167 $group_element = $this->buildGroup(
2168 $create_target_class,
2169 $obj_types_in_group,
2170 $group['title'],
2171 $subtypes
2172 );
2173
2174 if ($group_element !== null) {
2175 $add_new_item_elements[$group['pos']] = $group_element;
2176 }
2177 }
2178
2179 $ungrouped_types = array_diff(array_keys($subtypes), $grouped_types);
2180 if ($ungrouped_types !== []) {
2181 $add_new_item_elements[] = $this->buildGroup(
2182 $create_target_class,
2183 $ungrouped_types,
2184 $this->lng->txt('rep_new_item_group_other'),
2185 $subtypes
2186 );
2187 }
2188
2189 return $add_new_item_elements;
2190 }
2191
2192 protected function buildGroup(
2193 string $create_target_class,
2194 array $obj_types_in_group,
2195 string $title,
2196 array $subtypes
2197 ): ?AddNewItemElement {
2198 $add_new_items_content_array = $this->buildSubItemsForGroup(
2199 $create_target_class,
2200 $obj_types_in_group,
2201 $subtypes
2202 );
2203 if ($add_new_items_content_array === []) {
2204 return null;
2205 }
2206 return new AddNewItemElement(
2208 $title,
2209 null,
2210 null,
2211 $add_new_items_content_array
2212 );
2213 }
2214
2215 private function buildSubItemsForGroup(
2216 string $create_target_class,
2217 array $obj_types_in_group,
2218 array $subtypes
2219 ): array {
2220 $add_new_items_content_array = [];
2221 foreach ($obj_types_in_group as $type) {
2222 if (!array_key_exists($type, $subtypes)) {
2223 continue;
2224 }
2225 $subitem = $subtypes[$type];
2226 $this->ctrl->setParameterByClass($create_target_class, 'new_type', $type);
2227 $add_new_items_content_array[$subitem['pos']] = new AddNewItemElement(
2228 AddNewItemElementTypes::Object,
2229 $this->getTranslatedObjectTypeNameFromItemArray($subitem),
2230 empty($subitem['plugin'])
2231 ? $this->ui_factory->symbol()->icon()->standard($type, '')
2232 : $this->ui_factory->symbol()->icon()->custom(
2234 ''
2235 ),
2236 new URI(
2237 ILIAS_HTTP_PATH . '/' . $this->ctrl->getLinkTargetByClass($create_target_class, 'create')
2238 )
2239 );
2240 $this->ctrl->clearParameterByClass($create_target_class, 'new_type', $type);
2241 }
2242 ksort($add_new_items_content_array);
2243 return $add_new_items_content_array;
2244 }
2245
2246 private function checkWritePermissionOnRefIdArray(array $ref_ids): bool
2247 {
2248 foreach ($ref_ids as $ref_id) {
2249 if (!$this->access->checkAccess('write', '', $ref_id)) {
2250 return false;
2251 }
2252 }
2253 return true;
2254 }
2255
2256 private function getTranslatedObjectTypeNameFromItemArray(array $item_array): string
2257 {
2258 return empty($item_array['plugin'])
2259 ? $this->lng->txt('obj_' . $item_array['lng'])
2260 : ilObjectPlugin::lookupTxtById($item_array['lng'], 'obj_' . $item_array['lng']);
2261 }
2262}
$filename
Definition: buildRTE.php:78
$location
Definition: buildRTE.php:22
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
Builds data types.
Definition: Factory.php:36
The scope of this class is split ilias-conform URI's into components.
Definition: URI.php:35
Mime type determination.
Definition: MimeType.php:30
const IL_SCREEN_SIDE
const IL_COL_RIGHT
const IL_SCREEN_FULL
const IL_COL_LEFT
error(string $a_errmsg)
TableGUI class for sub items listed in repository administration.
static _recordReadEvent(string $a_type, int $a_ref_id, int $obj_id, int $usr_id, $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.
Class ilCommonActionDispatcherGUI.
Class ilContainerGUI This is a base GUI class for all container objects in ILIAS: root folder,...
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
static getInstanceByObjectType(string $a_obj_type)
Error Handling & global info handling.
Base class for ILIAS Exception handling.
Manages favourites, currently the interface for other components, needs discussion.
Import class.
language handling
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.
parses the objects.xml it handles the xml-description of all ilias objects
Base exception class for object service.
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
static _gotoSharedWorkspaceNode(int $wsp_id)
confirmedDeleteObject()
confirmed deletion of object -> objects are moved to trash or deleted immediately,...
const UPLOAD_TYPE_UPLOAD_DIRECTORY
buildAddNewItemElements(array $subtypes, string $create_target_class=ilRepositoryGUI::class, ?int $redirect_target_ref_id=null,)
cancelCreation()
cancel create action and go back to repository parent
ilAccessHandler $access
Refinery $refinery
getTranslatedObjectTypeNameFromItemArray(array $item_array)
ilGlobalTemplateInterface $tpl
setReturnLocation(string $cmd, string $location)
set specific return location for command
withReferences()
determines whether objects are referenced or not (got ref ids or not)
insertHeaderAction(?ilObjectListGUI $list_gui=null)
Insert header action into main template.
static _gotoRepositoryRoot(bool $raise_error=false)
Goto repository root.
initAddnewItemElementsFromDefaultGroups(string $create_target_class, array $default_groups, array $subtypes)
addExternalEditFormCustom(ilPropertyFormGUI $form)
getTabs()
@abstract overwrite in derived GUI class of your object type
getMultiObjectPropertiesManipulator()
RoundTrip $import_modal
buildRefIdsFromData(array $data)
GlobalHttpState $http
ilRbacReview $rbac_review
initAddNewItemElementsFromNewItemGroups(string $create_target_class, array $new_item_groups, array $new_item_groups_subitems, array $subtypes)
deleteObject(bool $error=false)
Display deletion confirmation screen.
afterUpdate()
Post (successful) object update hook.
UIFactory $ui_factory
retrieveAdditionalDidacticTemplateOptions()
setColumnSettings(ilColumnGUI $column_gui)
checkWritePermissionOnRefIdArray(array $ref_ids)
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)
deleteUploadedImportFile(string $path_to_uploaded_file_in_temp_dir)
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] does belong to the parent class The mode...
const ADMIN_MODE_SETTINGS
buildDeleletionModal(array $request_ids)
getAdminTabs()
administration tabs show only permissions and trash folder
addAvailabilityPeriodButtonToToolbar(ilToolbarGUI $toolbar)
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
showImportTypeSelectorModal(?string $file_to_import=null, ?string $path_to_uploaded_file_in_temp_dir=null)
getFileToImportFromImportFormData(array $data)
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
getCreationFormsHTML(StandardForm|ilPropertyFormGUI|array $form)
getCenterColumnHTML()
Get center column.
MultiPropertiesManipulator $multi_object_manipulator
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.
buildSubItemsForGroup(string $create_target_class, array $obj_types_in_group, array $subtypes)
isVisible(int $ref_id, string $type)
Filesystem $temp_file_system
RequestWrapper $request_wrapper
initDidacticTemplate(ilPropertyFormGUI $form)
extractFileTypeFromImportFilename(string $filename)
ilSetting $settings
addHeaderAction()
Add header action menu.
ILIAS Notes Service $notes_service
createObject()
create new object form
addAdminLocatorItems(bool $do_not_add_object=false)
should be overwritten to add object specific items (repository items are preloaded)
omitLocator(bool $omit=true)
ilObjectDefinition $obj_definition
putObjectInTree(ilObject $obj, ?int $parent_node_id=null)
Add object to tree at given position.
const SUPPORTED_IMPORT_MIME_TYPES
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.
CustomIconFactory $custom_icon_factory
retrieveFilesAndUploadTypeFromData(array $data)
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...
UIRenderer $ui_renderer
prepareOutput(bool $show_sub_objects=true)
string $requested_new_type
ilFavouritesManager $favourites
buildImportTypeSelectorInputs(?string $file_to_import=null, ?string $file_name_in_temp_dir=null)
buildImportTypeSelectorModal(?string $file_to_import=null, ?string $upload_file_name=null)
buildDeletionModalItems(array $ref_ids)
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.
buildInputsForAdditionalDeletionReferences(int $ref_id, ilPathGUI $path_gui)
showPossibleSubObjects()
show possible sub objects (pull down menu)
importFile(string $file_to_import, string $path_to_uploaded_file_in_temp_dir)
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.
parseDidacticTemplateVar(string $var, string $type)
RoundTrip $import_type_selector_modal
buildGroup(string $create_target_class, array $obj_types_in_group, string $title, array $subtypes)
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.
static lookupTxtById(string $plugin_id, string $lang_var)
Base class for all sub item list gui's.
Class ilObject Basic functions for all objects.
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 getIconForType(string $type)
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 class represents an option in a radio group.
Class ilRbacAdmin Core functions for role based access control.
static add(int $action, int $ref_id, array $diff, bool $source_ref_id=false)
static gatherFaPa(int $ref_id, array $role_ids, bool $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.
static clear(string $a_var)
ILIAS Setting Class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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...
addComponent(\ILIAS\UI\Component\Component $a_comp)
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
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...
const CLIENT_DATA_DIR
Definition: constants.php:46
const SYSTEM_FOLDER_ID
Definition: constants.php:35
const ROOT_FOLDER_ID
Definition: constants.php:32
$c
Definition: deliver.php:25
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
exit
$requested_ref_id
Definition: feed.php:40
The filesystem interface provides the public interface for the Filesystem service API consumer.
Definition: Filesystem.php:37
Interface GlobalHttpState.
Interface RequestWrapper.
setLocator()
Insert locator.
This describes a standard form.
Definition: Standard.php:30
This is what a radio-input looks like.
Definition: Radio.php:29
An entity that renders components to a string output.
Definition: Renderer.php:31
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
$ref_id
Definition: ltiauth.php:66
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:31
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
modal(string $title="", string $cancel_label="")
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
Class ilObjForumAdministration.
global $lng
Definition: privfeed.php:31
$_SERVER['HTTP_HOST']
Definition: raiseError.php:26
$ilErr
Definition: raiseError.php:33
if(!file_exists('../ilias.ini.php'))
global $DIC
Definition: shib_login.php:26