ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ilObjectGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
26 use ILIAS\Data\URI;
41 
49 {
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;
56  public const UPLOAD_TYPE_UPLOAD_DIRECTORY = 2;
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 
66  protected ilObjUser $user;
68  protected ilSetting $settings;
76  protected ilTree $tree;
77  protected ilCtrl $ctrl;
79  protected ilLanguage $lng;
80  protected ilTabsGUI $tabs_gui;
81  protected ILIAS $ilias;
84  protected Refinery $refinery;
86  protected CustomIconFactory $custom_icon_factory;
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 = "";
109  protected string $admin_mode = self::ADMIN_MODE_NONE;
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 
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['ilUser'];
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  {
252  return $this->object_service;
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  {
292  return $this->creation_mode;
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())) {
344  $this->enableDragDropFileUpload();
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  {
395  return new ilCommonActionDispatcherGUI(
397  $this->access,
398  $this->object->getType(),
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;
535  $tpl = $this->tpl;
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)
546  $ref_id = $this->requested_ref_id;
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 
622  $data = $this->buildDeleletionModal(
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  }
730  return ilObjectPlugin::lookupTxtById($this->requested_new_type, "obj_{$this->requested_new_type}");
731  }
732 
733  protected function getCreationFormTitle(): string
734  {
735  return $this->lng->txt($this->requested_new_type . '_new');
736  }
737 
738  protected function initCreateForm(string $new_type): StandardForm|ilPropertyFormGUI|array
739  {
740  $form_fields['title_and_description'] = (new ilObject())->getObjectProperties()->getPropertyTitleAndDescription()->toForm(
741  $this->lng,
742  $this->ui_factory->input()->field(),
744  );
745 
746  $didactic_templates = $this->didacticTemplatesToForm();
747 
748  if ($didactic_templates !== null) {
749  $form_fields['didactic_templates'] = $didactic_templates;
750  }
751 
752  return $this->ui_factory->input()->container()->form()->standard(
753  $this->ctrl->getFormAction($this, 'save'),
754  $form_fields
755  )->withSubmitLabel(
756  !$this->obj_definition->isPlugin($new_type)
757  ? $this->lng->txt($new_type . '_add')
759  $this->requested_new_type,
760  "{$this->requested_new_type}_add"
761  )
762  );
763  }
764 
765  protected function didacticTemplatesToForm(): ?Radio
766  {
767  $this->lng->loadLanguageModule('didactic');
768 
769  list($existing_exclusive, $options) = $this->buildDidacticTemplateOptions();
770 
771  if (sizeof($options) < 2) {
772  return null;
773  }
774 
775  $didactic_templates_radio = $this->ui_factory->input()->field()->radio($this->lng->txt('type'));
776 
777  foreach ($options as $value => $option) {
778  if ($existing_exclusive && $value == 'dtpl_0') {
779  //Skip default disabled if an exclusive template exists - Whatever the f*** that means!
780  continue;
781  }
782  $didactic_templates_radio = $didactic_templates_radio->withOption($value, $option[0], $option[1] ?? '');
783  }
784 
785  if (!$this->getCreationMode()) {
786  $value = 'dtpl_' . ilDidacticTemplateObjSettings::lookupTemplateId($this->object->getRefId());
787 
788  $didactic_templates_radio = $didactic_templates_radio->withValue($value);
789 
790  if (!in_array($value, array_keys($options)) || ($existing_exclusive && $value == "dtpl_0")) {
791  //add or rename actual value to not available
792  $options[$value] = [$this->lng->txt('not_available')];
793  }
794  } else {
795  if ($existing_exclusive) {
796  //if an exclusive template exists use the second template as default value
797  $keys = array_keys($options);
798  $didactic_templates_radio = $didactic_templates_radio->withValue($keys[1]);
799  } else {
800  $didactic_templates_radio = $didactic_templates_radio->withValue('dtpl_0');
801  }
802  }
803 
804  return $didactic_templates_radio;
805  }
806 
811  {
812  list($existing_exclusive, $options) = $this->buildDidacticTemplateOptions();
813 
814  if (sizeof($options) < 2) {
815  return $form;
816  }
817 
818  $type = new ilRadioGroupInputGUI(
819  $this->lng->txt('type'),
820  'didactic_type'
821  );
822  // workaround for containers in edit mode
823  if (!$this->getCreationMode()) {
824  $value = 'dtpl_' . ilDidacticTemplateObjSettings::lookupTemplateId($this->object->getRefId());
825 
826  $type->setValue($value);
827 
828  if (!in_array($value, array_keys($options)) || ($existing_exclusive && $value == "dtpl_0")) {
829  //add or rename actual value to not available
830  $options[$value] = [$this->lng->txt('not_available')];
831  }
832  } else {
833  if ($existing_exclusive) {
834  //if an exclusive template exists use the second template as default value - Whatever the f*** that means!
835  $keys = array_keys($options);
836  $type->setValue($keys[1]);
837  } else {
838  $type->setValue('dtpl_0');
839  }
840  }
841  $form->addItem($type);
842 
843  foreach ($options as $id => $data) {
844  $option = new ilRadioOption($data[0] ?? '', (string) $id, $data[1] ?? '');
845  if ($existing_exclusive && $id == 'dtpl_0') {
846  //set default disabled if an exclusive template exists
847  $option->setDisabled(true);
848  }
849 
850  $type->addOption($option);
851  }
852 
853  return $form;
854  }
855 
856  private function buildDidacticTemplateOptions(): array
857  {
858  $this->lng->loadLanguageModule('didactic');
859  $existing_exclusive = false;
860  $options = [];
861  $options['dtpl_0'] = [
862  $this->lng->txt('didactic_default_type'),
863  sprintf(
864  $this->lng->txt('didactic_default_type_info'),
865  $this->lng->txt('objs_' . $this->type)
866  )
867  ];
868 
869  $templates = ilDidacticTemplateSettings::getInstanceByObjectType($this->type)->getTemplates();
870  if ($templates) {
871  foreach ($templates as $template) {
872  if ($template->isEffective((int) $this->requested_ref_id)) {
873  $options["dtpl_" . $template->getId()] = [
874  $template->getPresentationTitle(),
875  $template->getPresentationDescription()
876  ];
877 
878  if ($template->isExclusive()) {
879  $existing_exclusive = true;
880  }
881  }
882  }
883  }
884 
885  return [$existing_exclusive, array_merge($options, $this->retrieveAdditionalDidacticTemplateOptions())];
886  }
887 
891  protected function retrieveAdditionalDidacticTemplateOptions(): array
892  {
893  return [];
894  }
895 
896  protected function addAdoptContentLinkToToolbar(): void
897  {
898  $this->toolbar->addComponent(
899  $this->ui_factory->link()->standard(
900  $this->lng->txt('cntr_adopt_content'),
901  $this->ctrl->getLinkTargetByClass(
902  'ilObjectCopyGUI',
903  'adoptContent'
904  )
905  )
906  );
907  }
908 
909  protected function addImportButtonToToolbar(): void
910  {
911  $modal = $this->import_modal ?? $this->buildImportModal();
912  $this->toolbar->addComponent(
913  $this->ui_factory->button()->standard(
914  $this->lng->txt('import'),
915  $modal->getShowSignal()
916  )
917  );
918 
919  $this->tpl->setVariable(
920  'IL_OBJECT_IMPORT_MODAL',
921  $this->ui_renderer->render(
922  $this->import_type_selector_modal === null
923  ? $modal
924  : [$modal, $this->import_type_selector_modal]
925  )
926  );
927  }
928 
929  private function buildImportModal(): RoundTrip
930  {
931  return $this->ui_factory->modal()
932  ->roundtrip(
933  $this->lng->txt('import'),
934  [],
935  $this->buildImportFormInputs(),
936  $this->ctrl->getFormAction($this, 'routeImportCmd')
937  )->withSubmitLabel($this->lng->txt('import'));
938  }
939 
941  ?string $file_to_import = null,
942  ?string $upload_file_name = null
943  ): Roundtrip {
944  return $this->ui_factory->modal()
945  ->roundtrip(
946  $this->lng->txt('select_object_type'),
947  [
948  $this->ui_factory->messageBox()->info(
949  $this->lng->txt('select_import_type_info')
950  )
951  ],
953  $file_to_import,
954  $upload_file_name
955  ),
956  $this->ctrl->getFormActionByClass(static::class, 'routeImportCmd')
957  )->withCloseWithKeyboard(false)
958  ->withSubmitLabel($this->lng->txt('import'));
959  }
960 
962  {
963  $toolbar->addSeparator();
964 
965  $toolbar->addComponent(
966  $this->getMultiObjectPropertiesManipulator()->getAvailabilityPeriodButton()
967  );
968  return $toolbar;
969  }
970 
971  public function editAvailabilityPeriodObject(): void
972  {
973  $item_ref_ids = $this->retriever->getSelectedIdsFromObjectList();
974  if (!$this->checkPermissionBool('write')
975  && !$this->checkWritePermissionOnRefIdArray($item_ref_ids)) {
976  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('msg_no_perm_write'));
977  return;
978  }
979 
980  $availability_period_modal = $this->getMultiObjectPropertiesManipulator()->getEditAvailabilityPeriodPropertiesModal(
981  $item_ref_ids,
982  $this
983  );
984  if ($availability_period_modal !== null) {
985  $this->tpl->setVariable(
986  'IL_OBJECT_EPHEMRAL_MODALS',
987  $this->ui_renderer->render(
988  $availability_period_modal->withOnLoad(
989  $availability_period_modal->getShowSignal()
990  )
991  )
992  );
993  }
994  $this->renderObject();
995  }
996 
997  public function saveAvailabilityPeriodObject(): void
998  {
999  $availability_period_modal = $this->getMultiObjectPropertiesManipulator()->saveEditAvailabilityPeriodPropertiesModal(
1000  $this,
1001  fn($ref_ids): bool => $this->checkPermissionBool('write') || $this->checkWritePermissionOnRefIdArray($ref_ids),
1002  $this->request
1003  );
1004  if ($availability_period_modal === true) {
1005  $this->tpl->setOnScreenMessage('success', $this->lng->txt('availability_period_changed'));
1006  } elseif ($availability_period_modal === false) {
1007  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('msg_no_perm_write'));
1008  } else {
1009  $this->tpl->setVariable(
1010  'IL_OBJECT_EPHEMRAL_MODALS',
1011  $this->ui_renderer->render(
1012  $availability_period_modal->withOnLoad(
1013  $availability_period_modal->getShowSignal()
1014  )
1015  )
1016  );
1017  }
1018  $this->renderObject();
1019  }
1020 
1024  public function cancelCreation(): void
1025  {
1026  $this->ctrl->redirectByClass("ilrepositorygui", "");
1027  }
1028 
1029  public function saveObject(): void
1030  {
1031  // create permission is already checked in createObject. This check here is done to prevent hacking attempts
1032  if (!$this->checkPermissionBool("create", "", $this->requested_new_type)) {
1033  $this->error->raiseError($this->lng->txt("no_create_permission"), $this->error->MESSAGE);
1034  }
1035 
1036  $this->lng->loadLanguageModule($this->requested_new_type);
1037  $this->ctrl->setParameter($this, "new_type", $this->requested_new_type);
1038 
1039  $form = $this->initCreateForm($this->requested_new_type)
1040  ->withRequest($this->request);
1041  $data = $form->getData();
1042  if ($data === null) {
1043  $this->tpl->setContent($this->getCreationFormsHTML($form));
1044  return;
1045  }
1046 
1047  $this->ctrl->setParameter($this, 'new_type', '');
1048 
1049  $class_name = 'ilObj' . $this->obj_definition->getClassName($this->requested_new_type);
1050 
1051  $new_obj = new $class_name();
1052  $new_obj->setType($this->requested_new_type);
1053  $new_obj->processAutoRating();
1054  $new_obj->setTitle($data['title_and_description']->getTitle());
1055  $new_obj->setDescription($data['title_and_description']->getDescription());
1056  $new_obj->create();
1057 
1058  $new_obj->getObjectProperties()->storePropertyTitleAndDescription(
1059  $data['title_and_description']
1060  );
1061 
1062  $this->putObjectInTree($new_obj);
1063 
1064  $dtpl = $data['didactic_templates'] ?? null;
1065  if ($dtpl !== null) {
1066  $dtpl_id = $this->parseDidacticTemplateVar($dtpl, 'dtpl');
1067  $new_obj->applyDidacticTemplate($dtpl_id);
1068  }
1069 
1070  $this->afterSave($new_obj);
1071  }
1072 
1078  public function getDidacticTemplateVar(string $type): int
1079  {
1080  $create_form = $this->initCreateForm($this->type);
1081  if ($create_form instanceof StandardForm) {
1082  try {
1083  $data = $create_form->withRequest($this->request)->getData();
1084  return isset($data['didactic_templates'])
1085  ? $this->parseDidacticTemplateVar($data['didactic_templates'], $type)
1086  : 0;
1087  } catch (InvalidArgumentException $e) {
1088  }
1089  }
1090 
1091  if (!$this->post_wrapper->has('didactic_type')) {
1092  return 0;
1093  }
1094 
1095  $tpl = $this->post_wrapper->retrieve('didactic_type', $this->refinery->kindlyTo()->string());
1096  return $this->parseDidacticTemplateVar($tpl, $type);
1097  }
1098 
1099  protected function parseDidacticTemplateVar(string $var, string $type): int
1100  {
1101  if (substr($var, 0, strlen($type) + 1) != $type . "_") {
1102  return 0;
1103  }
1104 
1105  return (int) substr($var, strlen($type) + 1);
1106  }
1107 
1111  public function putObjectInTree(ilObject $obj, ?int $parent_node_id = null): void
1112  {
1113  if (!$parent_node_id) {
1114  $parent_node_id = $this->requested_ref_id;
1115  }
1116 
1117  // add new object to custom parent container
1118  if ($this->requested_crtptrefid > 0) {
1119  $parent_node_id = $this->requested_crtptrefid;
1120  }
1121 
1122  $obj->createReference();
1123  $obj->putInTree($parent_node_id);
1124  $obj->setPermissions($parent_node_id);
1125 
1126  $this->obj_id = $obj->getId();
1127  $this->ref_id = $obj->getRefId();
1128 
1129  // BEGIN ChangeEvent: Record save object.
1130  ilChangeEvent::_recordWriteEvent($this->obj_id, $this->user->getId(), 'create');
1131  // END ChangeEvent: Record save object.
1132 
1133  // rbac log
1134  $rbac_log_roles = $this->rbac_review->getParentRoleIds($this->ref_id, false);
1135  $rbac_log = ilRbacLog::gatherFaPa($this->ref_id, array_keys($rbac_log_roles), true);
1136  ilRbacLog::add(ilRbacLog::CREATE_OBJECT, $this->ref_id, $rbac_log);
1137 
1138  // use forced callback after object creation
1139  $this->callCreationCallback($obj, $this->obj_definition, $this->requested_crtcb);
1140  }
1141 
1145  protected function afterSave(ilObject $new_object): void
1146  {
1147  $this->tpl->setOnScreenMessage("success", $this->lng->txt("object_added"), true);
1148  $this->ctrl->returnToParent($this);
1149  }
1150 
1151  public function editObject(): void
1152  {
1153  if (!$this->checkPermissionBool("write")) {
1154  $this->error->raiseError($this->lng->txt("msg_no_perm_write"), $this->error->MESSAGE);
1155  }
1156 
1157  $this->tabs_gui->activateTab("settings");
1158 
1159  $form = $this->initEditForm();
1160  $values = $this->getEditFormValues();
1161  if ($values) {
1162  $form->setValuesByArray($values);
1163  }
1164 
1165  $this->addExternalEditFormCustom($form);
1166 
1167  $this->tpl->setContent($form->getHTML());
1168  }
1169 
1170  public function addExternalEditFormCustom(ilPropertyFormGUI $form): void
1171  {
1172  // has to be done AFTER setValuesByArray() ...
1173  }
1174 
1175  protected function initEditForm(): ilPropertyFormGUI
1176  {
1177  $lng = $this->lng;
1178 
1179  $lng->loadLanguageModule($this->object->getType());
1180 
1181  $form = new ilPropertyFormGUI();
1182  $form->setFormAction($this->ctrl->getFormAction($this, "update"));
1183  $form->setTitle($this->lng->txt($this->object->getType() . "_edit"));
1184 
1185  $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
1186  $ti->setSize(min(40, ilObject::TITLE_LENGTH));
1187  $ti->setMaxLength(ilObject::TITLE_LENGTH);
1188  $ti->setRequired(true);
1189  $form->addItem($ti);
1190 
1191  $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
1192  $ta->setCols(40);
1193  $ta->setRows(2);
1194  $ta->setMaxNumOfChars(ilObject::LONG_DESC_LENGTH);
1195  $form->addItem($ta);
1196 
1197  $this->initEditCustomForm($form);
1198 
1199  $form->addCommandButton("update", $this->lng->txt("save"));
1200 
1201  return $form;
1202  }
1203 
1207  protected function initEditCustomForm(ilPropertyFormGUI $a_form): void
1208  {
1209  }
1210 
1211  protected function getEditFormValues(): array
1212  {
1213  $values["title"] = $this->object->getTitle();
1214  $values["desc"] = $this->object->getLongDescription();
1215  $this->getEditFormCustomValues($values);
1216  return $values;
1217  }
1218 
1222  protected function getEditFormCustomValues(array &$a_values): void
1223  {
1224  }
1225 
1229  public function updateObject(): void
1230  {
1231  if (!$this->checkPermissionBool("write")) {
1232  $this->error->raiseError($this->lng->txt("permission_denied"), $this->error->MESSAGE);
1233  }
1234 
1235  $form = $this->initEditForm();
1236  if ($form->checkInput() && $this->validateCustom($form)) {
1237  $this->updateCustom($form);
1238  $this->object->setTitle($form->getInput('title'));
1239  $this->object->setDescription($form->getInput('desc'));
1240  $this->object->update();
1241 
1242  $this->afterUpdate();
1243  return;
1244  }
1245 
1246  // display form again to correct errors
1247  $this->tabs_gui->activateTab("settings");
1248  $form->setValuesByPost();
1249  $this->tpl->setContent($form->getHTML());
1250  }
1251 
1255  protected function validateCustom(ilPropertyFormGUI $form): bool
1256  {
1257  return true;
1258  }
1259 
1263  protected function updateCustom(ilPropertyFormGUI $form): void
1264  {
1265  }
1266 
1270  protected function afterUpdate(): void
1271  {
1272  $this->tpl->setOnScreenMessage("success", $this->lng->txt("msg_obj_modified"), true);
1273  $this->ctrl->redirect($this, "edit");
1274  }
1275 
1276  private function buildImportFormInputs(): array
1277  {
1278  $trafo = $this->refinery->custom()->transformation(
1279  function ($vs): array {
1280  if ($vs === null) {
1281  return null;
1282  }
1283  if (!isset($vs[1])) {
1284  return [self::UPLOAD_TYPE_LOCAL => $vs[0]];
1285  } elseif ((int) $vs[1][0] === self::UPLOAD_TYPE_LOCAL) {
1286  return [self::UPLOAD_TYPE_LOCAL => $vs[1][0][0]];
1287  } else {
1288  $upload_factory = new ilImportDirectoryFactory();
1289  $export_upload = $upload_factory->getInstanceForComponent(ilImportDirectoryFactory::TYPE_EXPORT);
1290  $type = $this->extractFileTypeFromImportFilename($vs[1][0]) ?? '';
1291  $file = $export_upload->getAbsolutePathForHash($this->user->getId(), $type, $vs[1][0]);
1292  return [
1293  self::UPLOAD_TYPE_UPLOAD_DIRECTORY => $file
1294  ];
1295  }
1296  }
1297  );
1298 
1299  $import_directory_factory = new ilImportDirectoryFactory();
1300  $upload_files = $import_directory_factory->getInstanceForComponent(ilImportDirectoryFactory::TYPE_EXPORT)
1301  ->getFilesFor($this->user->getId());
1302 
1303  $field_factory = $this->ui_factory->input()->field();
1304 
1305  $file_upload_input = $field_factory->file(new \ImportUploadHandlerGUI(), $this->lng->txt('import_file'))
1306  ->withAcceptedMimeTypes(self::SUPPORTED_IMPORT_MIME_TYPES)
1307  ->withRequired(true)
1308  ->withMaxFiles(1);
1309 
1310  if ($upload_files !== []) {
1311  $this->lng->loadLanguageModule('content');
1312 
1313  $file_upload_input = $field_factory->switchableGroup(
1314  [
1315  self::UPLOAD_TYPE_LOCAL => $field_factory->group(
1316  [$file_upload_input],
1317  $this->lng->txt('cont_choose_local')
1318  ),
1319  self::UPLOAD_TYPE_UPLOAD_DIRECTORY => $field_factory->group(
1320  [$field_factory->select($this->lng->txt('cont_uploaded_file'), $upload_files)->withRequired(true)],
1321  $this->lng->txt('cont_choose_upload_dir'),
1322  )
1323  ],
1324  $this->lng->txt('cont_choose_file_source')
1325  );
1326  }
1327 
1328  return [
1329  'upload' => $file_upload_input->withAdditionalTransformation($trafo)
1330  ];
1331  }
1332 
1334  ?string $file_to_import = null,
1335  ?string $file_name_in_temp_dir = null
1336  ): array {
1337  $ff = $this->ui_factory->input()->field();
1338 
1339  $possible_sub_objects = array_map(
1340  fn(array $v): string => $this->getTranslatedObjectTypeNameFromItemArray($v),
1341  $this->object->getPossibleSubObjects()
1342  );
1343 
1344  asort($possible_sub_objects);
1345 
1346  return [
1347  'type' => $ff->select(
1348  $this->lng->txt('select_object_type'),
1349  $possible_sub_objects
1350  )->withRequired(true),
1351  'file_to_import' => $ff->hidden()->withValue($file_to_import),
1352  'temp_file' => $ff->hidden()->withValue($file_name_in_temp_dir)
1353  ];
1354  }
1355 
1356  protected function routeImportCmdObject(): void
1357  {
1358  if ($this->request_wrapper->has('step')) {
1360  } else {
1361  $data = $this->retrieveAndCheckImportData();
1362  }
1363 
1364  if ($data === null) {
1365  $this->viewObject();
1366  return;
1367  }
1368 
1369  [$new_type, $file_to_import, $path_to_uploaded_file_in_temp_dir] = $this
1370  ->retrieveFilesAndUploadTypeFromData($data);
1371 
1372  if ($new_type === null) {
1374  basename($file_to_import),
1375  $path_to_uploaded_file_in_temp_dir
1376  );
1377  return;
1378  }
1379 
1380  // create permission is already checked in createObject. This check here is done to prevent hacking attempts
1381  if (!$this->checkPermissionBool('create', '', $new_type)
1382  || !in_array($new_type, $this->obj_definition->getAllObjects())
1383  || !array_key_exists($new_type, $this->object->getPossibleSubObjects())) {
1384  $this->deleteUploadedImportFile($path_to_uploaded_file_in_temp_dir);
1385  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('no_create_permission'));
1386  $this->viewObject();
1387  return;
1388  }
1389 
1390  $this->lng->loadLanguageModule($new_type);
1391  $this->ctrl->setParameter($this, 'new_type', $new_type);
1392 
1393  $target_class = 'ilObj' . $this->obj_definition->getClassName($new_type) . 'GUI';
1394  try {
1395  $target = new $target_class('', 0, false, false);
1396  } catch (TypeError $e) {
1397  $target = new $target_class(0, ilObject2GUI::REPOSITORY_NODE_ID, $this->getRefId());
1398  }
1399  $target->importFile($file_to_import, $path_to_uploaded_file_in_temp_dir);
1400  $this->ctrl->clearParameterByClass(get_class($this), 'new_type');
1401  $this->viewObject();
1402  }
1403 
1404  protected function importFile(string $file_to_import, string $path_to_uploaded_file_in_temp_dir): void
1405  {
1406  if ($this instanceof ilContainerGUI) {
1407  $imp = new ilImportContainer($this->requested_ref_id);
1408  } else {
1409  $imp = new ilImport($this->requested_ref_id);
1410  }
1411 
1412  try {
1413  $new_id = $imp->importObject(
1414  null,
1415  $file_to_import,
1416  basename($file_to_import),
1417  $this->type,
1418  '',
1419  true
1420  );
1421  } catch (ilException $e) {
1422  $this->tmp_import_dir = $imp->getTemporaryImportDir();
1423  $this->tpl->setOnScreenMessage(
1424  'failure',
1425  $this->lng->txt('obj_import_file_error') . ' <br />' . $e->getMessage()
1426  );
1427  $this->deleteUploadedImportFile($path_to_uploaded_file_in_temp_dir);
1428  return;
1429  }
1430 
1431  if ($new_id === null
1432  || $new_id === 0) {
1433  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('import_file_not_valid_here'));
1434  $this->deleteUploadedImportFile($path_to_uploaded_file_in_temp_dir);
1435  return;
1436  }
1437 
1438  $this->ctrl->setParameter($this, 'new_type', '');
1439 
1440  $new_obj = ilObjectFactory::getInstanceByObjId($new_id);
1441  // put new object id into tree - already done in import for containers
1442  if (!$this->obj_definition->isContainer($this->type)) {
1443  $this->putObjectInTree($new_obj);
1444  } else {
1445  $ref_ids = ilObject::_getAllReferences($new_obj->getId());
1446  if (count($ref_ids) === 1) {
1447  $new_obj->setRefId((int) current($ref_ids));
1448  }
1449  $this->callCreationCallback($new_obj, $this->obj_definition, $this->requested_crtcb); // see #24244
1450  }
1451 
1452  if ($path_to_uploaded_file_in_temp_dir !== ''
1453  && $this->temp_file_system->hasDir($path_to_uploaded_file_in_temp_dir)) {
1454  $this->temp_file_system->deleteDir($path_to_uploaded_file_in_temp_dir);
1455  }
1456 
1457  $this->afterImport($new_obj);
1458  $this->ctrl->setParameterByClass(get_class($new_obj), 'ref_id', $new_obj->getRefId());
1459  $this->ctrl->redirectByClass(get_class($new_obj));
1460  }
1461 
1462  protected function deleteUploadedImportFile(string $path_to_uploaded_file_in_temp_dir): void
1463  {
1464  if ($path_to_uploaded_file_in_temp_dir !== ''
1465  && $this->temp_file_system->hasDir($path_to_uploaded_file_in_temp_dir)) {
1466  $this->temp_file_system->deleteDir($path_to_uploaded_file_in_temp_dir);
1467  }
1468  }
1469 
1470  private function retrieveAndCheckImportData(): ?array
1471  {
1472  $modal = $this->buildImportModal()->withRequest($this->request);
1473  $data = $modal->getData();
1474 
1475  if ($data !== null) {
1476  return $data;
1477  }
1478 
1479  $this->import_modal = $modal->withOnLoad($modal->getShowSignal());
1480  return null;
1481  }
1482 
1483  private function retrieveAndCheckImportTypeData(): ?array
1484  {
1485  $modal = $this->buildImportTypeSelectorModal()->withRequest($this->request);
1486  $data = $modal->getData();
1487 
1488  if ($data !== null) {
1489  return $data;
1490  }
1491 
1492  $this->import_type_selector_modal = $modal->withOnLoad($modal->getShowSignal());
1493  return null;
1494  }
1495 
1497  ?string $file_to_import = null,
1498  ?string $path_to_uploaded_file_in_temp_dir = null
1499  ): void {
1500  $this->ctrl->setParameterByClass(static::class, 'step', 'select_type');
1501  $modal = $this->buildImportTypeSelectorModal(
1502  $file_to_import,
1503  $path_to_uploaded_file_in_temp_dir
1504  );
1505  $this->ctrl->clearParameterByClass(static::class, 'step');
1506  $this->import_type_selector_modal = $modal->withOnLoad($modal->getShowSignal());
1507  $this->viewObject();
1508  return;
1509  }
1510 
1511  private function retrieveFilesAndUploadTypeFromData(array $data): array
1512  {
1513  if (isset($data['type']) && isset($data['file_to_import']) && isset($data['temp_file'])) {
1514  return [
1515  $data['type'],
1516  implode(
1517  DIRECTORY_SEPARATOR,
1518  [CLIENT_DATA_DIR, 'temp', $data['temp_file'], $data['file_to_import']]
1519  ),
1520  $data['temp_file']
1521  ];
1522  }
1523  $file_to_import = $this->getFileToImportFromImportFormData($data);
1524  $path_to_uploaded_file_in_temp_dir = '';
1525  if (array_key_first($data['upload']) === self::UPLOAD_TYPE_LOCAL) {
1526  $path_to_uploaded_file_in_temp_dir = $data['upload'][self::UPLOAD_TYPE_LOCAL];
1527  }
1528 
1529  return [
1530  $this->extractFileTypeFromImportFilename(basename($file_to_import)),
1531  $file_to_import,
1532  $path_to_uploaded_file_in_temp_dir
1533  ];
1534  }
1535 
1536  private function extractFileTypeFromImportFilename(string $filename): ?string
1537  {
1538  $matches = [];
1539  $result = preg_match('/[0-9]{10}__[0-9]{1,6}__([a-z]{1,4})_[0-9]{2,9}.zip/', $filename, $matches);
1540  if ($result === false
1541  || $result === 0
1542  || !isset($matches[1])) {
1543  return null;
1544  }
1545  return $matches[1];
1546  }
1547 
1549  {
1550  $upload_data = $data['upload'];
1551  if (array_key_first($upload_data) === self::UPLOAD_TYPE_LOCAL
1552  && $this->temp_file_system->hasDir($upload_data[self::UPLOAD_TYPE_LOCAL])) {
1553  $files = $this->temp_file_system->listContents($upload_data[self::UPLOAD_TYPE_LOCAL]);
1554  return CLIENT_DATA_DIR . DIRECTORY_SEPARATOR
1555  . 'temp' . DIRECTORY_SEPARATOR
1556  . $files[0]->getPath();
1557  }
1558  return $upload_data[self::UPLOAD_TYPE_UPLOAD_DIRECTORY];
1559  }
1560 
1564  protected function afterImport(ilObject $new_object): void
1565  {
1566  $this->tpl->setOnScreenMessage("success", $this->lng->txt("object_added"), true);
1567  $this->ctrl->returnToParent($this);
1568  }
1569 
1573  public function getFormAction(string $cmd, string $default_form_action = ""): string
1574  {
1575  if ($this->form_action[$cmd] != "") {
1576  return $this->form_action[$cmd];
1577  }
1578 
1579  return $default_form_action;
1580  }
1581 
1582  protected function setFormAction(string $cmd, string $form_action): void
1583  {
1584  $this->form_action[$cmd] = $form_action;
1585  }
1586 
1590  protected function getReturnLocation(string $cmd, string $default_location = ""): string
1591  {
1592  if (($this->return_location[$cmd] ?? "") !== "") {
1593  return $this->return_location[$cmd];
1594  } else {
1595  return $default_location;
1596  }
1597  }
1598 
1602  protected function setReturnLocation(string $cmd, string $location): void
1603  {
1604  $this->return_location[$cmd] = $location;
1605  }
1606 
1610  protected function getTargetFrame(string $cmd, string $default_target_frame = ""): string
1611  {
1612  if (isset($this->target_frame[$cmd]) && $this->target_frame[$cmd] != "") {
1613  return $this->target_frame[$cmd];
1614  }
1615 
1616  if (!empty($default_target_frame)) {
1617  return "target=\"" . $default_target_frame . "\"";
1618  }
1619 
1620  return "";
1621  }
1622 
1626  protected function setTargetFrame(string $cmd, string $target_frame): void
1627  {
1628  $this->target_frame[$cmd] = "target=\"" . $target_frame . "\"";
1629  }
1630 
1631  public function isVisible(int $ref_id, string $type): bool
1632  {
1633  $visible = $this->checkPermissionBool("visible,read", "", "", $ref_id);
1634 
1635  if ($visible && $type == 'crs') {
1636  $tree = $this->tree;
1637  if ($crs_id = $tree->checkForParentType($ref_id, 'crs')) {
1638  if (!$this->checkPermissionBool("write", "", "", $crs_id)) {
1639  // Show only activated courses
1640  $tmp_obj = ilObjectFactory::getInstanceByRefId($crs_id, false);
1641 
1642  if (!$tmp_obj->isActivated()) {
1643  unset($tmp_obj);
1644  $visible = false;
1645  }
1646  }
1647  }
1648  }
1649 
1650  return $visible;
1651  }
1652 
1656  public function viewObject(): void
1657  {
1658  $this->checkPermission('visible') && $this->checkPermission('read');
1659 
1660  $this->tabs_gui->activateTab('view');
1661 
1663  $this->object->getType(),
1664  $this->object->getRefId(),
1665  $this->object->getId(),
1666  $this->user->getId()
1667  );
1668 
1669  if (!$this->withReferences()) {
1670  $this->ctrl->setParameter($this, 'obj_id', $this->obj_id);
1671  }
1672 
1673  $itab = new ilAdminSubItemsTableGUI(
1674  $this,
1675  "view",
1676  $this->requested_ref_id,
1677  $this->checkPermissionBool('write')
1678  );
1679 
1680  $this->tpl->setContent($itab->getHTML());
1681  }
1682 
1688  public function deleteObject(bool $error = false): void
1689  {
1690  $request_ids = [];
1691  if ($this->post_wrapper->has('id')) {
1692  $request_ids = $this->post_wrapper->retrieve(
1693  'id',
1694  $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
1695  );
1696  }
1697 
1698  if (
1699  $this->request_wrapper->has('item_ref_id')
1700  && $this->request_wrapper->retrieve('item_ref_id', $this->refinery->kindlyTo()->string()) !== ""
1701  ) {
1702  $request_ids = [$this->request_wrapper->retrieve('item_ref_id', $this->refinery->kindlyTo()->int())];
1703  }
1704 
1705  if ($request_ids === []) {
1706  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('no_checkbox'), true);
1707  $this->ctrl->returnToParent($this);
1708  }
1709 
1710  $modal = $this->buildDeleletionModal(array_unique($request_ids));
1711  $this->tpl->setVariable(
1712  'IL_OBJECT_EPHEMRAL_MODALS',
1713  $this->ui_renderer->render(
1714  $modal->withOnLoad($modal->getShowSignal())
1715  )
1716  );
1717  $this->renderObject();
1718  }
1719 
1720  private function buildDeleletionModal(array $request_ids): \ILIAS\UI\Component\Modal\RoundTrip
1721  {
1722  [$listing_items, $inputs, $has_additional_references] = $this->buildDeletionModalItems($request_ids);
1723 
1724  $msg = $this->lng->txt('info_delete_sure');
1725  if (!$this->settings->get('enable_trash')) {
1726  $msg .= "<br/>" . $this->lng->txt('info_delete_warning_no_trash');
1727  }
1728 
1729  $content = [
1730  $this->ui_factory->messageBox()->confirmation($msg),
1731  $this->ui_factory->listing()->unordered($listing_items)
1732  ];
1733 
1734  if ($has_additional_references) {
1735  $content[] = $this->ui_factory->messageBox()->confirmation(
1736  $this->lng->txt('multiple_reference_deletion_info') . ' '
1737  . $this->lng->txt('rep_multiple_reference_deletion_instruction')
1738  );
1739  }
1740 
1741  $this->ctrl->setParameterByClass(static::class, 'id', implode(',', $request_ids));
1742  $target_url = $this->ctrl->getFormActionByClass(static::class, 'confirmedDelete');
1743  $this->ctrl->clearParameterByClass(static::class, 'id');
1744 
1745  return $this->ui_factory->modal()->roundtrip(
1746  $this->lng->txt('confirm'),
1747  $content,
1748  $inputs,
1749  $target_url
1750  )->withSubmitLabel($this->lng->txt('delete'));
1751  }
1752 
1753  private function buildDeletionModalItems(array $ref_ids): array
1754  {
1755  $path_gui = new ilPathGUI();
1756  $path_gui->enableTextOnly(true);
1757  $path_gui->enableHideLeaf(false);
1758  return array_reduce(
1759  $ref_ids,
1760  function (array $c, int $v) use ($path_gui): array {
1761  $c[0][] = ilObject::_lookupTitle(
1763  );
1764  $c[1][] = $this->ui_factory->input()->field()->hidden()->withValue($v);
1765 
1766  $other_references = $this->buildInputsForAdditionalDeletionReferences($v, $path_gui);
1767  if ($other_references !== []) {
1768  $c[1][] = $this->ui_factory->input()->field()->multiSelect(
1771  ),
1772  $other_references
1773  );
1774  $c[2] = true;
1775  }
1776  return $c;
1777  },
1778  [[], [], false]
1779  );
1780  }
1781 
1782  private function buildInputsForAdditionalDeletionReferences(int $ref_id, ilPathGUI $path_gui): array
1783  {
1784  return array_reduce(
1786  function (array $c, int $v) use ($ref_id, $path_gui): array {
1787  if ($v !== $ref_id
1788  && !$this->tree->isDeleted($v)
1789  && $this->access->checkAccess('delete', '', $v)) {
1790  $c[$v] = $path_gui->getPath(ROOT_FOLDER_ID, $v);
1791  }
1792  return $c;
1793  },
1794  []
1795  );
1796  }
1797 
1801  protected function showPossibleSubObjects(): void
1802  {
1803  if ($this->sub_objects == "") {
1804  $sub_objects = $this->obj_definition->getCreatableSubObjects(
1805  $this->object->getType(),
1808  );
1809  } else {
1810  $sub_objects = $this->sub_objects;
1811  }
1812 
1813  $subobj = [];
1814  if (count($sub_objects) > 0) {
1815  foreach ($sub_objects as $row) {
1816  $count = 0;
1817  if ($row["max"] > 0) {
1818  //how many elements are present?
1819  for ($i = 0; $i < count($this->data["ctrl"]); $i++) {
1820  if ($this->data["ctrl"][$i]["type"] == $row["name"]) {
1821  $count++;
1822  }
1823  }
1824  }
1825 
1826  if ($row["max"] == "" || $count < $row["max"]) {
1827  $subobj[] = $row["name"];
1828  }
1829  }
1830  }
1831 
1832  if (count($subobj) > 0) {
1833  $opts = ilLegacyFormElementsUtil::formSelect(12, "new_type", $subobj);
1834  $this->tpl->setCurrentBlock("add_object");
1835  $this->tpl->setVariable("SELECT_OBJTYPE", $opts);
1836  $this->tpl->setVariable("BTN_NAME", "create");
1837  $this->tpl->setVariable("TXT_ADD", $this->lng->txt("add"));
1838  $this->tpl->parseCurrentBlock();
1839  }
1840  }
1841 
1845  protected function getTabs(): void
1846  {
1847  }
1848 
1856  protected function redirectToRefId(int $ref_id, string $cmd = ""): void
1857  {
1858  $obj_type = ilObject::_lookupType($ref_id, true);
1859  $class_name = $this->obj_definition->getClassName($obj_type);
1860  $class = strtolower("ilObj" . $class_name . "GUI");
1861  $this->ctrl->setParameterByClass("ilrepositorygui", "ref_id", $ref_id);
1862  $this->ctrl->redirectByClass(["ilrepositorygui", $class], $cmd);
1863  }
1864 
1868  protected function getCenterColumnHTML(): string
1869  {
1870  $obj_id = ilObject::_lookupObjId($this->object->getRefId());
1871  $obj_type = ilObject::_lookupType($obj_id);
1872 
1873  if ($this->ctrl->getNextClass() != "ilcolumngui") {
1874  // normal command processing
1875  return $this->getContent();
1876  } else {
1877  if (!$this->ctrl->isAsynch()) {
1878  //if ($column_gui->getScreenMode() != IL_SCREEN_SIDE)
1880  // right column wants center
1882  $column_gui = new ilColumnGUI($obj_type, IL_COL_RIGHT);
1883  $this->setColumnSettings($column_gui);
1884  $this->html = $this->ctrl->forwardCommand($column_gui);
1885  }
1886  // left column wants center
1888  $column_gui = new ilColumnGUI($obj_type, IL_COL_LEFT);
1889  $this->setColumnSettings($column_gui);
1890  $this->html = $this->ctrl->forwardCommand($column_gui);
1891  }
1892  } else {
1893  // normal command processing
1894  return $this->getContent();
1895  }
1896  }
1897  }
1898  return "";
1899  }
1900 
1904  protected function getRightColumnHTML(): string
1905  {
1906  $obj_id = ilObject::_lookupObjId($this->object->getRefId());
1907  $obj_type = ilObject::_lookupType($obj_id);
1908 
1909  $column_gui = new ilColumnGUI($obj_type, IL_COL_RIGHT);
1910 
1911  if ($column_gui->getScreenMode() == IL_SCREEN_FULL) {
1912  return "";
1913  }
1914 
1915  $this->setColumnSettings($column_gui);
1916 
1917  $html = "";
1918  if (
1919  $this->ctrl->getNextClass() == "ilcolumngui" &&
1920  $column_gui->getCmdSide() == IL_COL_RIGHT &&
1921  $column_gui->getScreenMode() == IL_SCREEN_SIDE
1922  ) {
1923  return $this->ctrl->forwardCommand($column_gui);
1924  }
1925 
1926  if (!$this->ctrl->isAsynch()) {
1927  return $this->ctrl->getHTML($column_gui);
1928  }
1929 
1930  return $html;
1931  }
1932 
1933  public function setColumnSettings(ilColumnGUI $column_gui): void
1934  {
1935  $column_gui->setRepositoryMode(true);
1936  $column_gui->setEnableEdit(false);
1937  if ($this->checkPermissionBool("write")) {
1938  $column_gui->setEnableEdit(true);
1939  }
1940  }
1941 
1942  protected function checkPermission(string $perm, string $cmd = "", string $type = "", ?int $ref_id = null): void
1943  {
1944  if (!$this->checkPermissionBool($perm, $cmd, $type, $ref_id)) {
1945  if (!is_int(strpos($_SERVER['PHP_SELF'], 'goto.php'))) {
1946  if ($perm != 'create' && !is_object($this->object)) {
1947  return;
1948  }
1949 
1950  ilSession::clear('il_rep_ref_id');
1951 
1952  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('msg_no_perm_read'), true);
1953  $parent_ref_id = $this->tree->getParentId($this->object->getRefId());
1954  if ($parent_ref_id > 0) {
1955  $this->ctrl->redirectToURL(ilLink::_getLink($parent_ref_id));
1956  } else {
1957  $this->ctrl->redirectToURL('login.php?cmd=force_login');
1958  }
1959  }
1960 
1961  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('msg_no_perm_read'), true);
1962  self::_gotoRepositoryRoot();
1963  }
1964  }
1965 
1966  protected function checkPermissionBool(string $perm, string $cmd = "", string $type = "", ?int $ref_id = null): bool
1967  {
1968  if ($perm === "create") {
1969  if (!$ref_id) {
1970  $ref_id = $this->requested_ref_id;
1971  }
1972  return $this->access->checkAccess($perm . "_" . $type, $cmd, $ref_id);
1973  }
1974 
1975  if (!is_object($this->object)) {
1976  return false;
1977  }
1978 
1979  if (!$ref_id) {
1980  $ref_id = $this->object->getRefId();
1981  }
1982 
1983  return $this->access->checkAccess($perm, $cmd, $ref_id);
1984  }
1985 
1992  public static function _gotoRepositoryRoot(bool $raise_error = false): void
1993  {
1994  global $DIC;
1995 
1996  $ilAccess = $DIC->access();
1997  $ilErr = $DIC["ilErr"];
1998  $lng = $DIC->language();
1999  $ctrl = $DIC->ctrl();
2000 
2001  if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
2002  $ctrl->setParameterByClass("ilRepositoryGUI", "ref_id", ROOT_FOLDER_ID);
2003  $ctrl->redirectByClass("ilRepositoryGUI");
2004  }
2005 
2006  if ($raise_error) {
2007  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
2008  }
2009  }
2010 
2011  public static function _gotoRepositoryNode(int $ref_id, string $cmd = ""): void
2012  {
2013  global $DIC;
2014 
2015  $ctrl = $DIC->ctrl();
2016  $ctrl->setParameterByClass("ilRepositoryGUI", "ref_id", $ref_id);
2017  $ctrl->redirectByClass("ilRepositoryGUI", $cmd);
2018  }
2019 
2020  public static function _gotoSharedWorkspaceNode(int $wsp_id): void
2021  {
2022  global $DIC;
2023 
2024  $ctrl = $DIC->ctrl();
2025  $ctrl->setParameterByClass(ilSharedResourceGUI::class, "wsp_id", $wsp_id);
2026  $ctrl->redirectByClass(ilSharedResourceGUI::class, "");
2027  }
2028 
2032  protected function enableDragDropFileUpload(): void
2033  {
2034  $this->tpl->setFileUploadRefId($this->ref_id);
2035  }
2036 
2037  public function addToDeskObject(): void
2038  {
2039  $this->favourites->add(
2040  $this->user->getId(),
2041  $this->request_wrapper->retrieve("item_ref_id", $this->refinery->kindlyTo()->int())
2042  );
2043  $this->lng->loadLanguageModule("rep");
2044  $this->tpl->setOnScreenMessage("success", $this->lng->txt("rep_added_to_favourites"), true);
2045  $this->ctrl->redirectToURL(ilLink::_getLink($this->requested_ref_id));
2046  }
2047 
2048  public function removeFromDeskObject(): void
2049  {
2050  $this->lng->loadLanguageModule("rep");
2051  $item_ref_id = $this->request_wrapper->retrieve("item_ref_id", $this->refinery->kindlyTo()->int());
2052  $this->favourites->remove($this->user->getId(), $item_ref_id);
2053  $this->tpl->setOnScreenMessage("success", $this->lng->txt("rep_removed_from_favourites"), true);
2054  $this->ctrl->redirectToURL(ilLink::_getLink($this->requested_ref_id));
2055  }
2056 
2057  protected function getCreatableObjectTypes(): array
2058  {
2059  $subtypes = $this->obj_definition->getCreatableSubObjects(
2060  $this->object->getType(),
2062  $this->object->getRefId()
2063  );
2064 
2065  return array_filter(
2066  $subtypes,
2067  fn($key) => $this->access->checkAccess('create_' . $key, '', $this->ref_id, $this->type),
2068  ARRAY_FILTER_USE_KEY
2069  );
2070  }
2071 
2072  protected function buildAddNewItemElements(
2073  array $subtypes,
2074  string $create_target_class = ilRepositoryGUI::class,
2075  ?int $redirect_target_ref_id = null,
2076  ): array {
2077  if ($subtypes === []) {
2078  return [];
2079  }
2080  if ($redirect_target_ref_id !== null) {
2081  $this->ctrl->setParameterByClass($create_target_class, 'crtcb', (string) $redirect_target_ref_id);
2082  }
2083 
2084  $elements = $this->initAddNewItemElementsFromNewItemGroups(
2085  $create_target_class,
2088  $subtypes
2089  );
2090  if ($elements === []) {
2091  $elements = $this->initAddnewItemElementsFromDefaultGroups(
2092  $create_target_class,
2094  $subtypes
2095  );
2096  }
2097 
2098  $this->ctrl->clearParameterByClass(self::class, 'crtcb');
2099  return $elements;
2100  }
2101 
2103  string $create_target_class,
2104  array $new_item_groups,
2105  array $new_item_groups_subitems,
2106  array $subtypes
2107  ): array {
2108  if ($new_item_groups === []) {
2109  return [];
2110  }
2111 
2112  $new_item_groups[0] = $this->lng->txt('rep_new_item_group_other');
2113  $add_new_item_elements = [];
2114  foreach ($new_item_groups as $group_id => $group) {
2115  if (empty($new_item_groups_subitems[$group_id])) {
2116  continue;
2117  }
2118  $group_element = $this->buildGroup(
2119  $create_target_class,
2120  $new_item_groups_subitems[$group_id],
2121  $group['title'] ?? $group,
2122  $subtypes
2123  );
2124 
2125  if ($group_element !== null) {
2126  $add_new_item_elements[] = $group_element;
2127  }
2128  }
2129 
2130  return $add_new_item_elements;
2131  }
2132 
2134  string $create_target_class,
2135  array $default_groups,
2136  array $subtypes
2137  ): array {
2138  $add_new_item_elements = [];
2139  $grouped_types = [];
2140 
2141  foreach ($default_groups['groups'] as $group_id => $group) {
2142  $obj_types_in_group = array_keys(
2143  array_filter(
2144  $default_groups['items'],
2145  fn($item_group_id) => $item_group_id === $group_id
2146  )
2147  );
2148  $grouped_types = array_merge($grouped_types, $obj_types_in_group);
2149 
2150  $group_element = $this->buildGroup(
2151  $create_target_class,
2152  $obj_types_in_group,
2153  $group['title'],
2154  $subtypes
2155  );
2156 
2157  if ($group_element !== null) {
2158  $add_new_item_elements[$group['pos']] = $group_element;
2159  }
2160  }
2161 
2162  $ungrouped_types = array_diff(array_keys($subtypes), $grouped_types);
2163  if ($ungrouped_types !== []) {
2164  $add_new_item_elements[] = $this->buildGroup(
2165  $create_target_class,
2166  $ungrouped_types,
2167  $this->lng->txt('rep_new_item_group_other'),
2168  $subtypes
2169  );
2170  }
2171 
2172  return $add_new_item_elements;
2173  }
2174 
2175  protected function buildGroup(
2176  string $create_target_class,
2177  array $obj_types_in_group,
2178  string $title,
2179  array $subtypes
2180  ): ?AddNewItemElement {
2181  $add_new_items_content_array = $this->buildSubItemsForGroup(
2182  $create_target_class,
2183  $obj_types_in_group,
2184  $subtypes
2185  );
2186  if ($add_new_items_content_array === []) {
2187  return null;
2188  }
2189  return new AddNewItemElement(
2191  $title,
2192  null,
2193  null,
2194  $add_new_items_content_array
2195  );
2196  }
2197 
2198  private function buildSubItemsForGroup(
2199  string $create_target_class,
2200  array $obj_types_in_group,
2201  array $subtypes
2202  ): array {
2203  $add_new_items_content_array = [];
2204  foreach ($obj_types_in_group as $type) {
2205  if (!array_key_exists($type, $subtypes)) {
2206  continue;
2207  }
2208  $subitem = $subtypes[$type];
2209  $this->ctrl->setParameterByClass($create_target_class, 'new_type', $type);
2210  $add_new_items_content_array[$subitem['pos']] = new AddNewItemElement(
2211  AddNewItemElementTypes::Object,
2213  empty($subitem['plugin'])
2214  ? $this->ui_factory->symbol()->icon()->standard($type, '')
2215  : $this->ui_factory->symbol()->icon()->custom(
2216  ilObject::getIconForType($type),
2217  ''
2218  ),
2219  new URI(
2220  ILIAS_HTTP_PATH . '/' . $this->ctrl->getLinkTargetByClass($create_target_class, 'create')
2221  )
2222  );
2223  $this->ctrl->clearParameterByClass($create_target_class, 'new_type', $type);
2224  }
2225  ksort($add_new_items_content_array);
2226  return $add_new_items_content_array;
2227  }
2228 
2229  private function checkWritePermissionOnRefIdArray(array $ref_ids): bool
2230  {
2231  foreach ($ref_ids as $ref_id) {
2232  if (!$this->access->checkAccess('write', '', $ref_id)) {
2233  return false;
2234  }
2235  }
2236  return true;
2237  }
2238 
2239  private function getTranslatedObjectTypeNameFromItemArray(array $item_array): string
2240  {
2241  return empty($item_array['plugin'])
2242  ? $this->lng->txt('obj_' . $item_array['lng'])
2243  : ilObjectPlugin::lookupTxtById($item_array['lng'], 'obj_' . $item_array['lng']);
2244  }
2245 }
redrawHeaderActionObject()
Ajax call: redraw action header only.
ilObjectDefinition $obj_definition
This class represents an option in a radio group.
omitLocator(bool $omit=true)
setAdminMode(string $mode)
GlobalHttpState $http
const ADMIN_MODE_REPOSITORY
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
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.
CustomIconFactory $custom_icon_factory
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
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.
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)
Base exception class for object service.
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:25
setPermissions(int $parent_ref_id)
MultiPropertiesManipulator $multi_object_manipulator
setEnableEdit(bool $a_enableedit)
setLocator()
Insert locator.
Refinery $refinery
redirectByClass( $a_class, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false)
const SYSTEM_FOLDER_ID
Definition: constants.php:35
$ilErr
Definition: raiseError.php:33
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...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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
static http()
Fetches the global http state from ILIAS.
This class represents a property in a property form.
UIFactory $ui_factory
retrieveFilesAndUploadTypeFromData(array $data)
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:26
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:26
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)
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)
putObjectInTree(ilObject $obj, ?int $parent_node_id=null)
Add object to tree at given position.
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)
exit
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)
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 prepareJsLinks(string $redraw_url, string $notes_url, string $tags_url, ?ilGlobalTemplateInterface $tpl=null)
Insert js/ajax links into template.
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
setTargetFrame(string $cmd, string $target_frame)
Set specific target frame for command.
static _lookupContainerSetting(int $a_id, string $a_keyword, ?string $a_default_value=null)
setTabs()
set admin tabs
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)