ILIAS  release_8 Revision v8.24
class.ilECSNodeMappingSettings.php
Go to the documentation of this file.
1<?php
2
18declare(strict_types=1);
19
24{
25 private static array $instances = [];
26
28
29
30 private int $server_id;
34 private int $mid;
35
36 private bool $directory_active = false;
37 private bool $create_empty_containers = false;
38
42 private bool $course_active = false;
43 private int $default_cat = 0;
44 private bool $allinone = false;
45 private int $allinone_cat = 0;
46 private bool $attributes = false;
47 private array $role_mappings = array();
48 private ?string $auth_mode = null;
49
53 protected function __construct(int $a_server_id, int $a_mid)
54 {
55 global $DIC;
56
57 $this->server_id = $a_server_id;
58 $this->mid = $a_mid;
59
60 $this->initStorage();
61 $this->read();
62 }
63
67 public static function getInstanceByServerMid(int $a_server_id, int $a_mid): ilECSNodeMappingSettings
68 {
69 $id = $a_server_id . '_' . $a_mid;
70 return self::$instances[$id] ?? (self::$instances[$id] = new self($a_server_id, $a_mid));
71 }
72
76 public function getServerId(): int
77 {
78 return $this->server_id;
79 }
80
84 public function getMid(): int
85 {
86 return $this->mid;
87 }
88
92 public function isDirectoryMappingEnabled(): bool
93 {
95 }
96
100 public function enableDirectoryMapping(bool $a_status): void
101 {
102 $this->directory_active = $a_status;
103 }
104
108 public function enableEmptyContainerCreation(bool $a_status): void
109 {
110 $this->create_empty_containers = $a_status;
111 }
112
116 public function isEmptyContainerCreationEnabled(): bool
117 {
119 }
120
121 public function enableCourseAllocation(bool $a_stat): void
122 {
123 $this->course_active = $a_stat;
124 }
125
126 public function isCourseAllocationEnabled(): bool
127 {
129 }
130
131 public function setDefaultCourseCategory(int $a_default_category): void
132 {
133 $this->default_cat = $a_default_category;
134 }
135
136 public function getDefaultCourseCategory(): int
137 {
138 return $this->default_cat;
139 }
140
141 public function isAllInOneCategoryEnabled(): bool
142 {
143 return $this->allinone;
144 }
145
146 public function enableAllInOne(bool $a_stat): void
147 {
148 $this->allinone = $a_stat;
149 }
150
151 public function setAllInOneCategory(int $a_cat): void
152 {
153 $this->allinone_cat = $a_cat;
154 }
155
156 public function getAllInOneCategory(): int
157 {
158 return $this->allinone_cat;
159 }
160
161 public function enableAttributeMapping(bool $a_stat): void
162 {
163 $this->attributes = $a_stat;
164 }
165
166 public function isAttributeMappingEnabled(): bool
167 {
168 return $this->attributes;
169 }
170
171 public function setRoleMappings(array $a_mappings): void
172 {
173 $this->role_mappings = $a_mappings;
174 }
175
176 public function getRoleMappings(): array
177 {
179 }
180
184 public function setAuthMode(string $a_auth_mode): void
185 {
186 $this->auth_mode = $a_auth_mode;
187 }
188
192 public function getAuthMode(): ?string
193 {
194 return $this->auth_mode;
195 }
196
200 public function update(): bool
201 {
202 $this->getStorage()->set('directory_active', (string) $this->isDirectoryMappingEnabled());
203 $this->getStorage()->set('create_empty', (string) $this->isEmptyContainerCreationEnabled());
204 $this->getStorage()->set('course_active', (string) $this->isCourseAllocationEnabled());
205 $this->getStorage()->set('default_category', (string) $this->getDefaultCourseCategory());
206 $this->getStorage()->set('allinone', (string) $this->isAllInOneCategoryEnabled());
207 $this->getStorage()->set('allinone_cat', (string) $this->getAllInOneCategory());
208 $this->getStorage()->set('attributes', (string) $this->isAttributeMappingEnabled());
209 $this->getStorage()->set('role_mappings', serialize($this->getRoleMappings()));
210 $this->getStorage()->set('auth_mode', $this->getAuthMode());
211 return true;
212 }
213
217 protected function getStorage(): ilSetting
218 {
219 return $this->storage;
220 }
221
225 protected function initStorage(): void
226 {
227 $this->storage = new ilSetting('ecs_node_mapping_' . $this->getServerId() . '_' . $this->getMid());
228 }
229
230
235 protected function read(): void
236 {
237 if ($this->getStorage()->get('directory_active')) {
238 $this->enableDirectoryMapping((bool) $this->getStorage()->get('directory_active'));
239 }
240 if ($this->getStorage()->get('create_empty')) {
241 $this->enableEmptyContainerCreation((bool) $this->getStorage()->get('create_empty'));
242 }
243 if ($this->getStorage()->get('course_active')) {
244 $this->enableCourseAllocation((bool) $this->getStorage()->get('course_active'));
245 }
246 if ($this->getStorage()->get('default_category')) {
247 $this->setDefaultCourseCategory((int) $this->getStorage()->get('default_category'));
248 }
249 if ($this->getStorage()->get('allinone')) {
250 $this->enableAllInOne((bool) $this->getStorage()->get('allinone'));
251 }
252 if ($this->getStorage()->get('allinone_cat')) {
253 $this->setAllInOneCategory((int) $this->getStorage()->get('allinone_cat'));
254 }
255 if ($this->getStorage()->get('attributes')) {
256 $this->enableAttributeMapping((bool) $this->getStorage()->get('attributes'));
257 }
258 if ($this->getStorage()->get('role_mappings')) {
259 $this->setRoleMappings(unserialize($this->getStorage()->get('role_mappings'), ['allowed_classes' => true]));
260 }
261 if ($this->getStorage()->get('auth_mode')) {
262 $this->setAuthMode($this->getStorage()->get('auth_mode'));
263 }
264 }
265}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
setAuthMode(string $a_auth_mode)
Set user auth mode.
setDefaultCourseCategory(int $a_default_category)
enableDirectoryMapping(bool $a_status)
Enable node mapping.
isEmptyContainerCreationEnabled()
Check if the creation of empty containers (pathes without courses) is enabled.
isDirectoryMappingEnabled()
Check if node mapping is enabled.
getServerId()
Get server id of setting.
static getInstanceByServerMid(int $a_server_id, int $a_mid)
Get instance.
enableEmptyContainerCreation(bool $a_status)
enable creation of empty containers
__construct(int $a_server_id, int $a_mid)
Singeleton constructor.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28