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