ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
class.ilDashboardSidePanelSettingsRepository.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
23 public const CALENDAR = 'cal';
24 public const NEWS = 'news';
25 public const MAIL = 'mail';
26 public const TASKS = 'task';
27
28 public function __construct(protected readonly ilSetting $setting = new ilSetting('dash'))
29 {
30 }
31
35 final public function getValidModules(): array
36 {
37 return [
42 ];
43 }
44
48 public function setPositions(array $positions): void
49 {
50 $this->setting->set('side_panel_positions', serialize($positions));
51 }
52
56 public function getPositions(): array
57 {
58 $positions = $this->setting->get('side_panel_positions', '');
59 $modules = [];
60 if ($positions !== '') {
61 $modules = unserialize($positions, ['allowed_classes' => false]);
62 }
63 $all_modules = $this->getValidModules();
64 foreach ($all_modules as $mod) {
65 if (!in_array($mod, $modules, true)) {
66 $modules[] = $mod;
67 }
68 }
69 return $modules;
70 }
71
72 final protected function isValidModule(string $mod): bool
73 {
74 return in_array($mod, $this->getValidModules());
75 }
76
77 public function enable(string $mod, bool $active): void
78 {
79 if ($this->isValidModule($mod)) {
80 $this->setting->set('enable_' . $mod, $active ? '1' : '0');
81 }
82 }
83
84 public function isEnabled(string $mod): bool
85 {
86 if ($this->isValidModule($mod)) {
87 return (bool) $this->setting->get('enable_' . $mod, '1');
88 }
89 return false;
90 }
91}
__construct(protected readonly ilSetting $setting=new ilSetting('dash'))
ILIAS Setting Class.