19 declare(strict_types=1);
124 public function __construct(
$data,
int $id = 0,
bool $call_by_reference =
true,
bool $prepare_output =
true)
129 $this->request = $DIC->http()->request();
130 $this->
locator = $DIC[
"ilLocator"];
131 $this->
user = $DIC->user();
132 $this->
access = $DIC->access();
134 $this->
toolbar = $DIC->toolbar();
135 $this->rbac_admin = $DIC->rbac()->admin();
136 $this->rbac_system = $DIC->rbac()->system();
137 $this->rbac_review = $DIC->rbac()->review();
138 $this->object_service = $DIC->object();
139 $this->obj_definition = $DIC[
"objDefinition"];
140 $this->tpl = $DIC[
"tpl"];
141 $this->tree = $DIC->repositoryTree();
142 $this->
ctrl = $DIC->ctrl();
143 $this->error = $DIC[
"ilErr"];
144 $this->
lng = $DIC->language();
145 $this->tabs_gui = $DIC->tabs();
146 $this->
ilias = $DIC[
"ilias"];
147 $this->post_wrapper = $DIC->http()->wrapper()->post();
148 $this->request_wrapper = $DIC->http()->wrapper()->query();
152 $this->custom_icon_factory = $DIC[
'object.customicons.factory'];
153 $this->ui_factory = $DIC[
'ui.factory'];
154 $this->ui_renderer = $DIC[
'ui.renderer'];
155 $this->temp_file_system = $DIC->filesystem()->temp();
162 $this->
lng->loadLanguageModule(
'obj');
165 if (!$call_by_reference) {
170 if ($this->request_wrapper->has(
'ref_id')) {
171 $this->requested_ref_id = $this->request_wrapper->retrieve(
'ref_id', $this->
refinery->kindlyTo()->int());
177 if ($call_by_reference) {
180 if ($this->request_wrapper->has(
'obj_id')) {
181 $this->obj_id = $this->request_wrapper->retrieve(
'obj_id', $this->
refinery->kindlyTo()->int());
187 $this->requested_crtptrefid = $this->retriever->getMaybeInt(
'crtptrefid', 0);
188 $this->requested_crtcb = $this->retriever->getMaybeInt(
'crtcb', 0);
189 $this->requested_new_type = $this->retriever->getMaybeString(
'new_type',
'');
192 if ($this->
id != 0) {
198 if (is_object($this->
object)) {
199 if ($this->call_by_reference && $this->ref_id == $this->requested_ref_id) {
200 $this->
ctrl->setContextObject(
202 $this->
object->getType()
207 if ($prepare_output) {
211 $this->notes_service = $DIC->notes();
216 if (!isset($this->multi_object_manipulator)) {
217 $this->multi_object_manipulator = ilObjectDIC::dic()[
'multi_object_properties_manipulator'];
229 if (!in_array($mode, [
230 self::ADMIN_MODE_NONE,
231 self::ADMIN_MODE_REPOSITORY,
232 self::ADMIN_MODE_SETTINGS
236 $this->admin_mode = $mode;
256 $cmd = $this->
ctrl->getCmd();
281 $this->creation_mode = $mode;
292 if ($this->
id != 0) {
293 if ($this->call_by_reference) {
303 $this->tpl->loadStandardTemplate();
304 $base_class = $this->request_wrapper->retrieve(
"baseClass", $this->
refinery->kindlyTo()->string());
305 if (strtolower($base_class) ==
"iladministrationgui") {
307 $this->tpl->setLocator();
322 if ($this->call_by_reference) {
325 $class_name = $this->obj_definition->getClassName($obj_type);
326 $class = strtolower(
"ilObj" . $class_name .
"GUI");
327 $class_path = $this->
ctrl->lookupClassPath($class);
328 $class_name = $this->
ctrl->getClassForClasspath($class_path);
337 if ($file_upload_dropzone->isUploadAllowed($this->object->getType())) {
347 if (!is_object($this->
object)) {
348 if ($this->requested_crtptrefid > 0) {
350 $this->tpl->setTitle(
351 $this->
refinery->encode()->htmlSpecialCharsAsEntities()->transform(
359 $this->tpl->setTitle(
360 $this->
refinery->encode()->htmlSpecialCharsAsEntities()->transform(
361 $this->
object->getPresentationTitle()
364 $this->tpl->setDescription(
365 $this->
refinery->encode()->htmlSpecialCharsAsEntities()->transform(
366 $this->
object->getLongDescription()
370 $base_class = $this->request_wrapper->retrieve(
"baseClass", $this->
refinery->kindlyTo()->string());
371 if (strtolower($base_class) ===
"iladministrationgui") {
375 $this->tpl->setTitleIcon(
377 $this->
lng->txt(
"obj_" . $this->object->getType())
380 if (!$this->obj_definition->isAdministrationObject($this->object->getType())) {
382 $lgui->initItem($this->
object->getRefId(), $this->
object->getId(), $this->
object->getType());
383 $this->tpl->setAlertProperties($lgui->getAlertProperties());
394 $this->
object->getId()
403 if (!$this->creation_mode && $this->
object) {
406 $dispatcher->setSubObject($sub_type, $sub_id);
409 $this->
ctrl->getLinkTarget($this,
"redrawHeaderAction",
"",
true),
411 $this->
ctrl->getLinkTargetByClass([
"ilcommonactiondispatchergui",
"iltagginggui"],
"",
"",
true)
414 $lg = $dispatcher->initHeaderAction();
416 if (is_object($lg)) {
419 $lg->setContainerObject($this);
422 $lg->enableMultiDownload(
true);
427 $this->
access->checkAccess(
"write",
"", $this->ref_id) ||
428 $this->
access->checkAccess(
"edit_permissions",
"", $this->ref_id) ||
429 $this->notes_service->domain()->commentsActive($this->
object->getId())
431 $lg->enableComments(
true);
434 $lg->enableNotes(
true);
435 $lg->enableTags(
true);
449 !is_object($this->
object) ||
455 if (is_object($list_gui)) {
456 $this->tpl->setHeaderActionMenu($list_gui->getHeaderAction());
474 echo $lg->getHeaderAction();
477 echo $this->tpl->getOnLoadCodeForAsynch();
503 $this->tabs_gui->addTarget(
505 $this->
ctrl->getLinkTarget($this,
"view"),
512 $this->tabs_gui->addTarget(
514 $this->
ctrl->getLinkTargetByClass([get_class($this),
'ilpermissiongui'],
"perm"),
531 if ($this->omit_locator) {
536 if ($this->call_by_reference) {
541 if ($this->requested_ref_id === 0) {
542 $ref_id = $this->
object->getRefId();
544 $ilLocator->addRepositoryItems($ref_id);
547 if (!$this->creation_mode) {
564 $this->omit_locator = $omit;
573 if ($this->admin_mode == self::ADMIN_MODE_SETTINGS) {
574 $this->
ctrl->setParameterByClass(
575 "ilobjsystemfoldergui",
580 $this->
lng->txt(
"administration"),
581 $this->
ctrl->getLinkTargetByClass([
"iladministrationgui",
"ilobjsystemfoldergui"],
"")
585 $this->
object->getTitle(),
586 $this->
ctrl->getLinkTarget($this,
"view")
590 $this->
ctrl->setParameterByClass(
591 "iladministrationgui",
595 $this->
ctrl->setParameterByClass(
596 "iladministrationgui",
600 $this->
ctrl->clearParametersByClass(
"iladministrationgui");
601 $this->
locator->addAdministrationItems();
611 if (!$this->request_wrapper->has(
'id')) {
612 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'no_checkbox'),
true);
613 $this->
ctrl->returnToParent($this);
619 $this->request_wrapper->retrieve(
621 $this->refinery->kindlyTo()->string()
624 )->withRequest($this->request)->getData();
626 if (
$data === null) {
627 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'no_checkbox'),
true);
628 $this->
ctrl->returnToParent($this);
634 $this->
ctrl->redirectByClass(static::class);
641 function (array
$c, array|
int|null $v): array {
653 $c[] = $this->
refinery->kindlyTo()->int()->transform($v);
666 $this->
ctrl->returnToParent($this);
677 $this->
ctrl->saveParameter($this,
"crtptrefid");
679 $this->
ctrl->saveParameter($this,
"crtcb");
682 $this->error->raiseError($this->
lng->txt(
"permission_denied"), $this->error->MESSAGE);
685 $this->
lng->loadLanguageModule($new_type);
686 $this->
ctrl->setParameter($this,
'new_type', $new_type);
691 $this->tabs_gui->setBackTarget($this->
lng->txt(
'cancel'), $this->
ctrl->getLinkTargetByClass(static::class,
'cancel'));
702 if (is_array($form)) {
703 throw new Exception(
'We do not deal with arrays here.');
709 $form->setTitleIcon(
'');
710 $form->setTableWidth(
'100%');
711 $content = $this->ui_factory->legacy($form->getHTML());
714 return $this->ui_renderer->render(
715 $this->ui_factory->panel()->standard($title, $content)
721 if (!$this->obj_definition->isPlugin($this->requested_new_type)) {
722 return $this->
lng->txt(
'obj_' . $this->requested_new_type);
729 return $this->
lng->txt($this->requested_new_type .
'_new');
734 $form_fields[
'title_and_description'] = (
new ilObject())->getObjectProperties()->getPropertyTitleAndDescription()->toForm(
736 $this->ui_factory->input()->field(),
742 if ($didactic_templates !== null) {
743 $form_fields[
'didactic_templates'] = $didactic_templates;
746 return $this->ui_factory->input()->container()->form()->standard(
747 $this->
ctrl->getFormAction($this,
'save'),
750 !$this->obj_definition->isPlugin($new_type)
751 ? $this->
lng->txt($new_type .
'_add')
753 $this->requested_new_type,
754 "{$this->requested_new_type}_add" 761 $this->
lng->loadLanguageModule(
'didactic');
765 if (
sizeof($options) < 2) {
769 $didactic_templates_radio = $this->ui_factory->input()->field()->radio($this->
lng->txt(
'type'));
771 foreach ($options as $value => $option) {
772 if ($existing_exclusive && $value ==
'dtpl_0') {
776 $didactic_templates_radio = $didactic_templates_radio->withOption($value, $option[0], $option[1] ??
'');
782 $didactic_templates_radio = $didactic_templates_radio->withValue($value);
784 if (!in_array($value, array_keys($options)) || ($existing_exclusive && $value ==
"dtpl_0")) {
786 $options[$value] = [$this->
lng->txt(
'not_available')];
789 if ($existing_exclusive) {
791 $keys = array_keys($options);
792 $didactic_templates_radio = $didactic_templates_radio->withValue($keys[1]);
794 $didactic_templates_radio = $didactic_templates_radio->withValue(
'dtpl_0');
798 return $didactic_templates_radio;
808 if (
sizeof($options) < 2) {
813 $this->
lng->txt(
'type'),
820 $type->setValue($value);
822 if (!in_array($value, array_keys($options)) || ($existing_exclusive && $value ==
"dtpl_0")) {
824 $options[$value] = [$this->
lng->txt(
'not_available')];
827 if ($existing_exclusive) {
829 $keys = array_keys($options);
830 $type->setValue($keys[1]);
832 $type->setValue(
'dtpl_0');
837 foreach ($options as $id =>
$data) {
839 if ($existing_exclusive && $id ==
'dtpl_0') {
841 $option->setDisabled(
true);
844 $type->addOption($option);
852 $this->
lng->loadLanguageModule(
'didactic');
853 $existing_exclusive =
false;
855 $options[
'dtpl_0'] = [
856 $this->
lng->txt(
'didactic_default_type'),
858 $this->
lng->txt(
'didactic_default_type_info'),
859 $this->
lng->txt(
'objs_' . $this->type)
865 foreach ($templates as $template) {
866 if ($template->isEffective((
int) $this->requested_ref_id)) {
867 $options[
"dtpl_" . $template->getId()] = [
868 $template->getPresentationTitle(),
869 $template->getPresentationDescription()
872 if ($template->isExclusive()) {
873 $existing_exclusive =
true;
893 $this->ui_factory->link()->standard(
894 $this->
lng->txt(
'cntr_adopt_content'),
895 $this->
ctrl->getLinkTargetByClass(
907 $this->ui_factory->button()->standard(
908 $this->
lng->txt(
'import'),
909 $modal->getShowSignal()
913 $this->tpl->setVariable(
914 'IL_OBJECT_IMPORT_MODAL',
915 $this->ui_renderer->render(
916 $this->import_type_selector_modal === null
918 : [$modal, $this->import_type_selector_modal]
925 return $this->ui_factory->modal()
927 $this->
lng->txt(
'import'),
930 $this->
ctrl->getFormAction($this,
'routeImportCmd')
931 )->withSubmitLabel($this->
lng->txt(
'import'));
935 ?
string $file_to_import = null,
936 ?
string $upload_file_name = null
938 return $this->ui_factory->modal()
940 $this->
lng->txt(
'select_object_type'),
942 $this->ui_factory->messageBox()->info(
943 $this->
lng->txt(
'select_import_type_info')
950 $this->
ctrl->getFormActionByClass(static::class,
'routeImportCmd')
951 )->withCloseWithKeyboard(
false)
952 ->withSubmitLabel($this->
lng->txt(
'import'));
967 $item_ref_ids = $this->retriever->getSelectedIdsFromObjectList();
970 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'msg_no_perm_write'));
978 if ($availability_period_modal !== null) {
979 $this->tpl->setVariable(
980 'IL_OBJECT_EPHEMRAL_MODALS',
981 $this->ui_renderer->render(
982 $availability_period_modal->withOnLoad(
983 $availability_period_modal->getShowSignal()
988 $this->renderObject();
998 if ($availability_period_modal ===
true) {
999 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'availability_period_changed'));
1000 } elseif ($availability_period_modal ===
false) {
1001 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'msg_no_perm_write'));
1003 $this->tpl->setVariable(
1004 'IL_OBJECT_EPHEMRAL_MODALS',
1005 $this->ui_renderer->render(
1006 $availability_period_modal->withOnLoad(
1007 $availability_period_modal->getShowSignal()
1012 $this->renderObject();
1020 $this->
ctrl->redirectByClass(
"ilrepositorygui",
"");
1027 $this->error->raiseError($this->
lng->txt(
"no_create_permission"), $this->error->MESSAGE);
1030 $this->
lng->loadLanguageModule($this->requested_new_type);
1031 $this->
ctrl->setParameter($this,
"new_type", $this->requested_new_type);
1034 ->withRequest($this->request);
1035 $data = $form->getData();
1036 if (
$data === null) {
1041 $this->
ctrl->setParameter($this,
'new_type',
'');
1043 $class_name =
'ilObj' . $this->obj_definition->getClassName($this->requested_new_type);
1045 $new_obj =
new $class_name();
1046 $new_obj->setType($this->requested_new_type);
1047 $new_obj->processAutoRating();
1048 $new_obj->setTitle(
$data[
'title_and_description']->
getTitle());
1049 $new_obj->setDescription(
$data[
'title_and_description']->getDescription());
1052 $new_obj->getObjectProperties()->storePropertyTitleAndDescription(
1053 $data[
'title_and_description']
1058 $dtpl =
$data[
'didactic_templates'] ?? null;
1059 if ($dtpl !== null) {
1061 $new_obj->applyDidacticTemplate($dtpl_id);
1077 $data = $create_form->withRequest($this->request)->getData();
1078 return isset(
$data[
'didactic_templates'])
1085 if (!$this->post_wrapper->has(
'didactic_type')) {
1089 $tpl = $this->post_wrapper->retrieve(
'didactic_type', $this->
refinery->kindlyTo()->string());
1095 if (substr($var, 0, strlen($type) + 1) != $type .
"_") {
1099 return (
int) substr($var, strlen($type) + 1);
1107 if (!$parent_node_id) {
1112 if ($this->requested_crtptrefid > 0) {
1120 $this->obj_id = $obj->
getId();
1128 $rbac_log_roles = $this->rbac_review->getParentRoleIds($this->ref_id,
false);
1141 $this->tpl->setOnScreenMessage(
"success", $this->
lng->txt(
"object_added"),
true);
1142 $this->
ctrl->returnToParent($this);
1148 $this->error->raiseError($this->
lng->txt(
"msg_no_perm_write"), $this->error->MESSAGE);
1151 $this->tabs_gui->activateTab(
"settings");
1156 $form->setValuesByArray($values);
1161 $this->tpl->setContent($form->getHTML());
1176 $form->setFormAction($this->
ctrl->getFormAction($this,
"update"));
1177 $form->setTitle($this->
lng->txt($this->object->getType() .
"_edit"));
1182 $ti->setRequired(
true);
1183 $form->addItem($ti);
1189 $form->addItem($ta);
1193 $form->addCommandButton(
"update", $this->
lng->txt(
"save"));
1207 $values[
"title"] = $this->
object->getTitle();
1208 $values[
"desc"] = $this->
object->getLongDescription();
1226 $this->error->raiseError($this->
lng->txt(
"permission_denied"), $this->error->MESSAGE);
1232 $this->
object->setTitle($form->getInput(
'title'));
1233 $this->
object->setDescription($form->getInput(
'desc'));
1234 $this->
object->update();
1241 $this->tabs_gui->activateTab(
"settings");
1242 $form->setValuesByPost();
1243 $this->tpl->setContent($form->getHTML());
1266 $this->tpl->setOnScreenMessage(
"success", $this->
lng->txt(
"msg_obj_modified"),
true);
1267 $this->
ctrl->redirect($this,
"edit");
1272 $trafo = $this->
refinery->custom()->transformation(
1273 function ($vs): array {
1277 if (!isset($vs[1])) {
1278 return [self::UPLOAD_TYPE_LOCAL => $vs[0]];
1279 } elseif ((
int) $vs[1][0] === self::UPLOAD_TYPE_LOCAL) {
1280 return [self::UPLOAD_TYPE_LOCAL => $vs[1][0][0]];
1285 $file = $export_upload->getAbsolutePathForHash($this->
user->getId(),
$type, $vs[1][0]);
1287 self::UPLOAD_TYPE_UPLOAD_DIRECTORY => $file
1295 ->getFilesFor($this->
user->getId());
1297 $field_factory = $this->ui_factory->input()->field();
1300 ->withAcceptedMimeTypes(self::SUPPORTED_IMPORT_MIME_TYPES)
1301 ->withRequired(
true)
1304 if ($upload_files !== []) {
1305 $this->
lng->loadLanguageModule(
'content');
1307 $file_upload_input = $field_factory->switchableGroup(
1309 self::UPLOAD_TYPE_LOCAL => $field_factory->group(
1310 [$file_upload_input],
1311 $this->lng->txt(
'cont_choose_local')
1313 self::UPLOAD_TYPE_UPLOAD_DIRECTORY => $field_factory->group(
1314 [$field_factory->select($this->lng->txt(
'cont_uploaded_file'), $upload_files)->withRequired(
true)],
1315 $this->
lng->txt(
'cont_choose_upload_dir'),
1318 $this->
lng->txt(
'cont_choose_file_source')
1323 'upload' => $file_upload_input->withAdditionalTransformation($trafo)
1328 ?
string $file_to_import = null,
1329 ?
string $file_name_in_temp_dir = null
1331 $ff = $this->ui_factory->input()->field();
1335 $this->
object->getPossibleSubObjects()
1338 asort($possible_sub_objects);
1341 'type' => $ff->select(
1342 $this->
lng->txt(
'select_object_type'),
1343 $possible_sub_objects
1344 )->withRequired(
true),
1345 'file_to_import' => $ff->hidden()->withValue($file_to_import),
1346 'temp_file' => $ff->hidden()->withValue($file_name_in_temp_dir)
1352 if ($this->request_wrapper->has(
'step')) {
1358 if (
$data === null) {
1363 [$new_type, $file_to_import, $path_to_uploaded_file_in_temp_dir] = $this
1364 ->retrieveFilesAndUploadTypeFromData(
$data);
1366 if ($new_type === null) {
1368 basename($file_to_import),
1369 $path_to_uploaded_file_in_temp_dir
1376 || !in_array($new_type, $this->obj_definition->getAllObjects())
1377 || !array_key_exists($new_type, $this->
object->getPossibleSubObjects())) {
1379 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'no_create_permission'));
1384 $this->
lng->loadLanguageModule($new_type);
1385 $this->
ctrl->setParameter($this,
'new_type', $new_type);
1387 $target_class =
'ilObj' . $this->obj_definition->getClassName($new_type) .
'GUI';
1389 $target =
new $target_class(
'', 0,
false,
false);
1393 $target->importFile($file_to_import, $path_to_uploaded_file_in_temp_dir);
1394 $this->
ctrl->clearParameterByClass(get_class($this),
'new_type');
1398 protected function importFile(
string $file_to_import,
string $path_to_uploaded_file_in_temp_dir): void
1403 $imp =
new ilImport($this->requested_ref_id);
1407 $new_id = $imp->importObject(
1410 basename($file_to_import),
1416 $this->tmp_import_dir = $imp->getTemporaryImportDir();
1417 $this->tpl->setOnScreenMessage(
1419 $this->
lng->txt(
'obj_import_file_error') .
' <br />' . $e->getMessage()
1425 if ($new_id === null
1427 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'import_file_not_valid_here'));
1432 $this->
ctrl->setParameter($this,
'new_type',
'');
1436 if (!$this->obj_definition->isContainer($this->type)) {
1440 if (count($ref_ids) === 1) {
1441 $new_obj->setRefId((
int) current($ref_ids));
1446 if ($path_to_uploaded_file_in_temp_dir !==
'' 1447 && $this->temp_file_system->hasDir($path_to_uploaded_file_in_temp_dir)) {
1448 $this->temp_file_system->deleteDir($path_to_uploaded_file_in_temp_dir);
1452 $this->
ctrl->setParameterByClass(get_class($new_obj),
'ref_id', $new_obj->getRefId());
1453 $this->
ctrl->redirectByClass(get_class($new_obj));
1458 if ($path_to_uploaded_file_in_temp_dir !==
'' 1459 && $this->temp_file_system->hasDir($path_to_uploaded_file_in_temp_dir)) {
1460 $this->temp_file_system->deleteDir($path_to_uploaded_file_in_temp_dir);
1467 $data = $modal->getData();
1469 if (
$data !== null) {
1473 $this->import_modal = $modal->withOnLoad($modal->getShowSignal());
1480 $data = $modal->getData();
1482 if (
$data !== null) {
1486 $this->import_type_selector_modal = $modal->withOnLoad($modal->getShowSignal());
1491 ?
string $file_to_import = null,
1492 ?
string $path_to_uploaded_file_in_temp_dir = null
1494 $this->
ctrl->setParameterByClass(static::class,
'step',
'select_type');
1497 $path_to_uploaded_file_in_temp_dir
1499 $this->
ctrl->clearParameterByClass(static::class,
'step');
1500 $this->import_type_selector_modal = $modal->withOnLoad($modal->getShowSignal());
1507 if (isset($data[
'type']) && isset($data[
'file_to_import']) && isset($data[
'temp_file'])) {
1511 DIRECTORY_SEPARATOR,
1512 [
CLIENT_DATA_DIR,
'temp', $data[
'temp_file'], $data[
'file_to_import']]
1518 $path_to_uploaded_file_in_temp_dir =
'';
1519 if (array_key_first($data[
'upload']) === self::UPLOAD_TYPE_LOCAL) {
1520 $path_to_uploaded_file_in_temp_dir = $data[
'upload'][self::UPLOAD_TYPE_LOCAL];
1526 $path_to_uploaded_file_in_temp_dir
1533 $result = preg_match(
'/[0-9]{10}__[0-9]{1,6}__([a-z]{1,4})_[0-9]{2,9}.zip/', $filename, $matches);
1534 if ($result ===
false 1536 || !isset($matches[1])) {
1544 $upload_data = $data[
'upload'];
1545 if (array_key_first($upload_data) === self::UPLOAD_TYPE_LOCAL
1546 && $this->temp_file_system->hasDir($upload_data[self::UPLOAD_TYPE_LOCAL])) {
1547 $files = $this->temp_file_system->listContents($upload_data[self::UPLOAD_TYPE_LOCAL]);
1549 .
'temp' . DIRECTORY_SEPARATOR
1550 . $files[0]->getPath();
1552 return $upload_data[self::UPLOAD_TYPE_UPLOAD_DIRECTORY];
1560 $this->tpl->setOnScreenMessage(
"success", $this->
lng->txt(
"object_added"),
true);
1561 $this->
ctrl->returnToParent($this);
1567 public function getFormAction(
string $cmd,
string $default_form_action =
""): string
1569 if ($this->form_action[$cmd] !=
"") {
1570 return $this->form_action[$cmd];
1573 return $default_form_action;
1586 if (($this->return_location[$cmd] ??
"") !==
"") {
1587 return $this->return_location[$cmd];
1589 return $default_location;
1598 $this->return_location[$cmd] =
$location;
1604 protected function getTargetFrame(
string $cmd,
string $default_target_frame =
""): string
1606 if (isset($this->target_frame[$cmd]) && $this->target_frame[$cmd] !=
"") {
1607 return $this->target_frame[$cmd];
1610 if (!empty($default_target_frame)) {
1611 return "target=\"" . $default_target_frame .
"\"";
1622 $this->target_frame[$cmd] =
"target=\"" . $target_frame .
"\"";
1629 if ($visible && $type ==
'crs') {
1636 if (!$tmp_obj->isActivated()) {
1654 $this->tabs_gui->activateTab(
'view');
1657 $this->
object->getType(),
1658 $this->
object->getRefId(),
1659 $this->
object->getId(),
1660 $this->
user->getId()
1664 $this->
ctrl->setParameter($this,
'obj_id', $this->obj_id);
1670 $this->requested_ref_id,
1674 $this->tpl->setContent($itab->getHTML());
1685 if ($this->post_wrapper->has(
'id')) {
1686 $request_ids = $this->post_wrapper->retrieve(
1693 $this->request_wrapper->has(
'item_ref_id')
1694 && $this->request_wrapper->retrieve(
'item_ref_id', $this->
refinery->kindlyTo()->string()) !==
"" 1696 $request_ids = [$this->request_wrapper->retrieve(
'item_ref_id', $this->
refinery->kindlyTo()->int())];
1699 if ($request_ids === []) {
1700 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'no_checkbox'),
true);
1701 $this->
ctrl->returnToParent($this);
1705 $this->tpl->setVariable(
1706 'IL_OBJECT_EPHEMRAL_MODALS',
1707 $this->ui_renderer->render(
1708 $modal->withOnLoad($modal->getShowSignal())
1711 $this->renderObject();
1718 $msg = $this->
lng->txt(
'info_delete_sure');
1719 if (!$this->
settings->get(
'enable_trash')) {
1720 $msg .=
"<br/>" . $this->
lng->txt(
'info_delete_warning_no_trash');
1724 $this->ui_factory->messageBox()->confirmation($msg),
1725 $this->ui_factory->listing()->unordered($listing_items)
1728 if ($has_additional_references) {
1729 $content[] = $this->ui_factory->messageBox()->confirmation(
1730 $this->
lng->txt(
'multiple_reference_deletion_info') .
' ' 1731 . $this->
lng->txt(
'rep_multiple_reference_deletion_instruction')
1735 $this->
ctrl->setParameterByClass(static::class,
'id', implode(
',', $request_ids));
1736 $target_url = $this->
ctrl->getFormActionByClass(static::class,
'confirmedDelete');
1737 $this->
ctrl->clearParameterByClass(static::class,
'id');
1739 return $this->ui_factory->modal()->roundtrip(
1740 $this->
lng->txt(
'confirm'),
1744 )->withSubmitLabel($this->
lng->txt(
'delete'));
1750 $path_gui->enableTextOnly(
true);
1751 $path_gui->enableHideLeaf(
false);
1752 return array_reduce(
1754 function (array
$c,
int $v) use ($path_gui): array {
1758 $c[1][] = $this->ui_factory->input()->field()->hidden()->withValue($v);
1761 if ($other_references !== []) {
1762 $c[1][] = $this->ui_factory->input()->field()->multiSelect(
1778 return array_reduce(
1780 function (array
$c,
int $v) use ($ref_id, $path_gui): array {
1782 && !$this->tree->isDeleted($v)
1783 && $this->
access->checkAccess(
'delete',
'', $v)) {
1797 if ($this->sub_objects ==
"") {
1798 $sub_objects = $this->obj_definition->getCreatableSubObjects(
1799 $this->
object->getType(),
1808 if (count($sub_objects) > 0) {
1809 foreach ($sub_objects as $row) {
1811 if ($row[
"max"] > 0) {
1813 for ($i = 0; $i < count($this->data[
"ctrl"]); $i++) {
1814 if ($this->data[
"ctrl"][$i][
"type"] == $row[
"name"]) {
1820 if ($row[
"max"] ==
"" || $count < $row[
"max"]) {
1821 $subobj[] = $row[
"name"];
1826 if (count($subobj) > 0) {
1828 $this->tpl->setCurrentBlock(
"add_object");
1829 $this->tpl->setVariable(
"SELECT_OBJTYPE", $opts);
1830 $this->tpl->setVariable(
"BTN_NAME",
"create");
1831 $this->tpl->setVariable(
"TXT_ADD", $this->
lng->txt(
"add"));
1832 $this->tpl->parseCurrentBlock();
1853 $class_name = $this->obj_definition->getClassName($obj_type);
1854 $class = strtolower(
"ilObj" . $class_name .
"GUI");
1855 $this->
ctrl->setParameterByClass(
"ilrepositorygui",
"ref_id", $ref_id);
1856 $this->
ctrl->redirectByClass([
"ilrepositorygui", $class], $cmd);
1867 if ($this->
ctrl->getNextClass() !=
"ilcolumngui") {
1871 if (!$this->
ctrl->isAsynch()) {
1878 $this->
html = $this->
ctrl->forwardCommand($column_gui);
1884 $this->
html = $this->
ctrl->forwardCommand($column_gui);
1913 $this->
ctrl->getNextClass() ==
"ilcolumngui" &&
1917 return $this->
ctrl->forwardCommand($column_gui);
1920 if (!$this->
ctrl->isAsynch()) {
1921 return $this->
ctrl->getHTML($column_gui);
1936 protected function checkPermission(
string $perm,
string $cmd =
"",
string $type =
"", ?
int $ref_id = null): void
1939 if (!is_int(strpos(
$_SERVER[
'PHP_SELF'],
'goto.php'))) {
1940 if ($perm !=
'create' && !is_object($this->
object)) {
1946 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'msg_no_perm_read'),
true);
1947 $parent_ref_id = $this->tree->getParentId($this->
object->getRefId());
1948 if ($parent_ref_id > 0) {
1949 $this->
ctrl->redirectToURL(ilLink::_getLink($parent_ref_id));
1951 $this->
ctrl->redirectToURL(
'login.php?cmd=force_login');
1955 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'msg_no_perm_read'),
true);
1956 self::_gotoRepositoryRoot();
1960 protected function checkPermissionBool(
string $perm,
string $cmd =
"",
string $type =
"", ?
int $ref_id = null): bool
1962 if ($perm ===
"create") {
1966 return $this->
access->checkAccess($perm .
"_" . $type, $cmd, $ref_id);
1969 if (!is_object($this->
object)) {
1974 $ref_id = $this->
object->getRefId();
1977 return $this->
access->checkAccess($perm, $cmd, $ref_id);
1990 $ilAccess = $DIC->access();
1992 $lng = $DIC->language();
1993 $ctrl = $DIC->ctrl();
2009 $ctrl = $DIC->ctrl();
2018 $ctrl = $DIC->ctrl();
2028 $this->tpl->setFileUploadRefId($this->ref_id);
2033 $this->favourites->add(
2034 $this->
user->getId(),
2035 $this->request_wrapper->retrieve(
"item_ref_id", $this->
refinery->kindlyTo()->int())
2037 $this->
lng->loadLanguageModule(
"rep");
2038 $this->tpl->setOnScreenMessage(
"success", $this->
lng->txt(
"rep_added_to_favourites"),
true);
2039 $this->
ctrl->redirectToURL(ilLink::_getLink($this->requested_ref_id));
2044 $this->
lng->loadLanguageModule(
"rep");
2045 $item_ref_id = $this->request_wrapper->retrieve(
"item_ref_id", $this->
refinery->kindlyTo()->int());
2046 $this->favourites->remove($this->
user->getId(), $item_ref_id);
2047 $this->tpl->setOnScreenMessage(
"success", $this->
lng->txt(
"rep_removed_from_favourites"),
true);
2048 $this->
ctrl->redirectToURL(ilLink::_getLink($this->requested_ref_id));
2053 $subtypes = $this->obj_definition->getCreatableSubObjects(
2054 $this->
object->getType(),
2056 $this->
object->getRefId()
2059 return array_filter(
2061 fn($key) => $this->
access->checkAccess(
'create_' . $key,
'', $this->ref_id, $this->type),
2062 ARRAY_FILTER_USE_KEY
2068 string $create_target_class = ilRepositoryGUI::class,
2069 ?
int $redirect_target_ref_id = null,
2071 if ($subtypes === []) {
2074 if ($redirect_target_ref_id !== null) {
2075 $this->
ctrl->setParameterByClass($create_target_class,
'crtcb', (
string) $redirect_target_ref_id);
2079 $create_target_class,
2084 if ($elements === []) {
2086 $create_target_class,
2092 $this->
ctrl->clearParameterByClass(self::class,
'crtcb');
2097 string $create_target_class,
2098 array $new_item_groups,
2099 array $new_item_groups_subitems,
2102 if ($new_item_groups === []) {
2106 $new_item_groups[0] = $this->
lng->txt(
'rep_new_item_group_other');
2107 $add_new_item_elements = [];
2108 foreach ($new_item_groups as $group_id => $group) {
2109 if (empty($new_item_groups_subitems[$group_id])) {
2113 $create_target_class,
2114 $new_item_groups_subitems[$group_id],
2115 $group[
'title'] ?? $group,
2119 if ($group_element !== null) {
2120 $add_new_item_elements[] = $group_element;
2124 return $add_new_item_elements;
2128 string $create_target_class,
2129 array $default_groups,
2132 $add_new_item_elements = [];
2133 $grouped_types = [];
2135 foreach ($default_groups[
'groups'] as $group_id => $group) {
2136 $obj_types_in_group = array_keys(
2138 $default_groups[
'items'],
2139 fn($item_group_id) => $item_group_id === $group_id
2142 $grouped_types = array_merge($grouped_types, $obj_types_in_group);
2145 $create_target_class,
2146 $obj_types_in_group,
2151 if ($group_element !== null) {
2152 $add_new_item_elements[$group[
'pos']] = $group_element;
2156 $ungrouped_types = array_diff(array_keys($subtypes), $grouped_types);
2157 if ($ungrouped_types !== []) {
2158 $add_new_item_elements[] = $this->
buildGroup(
2159 $create_target_class,
2161 $this->
lng->txt(
'rep_new_item_group_other'),
2166 return $add_new_item_elements;
2170 string $create_target_class,
2171 array $obj_types_in_group,
2176 $create_target_class,
2177 $obj_types_in_group,
2180 if ($add_new_items_content_array === []) {
2188 $add_new_items_content_array
2193 string $create_target_class,
2194 array $obj_types_in_group,
2197 $add_new_items_content_array = [];
2198 foreach ($obj_types_in_group as $type) {
2199 if (!array_key_exists($type, $subtypes)) {
2202 $subitem = $subtypes[
$type];
2203 $this->
ctrl->setParameterByClass($create_target_class,
'new_type', $type);
2205 AddNewItemElementTypes::Object,
2207 empty($subitem[
'plugin'])
2208 ? $this->ui_factory->symbol()->icon()->standard($type,
'')
2209 : $this->ui_factory->symbol()->icon()->custom(
2214 ILIAS_HTTP_PATH .
'/' . $this->
ctrl->getLinkTargetByClass($create_target_class,
'create')
2217 $this->
ctrl->clearParameterByClass($create_target_class,
'new_type', $type);
2219 ksort($add_new_items_content_array);
2220 return $add_new_items_content_array;
2225 foreach ($ref_ids as $ref_id) {
2226 if (!$this->
access->checkAccess(
'write',
'', $ref_id)) {
2235 return empty($item_array[
'plugin'])
2236 ? $this->
lng->txt(
'obj_' . $item_array[
'lng'])
redrawHeaderActionObject()
Ajax call: redraw action header only.
ilObjectDefinition $obj_definition
saveAvailabilityPeriodObject()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
omitLocator(bool $omit=true)
buildDidacticTemplateOptions()
setAdminMode(string $mode)
const ADMIN_MODE_REPOSITORY
setLocator()
Insert locator.
ilRbacReview $rbac_review
getTargetFrame(string $cmd, string $default_target_frame="")
get target frame for command (command is method name without "Object", e.g.
static getCmdSide()
Get Column Side of Current Command.
ilRbacSystem $rbac_system
buildRefIdsFromData(array $data)
redirectByClass( $a_class, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
getTabs()
overwrite in derived GUI class of your object type
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
enableDragDropFileUpload()
Enables the file upload into this object by dropping files.
TableGUI class for sub items listed in repository administration.
const SUPPORTED_IMPORT_MIME_TYPES
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
cancelCreation()
cancel create action and go back to repository parent
getFormAction(string $cmd, string $default_form_action="")
Get form action for command (command is method name without "Object", e.g.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getCreationFormsHTML(StandardForm|ilPropertyFormGUI|array $form)
cancelObject()
cancel action and go back to previous page
ilObjectRequestRetriever $retriever
$location
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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.
static prepareJsLinks(string $redraw_url, string $notes_url, string $tags_url, ilGlobalTemplateInterface $tpl=null)
Insert js/ajax links into template.
buildInputsForAdditionalDeletionReferences(int $ref_id, ilPathGUI $path_gui)
getFileToImportFromImportFormData(array $data)
static _getAllReferences(int $id)
get all reference ids for object ID
redirectToRefId(int $ref_id, string $cmd="")
redirects to (repository) view per ref id usually to a container and usually used at the end of a sav...
isVisible(int $ref_id, string $type)
static getNewItemGroups()
buildSubItemsForGroup(string $create_target_class, array $obj_types_in_group, array $subtypes)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getDidacticTemplateVar(string $type)
Get didactic template setting from creation screen.
static _gotoRepositoryNode(int $ref_id, string $cmd="")
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()
Manages favourites, currently the interface for other components, needs discussion.
setEnableEdit(bool $a_enableedit)
static _lookupContainerSetting(int $a_id, string $a_keyword, string $a_default_value=null)
setFormAction(string $cmd, string $form_action)
addExternalEditFormCustom(ilPropertyFormGUI $form)
static _lookupObjId(int $ref_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
buildImportTypeSelectorInputs(?string $file_to_import=null, ?string $file_name_in_temp_dir=null)
setCreationMode(bool $mode=true)
If true, a creation screen is displayed the current [ref_id] does belong to the parent class The mode...
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()
retrieveFilesAndUploadTypeFromData(array $data)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilGlobalTemplateInterface $tpl
static _lookupTitle(int $obj_id)
ILIAS Notes Service $notes_service
checkWritePermissionOnRefIdArray(array $ref_ids)
Column user interface class.
ServerRequestInterface $request
const ADMIN_MODE_SETTINGS
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)
The scope of this class is split ilias-conform URI's into components.
ilObjectService $object_service
Class ilObjForumAdministration.
afterSave(ilObject $new_object)
Post (successful) object creation hook.
static _getListGUIByType(string $type, int $context=ilObjectListGUI::CONTEXT_REPOSITORY)
getTranslatedObjectTypeNameFromItemArray(array $item_array)
afterImport(ilObject $new_object)
Post (successful) object import hook.
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()
MultiObjectPropertiesManipulator $multi_object_manipulator
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)
putObjectInTree(ilObject $obj, int $parent_node_id=null)
Add object to tree at given position.
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 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
Class ilContainerGUI This is a base GUI class for all container objects in ILIAS: root folder...
getCreatableObjectTypes()
setTargetFrame(string $cmd, string $target_frame)
Set specific target frame for command.
ilObjectCustomIconFactory $custom_icon_factory
Class ilRbacAdmin Core functions for role based access control.
buildImportTypeSelectorModal(?string $file_to_import=null, ?string $upload_file_name=null)
initHeaderAction(?string $sub_type=null, ?int $sub_id=null)
Add header action menu.
addAdminLocatorItems(bool $do_not_add_object=false)
should be overwritten to add object specific items (repository items are preloaded) ...
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.