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