ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilECSNodeMappingSettings.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25{
26 private static array $instances = [];
27
29
30
31 private int $server_id;
35 private int $mid;
36
37 private bool $directory_active = false;
38 private bool $create_empty_containers = false;
39
43 private bool $course_active = false;
44 private int $default_cat = 0;
45 private bool $allinone = false;
46 private int $allinone_cat = 0;
47 private bool $attributes = false;
48 private array $role_mappings = array();
49 private ?string $auth_mode = null;
50
54 protected function __construct(int $a_server_id, int $a_mid)
55 {
56 global $DIC;
57
58 $this->server_id = $a_server_id;
59 $this->mid = $a_mid;
60
61 $this->initStorage();
62 $this->read();
63 }
64
68 public static function getInstanceByServerMid(int $a_server_id, int $a_mid): ilECSNodeMappingSettings
69 {
70 $id = $a_server_id . '_' . $a_mid;
71 return self::$instances[$id] ?? (self::$instances[$id] = new self($a_server_id, $a_mid));
72 }
73
77 public function getServerId(): int
78 {
79 return $this->server_id;
80 }
81
85 public function getMid(): int
86 {
87 return $this->mid;
88 }
89
93 public function isDirectoryMappingEnabled(): bool
94 {
96 }
97
101 public function enableDirectoryMapping(bool $a_status): void
102 {
103 $this->directory_active = $a_status;
104 }
105
109 public function enableEmptyContainerCreation(bool $a_status): void
110 {
111 $this->create_empty_containers = $a_status;
112 }
113
117 public function isEmptyContainerCreationEnabled(): bool
118 {
120 }
121
122 public function enableCourseAllocation(bool $a_stat): void
123 {
124 $this->course_active = $a_stat;
125 }
126
127 public function isCourseAllocationEnabled(): bool
128 {
130 }
131
132 public function setDefaultCourseCategory(int $a_default_category): void
133 {
134 $this->default_cat = $a_default_category;
135 }
136
137 public function getDefaultCourseCategory(): int
138 {
139 return $this->default_cat;
140 }
141
142 public function isAllInOneCategoryEnabled(): bool
143 {
144 return $this->allinone;
145 }
146
147 public function enableAllInOne(bool $a_stat): void
148 {
149 $this->allinone = $a_stat;
150 }
151
152 public function setAllInOneCategory(int $a_cat): void
153 {
154 $this->allinone_cat = $a_cat;
155 }
156
157 public function getAllInOneCategory(): int
158 {
159 return $this->allinone_cat;
160 }
161
162 public function enableAttributeMapping(bool $a_stat): void
163 {
164 $this->attributes = $a_stat;
165 }
166
167 public function isAttributeMappingEnabled(): bool
168 {
169 return $this->attributes;
170 }
171
172 public function setRoleMappings(array $a_mappings): void
173 {
174 $this->role_mappings = $a_mappings;
175 }
176
177 public function getRoleMappings(): array
178 {
180 }
181
185 public function setAuthMode(string $a_auth_mode): void
186 {
187 $this->auth_mode = $a_auth_mode;
188 }
189
193 public function getAuthMode(): ?string
194 {
195 return $this->auth_mode;
196 }
197
201 public function update(): bool
202 {
203 $this->getStorage()->set('directory_active', (string) $this->isDirectoryMappingEnabled());
204 $this->getStorage()->set('create_empty', (string) $this->isEmptyContainerCreationEnabled());
205 $this->getStorage()->set('course_active', (string) $this->isCourseAllocationEnabled());
206 $this->getStorage()->set('default_category', (string) $this->getDefaultCourseCategory());
207 $this->getStorage()->set('allinone', (string) $this->isAllInOneCategoryEnabled());
208 $this->getStorage()->set('allinone_cat', (string) $this->getAllInOneCategory());
209 $this->getStorage()->set('attributes', (string) $this->isAttributeMappingEnabled());
210 $this->getStorage()->set('role_mappings', serialize($this->getRoleMappings()));
211 $this->getStorage()->set('auth_mode', $this->getAuthMode());
212 return true;
213 }
214
218 protected function getStorage(): ilSetting
219 {
220 return $this->storage;
221 }
222
226 protected function initStorage(): void
227 {
228 $this->storage = new ilSetting('ecs_node_mapping_' . $this->getServerId() . '_' . $this->getMid());
229 }
230
231
236 protected function read(): void
237 {
238 if ($this->getStorage()->get('directory_active')) {
239 $this->enableDirectoryMapping((bool) $this->getStorage()->get('directory_active'));
240 }
241 if ($this->getStorage()->get('create_empty')) {
242 $this->enableEmptyContainerCreation((bool) $this->getStorage()->get('create_empty'));
243 }
244 if ($this->getStorage()->get('course_active')) {
245 $this->enableCourseAllocation((bool) $this->getStorage()->get('course_active'));
246 }
247 if ($this->getStorage()->get('default_category')) {
248 $this->setDefaultCourseCategory((int) $this->getStorage()->get('default_category'));
249 }
250 if ($this->getStorage()->get('allinone')) {
251 $this->enableAllInOne((bool) $this->getStorage()->get('allinone'));
252 }
253 if ($this->getStorage()->get('allinone_cat')) {
254 $this->setAllInOneCategory((int) $this->getStorage()->get('allinone_cat'));
255 }
256 if ($this->getStorage()->get('attributes')) {
257 $this->enableAttributeMapping((bool) $this->getStorage()->get('attributes'));
258 }
259 if ($this->getStorage()->get('role_mappings')) {
260 $this->setRoleMappings(unserialize($this->getStorage()->get('role_mappings'), ['allowed_classes' => true]));
261 }
262 if ($this->getStorage()->get('auth_mode')) {
263 $this->setAuthMode($this->getStorage()->get('auth_mode'));
264 }
265 }
266}
$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.
ILIAS Setting Class.
global $DIC
Definition: shib_login.php:26