19 declare(strict_types=1);
127 public function __construct(
$data,
int $id = 0,
bool $call_by_reference =
true,
bool $prepare_output =
true)
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'];
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();
156 $this->request = $this->
http->request();
157 $this->post_wrapper = $this->
http->wrapper()->post();
158 $this->request_wrapper = $this->
http->wrapper()->query();
168 $this->
lng->loadLanguageModule(
'obj');
171 if (!$call_by_reference) {
176 if ($this->request_wrapper->has(
'ref_id')) {
177 $this->requested_ref_id = $this->request_wrapper->retrieve(
'ref_id', $this->
refinery->kindlyTo()->int());
183 if ($call_by_reference) {
186 if ($this->request_wrapper->has(
'obj_id')) {
187 $this->obj_id = $this->request_wrapper->retrieve(
'obj_id', $this->
refinery->kindlyTo()->int());
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',
'');
198 if ($this->
id != 0) {
204 if (is_object($this->
object)) {
205 if ($this->call_by_reference && $this->ref_id == $this->requested_ref_id) {
206 $this->
ctrl->setContextObject(
208 $this->
object->getType()
213 if ($prepare_output) {
217 $this->notes_service = $DIC->notes();
222 if (!isset($this->multi_object_manipulator)) {
223 $this->multi_object_manipulator = LocalDIC::dic()[
'properties.multi_manipulator'];
235 if (!in_array($mode, [
236 self::ADMIN_MODE_NONE,
237 self::ADMIN_MODE_REPOSITORY,
238 self::ADMIN_MODE_SETTINGS
242 $this->admin_mode = $mode;
262 $cmd = $this->
ctrl->getCmd();
287 $this->creation_mode = $mode;
298 if ($this->
id != 0) {
299 if ($this->call_by_reference) {
309 $this->tpl->loadStandardTemplate();
310 $base_class = $this->request_wrapper->retrieve(
"baseClass", $this->
refinery->kindlyTo()->string());
311 if (strtolower($base_class) ==
"iladministrationgui") {
313 $this->tpl->setLocator();
328 if ($this->call_by_reference) {
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);
343 if ($file_upload_dropzone->isUploadAllowed($this->object->getType())) {
353 if (!is_object($this->
object)) {
354 if ($this->requested_crtptrefid > 0) {
356 $this->tpl->setTitle(
357 $this->
refinery->encode()->htmlSpecialCharsAsEntities()->transform(
365 $this->tpl->setTitle(
366 $this->
refinery->encode()->htmlSpecialCharsAsEntities()->transform(
367 $this->
object->getPresentationTitle()
370 $this->tpl->setDescription(
371 $this->
refinery->encode()->htmlSpecialCharsAsEntities()->transform(
372 $this->
object->getLongDescription()
376 $base_class = $this->request_wrapper->retrieve(
"baseClass", $this->
refinery->kindlyTo()->string());
377 if (strtolower($base_class) ===
"iladministrationgui") {
381 $this->tpl->setTitleIcon(
383 $this->
lng->txt(
"obj_" . $this->object->getType())
386 if (!$this->obj_definition->isAdministrationObject($this->object->getType())) {
388 $lgui->initItem($this->
object->getRefId(), $this->
object->getId(), $this->
object->getType());
389 $this->tpl->setAlertProperties($lgui->getAlertProperties());
400 $this->
object->getId()
409 if (!$this->creation_mode && $this->
object) {
412 $dispatcher->setSubObject($sub_type, $sub_id);
415 $this->
ctrl->getLinkTarget($this,
'redrawHeaderAction',
'',
true),
417 $this->
ctrl->getLinkTargetByClass([ilCommonActionDispatcherGUI::class, ilTaggingGUI::class],
'',
'',
true)
420 $lg = $dispatcher->initHeaderAction();
422 if (is_object($lg)) {
425 $lg->setContainerObject($this);
428 $lg->enableMultiDownload(
true);
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())
437 $lg->enableComments(
true);
440 $lg->enableNotes(
true);
441 $lg->enableTags(
true);
455 !is_object($this->
object) ||
461 if (is_object($list_gui)) {
462 $this->tpl->setHeaderActionMenu($list_gui->getHeaderAction());
480 echo $lg->getHeaderAction();
483 echo $this->tpl->getOnLoadCodeForAsynch();
509 $this->tabs_gui->addTarget(
511 $this->
ctrl->getLinkTarget($this,
"view"),
518 $this->tabs_gui->addTarget(
520 $this->
ctrl->getLinkTargetByClass([get_class($this),
'ilpermissiongui'],
"perm"),
537 if ($this->omit_locator) {
542 if ($this->call_by_reference) {
547 if ($this->requested_ref_id === 0) {
548 $ref_id = $this->
object->getRefId();
550 $ilLocator->addRepositoryItems($ref_id);
553 if (!$this->creation_mode) {
570 $this->omit_locator = $omit;
579 if ($this->admin_mode == self::ADMIN_MODE_SETTINGS) {
580 $this->
ctrl->setParameterByClass(
581 "ilobjsystemfoldergui",
586 $this->
lng->txt(
"administration"),
587 $this->
ctrl->getLinkTargetByClass([
"iladministrationgui",
"ilobjsystemfoldergui"],
"")
591 $this->
object->getTitle(),
592 $this->
ctrl->getLinkTarget($this,
"view")
596 $this->
ctrl->setParameterByClass(
597 "iladministrationgui",
601 $this->
ctrl->setParameterByClass(
602 "iladministrationgui",
606 $this->
ctrl->clearParametersByClass(
"iladministrationgui");
607 $this->
locator->addAdministrationItems();
617 if (!$this->request_wrapper->has(
'id')) {
618 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'no_checkbox'),
true);
619 $this->
ctrl->returnToParent($this);
625 $this->request_wrapper->retrieve(
627 $this->refinery->kindlyTo()->string()
630 )->withRequest($this->request)->getData();
633 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'no_checkbox'),
true);
634 $this->
ctrl->returnToParent($this);
640 $this->
ctrl->redirectByClass(static::class);
647 function (array
$c, array|
int|
null $v): array {
659 $c[] = $this->
refinery->kindlyTo()->int()->transform($v);
672 $this->
ctrl->returnToParent($this);
683 $this->
ctrl->saveParameter($this,
"crtptrefid");
685 $this->
ctrl->saveParameter($this,
"crtcb");
688 $this->error->raiseError($this->
lng->txt(
"permission_denied"), $this->error->MESSAGE);
691 $this->
lng->loadLanguageModule($new_type);
692 $this->
ctrl->setParameter($this,
'new_type', $new_type);
697 $this->tabs_gui->setBackTarget($this->
lng->txt(
'cancel'), $this->
ctrl->getLinkTargetByClass(static::class,
'cancel'));
708 if (is_array($form)) {
709 throw new Exception(
'We do not deal with arrays here.');
715 $form->setTitleIcon(
'');
716 $form->setTableWidth(
'100%');
717 $content = $this->ui_factory->legacy()->content($form->getHTML());
720 return $this->ui_renderer->render(
721 $this->ui_factory->panel()->standard($title, $content)
727 if (!$this->obj_definition->isPlugin($this->requested_new_type)) {
728 return $this->
lng->txt(
'obj_' . $this->requested_new_type);
735 return $this->
lng->txt($this->requested_new_type .
'_new');
740 $form_fields[
'title_and_description'] = (
new ilObject())->getObjectProperties()->getPropertyTitleAndDescription()->toForm(
742 $this->ui_factory->input()->field(),
748 if ($didactic_templates !==
null) {
749 $form_fields[
'didactic_templates'] = $didactic_templates;
752 return $this->ui_factory->input()->container()->form()->standard(
753 $this->
ctrl->getFormAction($this,
'save'),
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" 767 $this->
lng->loadLanguageModule(
'didactic');
771 if (
sizeof($options) < 2) {
775 $didactic_templates_radio = $this->ui_factory->input()->field()->radio($this->
lng->txt(
'type'));
777 foreach ($options as $value => $option) {
778 if ($existing_exclusive && $value ==
'dtpl_0') {
782 $didactic_templates_radio = $didactic_templates_radio->withOption($value, $option[0], $option[1] ??
'');
788 $didactic_templates_radio = $didactic_templates_radio->withValue($value);
790 if (!in_array($value, array_keys($options)) || ($existing_exclusive && $value ==
"dtpl_0")) {
792 $options[$value] = [$this->
lng->txt(
'not_available')];
795 if ($existing_exclusive) {
797 $keys = array_keys($options);
798 $didactic_templates_radio = $didactic_templates_radio->withValue($keys[1]);
800 $didactic_templates_radio = $didactic_templates_radio->withValue(
'dtpl_0');
804 return $didactic_templates_radio;
814 if (
sizeof($options) < 2) {
819 $this->
lng->txt(
'type'),
826 $type->setValue($value);
828 if (!in_array($value, array_keys($options)) || ($existing_exclusive && $value ==
"dtpl_0")) {
830 $options[$value] = [$this->
lng->txt(
'not_available')];
833 if ($existing_exclusive) {
835 $keys = array_keys($options);
836 $type->setValue($keys[1]);
838 $type->setValue(
'dtpl_0');
843 foreach ($options as $id =>
$data) {
845 if ($existing_exclusive && $id ==
'dtpl_0') {
847 $option->setDisabled(
true);
850 $type->addOption($option);
858 $this->
lng->loadLanguageModule(
'didactic');
859 $existing_exclusive =
false;
861 $options[
'dtpl_0'] = [
862 $this->
lng->txt(
'didactic_default_type'),
864 $this->
lng->txt(
'didactic_default_type_info'),
865 $this->
lng->txt(
'objs_' . $this->type)
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()
878 if ($template->isExclusive()) {
879 $existing_exclusive =
true;
899 $this->ui_factory->link()->standard(
900 $this->
lng->txt(
'cntr_adopt_content'),
901 $this->
ctrl->getLinkTargetByClass(
913 $this->ui_factory->button()->standard(
914 $this->
lng->txt(
'import'),
915 $modal->getShowSignal()
919 $this->tpl->setVariable(
920 'IL_OBJECT_IMPORT_MODAL',
921 $this->ui_renderer->render(
922 $this->import_type_selector_modal ===
null 924 : [$modal, $this->import_type_selector_modal]
931 return $this->ui_factory->modal()
933 $this->
lng->txt(
'import'),
936 $this->
ctrl->getFormAction($this,
'routeImportCmd')
937 )->withSubmitLabel($this->
lng->txt(
'import'));
941 ?
string $file_to_import =
null,
942 ?
string $upload_file_name =
null 944 return $this->ui_factory->modal()
946 $this->
lng->txt(
'select_object_type'),
948 $this->ui_factory->messageBox()->info(
949 $this->
lng->txt(
'select_import_type_info')
956 $this->
ctrl->getFormActionByClass(static::class,
'routeImportCmd')
957 )->withCloseWithKeyboard(
false)
958 ->withSubmitLabel($this->
lng->txt(
'import'));
973 $item_ref_ids = $this->retriever->getSelectedIdsFromObjectList();
976 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'msg_no_perm_write'));
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()
994 $this->renderObject();
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'));
1009 $this->tpl->setVariable(
1010 'IL_OBJECT_EPHEMRAL_MODALS',
1011 $this->ui_renderer->render(
1012 $availability_period_modal->withOnLoad(
1013 $availability_period_modal->getShowSignal()
1018 $this->renderObject();
1026 $this->
ctrl->redirectByClass(
"ilrepositorygui",
"");
1033 $this->error->raiseError($this->
lng->txt(
"no_create_permission"), $this->error->MESSAGE);
1036 $this->
lng->loadLanguageModule($this->requested_new_type);
1037 $this->
ctrl->setParameter($this,
"new_type", $this->requested_new_type);
1040 ->withRequest($this->request);
1041 $data = $form->getData();
1047 $this->
ctrl->setParameter($this,
'new_type',
'');
1049 $class_name =
'ilObj' . $this->obj_definition->getClassName($this->requested_new_type);
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());
1058 $new_obj->getObjectProperties()->storePropertyTitleAndDescription(
1059 $data[
'title_and_description']
1064 $dtpl =
$data[
'didactic_templates'] ??
null;
1065 if ($dtpl !== null) {
1067 $new_obj->applyDidacticTemplate($dtpl_id);
1083 $data = $create_form->withRequest($this->request)->getData();
1084 return isset(
$data[
'didactic_templates'])
1091 if (!$this->post_wrapper->has(
'didactic_type')) {
1095 $tpl = $this->post_wrapper->retrieve(
'didactic_type', $this->
refinery->kindlyTo()->string());
1101 if (substr($var, 0, strlen($type) + 1) != $type .
"_") {
1105 return (
int) substr($var, strlen($type) + 1);
1113 if (!$parent_node_id) {
1118 if ($this->requested_crtptrefid > 0) {
1126 $this->obj_id = $obj->
getId();
1134 $rbac_log_roles = $this->rbac_review->getParentRoleIds($this->ref_id,
false);
1147 $this->tpl->setOnScreenMessage(
"success", $this->
lng->txt(
"object_added"),
true);
1148 $this->
ctrl->returnToParent($this);
1154 $this->error->raiseError($this->
lng->txt(
"msg_no_perm_write"), $this->error->MESSAGE);
1157 $this->tabs_gui->activateTab(
"settings");
1162 $form->setValuesByArray($values);
1167 $this->tpl->setContent($form->getHTML());
1182 $form->setFormAction($this->
ctrl->getFormAction($this,
"update"));
1183 $form->setTitle($this->
lng->txt($this->object->getType() .
"_edit"));
1188 $ti->setRequired(
true);
1189 $form->addItem($ti);
1195 $form->addItem($ta);
1199 $form->addCommandButton(
"update", $this->
lng->txt(
"save"));
1213 $values[
"title"] = $this->
object->getTitle();
1214 $values[
"desc"] = $this->
object->getLongDescription();
1232 $this->error->raiseError($this->
lng->txt(
"permission_denied"), $this->error->MESSAGE);
1238 $this->
object->setTitle($form->getInput(
'title'));
1239 $this->
object->setDescription($form->getInput(
'desc'));
1240 $this->
object->update();
1247 $this->tabs_gui->activateTab(
"settings");
1248 $form->setValuesByPost();
1249 $this->tpl->setContent($form->getHTML());
1272 $this->tpl->setOnScreenMessage(
"success", $this->
lng->txt(
"msg_obj_modified"),
true);
1273 $this->
ctrl->redirect($this,
"edit");
1278 $trafo = $this->
refinery->custom()->transformation(
1279 function ($vs): array {
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]];
1291 $file = $export_upload->getAbsolutePathForHash($this->
user->getId(),
$type, $vs[1][0]);
1293 self::UPLOAD_TYPE_UPLOAD_DIRECTORY => $file
1301 ->getFilesFor($this->
user->getId());
1303 $field_factory = $this->ui_factory->input()->field();
1306 ->withAcceptedMimeTypes(self::SUPPORTED_IMPORT_MIME_TYPES)
1307 ->withRequired(
true)
1310 if ($upload_files !== []) {
1311 $this->
lng->loadLanguageModule(
'content');
1313 $file_upload_input = $field_factory->switchableGroup(
1315 self::UPLOAD_TYPE_LOCAL => $field_factory->group(
1316 [$file_upload_input],
1317 $this->lng->txt(
'cont_choose_local')
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'),
1324 $this->
lng->txt(
'cont_choose_file_source')
1329 'upload' => $file_upload_input->withAdditionalTransformation($trafo)
1334 ?
string $file_to_import =
null,
1335 ?
string $file_name_in_temp_dir =
null 1337 $ff = $this->ui_factory->input()->field();
1341 $this->
object->getPossibleSubObjects()
1344 asort($possible_sub_objects);
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)
1358 if ($this->request_wrapper->has(
'step')) {
1369 [$new_type, $file_to_import, $path_to_uploaded_file_in_temp_dir] = $this
1370 ->retrieveFilesAndUploadTypeFromData(
$data);
1372 if ($new_type ===
null) {
1374 basename($file_to_import),
1375 $path_to_uploaded_file_in_temp_dir
1382 || !in_array($new_type, $this->obj_definition->getAllObjects())
1383 || !array_key_exists($new_type, $this->
object->getPossibleSubObjects())) {
1385 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'no_create_permission'));
1390 $this->
lng->loadLanguageModule($new_type);
1391 $this->
ctrl->setParameter($this,
'new_type', $new_type);
1393 $target_class =
'ilObj' . $this->obj_definition->getClassName($new_type) .
'GUI';
1395 $target =
new $target_class(
'', 0,
false,
false);
1399 $target->importFile($file_to_import, $path_to_uploaded_file_in_temp_dir);
1400 $this->
ctrl->clearParameterByClass(get_class($this),
'new_type');
1404 protected function importFile(
string $file_to_import,
string $path_to_uploaded_file_in_temp_dir): void
1409 $imp =
new ilImport($this->requested_ref_id);
1413 $new_id = $imp->importObject(
1416 basename($file_to_import),
1422 $this->tmp_import_dir = $imp->getTemporaryImportDir();
1423 $this->tpl->setOnScreenMessage(
1425 $this->
lng->txt(
'obj_import_file_error') .
' <br />' . $e->getMessage()
1431 if ($new_id ===
null 1433 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'import_file_not_valid_here'));
1438 $this->
ctrl->setParameter($this,
'new_type',
'');
1442 if (!$this->obj_definition->isContainer($this->type)) {
1446 if (count($ref_ids) === 1) {
1447 $new_obj->setRefId((
int) current($ref_ids));
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);
1458 $this->
ctrl->setParameterByClass(get_class($new_obj),
'ref_id', $new_obj->getRefId());
1459 $this->
ctrl->redirectByClass(get_class($new_obj));
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);
1473 $data = $modal->getData();
1479 $this->import_modal = $modal->withOnLoad($modal->getShowSignal());
1486 $data = $modal->getData();
1492 $this->import_type_selector_modal = $modal->withOnLoad($modal->getShowSignal());
1497 ?
string $file_to_import =
null,
1498 ?
string $path_to_uploaded_file_in_temp_dir =
null 1500 $this->
ctrl->setParameterByClass(static::class,
'step',
'select_type');
1503 $path_to_uploaded_file_in_temp_dir
1505 $this->
ctrl->clearParameterByClass(static::class,
'step');
1506 $this->import_type_selector_modal = $modal->withOnLoad($modal->getShowSignal());
1513 if (isset($data[
'type']) && isset($data[
'file_to_import']) && isset($data[
'temp_file'])) {
1517 DIRECTORY_SEPARATOR,
1518 [
CLIENT_DATA_DIR,
'temp', $data[
'temp_file'], $data[
'file_to_import']]
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];
1532 $path_to_uploaded_file_in_temp_dir
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 1542 || !isset($matches[1])) {
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]);
1555 .
'temp' . DIRECTORY_SEPARATOR
1556 . $files[0]->getPath();
1558 return $upload_data[self::UPLOAD_TYPE_UPLOAD_DIRECTORY];
1566 $this->tpl->setOnScreenMessage(
"success", $this->
lng->txt(
"object_added"),
true);
1567 $this->
ctrl->returnToParent($this);
1573 public function getFormAction(
string $cmd,
string $default_form_action =
""): string
1575 if ($this->form_action[$cmd] !=
"") {
1576 return $this->form_action[$cmd];
1579 return $default_form_action;
1592 if (($this->return_location[$cmd] ??
"") !==
"") {
1593 return $this->return_location[$cmd];
1595 return $default_location;
1604 $this->return_location[$cmd] =
$location;
1610 protected function getTargetFrame(
string $cmd,
string $default_target_frame =
""): string
1612 if (isset($this->target_frame[$cmd]) && $this->target_frame[$cmd] !=
"") {
1613 return $this->target_frame[$cmd];
1616 if (!empty($default_target_frame)) {
1617 return "target=\"" . $default_target_frame .
"\"";
1628 $this->target_frame[$cmd] =
"target=\"" . $target_frame .
"\"";
1635 if ($visible && $type ==
'crs') {
1642 if (!$tmp_obj->isActivated()) {
1660 $this->tabs_gui->activateTab(
'view');
1663 $this->
object->getType(),
1664 $this->
object->getRefId(),
1665 $this->
object->getId(),
1666 $this->
user->getId()
1670 $this->
ctrl->setParameter($this,
'obj_id', $this->obj_id);
1676 $this->requested_ref_id,
1680 $this->tpl->setContent($itab->getHTML());
1691 if ($this->post_wrapper->has(
'id')) {
1692 $request_ids = $this->post_wrapper->retrieve(
1699 $this->request_wrapper->has(
'item_ref_id')
1700 && $this->request_wrapper->retrieve(
'item_ref_id', $this->
refinery->kindlyTo()->string()) !==
"" 1702 $request_ids = [$this->request_wrapper->retrieve(
'item_ref_id', $this->
refinery->kindlyTo()->int())];
1705 if ($request_ids === []) {
1706 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'no_checkbox'),
true);
1707 $this->
ctrl->returnToParent($this);
1711 $this->tpl->setVariable(
1712 'IL_OBJECT_EPHEMRAL_MODALS',
1713 $this->ui_renderer->render(
1714 $modal->withOnLoad($modal->getShowSignal())
1717 $this->renderObject();
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');
1730 $this->ui_factory->messageBox()->confirmation($msg),
1731 $this->ui_factory->listing()->unordered($listing_items)
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')
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');
1745 return $this->ui_factory->modal()->roundtrip(
1746 $this->
lng->txt(
'confirm'),
1750 )->withSubmitLabel($this->
lng->txt(
'delete'));
1756 $path_gui->enableTextOnly(
true);
1757 $path_gui->enableHideLeaf(
false);
1758 return array_reduce(
1760 function (array
$c,
int $v) use ($path_gui): array {
1764 $c[1][] = $this->ui_factory->input()->field()->hidden()->withValue($v);
1767 if ($other_references !== []) {
1768 $c[1][] = $this->ui_factory->input()->field()->multiSelect(
1784 return array_reduce(
1786 function (array
$c,
int $v) use ($ref_id, $path_gui): array {
1788 && !$this->tree->isDeleted($v)
1789 && $this->
access->checkAccess(
'delete',
'', $v)) {
1803 if ($this->sub_objects ==
"") {
1804 $sub_objects = $this->obj_definition->getCreatableSubObjects(
1805 $this->
object->getType(),
1814 if (count($sub_objects) > 0) {
1815 foreach ($sub_objects as $row) {
1817 if ($row[
"max"] > 0) {
1819 for ($i = 0; $i < count($this->data[
"ctrl"]); $i++) {
1820 if ($this->data[
"ctrl"][$i][
"type"] == $row[
"name"]) {
1826 if ($row[
"max"] ==
"" || $count < $row[
"max"]) {
1827 $subobj[] = $row[
"name"];
1832 if (count($subobj) > 0) {
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();
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);
1873 if ($this->
ctrl->getNextClass() !=
"ilcolumngui") {
1877 if (!$this->
ctrl->isAsynch()) {
1884 $this->
html = $this->
ctrl->forwardCommand($column_gui);
1890 $this->
html = $this->
ctrl->forwardCommand($column_gui);
1919 $this->
ctrl->getNextClass() ==
"ilcolumngui" &&
1923 return $this->
ctrl->forwardCommand($column_gui);
1926 if (!$this->
ctrl->isAsynch()) {
1927 return $this->
ctrl->getHTML($column_gui);
1942 protected function checkPermission(
string $perm,
string $cmd =
"",
string $type =
"", ?
int $ref_id =
null): void
1945 if (!is_int(strpos(
$_SERVER[
'PHP_SELF'],
'goto.php'))) {
1946 if ($perm !=
'create' && !is_object($this->
object)) {
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));
1957 $this->
ctrl->redirectToURL(
'login.php?cmd=force_login');
1961 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'msg_no_perm_read'),
true);
1962 self::_gotoRepositoryRoot();
1968 if ($perm ===
"create") {
1972 return $this->
access->checkAccess($perm .
"_" . $type, $cmd, $ref_id);
1975 if (!is_object($this->
object)) {
1980 $ref_id = $this->
object->getRefId();
1983 return $this->
access->checkAccess($perm, $cmd, $ref_id);
1996 $ilAccess = $DIC->access();
1998 $lng = $DIC->language();
1999 $ctrl = $DIC->ctrl();
2015 $ctrl = $DIC->ctrl();
2024 $ctrl = $DIC->ctrl();
2034 $this->tpl->setFileUploadRefId($this->ref_id);
2039 $this->favourites->add(
2040 $this->
user->getId(),
2041 $this->request_wrapper->retrieve(
"item_ref_id", $this->
refinery->kindlyTo()->int())
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));
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));
2059 $subtypes = $this->obj_definition->getCreatableSubObjects(
2060 $this->
object->getType(),
2062 $this->
object->getRefId()
2065 return array_filter(
2067 fn($key) => $this->
access->checkAccess(
'create_' . $key,
'', $this->ref_id, $this->type),
2068 ARRAY_FILTER_USE_KEY
2074 string $create_target_class = ilRepositoryGUI::class,
2075 ?
int $redirect_target_ref_id =
null,
2077 if ($subtypes === []) {
2080 if ($redirect_target_ref_id !==
null) {
2081 $this->
ctrl->setParameterByClass($create_target_class,
'crtcb', (
string) $redirect_target_ref_id);
2085 $create_target_class,
2090 if ($elements === []) {
2092 $create_target_class,
2098 $this->
ctrl->clearParameterByClass(self::class,
'crtcb');
2103 string $create_target_class,
2104 array $new_item_groups,
2105 array $new_item_groups_subitems,
2108 if ($new_item_groups === []) {
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])) {
2119 $create_target_class,
2120 $new_item_groups_subitems[$group_id],
2121 $group[
'title'] ?? $group,
2125 if ($group_element !==
null) {
2126 $add_new_item_elements[] = $group_element;
2130 return $add_new_item_elements;
2134 string $create_target_class,
2135 array $default_groups,
2138 $add_new_item_elements = [];
2139 $grouped_types = [];
2141 foreach ($default_groups[
'groups'] as $group_id => $group) {
2142 $obj_types_in_group = array_keys(
2144 $default_groups[
'items'],
2145 fn($item_group_id) => $item_group_id === $group_id
2148 $grouped_types = array_merge($grouped_types, $obj_types_in_group);
2151 $create_target_class,
2152 $obj_types_in_group,
2157 if ($group_element !==
null) {
2158 $add_new_item_elements[$group[
'pos']] = $group_element;
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,
2167 $this->
lng->txt(
'rep_new_item_group_other'),
2172 return $add_new_item_elements;
2176 string $create_target_class,
2177 array $obj_types_in_group,
2182 $create_target_class,
2183 $obj_types_in_group,
2186 if ($add_new_items_content_array === []) {
2194 $add_new_items_content_array
2199 string $create_target_class,
2200 array $obj_types_in_group,
2203 $add_new_items_content_array = [];
2204 foreach ($obj_types_in_group as $type) {
2205 if (!array_key_exists($type, $subtypes)) {
2208 $subitem = $subtypes[
$type];
2209 $this->
ctrl->setParameterByClass($create_target_class,
'new_type', $type);
2211 AddNewItemElementTypes::Object,
2213 empty($subitem[
'plugin'])
2214 ? $this->ui_factory->symbol()->icon()->standard($type,
'')
2215 : $this->ui_factory->symbol()->icon()->custom(
2220 ILIAS_HTTP_PATH .
'/' . $this->
ctrl->getLinkTargetByClass($create_target_class,
'create')
2223 $this->
ctrl->clearParameterByClass($create_target_class,
'new_type', $type);
2225 ksort($add_new_items_content_array);
2226 return $add_new_items_content_array;
2231 foreach ($ref_ids as $ref_id) {
2232 if (!$this->
access->checkAccess(
'write',
'', $ref_id)) {
2241 return empty($item_array[
'plugin'])
2242 ? $this->
lng->txt(
'obj_' . $item_array[
'lng'])
redrawHeaderActionObject()
Ajax call: redraw action header only.
ilObjectDefinition $obj_definition
saveAvailabilityPeriodObject()
This class represents an option in a radio group.
omitLocator(bool $omit=true)
buildDidacticTemplateOptions()
setAdminMode(string $mode)
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)
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
retrieveAndCheckImportTypeData()
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
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)
static getNewItemGroups()
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="")
setParameterByClass(string $a_class, string $a_parameter, $a_value)
extractFileTypeFromImportFilename(string $filename)
setRepositoryMode(bool $a_repositorymode)
Filesystem $temp_file_system
confirmedDeleteObject()
confirmed deletion of object -> objects are moved to trash or deleted immediately, if trash is disabled
loadLanguageModule(string $a_module)
Load language module.
RoundTrip $import_type_selector_modal
viewObject()
viewObject container presentation for "administration -> repository, trash, permissions" ...
createObject()
create new object form
deleteObject(bool $error=false)
Display deletion confirmation screen.
setPermissions(int $parent_ref_id)
static getNewItemGroupSubItems()
retrieveAndCheckImportData()
MultiPropertiesManipulator $multi_object_manipulator
setEnableEdit(bool $a_enableedit)
setLocator()
Insert locator.
redirectByClass( $a_class, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false)
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
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)
initAddnewItemElementsFromDefaultGroups(string $create_target_class, array $default_groups, array $subtypes)
static lookupTemplateId(int $a_ref_id)
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...
getTitleForCreationFormPage()
static http()
Fetches the global http state from ILIAS.
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
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
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.
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.
static getDefaultNewItemGrouping()
ilFavouritesManager $favourites
Base class for all sub item list gui's.
showImportTypeSelectorModal(?string $file_to_import=null, ?string $path_to_uploaded_file_in_temp_dir=null)
editAvailabilityPeriodObject()
ArrayBasedRequestWrapper $post_wrapper
getMultiObjectPropertiesManipulator()
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)
createActionDispatcherGUI()
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)
addAdoptContentLinkToToolbar()
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)
addAvailabilityPeriodButtonToToolbar(ilToolbarGUI $toolbar)
getRightColumnHTML()
Display right column.
addImportButtonToToolbar()
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
RequestWrapper $request_wrapper
int $requested_crtptrefid
validateCustom(ilPropertyFormGUI $form)
Validate custom values (if not possible with checkInput())
setColumnSettings(ilColumnGUI $column_gui)
updateObject()
updates object entry in object_data
getCreatableObjectTypes()
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)
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) ...
didacticTemplatesToForm()
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)
addHeaderAction()
Add header action menu.
static clear(string $a_var)
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.
buildDeletionModalItems(array $ref_ids)
Class ArrayBasedRequestWrapper.