ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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
29
30 public function __construct(?ilSetting $dashboard_settings = null)
31 {
32 $this->setting = is_null($dashboard_settings)
33 ? new ilSetting('dash')
34 : $dashboard_settings;
35 }
36
40 public function getValidModules(): array
41 {
42 return [
47 ];
48 }
49
53 public function setPositions(array $positions): void
54 {
55 $this->setting->set('side_panel_positions', serialize($positions));
56 }
57
61 public function getPositions(): array
62 {
63 $positions = $this->setting->get('side_panel_positions', '');
64 $modules = [];
65 if ($positions !== '') {
66 $modules = unserialize($positions, ['allowed_classes' => false]);
67 }
68 $all_modules = $this->getValidModules();
69 foreach ($all_modules as $mod) {
70 if (!in_array($mod, $modules, true)) {
71 $modules[] = $mod;
72 }
73 }
74 return $modules;
75 }
76
77 protected function isValidModule(string $mod): bool
78 {
79 return in_array($mod, $this->getValidModules());
80 }
81
82 public function enable(string $mod, bool $active): void
83 {
84 if ($this->isValidModule($mod)) {
85 $this->setting->set('enable_' . $mod, $active ? '1' : '0');
86 }
87 }
88
89 public function isEnabled(string $mod): bool
90 {
91 if ($this->isValidModule($mod)) {
92 return (bool) $this->setting->get('enable_' . $mod, '1');
93 }
94 return false;
95 }
96}
ILIAS Setting Class.