-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.php
More file actions
66 lines (56 loc) · 2.3 KB
/
plugin.php
File metadata and controls
66 lines (56 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
declare(strict_types=1);
/**
* SystemSettingsOverride v2.0.0
*
* This plugin is based on ClientConfig by Mark Hamstra
* https://github.com/modmore/ClientConfig/blob/master/core/components/clientconfig/elements/plugins/clientconfig.plugin.php
*
* Thank you Mark for the code you've released!
*
* SystemSettingsOverride is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* SystemSettingsOverride is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* SystemSettingsOverride; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
$eventName = $modx->event->name;
switch ($eventName) {
case 'OnMODXInit':
case 'OnHandleRequest':
case 'pdoToolsOnFenomInit':
$settings = [];
$file = MODX_CORE_PATH . 'config/system_settings.php';
if (file_exists($file)) {
$settings = require $file;
} else {
$modx->log(modX::LOG_LEVEL_DEBUG, 'SystemSettingsOverride: File ' . $file . ' does not exist.');
}
$file = MODX_CORE_PATH . 'config/system_settings.local.php';
if (file_exists($file)) {
$settings = array_merge($settings, require $file);
} else {
$modx->log(modX::LOG_LEVEL_DEBUG, 'SystemSettingsOverride: File ' . $file . ' does not exist.');
}
if (count($settings) === 0) {
return;
}
/* Make settings available as [[++tags]] */
$modx->setPlaceholders($settings, '+');
/* Make settings available as $modx->config['tags'] */
foreach ($settings as $key => $value) {
if ($oldValue = $modx->getOption($key)) {
$modx->log(modX::LOG_LEVEL_DEBUG, "Overriding system setting {$key} with value '{$value}' (previously '{$oldValue}')");
}
$modx->setOption($key, $value);
}
break;
}
return;