|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* For licensing terms, see /license.txt */ |
|
6
|
|
|
|
|
7
|
|
|
namespace Chamilo\CoreBundle\Settings; |
|
8
|
|
|
|
|
9
|
|
|
use Chamilo\CoreBundle\Entity\AccessUrl; |
|
10
|
|
|
use Chamilo\CoreBundle\Entity\Course; |
|
11
|
|
|
use Chamilo\CoreBundle\Entity\SettingsCurrent; |
|
12
|
|
|
use Doctrine\ORM\EntityManager; |
|
13
|
|
|
use Doctrine\ORM\EntityRepository; |
|
14
|
|
|
use InvalidArgumentException; |
|
15
|
|
|
use Sylius\Bundle\SettingsBundle\Manager\SettingsManagerInterface; |
|
16
|
|
|
use Sylius\Bundle\SettingsBundle\Model\Settings; |
|
17
|
|
|
use Sylius\Bundle\SettingsBundle\Model\SettingsInterface; |
|
18
|
|
|
use Sylius\Bundle\SettingsBundle\Registry\ServiceRegistryInterface; |
|
19
|
|
|
use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface; |
|
20
|
|
|
use Sylius\Bundle\SettingsBundle\Schema\SettingsBuilder; |
|
21
|
|
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface; |
|
22
|
|
|
use Symfony\Component\HttpFoundation\RequestStack; |
|
23
|
|
|
use Symfony\Component\Validator\Exception\ValidatorException; |
|
24
|
|
|
|
|
25
|
|
|
use const ARRAY_FILTER_USE_KEY; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Handles the platform settings. |
|
29
|
|
|
*/ |
|
30
|
|
|
class SettingsManager implements SettingsManagerInterface |
|
31
|
|
|
{ |
|
32
|
|
|
protected ?AccessUrl $url = null; |
|
33
|
|
|
|
|
34
|
|
|
protected ServiceRegistryInterface $schemaRegistry; |
|
35
|
|
|
|
|
36
|
|
|
protected EntityManager $manager; |
|
37
|
|
|
|
|
38
|
|
|
protected EntityRepository $repository; |
|
39
|
|
|
|
|
40
|
|
|
protected EventDispatcherInterface $eventDispatcher; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Runtime cache for resolved parameters. |
|
44
|
|
|
* |
|
45
|
|
|
* @var Settings[] |
|
46
|
|
|
*/ |
|
47
|
|
|
protected array $resolvedSettings = []; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @var null|array<string, Settings>|mixed[] |
|
51
|
|
|
*/ |
|
52
|
|
|
protected ?array $schemaList; |
|
53
|
|
|
|
|
54
|
|
|
protected RequestStack $request; |
|
55
|
|
|
|
|
56
|
|
|
public function __construct( |
|
57
|
|
|
ServiceRegistryInterface $schemaRegistry, |
|
58
|
|
|
EntityManager $manager, |
|
59
|
|
|
EntityRepository $repository, |
|
60
|
|
|
EventDispatcherInterface $eventDispatcher, |
|
61
|
|
|
RequestStack $request |
|
62
|
|
|
) { |
|
63
|
|
|
$this->schemaRegistry = $schemaRegistry; |
|
64
|
|
|
$this->manager = $manager; |
|
65
|
|
|
$this->repository = $repository; |
|
66
|
|
|
$this->eventDispatcher = $eventDispatcher; |
|
67
|
|
|
$this->request = $request; |
|
68
|
|
|
$this->schemaList = []; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
public function getUrl(): ?AccessUrl |
|
72
|
|
|
{ |
|
73
|
|
|
return $this->url; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
public function setUrl(AccessUrl $url): void |
|
77
|
|
|
{ |
|
78
|
|
|
$this->url = $url; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
public function updateSchemas(AccessUrl $url): void |
|
82
|
|
|
{ |
|
83
|
|
|
$this->url = $url; |
|
84
|
|
|
$schemas = array_keys($this->getSchemas()); |
|
85
|
|
|
foreach ($schemas as $schema) { |
|
86
|
|
|
$settings = $this->load($this->convertServiceToNameSpace($schema)); |
|
87
|
|
|
$this->update($settings); |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
public function installSchemas(AccessUrl $url): void |
|
92
|
|
|
{ |
|
93
|
|
|
$this->url = $url; |
|
94
|
|
|
$schemas = array_keys($this->getSchemas()); |
|
95
|
|
|
foreach ($schemas as $schema) { |
|
96
|
|
|
$settings = $this->load($this->convertServiceToNameSpace($schema)); |
|
97
|
|
|
$this->save($settings); |
|
98
|
|
|
} |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* @return array|AbstractSettingsSchema[] |
|
103
|
|
|
*/ |
|
104
|
|
|
public function getSchemas(): array |
|
105
|
|
|
{ |
|
106
|
|
|
return $this->schemaRegistry->all(); |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
public function convertNameSpaceToService(string $category): string |
|
110
|
|
|
{ |
|
111
|
|
|
return 'chamilo_core.settings.'.$category; |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
public function convertServiceToNameSpace(string $category): string |
|
115
|
|
|
{ |
|
116
|
|
|
return str_replace('chamilo_core.settings.', '', $category); |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
public function updateSetting(string $name, $value): void |
|
120
|
|
|
{ |
|
121
|
|
|
$name = $this->validateSetting($name); |
|
122
|
|
|
|
|
123
|
|
|
[$category, $name] = explode('.', $name); |
|
124
|
|
|
$settings = $this->load($category); |
|
125
|
|
|
|
|
126
|
|
|
if (!$settings->has($name)) { |
|
127
|
|
|
$message = \sprintf("Parameter %s doesn't exists.", $name); |
|
128
|
|
|
|
|
129
|
|
|
throw new InvalidArgumentException($message); |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
$settings->set($name, $value); |
|
133
|
|
|
$this->update($settings); |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
/** |
|
137
|
|
|
* Get a specific configuration setting, getting from the previously stored |
|
138
|
|
|
* PHP session data whenever possible. |
|
139
|
|
|
* |
|
140
|
|
|
* @param string $name The setting name (composed if in a category, i.e. 'platform.institution') |
|
141
|
|
|
* @param bool $loadFromDb Whether to load from the database |
|
142
|
|
|
*/ |
|
143
|
|
|
public function getSetting(string $name, bool $loadFromDb = false): mixed |
|
144
|
|
|
{ |
|
145
|
|
|
$name = $this->validateSetting($name); |
|
146
|
|
|
|
|
147
|
|
|
[$category, $name] = explode('.', $name); |
|
148
|
|
|
|
|
149
|
|
|
if ($loadFromDb) { |
|
150
|
|
|
$settings = $this->load($category, $name); |
|
151
|
|
|
if ($settings->has($name)) { |
|
152
|
|
|
return $settings->get($name); |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
return null; |
|
156
|
|
|
} |
|
157
|
|
|
|
|
158
|
|
|
$this->loadAll(); |
|
159
|
|
|
|
|
160
|
|
|
if (!empty($this->schemaList) && isset($this->schemaList[$category])) { |
|
161
|
|
|
$settings = $this->schemaList[$category]; |
|
162
|
|
|
if ($settings->has($name)) { |
|
163
|
|
|
return $settings->get($name); |
|
164
|
|
|
} |
|
165
|
|
|
error_log("Attempted to access undefined setting '$name' in category '$category'."); |
|
166
|
|
|
|
|
167
|
|
|
return null; |
|
168
|
|
|
} |
|
169
|
|
|
|
|
170
|
|
|
throw new InvalidArgumentException(\sprintf('Category %s not found', $category)); |
|
171
|
|
|
} |
|
172
|
|
|
|
|
173
|
|
|
public function loadAll(): void |
|
174
|
|
|
{ |
|
175
|
|
|
$session = null; |
|
176
|
|
|
|
|
177
|
|
|
if ($this->request->getCurrentRequest()) { |
|
178
|
|
|
$session = $this->request->getCurrentRequest()->getSession(); |
|
179
|
|
|
$schemaList = $session->get('schemas'); |
|
180
|
|
|
if (!empty($schemaList)) { |
|
181
|
|
|
$this->schemaList = $schemaList; |
|
182
|
|
|
|
|
183
|
|
|
return; |
|
184
|
|
|
} |
|
185
|
|
|
} |
|
186
|
|
|
|
|
187
|
|
|
$schemas = array_keys($this->getSchemas()); |
|
188
|
|
|
$schemaList = []; |
|
189
|
|
|
$settingsBuilder = new SettingsBuilder(); |
|
190
|
|
|
$all = $this->getAllParametersByCategory(); |
|
191
|
|
|
|
|
192
|
|
|
foreach ($schemas as $schema) { |
|
193
|
|
|
$schemaRegister = $this->schemaRegistry->get($schema); |
|
194
|
|
|
$schemaRegister->buildSettings($settingsBuilder); |
|
195
|
|
|
$name = $this->convertServiceToNameSpace($schema); |
|
196
|
|
|
$settings = new Settings(); |
|
197
|
|
|
|
|
198
|
|
|
/** @var array<string, mixed> $parameters */ |
|
199
|
|
|
$parameters = $all[$name] ?? []; |
|
200
|
|
|
|
|
201
|
|
|
$knownParameters = array_filter( |
|
202
|
|
|
$parameters, |
|
203
|
|
|
fn ($key): bool => $settingsBuilder->isDefined($key), |
|
204
|
|
|
ARRAY_FILTER_USE_KEY |
|
205
|
|
|
); |
|
206
|
|
|
|
|
207
|
|
|
$transformers = $settingsBuilder->getTransformers(); |
|
208
|
|
|
foreach ($transformers as $parameter => $transformer) { |
|
209
|
|
|
if (\array_key_exists($parameter, $knownParameters)) { |
|
210
|
|
|
if ('course_creation_use_template' === $parameter) { |
|
211
|
|
|
if (empty($knownParameters[$parameter])) { |
|
212
|
|
|
$knownParameters[$parameter] = null; |
|
213
|
|
|
} |
|
214
|
|
|
} else { |
|
215
|
|
|
$knownParameters[$parameter] = $transformer->reverseTransform($knownParameters[$parameter]); |
|
216
|
|
|
} |
|
217
|
|
|
} |
|
218
|
|
|
} |
|
219
|
|
|
|
|
220
|
|
|
$parameters = $settingsBuilder->resolve($knownParameters); |
|
221
|
|
|
$settings->setParameters($parameters); |
|
222
|
|
|
$schemaList[$name] = $settings; |
|
223
|
|
|
} |
|
224
|
|
|
$this->schemaList = $schemaList; |
|
225
|
|
|
if ($session && $this->request->getCurrentRequest()) { |
|
226
|
|
|
$session->set('schemas', $schemaList); |
|
227
|
|
|
} |
|
228
|
|
|
} |
|
229
|
|
|
|
|
230
|
|
|
public function load(string $schemaAlias, ?string $namespace = null, bool $ignoreUnknown = true): SettingsInterface |
|
231
|
|
|
{ |
|
232
|
|
|
$settings = new Settings(); |
|
233
|
|
|
$schemaAliasNoPrefix = $schemaAlias; |
|
234
|
|
|
$schemaAlias = 'chamilo_core.settings.'.$schemaAlias; |
|
235
|
|
|
if ($this->schemaRegistry->has($schemaAlias)) { |
|
236
|
|
|
/** @var SchemaInterface $schema */ |
|
237
|
|
|
$schema = $this->schemaRegistry->get($schemaAlias); |
|
238
|
|
|
} else { |
|
239
|
|
|
return $settings; |
|
240
|
|
|
} |
|
241
|
|
|
|
|
242
|
|
|
$settings->setSchemaAlias($schemaAlias); |
|
243
|
|
|
|
|
244
|
|
|
// We need to get a plain parameters array since we use the options resolver on it |
|
245
|
|
|
$parameters = $this->getParameters($schemaAliasNoPrefix); |
|
246
|
|
|
$settingsBuilder = new SettingsBuilder(); |
|
247
|
|
|
$schema->buildSettings($settingsBuilder); |
|
248
|
|
|
|
|
249
|
|
|
// Remove unknown settings' parameters (e.g. From a previous version of the settings schema) |
|
250
|
|
|
if (true === $ignoreUnknown) { |
|
251
|
|
|
foreach ($parameters as $name => $value) { |
|
252
|
|
|
if (!$settingsBuilder->isDefined($name)) { |
|
253
|
|
|
unset($parameters[$name]); |
|
254
|
|
|
} |
|
255
|
|
|
} |
|
256
|
|
|
} |
|
257
|
|
|
|
|
258
|
|
|
foreach ($settingsBuilder->getTransformers() as $parameter => $transformer) { |
|
259
|
|
|
if (\array_key_exists($parameter, $parameters)) { |
|
260
|
|
|
$parameters[$parameter] = $transformer->reverseTransform($parameters[$parameter]); |
|
261
|
|
|
} |
|
262
|
|
|
} |
|
263
|
|
|
|
|
264
|
|
|
$parameters = $settingsBuilder->resolve($parameters); |
|
265
|
|
|
$settings->setParameters($parameters); |
|
266
|
|
|
|
|
267
|
|
|
return $settings; |
|
268
|
|
|
} |
|
269
|
|
|
|
|
270
|
|
|
public function update(SettingsInterface $settings): void |
|
271
|
|
|
{ |
|
272
|
|
|
$namespace = $settings->getSchemaAlias(); |
|
273
|
|
|
|
|
274
|
|
|
/** @var SchemaInterface $schema */ |
|
275
|
|
|
$schema = $this->schemaRegistry->get($settings->getSchemaAlias()); |
|
276
|
|
|
|
|
277
|
|
|
$settingsBuilder = new SettingsBuilder(); |
|
278
|
|
|
$schema->buildSettings($settingsBuilder); |
|
279
|
|
|
$parameters = $settingsBuilder->resolve($settings->getParameters()); |
|
280
|
|
|
// Transform value. Example array to string using transformer. Example: |
|
281
|
|
|
// 1. Setting "tool_visible_by_default_at_creation" it's a multiple select |
|
282
|
|
|
// 2. Is defined as an array in class DocumentSettingsSchema |
|
283
|
|
|
// 3. Add transformer for that variable "ArrayToIdentifierTransformer" |
|
284
|
|
|
// 4. Here we recover the transformer and convert the array to string |
|
285
|
|
|
foreach ($parameters as $parameter => $value) { |
|
286
|
|
|
$parameters[$parameter] = $this->transformToString($value); |
|
287
|
|
|
} |
|
288
|
|
|
|
|
289
|
|
|
$settings->setParameters($parameters); |
|
290
|
|
|
$category = $this->convertServiceToNameSpace($settings->getSchemaAlias()); |
|
291
|
|
|
$persistedParameters = $this->repository->findBy([ |
|
292
|
|
|
'category' => $category, |
|
293
|
|
|
]); |
|
294
|
|
|
|
|
295
|
|
|
$persistedParametersMap = []; |
|
296
|
|
|
|
|
297
|
|
|
/** @var SettingsCurrent $parameter */ |
|
298
|
|
|
foreach ($persistedParameters as $parameter) { |
|
299
|
|
|
$persistedParametersMap[$parameter->getVariable()] = $parameter; |
|
300
|
|
|
} |
|
301
|
|
|
|
|
302
|
|
|
$url = $this->getUrl(); |
|
303
|
|
|
$simpleCategoryName = str_replace('chamilo_core.settings.', '', $namespace); |
|
304
|
|
|
|
|
305
|
|
|
foreach ($parameters as $name => $value) { |
|
306
|
|
|
if (isset($persistedParametersMap[$name])) { |
|
307
|
|
|
$parameter = $persistedParametersMap[$name]; |
|
308
|
|
|
$parameter->setSelectedValue($value); |
|
309
|
|
|
$parameter->setCategory($simpleCategoryName); |
|
310
|
|
|
$this->manager->persist($parameter); |
|
311
|
|
|
} else { |
|
312
|
|
|
$parameter = (new SettingsCurrent()) |
|
313
|
|
|
->setVariable($name) |
|
314
|
|
|
->setCategory($simpleCategoryName) |
|
315
|
|
|
->setTitle($name) |
|
316
|
|
|
->setSelectedValue($value) |
|
317
|
|
|
->setUrl($url) |
|
318
|
|
|
->setAccessUrlChangeable(1) |
|
319
|
|
|
->setAccessUrlLocked(1) |
|
320
|
|
|
; |
|
321
|
|
|
|
|
322
|
|
|
$this->manager->persist($parameter); |
|
323
|
|
|
} |
|
324
|
|
|
} |
|
325
|
|
|
|
|
326
|
|
|
$this->manager->flush(); |
|
327
|
|
|
} |
|
328
|
|
|
|
|
329
|
|
|
/** |
|
330
|
|
|
* @throws ValidatorException |
|
331
|
|
|
*/ |
|
332
|
|
|
public function save(SettingsInterface $settings): void |
|
333
|
|
|
{ |
|
334
|
|
|
$namespace = $settings->getSchemaAlias(); |
|
335
|
|
|
|
|
336
|
|
|
/** @var SchemaInterface $schema */ |
|
337
|
|
|
$schema = $this->schemaRegistry->get($settings->getSchemaAlias()); |
|
338
|
|
|
|
|
339
|
|
|
$settingsBuilder = new SettingsBuilder(); |
|
340
|
|
|
$schema->buildSettings($settingsBuilder); |
|
341
|
|
|
$parameters = $settingsBuilder->resolve($settings->getParameters()); |
|
342
|
|
|
// Transform value. Example array to string using transformer. Example: |
|
343
|
|
|
// 1. Setting "tool_visible_by_default_at_creation" it's a multiple select |
|
344
|
|
|
// 2. Is defined as an array in class DocumentSettingsSchema |
|
345
|
|
|
// 3. Add transformer for that variable "ArrayToIdentifierTransformer" |
|
346
|
|
|
// 4. Here we recover the transformer and convert the array to string |
|
347
|
|
|
foreach ($parameters as $parameter => $value) { |
|
348
|
|
|
$parameters[$parameter] = $this->transformToString($value); |
|
349
|
|
|
} |
|
350
|
|
|
$settings->setParameters($parameters); |
|
351
|
|
|
$persistedParameters = $this->repository->findBy([ |
|
352
|
|
|
'category' => $this->convertServiceToNameSpace($settings->getSchemaAlias()), |
|
353
|
|
|
]); |
|
354
|
|
|
$persistedParametersMap = []; |
|
355
|
|
|
foreach ($persistedParameters as $parameter) { |
|
356
|
|
|
$persistedParametersMap[$parameter->getVariable()] = $parameter; |
|
357
|
|
|
} |
|
358
|
|
|
|
|
359
|
|
|
$url = $this->getUrl(); |
|
360
|
|
|
$simpleCategoryName = str_replace('chamilo_core.settings.', '', $namespace); |
|
361
|
|
|
|
|
362
|
|
|
foreach ($parameters as $name => $value) { |
|
363
|
|
|
if (isset($persistedParametersMap[$name])) { |
|
364
|
|
|
$parameter = $persistedParametersMap[$name]; |
|
365
|
|
|
$parameter->setSelectedValue($value); |
|
366
|
|
|
} else { |
|
367
|
|
|
$parameter = (new SettingsCurrent()) |
|
368
|
|
|
->setVariable($name) |
|
369
|
|
|
->setCategory($simpleCategoryName) |
|
370
|
|
|
->setTitle($name) |
|
371
|
|
|
->setSelectedValue($value) |
|
372
|
|
|
->setUrl($url) |
|
373
|
|
|
->setAccessUrlChangeable(1) |
|
374
|
|
|
->setAccessUrlLocked(1) |
|
375
|
|
|
; |
|
376
|
|
|
|
|
377
|
|
|
$this->manager->persist($parameter); |
|
378
|
|
|
} |
|
379
|
|
|
} |
|
380
|
|
|
|
|
381
|
|
|
$this->manager->flush(); |
|
382
|
|
|
} |
|
383
|
|
|
|
|
384
|
|
|
/** |
|
385
|
|
|
* @param string $keyword |
|
386
|
|
|
*/ |
|
387
|
|
|
public function getParametersFromKeywordOrderedByCategory($keyword): array |
|
388
|
|
|
{ |
|
389
|
|
|
$query = $this->repository->createQueryBuilder('s') |
|
390
|
|
|
->where('s.variable LIKE :keyword OR s.title LIKE :keyword') |
|
391
|
|
|
->setParameter('keyword', "%{$keyword}%") |
|
392
|
|
|
; |
|
393
|
|
|
$parametersFromDb = $query->getQuery()->getResult(); |
|
394
|
|
|
$parameters = []; |
|
395
|
|
|
|
|
396
|
|
|
/** @var SettingsCurrent $parameter */ |
|
397
|
|
|
foreach ($parametersFromDb as $parameter) { |
|
398
|
|
|
$parameters[$parameter->getCategory()][] = $parameter; |
|
399
|
|
|
} |
|
400
|
|
|
|
|
401
|
|
|
return $parameters; |
|
402
|
|
|
} |
|
403
|
|
|
|
|
404
|
|
|
/** |
|
405
|
|
|
* @param string $namespace |
|
406
|
|
|
* @param string $keyword |
|
407
|
|
|
* @param bool $returnObjects |
|
408
|
|
|
* |
|
409
|
|
|
* @return array |
|
410
|
|
|
*/ |
|
411
|
|
|
public function getParametersFromKeyword($namespace, $keyword = '', $returnObjects = false) |
|
412
|
|
|
{ |
|
413
|
|
|
if (empty($keyword)) { |
|
414
|
|
|
$criteria = [ |
|
415
|
|
|
'category' => $namespace, |
|
416
|
|
|
]; |
|
417
|
|
|
$parametersFromDb = $this->repository->findBy($criteria); |
|
418
|
|
|
} else { |
|
419
|
|
|
$query = $this->repository->createQueryBuilder('s') |
|
420
|
|
|
->where('s.variable LIKE :keyword') |
|
421
|
|
|
->setParameter('keyword', "%{$keyword}%") |
|
422
|
|
|
; |
|
423
|
|
|
$parametersFromDb = $query->getQuery()->getResult(); |
|
424
|
|
|
} |
|
425
|
|
|
|
|
426
|
|
|
if ($returnObjects) { |
|
427
|
|
|
return $parametersFromDb; |
|
428
|
|
|
} |
|
429
|
|
|
$parameters = []; |
|
430
|
|
|
|
|
431
|
|
|
/** @var SettingsCurrent $parameter */ |
|
432
|
|
|
foreach ($parametersFromDb as $parameter) { |
|
433
|
|
|
$parameters[$parameter->getVariable()] = $parameter->getSelectedValue(); |
|
434
|
|
|
} |
|
435
|
|
|
|
|
436
|
|
|
return $parameters; |
|
437
|
|
|
} |
|
438
|
|
|
|
|
439
|
|
|
private function validateSetting(string $name): string |
|
440
|
|
|
{ |
|
441
|
|
|
if (!str_contains($name, '.')) { |
|
442
|
|
|
// throw new \InvalidArgumentException(sprintf('Parameter must be in format "namespace.name", "%s" given.', $name)); |
|
443
|
|
|
|
|
444
|
|
|
// This code allows the possibility of calling |
|
445
|
|
|
// api_get_setting('allow_skills_tool') instead of |
|
446
|
|
|
// the "correct" way api_get_setting('platform.allow_skills_tool') |
|
447
|
|
|
$items = $this->getVariablesAndCategories(); |
|
448
|
|
|
|
|
449
|
|
|
if (isset($items[$name])) { |
|
450
|
|
|
$originalName = $name; |
|
451
|
|
|
$name = $this->renameVariable($name); |
|
452
|
|
|
$category = $this->fixCategory( |
|
453
|
|
|
strtolower($name), |
|
454
|
|
|
strtolower($items[$originalName]) |
|
455
|
|
|
); |
|
456
|
|
|
$name = $category.'.'.$name; |
|
457
|
|
|
} else { |
|
458
|
|
|
$message = \sprintf('Parameter must be in format "category.name", "%s" given.', $name); |
|
459
|
|
|
|
|
460
|
|
|
throw new InvalidArgumentException($message); |
|
461
|
|
|
} |
|
462
|
|
|
} |
|
463
|
|
|
|
|
464
|
|
|
return $name; |
|
465
|
|
|
} |
|
466
|
|
|
|
|
467
|
|
|
/** |
|
468
|
|
|
* Load parameter from database. |
|
469
|
|
|
* |
|
470
|
|
|
* @param string $namespace |
|
471
|
|
|
* |
|
472
|
|
|
* @return array |
|
473
|
|
|
*/ |
|
474
|
|
|
private function getParameters($namespace) |
|
475
|
|
|
{ |
|
476
|
|
|
$parameters = []; |
|
477
|
|
|
$category = $this->repository->findBy(['category' => $namespace]); |
|
478
|
|
|
|
|
479
|
|
|
/** @var SettingsCurrent $parameter */ |
|
480
|
|
|
foreach ($category as $parameter) { |
|
481
|
|
|
$parameters[$parameter->getVariable()] = $parameter->getSelectedValue(); |
|
482
|
|
|
} |
|
483
|
|
|
|
|
484
|
|
|
return $parameters; |
|
485
|
|
|
} |
|
486
|
|
|
|
|
487
|
|
|
private function getAllParametersByCategory() |
|
488
|
|
|
{ |
|
489
|
|
|
$parameters = []; |
|
490
|
|
|
$all = $this->repository->findAll(); |
|
491
|
|
|
|
|
492
|
|
|
/** @var SettingsCurrent $parameter */ |
|
493
|
|
|
foreach ($all as $parameter) { |
|
494
|
|
|
$parameters[$parameter->getCategory()][$parameter->getVariable()] = $parameter->getSelectedValue(); |
|
495
|
|
|
} |
|
496
|
|
|
|
|
497
|
|
|
return $parameters; |
|
498
|
|
|
} |
|
499
|
|
|
|
|
500
|
|
|
/*private function transformParameters(SettingsBuilder $settingsBuilder, array $parameters) |
|
501
|
|
|
* { |
|
502
|
|
|
* $transformedParameters = $parameters; |
|
503
|
|
|
* foreach ($settingsBuilder->getTransformers() as $parameter => $transformer) { |
|
504
|
|
|
* if (array_key_exists($parameter, $parameters)) { |
|
505
|
|
|
* $transformedParameters[$parameter] = $transformer->reverseTransform($parameters[$parameter]); |
|
506
|
|
|
* } |
|
507
|
|
|
* } |
|
508
|
|
|
* return $transformedParameters; |
|
509
|
|
|
* }*/ |
|
510
|
|
|
|
|
511
|
|
|
/** |
|
512
|
|
|
* Get variables and categories as in 1.11.x. |
|
513
|
|
|
*/ |
|
514
|
|
|
private function getVariablesAndCategories(): array |
|
515
|
|
|
{ |
|
516
|
|
|
return [ |
|
517
|
|
|
'Institution' => 'Platform', |
|
518
|
|
|
'InstitutionUrl' => 'Platform', |
|
519
|
|
|
'siteName' => 'Platform', |
|
520
|
|
|
'site_name' => 'Platform', |
|
521
|
|
|
'emailAdministrator' => 'admin', |
|
522
|
|
|
// 'emailAdministrator' => 'Platform', |
|
523
|
|
|
'administratorSurname' => 'admin', |
|
524
|
|
|
'administratorTelephone' => 'admin', |
|
525
|
|
|
'administratorName' => 'admin', |
|
526
|
|
|
'show_administrator_data' => 'Platform', |
|
527
|
|
|
'show_tutor_data' => 'Session', |
|
528
|
|
|
'show_teacher_data' => 'Platform', |
|
529
|
|
|
'show_toolshortcuts' => 'Course', |
|
530
|
|
|
'allow_group_categories' => 'Course', |
|
531
|
|
|
'server_type' => 'Platform', |
|
532
|
|
|
'platformLanguage' => 'Language', |
|
533
|
|
|
'showonline' => 'Platform', |
|
534
|
|
|
'profile' => 'User', |
|
535
|
|
|
'default_document_quotum' => 'Course', |
|
536
|
|
|
'registration' => 'User', |
|
537
|
|
|
'default_group_quotum' => 'Course', |
|
538
|
|
|
'allow_registration' => 'Platform', |
|
539
|
|
|
'allow_registration_as_teacher' => 'Platform', |
|
540
|
|
|
'allow_lostpassword' => 'Platform', |
|
541
|
|
|
'allow_user_headings' => 'Course', |
|
542
|
|
|
'allow_personal_agenda' => 'agenda', |
|
543
|
|
|
'display_coursecode_in_courselist' => 'Platform', |
|
544
|
|
|
'display_teacher_in_courselist' => 'Platform', |
|
545
|
|
|
'permanently_remove_deleted_files' => 'Tools', |
|
546
|
|
|
'dropbox_allow_overwrite' => 'Tools', |
|
547
|
|
|
'dropbox_max_filesize' => 'Tools', |
|
548
|
|
|
'dropbox_allow_just_upload' => 'Tools', |
|
549
|
|
|
'dropbox_allow_student_to_student' => 'Tools', |
|
550
|
|
|
'dropbox_allow_group' => 'Tools', |
|
551
|
|
|
'dropbox_allow_mailing' => 'Tools', |
|
552
|
|
|
'extended_profile' => 'User', |
|
553
|
|
|
'student_view_enabled' => 'Platform', |
|
554
|
|
|
'show_navigation_menu' => 'Course', |
|
555
|
|
|
'enable_tool_introduction' => 'course', |
|
556
|
|
|
'page_after_login' => 'Platform', |
|
557
|
|
|
'time_limit_whosonline' => 'Platform', |
|
558
|
|
|
'breadcrumbs_course_homepage' => 'Course', |
|
559
|
|
|
'example_material_course_creation' => 'Platform', |
|
560
|
|
|
'account_valid_duration' => 'Platform', |
|
561
|
|
|
'use_session_mode' => 'Session', |
|
562
|
|
|
'allow_email_editor' => 'Tools', |
|
563
|
|
|
// 'registered' => null', |
|
564
|
|
|
// 'donotlistcampus' =>'null', |
|
565
|
|
|
'show_email_addresses' => 'Platform', |
|
566
|
|
|
'service_ppt2lp' => 'NULL', |
|
567
|
|
|
'upload_extensions_list_type' => 'Security', |
|
568
|
|
|
'upload_extensions_blacklist' => 'Security', |
|
569
|
|
|
'upload_extensions_whitelist' => 'Security', |
|
570
|
|
|
'upload_extensions_skip' => 'Security', |
|
571
|
|
|
'upload_extensions_replace_by' => 'Security', |
|
572
|
|
|
'show_number_of_courses' => 'Platform', |
|
573
|
|
|
'show_empty_course_categories' => 'Platform', |
|
574
|
|
|
'show_back_link_on_top_of_tree' => 'Platform', |
|
575
|
|
|
'show_different_course_language' => 'Platform', |
|
576
|
|
|
'split_users_upload_directory' => 'Tuning', |
|
577
|
|
|
'hide_dltt_markup' => 'Languages', |
|
578
|
|
|
'display_categories_on_homepage' => 'Platform', |
|
579
|
|
|
'permissions_for_new_directories' => 'Security', |
|
580
|
|
|
'permissions_for_new_files' => 'Security', |
|
581
|
|
|
'show_tabs' => 'Platform', |
|
582
|
|
|
'default_forum_view' => 'Course', |
|
583
|
|
|
'platform_charset' => 'Languages', |
|
584
|
|
|
'noreply_email_address' => 'Platform', |
|
585
|
|
|
'survey_email_sender_noreply' => 'Course', |
|
586
|
|
|
'gradebook_enable' => 'Gradebook', |
|
587
|
|
|
'gradebook_score_display_coloring' => 'Gradebook', |
|
588
|
|
|
'gradebook_score_display_custom' => 'Gradebook', |
|
589
|
|
|
'gradebook_score_display_colorsplit' => 'Gradebook', |
|
590
|
|
|
'gradebook_score_display_upperlimit' => 'Gradebook', |
|
591
|
|
|
'gradebook_number_decimals' => 'Gradebook', |
|
592
|
|
|
'user_selected_theme' => 'Platform', |
|
593
|
|
|
'allow_course_theme' => 'Course', |
|
594
|
|
|
'show_closed_courses' => 'Platform', |
|
595
|
|
|
'extendedprofile_registration' => 'User', |
|
596
|
|
|
'extendedprofile_registrationrequired' => 'User', |
|
597
|
|
|
'add_users_by_coach' => 'Session', |
|
598
|
|
|
'extend_rights_for_coach' => 'Security', |
|
599
|
|
|
'extend_rights_for_coach_on_survey' => 'Security', |
|
600
|
|
|
'course_create_active_tools' => 'Tools', |
|
601
|
|
|
'show_session_coach' => 'Session', |
|
602
|
|
|
'allow_users_to_create_courses' => 'Platform', |
|
603
|
|
|
'allow_message_tool' => 'Tools', |
|
604
|
|
|
'allow_social_tool' => 'Tools', |
|
605
|
|
|
'allow_students_to_browse_courses' => 'Platform', |
|
606
|
|
|
'show_session_data' => 'Session', |
|
607
|
|
|
'allow_use_sub_language' => 'language', |
|
608
|
|
|
'show_glossary_in_documents' => 'Course', |
|
609
|
|
|
'allow_terms_conditions' => 'Platform', |
|
610
|
|
|
'search_enabled' => 'Search', |
|
611
|
|
|
'search_prefilter_prefix' => 'Search', |
|
612
|
|
|
'search_show_unlinked_results' => 'Search', |
|
613
|
|
|
'show_courses_descriptions_in_catalog' => 'Course', |
|
614
|
|
|
'allow_coach_to_edit_course_session' => 'Session', |
|
615
|
|
|
'show_glossary_in_extra_tools' => 'Course', |
|
616
|
|
|
'send_email_to_admin_when_create_course' => 'Platform', |
|
617
|
|
|
'go_to_course_after_login' => 'Course', |
|
618
|
|
|
'math_asciimathML' => 'Editor', |
|
619
|
|
|
'enabled_asciisvg' => 'Editor', |
|
620
|
|
|
'include_asciimathml_script' => 'Editor', |
|
621
|
|
|
'youtube_for_students' => 'Editor', |
|
622
|
|
|
'block_copy_paste_for_students' => 'Editor', |
|
623
|
|
|
'more_buttons_maximized_mode' => 'Editor', |
|
624
|
|
|
'students_download_folders' => 'Document', |
|
625
|
|
|
'users_copy_files' => 'Tools', |
|
626
|
|
|
'allow_students_to_create_groups_in_social' => 'Tools', |
|
627
|
|
|
'allow_send_message_to_all_platform_users' => 'Message', |
|
628
|
|
|
'message_max_upload_filesize' => 'Tools', |
|
629
|
|
|
'use_users_timezone' => 'profile', |
|
630
|
|
|
// 'use_users_timezone' => 'Timezones', |
|
631
|
|
|
'timezone_value' => 'platform', |
|
632
|
|
|
// 'timezone_value' => 'Timezones', |
|
633
|
|
|
'allow_user_course_subscription_by_course_admin' => 'Security', |
|
634
|
|
|
'show_link_bug_notification' => 'Platform', |
|
635
|
|
|
'show_link_ticket_notification' => 'Platform', |
|
636
|
|
|
'course_validation' => 'course', |
|
637
|
|
|
// 'course_validation' => 'Platform', |
|
638
|
|
|
'course_validation_terms_and_conditions_url' => 'Platform', |
|
639
|
|
|
'enabled_wiris' => 'Editor', |
|
640
|
|
|
'allow_spellcheck' => 'Editor', |
|
641
|
|
|
'force_wiki_paste_as_plain_text' => 'Editor', |
|
642
|
|
|
'enabled_googlemaps' => 'Editor', |
|
643
|
|
|
'enabled_imgmap' => 'Editor', |
|
644
|
|
|
'enabled_support_svg' => 'Tools', |
|
645
|
|
|
'pdf_export_watermark_enable' => 'Platform', |
|
646
|
|
|
'pdf_export_watermark_by_course' => 'Platform', |
|
647
|
|
|
'pdf_export_watermark_text' => 'Platform', |
|
648
|
|
|
'enabled_insertHtml' => 'Editor', |
|
649
|
|
|
'students_export2pdf' => 'Document', |
|
650
|
|
|
'exercise_min_score' => 'Course', |
|
651
|
|
|
'exercise_max_score' => 'Course', |
|
652
|
|
|
'show_users_folders' => 'Tools', |
|
653
|
|
|
'show_default_folders' => 'Tools', |
|
654
|
|
|
'show_chat_folder' => 'Tools', |
|
655
|
|
|
'enabled_text2audio' => 'Tools', |
|
656
|
|
|
'course_hide_tools' => 'Course', |
|
657
|
|
|
'enabled_support_pixlr' => 'Tools', |
|
658
|
|
|
'show_groups_to_users' => 'Session', |
|
659
|
|
|
'accessibility_font_resize' => 'Platform', |
|
660
|
|
|
'hide_courses_in_sessions' => 'Session', |
|
661
|
|
|
'enable_quiz_scenario' => 'Course', |
|
662
|
|
|
'filter_terms' => 'Security', |
|
663
|
|
|
'header_extra_content' => 'Tracking', |
|
664
|
|
|
'footer_extra_content' => 'Tracking', |
|
665
|
|
|
'show_documents_preview' => 'Tools', |
|
666
|
|
|
'htmlpurifier_wiki' => 'Editor', |
|
667
|
|
|
'cas_activate' => 'CAS', |
|
668
|
|
|
'cas_server' => 'CAS', |
|
669
|
|
|
'cas_server_uri' => 'CAS', |
|
670
|
|
|
'cas_port' => 'CAS', |
|
671
|
|
|
'cas_protocol' => 'CAS', |
|
672
|
|
|
'cas_add_user_activate' => 'CAS', |
|
673
|
|
|
'update_user_info_cas_with_ldap' => 'CAS', |
|
674
|
|
|
'student_page_after_login' => 'Platform', |
|
675
|
|
|
'teacher_page_after_login' => 'Platform', |
|
676
|
|
|
'drh_page_after_login' => 'Platform', |
|
677
|
|
|
'sessionadmin_page_after_login' => 'Session', |
|
678
|
|
|
'student_autosubscribe' => 'Platform', |
|
679
|
|
|
'teacher_autosubscribe' => 'Platform', |
|
680
|
|
|
'drh_autosubscribe' => 'Platform', |
|
681
|
|
|
'sessionadmin_autosubscribe' => 'Session', |
|
682
|
|
|
'scorm_cumulative_session_time' => 'Course', |
|
683
|
|
|
'allow_hr_skills_management' => 'Gradebook', |
|
684
|
|
|
'enable_help_link' => 'Platform', |
|
685
|
|
|
'teachers_can_change_score_settings' => 'Gradebook', |
|
686
|
|
|
'allow_users_to_change_email_with_no_password' => 'User', |
|
687
|
|
|
'show_admin_toolbar' => 'display', |
|
688
|
|
|
'allow_global_chat' => 'Platform', |
|
689
|
|
|
'languagePriority1' => 'language', |
|
690
|
|
|
'languagePriority2' => 'language', |
|
691
|
|
|
'languagePriority3' => 'language', |
|
692
|
|
|
'languagePriority4' => 'language', |
|
693
|
|
|
'login_is_email' => 'Platform', |
|
694
|
|
|
'courses_default_creation_visibility' => 'Course', |
|
695
|
|
|
'gradebook_enable_grade_model' => 'Gradebook', |
|
696
|
|
|
'teachers_can_change_grade_model_settings' => 'Gradebook', |
|
697
|
|
|
'gradebook_default_weight' => 'Gradebook', |
|
698
|
|
|
'ldap_description' => 'LDAP', |
|
699
|
|
|
'shibboleth_description' => 'Shibboleth', |
|
700
|
|
|
'facebook_description' => 'Facebook', |
|
701
|
|
|
'gradebook_locking_enabled' => 'Gradebook', |
|
702
|
|
|
'gradebook_default_grade_model_id' => 'Gradebook', |
|
703
|
|
|
'allow_session_admins_to_manage_all_sessions' => 'Session', |
|
704
|
|
|
'allow_skills_tool' => 'Platform', |
|
705
|
|
|
'allow_public_certificates' => 'Course', |
|
706
|
|
|
'platform_unsubscribe_allowed' => 'Platform', |
|
707
|
|
|
'enable_iframe_inclusion' => 'Editor', |
|
708
|
|
|
'show_hot_courses' => 'Platform', |
|
709
|
|
|
'enable_webcam_clip' => 'Tools', |
|
710
|
|
|
'use_custom_pages' => 'Platform', |
|
711
|
|
|
'tool_visible_by_default_at_creation' => 'Tools', |
|
712
|
|
|
'prevent_session_admins_to_manage_all_users' => 'Session', |
|
713
|
|
|
'documents_default_visibility_defined_in_course' => 'Tools', |
|
714
|
|
|
'enabled_mathjax' => 'Editor', |
|
715
|
|
|
'meta_twitter_site' => 'Tracking', |
|
716
|
|
|
'meta_twitter_creator' => 'Tracking', |
|
717
|
|
|
'meta_title' => 'Tracking', |
|
718
|
|
|
'meta_description' => 'Tracking', |
|
719
|
|
|
'meta_image_path' => 'Tracking', |
|
720
|
|
|
'allow_teachers_to_create_sessions' => 'Session', |
|
721
|
|
|
'institution_address' => 'Platform', |
|
722
|
|
|
'chamilo_database_version' => 'null', |
|
723
|
|
|
'cron_remind_course_finished_activate' => 'Crons', |
|
724
|
|
|
'cron_remind_course_expiration_frequency' => 'Crons', |
|
725
|
|
|
'cron_remind_course_expiration_activate' => 'Crons', |
|
726
|
|
|
'allow_coach_feedback_exercises' => 'Session', |
|
727
|
|
|
'allow_my_files' => 'Platform', |
|
728
|
|
|
'ticket_allow_student_add' => 'Ticket', |
|
729
|
|
|
'ticket_send_warning_to_all_admins' => 'Ticket', |
|
730
|
|
|
'ticket_warn_admin_no_user_in_category' => 'Ticket', |
|
731
|
|
|
'ticket_allow_category_edition' => 'Ticket', |
|
732
|
|
|
'load_term_conditions_section' => 'Platform', |
|
733
|
|
|
'show_terms_if_profile_completed' => 'Ticket', |
|
734
|
|
|
'hide_home_top_when_connected' => 'Platform', |
|
735
|
|
|
'hide_global_announcements_when_not_connected' => 'Platform', |
|
736
|
|
|
'course_creation_use_template' => 'Course', |
|
737
|
|
|
'allow_strength_pass_checker' => 'Security', |
|
738
|
|
|
'allow_captcha' => 'Security', |
|
739
|
|
|
'captcha_number_mistakes_to_block_account' => 'Security', |
|
740
|
|
|
'captcha_time_to_block' => 'Security', |
|
741
|
|
|
'drh_can_access_all_session_content' => 'Session', |
|
742
|
|
|
'display_groups_forum_in_general_tool' => 'Tools', |
|
743
|
|
|
'allow_tutors_to_assign_students_to_session' => 'Session', |
|
744
|
|
|
'allow_lp_return_link' => 'Course', |
|
745
|
|
|
'hide_scorm_export_link' => 'Course', |
|
746
|
|
|
'hide_scorm_copy_link' => 'Course', |
|
747
|
|
|
'hide_scorm_pdf_link' => 'Course', |
|
748
|
|
|
'session_days_before_coach_access' => 'Session', |
|
749
|
|
|
'session_days_after_coach_access' => 'Session', |
|
750
|
|
|
'pdf_logo_header' => 'Course', |
|
751
|
|
|
'order_user_list_by_official_code' => 'Platform', |
|
752
|
|
|
'email_alert_manager_on_new_quiz' => 'exercise', |
|
753
|
|
|
'show_official_code_exercise_result_list' => 'Tools', |
|
754
|
|
|
'course_catalog_hide_private' => 'Platform', |
|
755
|
|
|
'catalog_show_courses_sessions' => 'Platform', |
|
756
|
|
|
'auto_detect_language_custom_pages' => 'Platform', |
|
757
|
|
|
'lp_show_reduced_report' => 'Course', |
|
758
|
|
|
'allow_session_course_copy_for_teachers' => 'Session', |
|
759
|
|
|
'hide_logout_button' => 'Platform', |
|
760
|
|
|
'redirect_admin_to_courses_list' => 'Platform', |
|
761
|
|
|
'course_images_in_courses_list' => 'Course', |
|
762
|
|
|
'student_publication_to_take_in_gradebook' => 'Gradebook', |
|
763
|
|
|
'certificate_filter_by_official_code' => 'Gradebook', |
|
764
|
|
|
'exercise_max_ckeditors_in_page' => 'Tools', |
|
765
|
|
|
'document_if_file_exists_option' => 'Tools', |
|
766
|
|
|
'add_gradebook_certificates_cron_task_enabled' => 'Gradebook', |
|
767
|
|
|
'openbadges_backpack' => 'Gradebook', |
|
768
|
|
|
'cookie_warning' => 'Tools', |
|
769
|
|
|
'hide_course_group_if_no_tools_available' => 'Tools', |
|
770
|
|
|
'catalog_allow_session_auto_subscription' => 'Session', |
|
771
|
|
|
'registration.soap.php.decode_utf8' => 'Platform', |
|
772
|
|
|
'allow_delete_attendance' => 'Tools', |
|
773
|
|
|
'gravatar_enabled' => 'Platform', |
|
774
|
|
|
'gravatar_type' => 'Platform', |
|
775
|
|
|
'limit_session_admin_role' => 'Session', |
|
776
|
|
|
'show_session_description' => 'Session', |
|
777
|
|
|
'hide_certificate_export_link_students' => 'Gradebook', |
|
778
|
|
|
'hide_certificate_export_link' => 'Gradebook', |
|
779
|
|
|
'dropbox_hide_course_coach' => 'Tools', |
|
780
|
|
|
'dropbox_hide_general_coach' => 'Tools', |
|
781
|
|
|
'session_course_ordering' => 'Session', |
|
782
|
|
|
'gamification_mode' => 'Platform', |
|
783
|
|
|
'prevent_multiple_simultaneous_login' => 'Security', |
|
784
|
|
|
'gradebook_detailed_admin_view' => 'Gradebook', |
|
785
|
|
|
'course_catalog_published' => 'Course', |
|
786
|
|
|
'user_reset_password' => 'Security', |
|
787
|
|
|
'user_reset_password_token_limit' => 'Security', |
|
788
|
|
|
'my_courses_view_by_session' => 'Session', |
|
789
|
|
|
'show_full_skill_name_on_skill_wheel' => 'Platform', |
|
790
|
|
|
'messaging_allow_send_push_notification' => 'WebServices', |
|
791
|
|
|
'messaging_gdc_project_number' => 'WebServices', |
|
792
|
|
|
'messaging_gdc_api_key' => 'WebServices', |
|
793
|
|
|
'teacher_can_select_course_template' => 'Course', |
|
794
|
|
|
'enable_record_audio' => 'Tools', |
|
795
|
|
|
'allow_show_skype_account' => 'Platform', |
|
796
|
|
|
'allow_show_linkedin_url' => 'Platform', |
|
797
|
|
|
'enable_profile_user_address_geolocalization' => 'User', |
|
798
|
|
|
'show_official_code_whoisonline' => 'Profile', |
|
799
|
|
|
'icons_mode_svg' => 'display', |
|
800
|
|
|
'user_name_order' => 'display', |
|
801
|
|
|
'user_name_sort_by' => 'display', |
|
802
|
|
|
'default_calendar_view' => 'agenda', |
|
803
|
|
|
'exercise_invisible_in_session' => 'exercise', |
|
804
|
|
|
'configure_exercise_visibility_in_course' => 'exercise', |
|
805
|
|
|
'allow_download_documents_by_api_key' => 'Webservices', |
|
806
|
|
|
'profiling_filter_adding_users' => 'profile', |
|
807
|
|
|
'donotlistcampus' => 'platform', |
|
808
|
|
|
'course_creation_splash_screen' => 'Course', |
|
809
|
|
|
'translate_html' => 'Editor', |
|
810
|
|
|
'enable_bootstrap_in_documents_html' => 'Course', |
|
811
|
|
|
]; |
|
812
|
|
|
} |
|
813
|
|
|
|
|
814
|
|
|
/** |
|
815
|
|
|
* Rename old variable with variable used in Chamilo 2.0. |
|
816
|
|
|
* |
|
817
|
|
|
* @param string $variable |
|
818
|
|
|
*/ |
|
819
|
|
|
private function renameVariable($variable) |
|
820
|
|
|
{ |
|
821
|
|
|
$list = [ |
|
822
|
|
|
'timezone_value' => 'timezone', |
|
823
|
|
|
'Institution' => 'institution', |
|
824
|
|
|
'SiteName' => 'site_name', |
|
825
|
|
|
'siteName' => 'site_name', |
|
826
|
|
|
'InstitutionUrl' => 'institution_url', |
|
827
|
|
|
'registration' => 'required_profile_fields', |
|
828
|
|
|
'platformLanguage' => 'platform_language', |
|
829
|
|
|
'languagePriority1' => 'language_priority_1', |
|
830
|
|
|
'languagePriority2' => 'language_priority_2', |
|
831
|
|
|
'languagePriority3' => 'language_priority_3', |
|
832
|
|
|
'languagePriority4' => 'language_priority_4', |
|
833
|
|
|
'gradebook_score_display_coloring' => 'my_display_coloring', |
|
834
|
|
|
'ProfilingFilterAddingUsers' => 'profiling_filter_adding_users', |
|
835
|
|
|
'course_create_active_tools' => 'active_tools_on_create', |
|
836
|
|
|
'emailAdministrator' => 'administrator_email', |
|
837
|
|
|
'administratorSurname' => 'administrator_surname', |
|
838
|
|
|
'administratorName' => 'administrator_name', |
|
839
|
|
|
'administratorTelephone' => 'administrator_phone', |
|
840
|
|
|
'registration.soap.php.decode_utf8' => 'decode_utf8', |
|
841
|
|
|
'profile' => 'changeable_options', |
|
842
|
|
|
]; |
|
843
|
|
|
|
|
844
|
|
|
return $list[$variable] ?? $variable; |
|
845
|
|
|
} |
|
846
|
|
|
|
|
847
|
|
|
/** |
|
848
|
|
|
* Replace old Chamilo 1.x category with 2.0 version. |
|
849
|
|
|
* |
|
850
|
|
|
* @param string $variable |
|
851
|
|
|
* @param string $defaultCategory |
|
852
|
|
|
*/ |
|
853
|
|
|
private function fixCategory($variable, $defaultCategory) |
|
854
|
|
|
{ |
|
855
|
|
|
$settings = [ |
|
856
|
|
|
'cookie_warning' => 'platform', |
|
857
|
|
|
'donotlistcampus' => 'platform', |
|
858
|
|
|
'administrator_email' => 'admin', |
|
859
|
|
|
'administrator_surname' => 'admin', |
|
860
|
|
|
'administrator_name' => 'admin', |
|
861
|
|
|
'administrator_phone' => 'admin', |
|
862
|
|
|
'exercise_max_ckeditors_in_page' => 'exercise', |
|
863
|
|
|
'allow_hr_skills_management' => 'skill', |
|
864
|
|
|
'accessibility_font_resize' => 'display', |
|
865
|
|
|
'account_valid_duration' => 'profile', |
|
866
|
|
|
'allow_global_chat' => 'chat', |
|
867
|
|
|
'allow_lostpassword' => 'registration', |
|
868
|
|
|
'allow_registration' => 'registration', |
|
869
|
|
|
'allow_registration_as_teacher' => 'registration', |
|
870
|
|
|
'required_profile_fields' => 'registration', |
|
871
|
|
|
'allow_skills_tool' => 'skill', |
|
872
|
|
|
'allow_students_to_browse_courses' => 'display', |
|
873
|
|
|
'allow_terms_conditions' => 'registration', |
|
874
|
|
|
'allow_users_to_create_courses' => 'course', |
|
875
|
|
|
'auto_detect_language_custom_pages' => 'language', |
|
876
|
|
|
'platform_language' => 'language', |
|
877
|
|
|
'course_validation' => 'course', |
|
878
|
|
|
'course_validation_terms_and_conditions_url' => 'course', |
|
879
|
|
|
'display_categories_on_homepage' => 'display', |
|
880
|
|
|
'display_coursecode_in_courselist' => 'course', |
|
881
|
|
|
'display_teacher_in_courselist' => 'course', |
|
882
|
|
|
'drh_autosubscribe' => 'registration', |
|
883
|
|
|
'drh_page_after_login' => 'registration', |
|
884
|
|
|
'enable_help_link' => 'display', |
|
885
|
|
|
'example_material_course_creation' => 'course', |
|
886
|
|
|
'login_is_email' => 'profile', |
|
887
|
|
|
'noreply_email_address' => 'mail', |
|
888
|
|
|
'page_after_login' => 'registration', |
|
889
|
|
|
'pdf_export_watermark_by_course' => 'document', |
|
890
|
|
|
'pdf_export_watermark_enable' => 'document', |
|
891
|
|
|
'pdf_export_watermark_text' => 'document', |
|
892
|
|
|
'platform_unsubscribe_allowed' => 'registration', |
|
893
|
|
|
'send_email_to_admin_when_create_course' => 'course', |
|
894
|
|
|
'show_admin_toolbar' => 'display', |
|
895
|
|
|
'show_administrator_data' => 'display', |
|
896
|
|
|
'show_back_link_on_top_of_tree' => 'display', |
|
897
|
|
|
'show_closed_courses' => 'display', |
|
898
|
|
|
'show_different_course_language' => 'display', |
|
899
|
|
|
'show_email_addresses' => 'display', |
|
900
|
|
|
'show_empty_course_categories' => 'display', |
|
901
|
|
|
'show_full_skill_name_on_skill_wheel' => 'skill', |
|
902
|
|
|
'show_hot_courses' => 'display', |
|
903
|
|
|
'show_link_bug_notification' => 'display', |
|
904
|
|
|
'show_number_of_courses' => 'display', |
|
905
|
|
|
'show_teacher_data' => 'display', |
|
906
|
|
|
'showonline' => 'display', |
|
907
|
|
|
'student_autosubscribe' => 'registration', |
|
908
|
|
|
'student_page_after_login' => 'registration', |
|
909
|
|
|
'student_view_enabled' => 'course', |
|
910
|
|
|
'teacher_autosubscribe' => 'registration', |
|
911
|
|
|
'teacher_page_after_login' => 'registration', |
|
912
|
|
|
'time_limit_whosonline' => 'display', |
|
913
|
|
|
'user_selected_theme' => 'profile', |
|
914
|
|
|
'hide_global_announcements_when_not_connected' => 'announcement', |
|
915
|
|
|
'hide_home_top_when_connected' => 'display', |
|
916
|
|
|
'hide_logout_button' => 'display', |
|
917
|
|
|
'institution_address' => 'platform', |
|
918
|
|
|
'redirect_admin_to_courses_list' => 'admin', |
|
919
|
|
|
'use_custom_pages' => 'platform', |
|
920
|
|
|
'allow_group_categories' => 'group', |
|
921
|
|
|
'allow_user_headings' => 'display', |
|
922
|
|
|
'default_document_quotum' => 'document', |
|
923
|
|
|
'default_forum_view' => 'forum', |
|
924
|
|
|
'default_group_quotum' => 'document', |
|
925
|
|
|
'enable_quiz_scenario' => 'exercise', |
|
926
|
|
|
'exercise_max_score' => 'exercise', |
|
927
|
|
|
'exercise_min_score' => 'exercise', |
|
928
|
|
|
'pdf_logo_header' => 'platform', |
|
929
|
|
|
'show_glossary_in_documents' => 'document', |
|
930
|
|
|
'show_glossary_in_extra_tools' => 'glossary', |
|
931
|
|
|
'survey_email_sender_noreply' => 'survey', |
|
932
|
|
|
'allow_coach_feedback_exercises' => 'exercise', |
|
933
|
|
|
'sessionadmin_autosubscribe' => 'registration', |
|
934
|
|
|
'sessionadmin_page_after_login' => 'registration', |
|
935
|
|
|
'show_tutor_data' => 'display', |
|
936
|
|
|
'allow_social_tool' => 'social', |
|
937
|
|
|
'allow_message_tool' => 'message', |
|
938
|
|
|
'allow_email_editor' => 'editor', |
|
939
|
|
|
'show_link_ticket_notification' => 'display', |
|
940
|
|
|
'permissions_for_new_directories' => 'document', |
|
941
|
|
|
'enable_profile_user_address_geolocalization' => 'profile', |
|
942
|
|
|
'allow_show_skype_account' => 'profile', |
|
943
|
|
|
'allow_show_linkedin_url' => 'profile', |
|
944
|
|
|
'allow_students_to_create_groups_in_social' => 'social', |
|
945
|
|
|
'default_calendar_view' => 'agenda', |
|
946
|
|
|
'documents_default_visibility_defined_in_course' => 'document', |
|
947
|
|
|
'message_max_upload_filesize' => 'message', |
|
948
|
|
|
'course_create_active_tools' => 'course', |
|
949
|
|
|
'tool_visible_by_default_at_creation' => 'document', |
|
950
|
|
|
'show_users_folders' => 'document', |
|
951
|
|
|
'show_default_folders' => 'document', |
|
952
|
|
|
'show_chat_folder' => 'chat', |
|
953
|
|
|
'enabled_support_svg' => 'editor', |
|
954
|
|
|
'enabled_support_pixlr' => 'editor', |
|
955
|
|
|
'enable_webcam_clip' => 'document', |
|
956
|
|
|
'enable_record_audio' => 'course', |
|
957
|
|
|
'enabled_text2audio' => 'document', |
|
958
|
|
|
'permanently_remove_deleted_files' => 'document', |
|
959
|
|
|
'allow_delete_attendance' => 'attendance', |
|
960
|
|
|
'display_groups_forum_in_general_tool' => 'forum', |
|
961
|
|
|
'dropbox_allow_overwrite' => 'dropbox', |
|
962
|
|
|
'allow_user_course_subscription_by_course_admin' => 'course', |
|
963
|
|
|
'hide_course_group_if_no_tools_available' => 'group', |
|
964
|
|
|
'extend_rights_for_coach_on_survey' => 'survey', |
|
965
|
|
|
'show_official_code_exercise_result_list' => 'exercise', |
|
966
|
|
|
'dropbox_max_filesize' => 'dropbox', |
|
967
|
|
|
'dropbox_allow_just_upload' => 'dropbox', |
|
968
|
|
|
'dropbox_allow_student_to_student' => 'dropbox', |
|
969
|
|
|
'dropbox_allow_group' => 'dropbox', |
|
970
|
|
|
'dropbox_allow_mailing' => 'dropbox', |
|
971
|
|
|
'upload_extensions_list_type' => 'document', |
|
972
|
|
|
'upload_extensions_blacklist' => 'document', |
|
973
|
|
|
'upload_extensions_skip' => 'document', |
|
974
|
|
|
'changeable_options' => 'profile', |
|
975
|
|
|
'users_copy_files' => 'document', |
|
976
|
|
|
'document_if_file_exists_option' => 'document', |
|
977
|
|
|
'permissions_for_new_files' => 'document', |
|
978
|
|
|
'extended_profile' => 'profile', |
|
979
|
|
|
'split_users_upload_directory' => 'profile', |
|
980
|
|
|
'show_documents_preview' => 'document', |
|
981
|
|
|
'messaging_allow_send_push_notification' => 'webservice', |
|
982
|
|
|
'messaging_gdc_project_number' => 'webservice', |
|
983
|
|
|
'messaging_gdc_api_key' => 'webservice', |
|
984
|
|
|
'allow_download_documents_by_api_key' => 'webservice', |
|
985
|
|
|
'profiling_filter_adding_users' => 'profile', |
|
986
|
|
|
'hide_dltt_markup' => 'language', |
|
987
|
|
|
'active_tools_on_create' => 'course', |
|
988
|
|
|
]; |
|
989
|
|
|
|
|
990
|
|
|
return $settings[$variable] ?? $defaultCategory; |
|
991
|
|
|
} |
|
992
|
|
|
|
|
993
|
|
|
private function transformToString($value): string |
|
994
|
|
|
{ |
|
995
|
|
|
if (\is_array($value)) { |
|
996
|
|
|
return implode(',', $value); |
|
997
|
|
|
} |
|
998
|
|
|
|
|
999
|
|
|
if ($value instanceof Course) { |
|
1000
|
|
|
return (string) $value->getId(); |
|
1001
|
|
|
} |
|
1002
|
|
|
|
|
1003
|
|
|
if (\is_bool($value)) { |
|
1004
|
|
|
return $value ? 'true' : 'false'; |
|
1005
|
|
|
} |
|
1006
|
|
|
|
|
1007
|
|
|
if (null === $value) { |
|
1008
|
|
|
return ''; |
|
1009
|
|
|
} |
|
1010
|
|
|
|
|
1011
|
|
|
return (string) $value; |
|
1012
|
|
|
} |
|
1013
|
|
|
} |
|
1014
|
|
|
|