ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilObjRepositorySettingsGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
28 
36 {
42  protected UIFactory $factory;
43  protected UIRenderer $renderer;
44  protected RefFactory $refinery;
45 
46  public function __construct(
47  $a_data,
48  int $a_id,
49  bool $a_call_by_reference = true,
50  bool $a_prepare_output = true
51  ) {
52  global $DIC;
53 
54  $this->error = $DIC["ilErr"];
55  $this->access = $DIC->access();
56  $this->rbacsystem = $DIC->rbac()->system();
57  $this->settings = $DIC->settings();
58  $this->folder_settings = new ilSetting('fold');
59  $this->http = $DIC->http();
60  $this->ctrl = $DIC->ctrl();
61  $this->lng = $DIC->language();
62  $this->toolbar = $DIC->toolbar();
63  $this->factory = $DIC->ui()->factory();
64  $this->renderer = $DIC->ui()->renderer();
65  $this->refinery = $DIC->refinery();
66  parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
67 
68  $this->type = 'reps';
69  $this->lng->loadLanguageModule('rep');
70  $this->lng->loadLanguageModule('cmps');
71 
72  $this->admin_gui_request = $DIC
73  ->repository()
74  ->internal()
75  ->gui()
76  ->administration()
77  ->request();
78  }
79 
80  public function executeCommand(): void
81  {
83  $ilAccess = $this->access;
84 
85  $next_class = $this->ctrl->getNextClass($this);
86  $cmd = $this->ctrl->getCmd();
87 
88  $this->prepareOutput();
89 
90  if (!$ilAccess->checkAccess('read', '', $this->object->getRefId())) {
91  $ilErr->raiseError($this->lng->txt('no_permission'), $ilErr->WARNING);
92  }
93 
94  switch ($next_class) {
95  case 'ilpermissiongui':
96  $this->tabs_gui->setTabActive('perm_settings');
97  $perm_gui = new ilPermissionGUI($this);
98  $this->ctrl->forwardCommand($perm_gui);
99  break;
100 
101  default:
102  $this->$cmd();
103  break;
104  }
105  }
106 
107  public function getAdminTabs(): void
108  {
109  $rbacsystem = $this->rbacsystem;
110 
111  $this->tabs_gui->addTab(
112  "settings",
113  $this->lng->txt("settings"),
114  $this->ctrl->getLinkTarget($this, "view")
115  );
116 
117  $this->tabs_gui->addTab(
118  "icons",
119  $this->lng->txt("rep_custom_icons"),
120  $this->ctrl->getLinkTarget($this, "customIcons")
121  );
122 
123  $this->tabs_gui->addTab(
124  "modules",
125  $this->lng->txt("cmps_repository_object_types"),
126  $this->ctrl->getLinkTarget($this, "listModules")
127  );
128 
129  if ($rbacsystem->checkAccess('edit_permission', $this->object->getRefId())) {
130  $this->tabs_gui->addTab(
131  "perm_settings",
132  $this->lng->txt("perm_settings"),
133  $this->ctrl->getLinkTargetByClass('ilpermissiongui', "perm")
134  );
135  }
136  }
137 
138  public function view(StandardForm $a_form = null): void
139  {
140  $this->tabs_gui->activateTab("settings");
141 
142  if (!$a_form) {
143  $a_form = $this->initSettingsForm();
144  }
145 
146  $this->tpl->setContent($this->renderer->render($a_form));
147  }
148 
149  protected function initSettingsForm(): StandardForm
150  {
152  $ilAccess = $this->access;
153 
154  $read_only = !$ilAccess->checkAccess('write', '', $this->object->getRefId());
155 
156  $f = $this->factory->input()->field();
157 
158  // repository tree
159  $op1 = $f->group(
160  [],
161  $this->lng->txt("adm_rep_tree_only_cntr")
162  )->withByline($this->lng->txt("adm_rep_tree_only_cntr_info"));
163 
164  // limit tree in courses and groups
165  $cb = $f->checkbox(
166  $this->lng->txt("adm_rep_tree_limit_grp_crs"),
167  $this->lng->txt("adm_rep_tree_limit_grp_crs_info")
168  )->withValue((bool) $ilSetting->get("rep_tree_limit_grp_crs"));
169 
170  $op2 = $f->group(
171  [
172  'rep_tree_limit_grp_crs' => $cb
173  ],
174  $this->lng->txt("adm_rep_tree_all_types")
175  )->withByline($this->lng->txt("adm_rep_tree_all_types_info"));
176 
177  $tree_pres = $f->switchableGroup(
178  [
179  '' => $op1,
180  'all_types' => $op2
181  ],
182  $this->lng->txt("adm_rep_tree_presentation")
183  )->withValue($ilSetting->get("repository_tree_pres") ?? "");
184 
185  // limit items in tree (number)
186  $tree_limit_number = $f->numeric(
187  $this->lng->txt("rep_tree_limit_number"),
188  $this->lng->txt("rep_tree_limit_number_info")
189  )->withValue($ilSetting->get("rep_tree_limit_number"))
192 
193  // limit items in tree
194  $tree_limit = $f->optionalGroup(
195  [
196  'rep_tree_limit_number' => $tree_limit_number
197  ],
198  $this->lng->txt("rep_tree_limit"),
199  $this->lng->txt("rep_tree_limit_info")
200  );
201  if ($ilSetting->get("rep_tree_limit_number") <= 0) {
202  $tree_limit = $tree_limit->withValue(null);
203  }
204 
205  // breadcrumbs start with courses
206  $change_mode = $f->radio(
207  $this->lng->txt("rep_breadcr_crs_config")
208  )->withOption(
209  '1',
210  $this->lng->txt("rep_breadcr_crs_overwrite")
211  )->withOption(
212  'rep_breadcr_crs_default',
213  $this->lng->txt("rep_breadcr_crs_overwrite_with_default")
214  )->withOption(
215  '0',
216  $this->lng->txt("rep_breadcr_crs_overwrite_not")
217  )->withValue((string) ((int) $ilSetting->get("rep_breadcr_crs_overwrite")));
218  if ($ilSetting->get("rep_breadcr_crs_default")) {
219  $change_mode = $change_mode->withValue('rep_breadcr_crs_default');
220  }
221 
222  $breadcrumbs = $f->optionalGroup(
223  [
224  'rep_breadcr_crs_overwrite' => $change_mode
225  ],
226  $this->lng->txt("rep_breadcr_crs")
227  );
228  if (!$ilSetting->get("rep_breadcr_crs")) {
229  $breadcrumbs = $breadcrumbs->withValue(null);
230  }
231 
232  // trash
233  $enable_trash = $f->checkbox(
234  $this->lng->txt("enable_trash"),
235  $this->lng->txt("enable_trash_info")
236  )->withValue((bool) $ilSetting->get("enable_trash"));
237 
238  // change event
239  $this->lng->loadLanguageModule("trac");
240  $event = $f->checkbox(
241  $this->lng->txt('trac_show_repository_views'),
242  $this->lng->txt("trac_show_repository_views_info")
244 
245  // export limitations
246  $exp_disabled = $f->group(
247  [],
248  $this->lng->txt("rep_export_limitation_disabled")
249  );
250 
251  // export unlimited
252  $exp_unlimited = $f->group(
253  [],
254  $this->lng->txt("rep_export_limitation_unlimited")
255  );
256 
257  // limit export items (number)
258  $exp_limit_num = $f->numeric(
259  $this->lng->txt("rep_export_limit_number")
262  ->withValue($ilSetting->get("rep_export_limit_number"))
263  ->withRequired(true);
264 
265  $exp_limited = $f->group(
266  [
267  'rep_export_limit_number' => $exp_limit_num
268  ],
269  $this->lng->txt("rep_export_limitation_limited")
270  );
271 
272  $limiter = new ilExportLimitation();
273  $exp_limit = $f->switchableGroup(
274  [
275  (string) ilExportLimitation::SET_EXPORT_DISABLED => $exp_disabled,
276  (string) ilExportLimitation::SET_EXPORT_LIMITED => $exp_limited,
277  'rep_export_unlimited' => $exp_unlimited
278  ],
279  $this->lng->txt("rep_export_limitation"),
280  $this->lng->txt("rep_export_limitation_info")
281  )->withValue((string) $limiter->getLimitationMode());
282 
283  if (
284  $limiter->getLimitationMode() === ilExportLimitation::SET_EXPORT_LIMITED &&
285  $ilSetting->get("rep_export_limit_number") === ''
286  ) {
287  $exp_limit = $exp_limit->withValue('rep_export_unlimited');
288  }
289 
290  // Show download action for folder
291  $dl_prob = $f->checkbox(
292  $this->lng->txt("enable_download_folder"),
293  $this->lng->txt('enable_download_folder_info')
294  )->withValue(
295  (int) $this->folder_settings->get(
296  "enable_download_folder",
297  '0'
298  ) === 1
299  ); // default value should reflect previous behaviour (-> 0)
300 
301  // multi download
302  $dl_prop = $f->checkbox(
303  $this->lng->txt("enable_multi_download"),
304  $this->lng->txt('enable_multi_download_info')
305  )->withValue(
306  (int) $this->folder_settings->get(
307  "enable_multi_download",
308  '1'
309  ) === 1
310  ); // default value should reflect previous behaviour (-> 0)
311 
312  // favourites
313  $fav = $f->checkbox(
314  $this->lng->txt("rep_favourites"),
315  $this->lng->txt("rep_favourites_info")
316  )->withValue($ilSetting->get("rep_favourites", "0") === "1");
317 
318  //TODO split this up into two sections
319  $settings = $f->section(
320  [
321  'tree_pres' => $tree_pres,
322  'rep_tree_limit' => $tree_limit,
323  'rep_breadcr_crs' => $breadcrumbs,
324  'enable_trash' => $enable_trash,
325  'change_event_tracking' => $event,
326  'rep_export_limitation' => $exp_limit,
327  'enable_download_folder' => $dl_prob,
328  'enable_multi_download' => $dl_prop,
329  'rep_favourites' => $fav
330  ],
331  $this->lng->txt("settings")
332  )->withDisabled($read_only);
333 
334  // object lists
335  //shorten description
336  $sdesclen = $f->numeric(
337  $this->lng->txt("adm_rep_shorten_description_length")
338  )->withValue($ilSetting->get("rep_shorten_description_length"))
341 
342  $sdesc = $f->optionalGroup(
343  [
344  'rep_shorten_description_length' => $sdesclen
345  ],
346  $this->lng->txt("adm_rep_shorten_description"),
347  $this->lng->txt("adm_rep_shorten_description_info")
348  );
349  if (!$ilSetting->get("rep_shorten_description")) {
350  $sdesc = $sdesc->withValue(null);
351  }
352 
353  // load action commands asynchronously
354  $async = $f->checkbox(
355  $this->lng->txt("adm_item_cmd_asynch"),
356  $this->lng->txt("adm_item_cmd_asynch_info")
357  )->withValue((bool) $ilSetting->get("item_cmd_asynch"));
358 
359  // notes/comments/tagging
360  $pltags = $f->checkbox(
361  $this->lng->txt('adm_show_comments_tagging_in_lists_tags')
362  )->withValue((bool) $ilSetting->get('comments_tagging_in_lists_tags'));
363 
364  $pl = $f->optionalGroup(
365  [
366  'comments_tagging_in_lists_tags' => $pltags
367  ],
368  $this->lng->txt('adm_show_comments_tagging_in_lists')
369  );
370  if (!$ilSetting->get('comments_tagging_in_lists')) {
371  $pl = $pl->withValue(null);
372  }
373 
374  $obj_lists = $f->section(
375  [
376  'rep_shorten_description' => $sdesc,
377  'item_cmd_asynch' => $async,
378  'comments_tagging_in_lists' => $pl
379  ],
380  $this->lng->txt("rep_object_lists")
381  )->withDisabled($read_only);
382 
383  $form = $this->factory->input()->container()->form()->standard(
384  $this->ctrl->getFormAction($this, 'saveSettings'),
385  [
386  'settings' => $settings,
387  'obj_lists' => $obj_lists
388  ]
389  );
390 
391  return $form;
392  }
393 
394  public function saveSettings(): void
395  {
397  $ilAccess = $this->access;
398 
399  if (!$ilAccess->checkAccess('write', '', $this->object->getRefId())) {
400  $this->tpl->setOnScreenMessage(
401  'failure',
402  $this->lng->txt('permission_denied'),
403  true
404  );
405  $this->ctrl->redirect($this, "view");
406  }
407 
408  $form = $this->initSettingsForm()
409  ->withRequest($this->http->request());
410  if ($form->getData()) {
411  $data = $form->getData()['settings'];
412  $ilSetting->set(
413  "repository_tree_pres",
414  $data["tree_pres"][0]
415  );
416  if ($data['tree_pres'][0] === 'all_types') {
417  $ilSetting->set(
418  "rep_tree_limit_grp_crs",
419  (string) $data['tree_pres'][1]["rep_tree_limit_grp_crs"] ?? ''
420  );
421  }
422 
423  $ilSetting->set(
424  "rep_favourites",
425  $data["rep_favourites"] ? "1" : "0"
426  );
427 
428  if ($data["rep_export_limitation"][0] === 'rep_export_unlimited') {
429  $ilSetting->set(
430  "rep_export_limitation",
432  );
433  $ilSetting->set(
434  "rep_export_limit_number",
435  ''
436  );
437  } else {
438  $ilSetting->set(
439  "rep_export_limitation",
440  (string) $data["rep_export_limitation"][0]
441  );
442  }
443  if ($data["rep_export_limitation"][0] === (string) ilExportLimitation::SET_EXPORT_LIMITED) {
444  $ilSetting->set(
445  "rep_export_limit_number",
446  (string) ($data["rep_export_limitation"][1]["rep_export_limit_number"] ?? '')
447  );
448  }
449 
450  $ilSetting->set(
451  "enable_trash",
452  (string) $data["enable_trash"]
453  );
454 
455  $ilSetting->set(
456  "rep_breadcr_crs",
457  (string) ((int) $data["rep_breadcr_crs"])
458  );
459  if (isset($data["rep_breadcr_crs"])) {
460  $overwrite = $data["rep_breadcr_crs"]["rep_breadcr_crs_overwrite"];
461  $ilSetting->set(
462  "rep_breadcr_crs_default",
463  (string) ((int) ($overwrite === 'rep_breadcr_crs_default'))
464  );
465  if ($overwrite === 'rep_breadcr_crs_default') {
466  $overwrite = '1';
467  }
468  $ilSetting->set(
469  "rep_breadcr_crs_overwrite",
470  (string) ((int) $overwrite)
471  );
472  }
473 
474  // repository tree limit of children
475  $limit_number = ($data['rep_tree_limit'] &&
476  $data['rep_tree_limit']['rep_tree_limit_number'] > 0)
477  ? (int) $data['rep_tree_limit']['rep_tree_limit_number']
478  : 0;
479  $ilSetting->set('rep_tree_limit_number', (string) $limit_number);
480 
481  $this->folder_settings->set(
482  "enable_download_folder",
483  (string) ((int) $data["enable_download_folder"] === 1)
484  );
485  $this->folder_settings->set(
486  "enable_multi_download",
487  (string) ((int) $data["enable_multi_download"] === 1)
488  );
489  if ($data['change_event_tracking']) {
491  } else {
493  }
494 
495  //object lists
496  $data = $form->getData()['obj_lists'];
497  $ilSetting->set(
498  "rep_shorten_description",
499  (string) ((int) $data['rep_shorten_description'])
500  );
501  if (isset($data['rep_shorten_description'])) {
502  $ilSetting->set(
503  "rep_shorten_description_length",
504  (string) ((int) $data['rep_shorten_description']['rep_shorten_description_length'])
505  );
506  }
507  $ilSetting->set(
508  'item_cmd_asynch',
509  (string) ((int) $data['item_cmd_asynch'])
510  );
511  $ilSetting->set(
512  'comments_tagging_in_lists',
513  (string) ((int) $data['comments_tagging_in_lists'])
514  );
515  if (isset($data['comments_tagging_in_lists'])) {
516  $ilSetting->set(
517  'comments_tagging_in_lists_tags',
518  (string) $data['comments_tagging_in_lists']['comments_tagging_in_lists_tags']
519  );
520  }
521 
522  $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
523  $this->ctrl->redirect($this, "view");
524  }
525 
526  $this->view($form);
527  }
528 
529  public function customIcons(StandardForm $a_form = null): void
530  {
531  $this->tabs_gui->activateTab("icons");
532 
533  if (!$a_form) {
534  $a_form = $this->initCustomIconsForm();
535  }
536 
537  $this->tpl->setContent($this->renderer->render($a_form));
538  }
539 
540  protected function initCustomIconsForm(): StandardForm
541  {
543  $ilAccess = $this->access;
544 
545  $cb = $this->factory->input()->field()->checkbox(
546  $this->lng->txt("enable_custom_icons"),
547  $this->lng->txt("enable_custom_icons_info")
548  )->withValue((bool) $ilSetting->get("custom_icons"));
549 
550  $section = $this->factory->input()->field()->section(
551  ['custom_icons' => $cb],
552  $this->lng->txt("rep_custom_icons")
553  )->withDisabled(
554  !$ilAccess->checkAccess('write', '', $this->object->getRefId())
555  );
556 
557  $form = $this->factory->input()->container()->form()->standard(
558  $this->ctrl->getFormAction($this, 'saveCustomIcons'),
559  ['section' => $section]
560  );
561 
562  return $form;
563  }
564 
565  public function saveCustomIcons(): void
566  {
568  $ilAccess = $this->access;
569 
570  if (!$ilAccess->checkAccess('write', '', $this->object->getRefId())) {
571  $this->tpl->setOnScreenMessage(
572  'failure',
573  $this->lng->txt('permission_denied'),
574  true
575  );
576  $this->ctrl->redirect($this, "customIcons");
577  }
578 
579  $form = $this->initCustomIconsForm()
580  ->withRequest($this->http->request());
581  if ($form->getData()) {
582  $ilSetting->set(
583  "custom_icons",
584  (string) ((int) $form->getData()['section']['custom_icons'])
585  );
586  $this->tpl->setOnScreenMessage(
587  'success',
588  $this->lng->txt("msg_obj_modified"),
589  true
590  );
591  $this->ctrl->redirect($this, "customIcons");
592  }
593 
594  $this->customIcons($form);
595  }
596 
597  protected function setModuleSubTabs(string $a_active): void
598  {
599  $this->tabs_gui->activateTab('modules');
600 
601  $this->tabs_gui->addSubTab(
602  "list_mods",
603  $this->lng->txt("rep_new_item_menu"),
604  $this->ctrl->getLinkTarget($this, "listModules")
605  );
606 
607  $this->tabs_gui->addSubTab(
608  "new_item_groups",
609  $this->lng->txt("rep_new_item_groups"),
610  $this->ctrl->getLinkTarget($this, "listNewItemGroups")
611  );
612 
613  $this->tabs_gui->activateSubTab($a_active);
614  }
615 
616  protected function listModules(): void
617  {
618  $ilAccess = $this->access;
619 
620  $this->setModuleSubTabs("list_mods");
621 
622  $has_write = $ilAccess->checkAccess('write', '', $this->object->getRefId());
623 
624  $comp_table = new ilModulesTableGUI($this, "listModules", $has_write);
625 
626  $this->tpl->setContent($comp_table->getHTML());
627  }
628 
629  protected function saveModules(): void
630  {
632  $ilCtrl = $this->ctrl;
633  $lng = $this->lng;
634  $ilAccess = $this->access;
635 
636  $item_groups = $this->admin_gui_request->getNewItemGroups();
637  $item_positions = $this->admin_gui_request->getNewItemPositions();
638 
639  if (count($item_groups) === 0 || count($item_positions) === 0 ||
640  !$ilAccess->checkAccess('write', '', $this->object->getRefId())) {
641  $ilCtrl->redirect($this, "listModules");
642  }
643 
644  $grp_pos_map = [0 => 9999];
645  foreach (ilObjRepositorySettings::getNewItemGroups() as $item) {
646  $grp_pos_map[$item["id"]] = $item["pos"];
647  }
648 
649  $type_pos_map = [];
650  $item_enablings = $this->admin_gui_request->getNewItemEnablings();
651  foreach ($item_positions as $obj_type => $pos) {
652  $grp_id = ($item_groups[$obj_type] ?? 0);
653  $type_pos_map[$grp_id][$obj_type] = $pos;
654 
655  // enable creation?
656  $ilSetting->set(
657  "obj_dis_creation_" . $obj_type,
658  (string) ((int) (!($item_enablings[$obj_type] ?? false)))
659  );
660  }
661 
662  foreach ($type_pos_map as $grp_id => $obj_types) {
663  $grp_pos = str_pad((string) $grp_pos_map[$grp_id], 4, "0", STR_PAD_LEFT);
664 
665  asort($obj_types);
666  $pos = 0;
667  foreach (array_keys($obj_types) as $obj_type) {
668  $pos += 10;
669  $type_pos = $grp_pos . str_pad((string) $pos, 4, "0", STR_PAD_LEFT);
670  $ilSetting->set("obj_add_new_pos_" . $obj_type, (string) $type_pos);
671  $ilSetting->set("obj_add_new_pos_grp_" . $obj_type, (string) $grp_id);
672  }
673  }
674 
675  $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
676  $ilCtrl->redirect($this, "listModules");
677  }
678 
679  protected function listNewItemGroups(): void
680  {
681  $ilToolbar = $this->toolbar;
682  $ilAccess = $this->access;
683 
684  $this->setModuleSubTabs("new_item_groups");
685 
686  $has_write = $ilAccess->checkAccess('write', '', $this->object->getRefId());
687 
688  if ($has_write) {
689  $ilToolbar->addButton(
690  $this->lng->txt("rep_new_item_group_add"),
691  $this->ctrl->getLinkTarget($this, "addNewItemGroup")
692  );
693 
694  $ilToolbar->addButton(
695  $this->lng->txt("rep_new_item_group_add_separator"),
696  $this->ctrl->getLinkTarget($this, "addNewItemGroupSeparator")
697  );
698  }
699 
700  $grp_table = new ilNewItemGroupTableGUI($this, "listNewItemGroups", $has_write);
701 
702  $this->tpl->setContent($grp_table->getHTML());
703  }
704 
705  protected function initNewItemGroupForm(int $a_grp_id = 0): ilPropertyFormGUI
706  {
707  $this->setModuleSubTabs("new_item_groups");
708 
709  $form = new ilPropertyFormGUI();
710 
711  $this->lng->loadLanguageModule("meta");
712  $def_lng = $this->lng->getDefaultLanguage();
713 
714  $title = new ilTextInputGUI($this->lng->txt("title"), "title_" . $def_lng);
715  $title->setInfo($this->lng->txt("meta_l_" . $def_lng) .
716  " (" . $this->lng->txt("default_language") . ")");
717  $title->setRequired(true);
718  $form->addItem($title);
719 
720  foreach ($this->lng->getInstalledLanguages() as $lang_id) {
721  if ($lang_id !== $def_lng) {
722  $title = new ilTextInputGUI($this->lng->txt("translation"), "title_" . $lang_id);
723  $title->setInfo($this->lng->txt("meta_l_" . $lang_id));
724  $form->addItem($title);
725  }
726  }
727 
728  if (!$a_grp_id) {
729  $form->setTitle($this->lng->txt("rep_new_item_group_add"));
730  $form->setFormAction($this->ctrl->getFormAction($this, "saveNewItemGroup"));
731 
732  $form->addCommandButton("saveNewItemGroup", $this->lng->txt("save"));
733  } else {
734  $form->setTitle($this->lng->txt("rep_new_item_group_edit"));
735  $form->setFormAction($this->ctrl->getFormAction($this, "updateNewItemGroup"));
736 
738  $grp = $grp[$a_grp_id];
739 
740  foreach ($grp["titles"] as $id => $value) {
741  $field = $form->getItemByPostVar("title_" . $id);
742  if ($field) {
743  $field->setValue($value);
744  }
745  }
746 
747  $form->addCommandButton("updateNewItemGroup", $this->lng->txt("save"));
748  }
749  $form->addCommandButton("listNewItemGroups", $this->lng->txt("cancel"));
750 
751  return $form;
752  }
753 
754  protected function addNewItemGroup(ilPropertyFormGUI $a_form = null): void
755  {
756  if (!$a_form) {
757  $a_form = $this->initNewItemGroupForm();
758  }
759 
760  $this->tpl->setContent($a_form->getHTML());
761  }
762 
763  protected function saveNewItemGroup(): void
764  {
765  $form = $this->initNewItemGroupForm();
766  if ($form->checkInput()) {
767  $titles = [];
768  foreach ($this->lng->getInstalledLanguages() as $lang_id) {
769  $titles[$lang_id] = $form->getInput("title_" . $lang_id);
770  }
771 
773  $this->tpl->setOnScreenMessage('success', $this->lng->txt("settings_saved"), true);
774  $this->ctrl->redirect($this, "listNewItemGroups");
775  }
776  }
777 
778  $form->setValuesByPost();
779  $this->addNewItemGroup($form);
780  }
781 
782  protected function editNewItemGroup(ilPropertyFormGUI $a_form = null): void
783  {
784  $grp_id = $this->admin_gui_request->getNewItemGroupId();
785  if (!$grp_id) {
786  $this->ctrl->redirect($this, "listNewItemGroups");
787  }
788 
789  if (!$a_form) {
790  $this->ctrl->setParameter($this, "grp_id", $grp_id);
791  $a_form = $this->initNewItemGroupForm($grp_id);
792  }
793 
794  $this->tpl->setContent($a_form->getHTML());
795  }
796 
797  protected function updateNewItemGroup(): void
798  {
799  $grp_id = $this->admin_gui_request->getNewItemGroupId();
800  if (!$grp_id) {
801  $this->ctrl->redirect($this, "listNewItemGroups");
802  }
803 
804  $this->ctrl->setParameter($this, "grp_id", $grp_id);
805 
806  $form = $this->initNewItemGroupForm($grp_id);
807  if ($form->checkInput()) {
808  $titles = [];
809  foreach ($this->lng->getInstalledLanguages() as $lang_id) {
810  $titles[$lang_id] = $form->getInput("title_" . $lang_id);
811  }
812 
813  if (ilObjRepositorySettings::updateNewItemGroup($grp_id, $titles)) {
814  $this->tpl->setOnScreenMessage('success', $this->lng->txt("settings_saved"), true);
815  $this->ctrl->redirect($this, "listNewItemGroups");
816  }
817  }
818 
819  $form->setValuesByPost();
820  $this->addNewItemGroup($form);
821  }
822 
823  protected function addNewItemGroupSeparator(): void
824  {
826  $this->tpl->setOnScreenMessage('success', $this->lng->txt("settings_saved"), true);
827  }
828  $this->ctrl->redirect($this, "listNewItemGroups");
829  }
830 
831  protected function saveNewItemGroupOrder(): void
832  {
834 
835  $group_order = $this->admin_gui_request->getNewItemGroupOrder();
836  if (count($group_order) > 0) {
838 
839  $grp_pos_map = [];
840  foreach (ilObjRepositorySettings::getNewItemGroups() as $item) {
841  $grp_pos_map[$item["id"]] = str_pad((string) $item["pos"], 4, "0", STR_PAD_LEFT);
842  }
843 
844  // update order of assigned objects
845  foreach (ilObjRepositorySettings::getNewItemGroupSubItems() as $grp_id => $subitems) {
846  // unassigned objects will always be last
847  if ($grp_id) {
848  foreach ($subitems as $obj_type) {
849  $old_pos = $ilSetting->get("obj_add_new_pos_" . $obj_type);
850  if (strlen($old_pos) === 8) {
851  $new_pos = $grp_pos_map[$grp_id] . substr($old_pos, 4);
852  $ilSetting->set("obj_add_new_pos_" . $obj_type, $new_pos);
853  }
854  }
855  }
856  }
857 
858  $this->tpl->setOnScreenMessage('success', $this->lng->txt("settings_saved"), true);
859  }
860  $this->ctrl->redirect($this, "listNewItemGroups");
861  }
862 
863  protected function confirmDeleteNewItemGroup(): void
864  {
865  $group_ids = $this->admin_gui_request->getNewItemGroupIds();
866  if (count($group_ids) === 0) {
867  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("select_one"));
868  $this->listNewItemGroups();
869  return;
870  }
871 
872  $this->setModuleSubTabs("new_item_groups");
873 
874  $cgui = new ilConfirmationGUI();
875  $cgui->setHeaderText($this->lng->txt("rep_new_item_group_delete_sure"));
876 
877  $cgui->setFormAction($this->ctrl->getFormAction($this));
878  $cgui->setCancel($this->lng->txt("cancel"), "listNewItemGroups");
879  $cgui->setConfirm($this->lng->txt("confirm"), "deleteNewItemGroup");
880 
882 
883  foreach ($group_ids as $grp_id) {
884  $cgui->addItem("grp_ids[]", (string) $grp_id, $groups[$grp_id]["title"]);
885  }
886 
887  $this->tpl->setContent($cgui->getHTML());
888  }
889 
890  protected function deleteNewItemGroup(): void
891  {
892  $group_ids = $this->admin_gui_request->getNewItemGroupIds();
893  if (count($group_ids) === 0) {
894  $this->listNewItemGroups();
895  return;
896  }
897 
898  foreach ($group_ids as $grp_id) {
900  }
901 
902  $this->tpl->setOnScreenMessage('success', $this->lng->txt("settings_saved"), true);
903  $this->ctrl->redirect($this, "listNewItemGroups");
904  }
905 
906  public function addToExternalSettingsForm(int $a_form_id): ?array
907  {
909 
910  switch ($a_form_id) {
912 
913  $fields = ['trac_show_repository_views' => [ilChangeEvent::_isActive(), ilAdministrationSettingsFormHandler::VALUE_BOOL]];
914 
915  return [["view", $fields]];
916 
917 
919 
920  $fields = [
921  'adm_show_comments_tagging_in_lists' => [
922  $ilSetting->get('comments_tagging_in_lists'), ilAdministrationSettingsFormHandler::VALUE_BOOL,
923  ['adm_show_comments_tagging_in_lists_tags' => [$ilSetting->get('comments_tagging_in_lists_tags'), ilAdministrationSettingsFormHandler::VALUE_BOOL]]
924  ]
925  ];
926 
927  return [["view", $fields]];
928  }
929  return null;
930  }
931 
932  protected function getMaxLengthConstraint(int $max_length): Constraint
933  {
934  //This gives max_length many 9's in a row (and 0 for non-positive max_length)
935  //The int cast is necessary for negative max_length
936  $bound = (int) (10 ** $max_length - 1);
937 
938  return $this->refinery->int()->isLessThanOrEqual($bound);
939  }
940 
941  protected function getPositiveConstraint(): Constraint
942  {
943  return $this->refinery->int()->isGreaterThan(0);
944  }
945 
946  protected function getNonNegativeConstraint(): Constraint
947  {
948  return $this->refinery->int()->isGreaterThanOrEqual(0);
949  }
950 }
Interface GlobalHttpState.
static _activate()
Activates change event tracking.
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...
prepareOutput(bool $show_sub_objects=true)
checkAccess(string $a_permission, string $a_cmd, int $a_ref_id, string $a_type="", ?int $a_obj_id=null, ?int $a_tree_id=null)
check access for an object (provide $a_type and $a_obj_id if available for better performance) ...
A constraint encodes some resrtictions on values.
Definition: Constraint.php:31
$ilErr
Definition: raiseError.php:17
global $DIC
Definition: feed.php:28
checkAccess(string $a_operations, int $a_ref_id, string $a_type="")
checkAccess represents the main method of the RBAC-system in ILIAS3 developers want to use With this ...
ilLanguage $lng
static http()
Fetches the global http state from ILIAS.
__construct(VocabulariesInterface $vocabularies)
Class ilObjectGUI Basic methods of all Output classes.
__construct( $a_data, int $a_id, bool $a_call_by_reference=true, bool $a_prepare_output=true)
ilToolbarGUI $toolbar
static updateNewItemGroup(int $a_id, array $a_titles)
withValue($value)
Get an input like this with another value displayed on the client side.
Definition: Group.php:58
static updateNewItemGroupOrder(array $a_order)
static addNewItemGroup(array $a_titles)
Error Handling & global info handling.
global $ilSetting
Definition: privfeed.php:18
static _isActive()
Returns true, if change event tracking is active.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _deactivate()
Deactivates change event tracking.
ilAccessHandler $access
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addNewItemGroup(ilPropertyFormGUI $a_form=null)
editNewItemGroup(ilPropertyFormGUI $a_form=null)
ilSetting $settings