1: <?php
2: /**
3: * This code is licensed under AGPLv3 license or Afterlogic Software License
4: * if commercial version of the product was purchased.
5: * For full statements of the licenses see LICENSE-AFTERLOGIC and LICENSE-AGPL3 files.
6: */
7:
8: namespace Aurora\System;
9:
10: /**
11: * @license https://www.gnu.org/licenses/agpl-3.0.html AGPL-3.0
12: * @license https://afterlogic.com/products/common-licensing Afterlogic Software License
13: * @copyright Copyright (c) 2019, Afterlogic Corp.
14: *
15: * @package Api
16: */
17: class Settings extends AbstractSettings
18: {
19: protected function initDefaults()
20: {
21: $this->aContainer = array(
22: 'LicenseKey' => new SettingsProperty('LicenseKey', '', 'string'),
23:
24: 'AdminLogin' => new SettingsProperty('AdminLogin', 'superadmin', 'string'),
25: 'AdminPassword' => new SettingsProperty('AdminPassword', '', 'string'),
26: 'AdminLanguage' => new SettingsProperty('AdminLanguage', 'English', 'string'),
27:
28: 'DBType' => new SettingsProperty('DBType', Enums\DbType::MySQL, 'spec', '\Aurora\System\Enums\DbType'),
29: 'DBPrefix' => new SettingsProperty('DBPrefix', 'au_', 'string'),
30: 'DBHost' => new SettingsProperty('DBHost', '127.0.0.1', 'string'),
31: 'DBName' => new SettingsProperty('DBName', '', 'string'),
32: 'DBLogin' => new SettingsProperty('DBLogin', 'root', 'string'),
33: 'DBPassword' => new SettingsProperty('DBPassword', '', 'string'),
34:
35: 'UseSlaveConnection' => new SettingsProperty('UseSlaveConnection', false, 'bool'),
36: 'DBSlaveHost' => new SettingsProperty('DBSlaveHost', '127.0.0.1', 'string'),
37: 'DBSlaveName' => new SettingsProperty('DBSlaveName', '', 'string'),
38: 'DBSlaveLogin' => new SettingsProperty('DBSlaveLogin', 'root', 'string'),
39: 'DBSlavePassword' => new SettingsProperty('DBSlavePassword', '', 'string'),
40: 'DBUseExplain' => new SettingsProperty('DBUseExplain', false, 'bool'),
41: 'DBUseExplainExtended' => new SettingsProperty('DBUseExplainExtended', false, 'bool'),
42: 'DBLogQueryParams' => new SettingsProperty('DBLogQueryParams', false, 'bool'),
43: 'DBDebugBacktraceLimit' => new SettingsProperty('DBDebugBacktraceLimit', false, 'bool'),
44:
45: 'EnableLogging' => new SettingsProperty('EnableLogging', false, 'bool'),
46: 'EnableEventLogging' => new SettingsProperty('EnableEventLogging', false, 'bool'),
47: 'LoggingLevel' => new SettingsProperty('LoggingLevel', Enums\LogLevel::Full, 'spec', '\Aurora\System\Enums\LogLevel'),
48: 'LogFileName' => new SettingsProperty('LogFileName', 'log-{Y-m-d}.txt', 'string'),
49: 'LogCustomFullPath' => new SettingsProperty('LogCustomFullPath', '', 'string'),
50: 'LogPostView' => new SettingsProperty('LogPostView', false, 'bool'),
51:
52: 'EnableMultiChannel' => new SettingsProperty('EnableMultiChannel', false, 'bool'),
53: 'EnableMultiTenant' => new SettingsProperty('EnableMultiTenant', false, 'bool'),
54: 'TenantGlobalCapa' => new SettingsProperty('TenantGlobalCapa', '', 'string'),
55:
56: 'AllowThumbnail' => new SettingsProperty('AllowThumbnail', true, 'bool'),
57: 'ThumbnailMaxFileSizeMb' => new SettingsProperty('ThumbnailMaxFileSizeMb', 5, 'int'),
58: 'CacheCtrl' => new SettingsProperty('CacheCtrl', true, 'bool'),
59: 'CacheLangs' => new SettingsProperty('CacheLangs', true, 'bool'),
60: 'CacheTemplates' => new SettingsProperty('CacheTemplates', true, 'bool'),
61: 'DisplayServerErrorInformation' => new SettingsProperty('DisplayServerErrorInformation', true, 'bool'),
62: 'EnableImap4PlainAuth' => new SettingsProperty('EnableImap4PlainAuth', false, 'bool'),
63: 'RedirectToHttps' => new SettingsProperty('RedirectToHttps', false, 'bool'),
64: 'SocketConnectTimeoutSeconds' => new SettingsProperty('SocketConnectTimeoutSeconds', 20, 'int'),
65: 'SocketGetTimeoutSeconds' => new SettingsProperty('SocketGetTimeoutSeconds', 20, 'int'),
66: 'SocketVerifySsl' => new SettingsProperty('SocketVerifySsl', false, 'bool'),
67: 'UseAppMinJs' => new SettingsProperty('UseAppMinJs', true, 'bool'),
68: 'XFrameOptions' => new SettingsProperty('XFrameOptions', '', 'string'),
69: 'RemoveOldLogs' => new SettingsProperty('RemoveOldLogs', true, 'bool'),
70: 'LogStackTrace' => new SettingsProperty('LogStackTrace', false, 'bool'),
71: 'ExpireUserSessionsBeforeTimestamp' => new SettingsProperty('ExpireUserSessionsBeforeTimestamp', 0, 'int'),
72:
73: 'PasswordMinLength' => new SettingsProperty('PasswordMinLength', 0, 'int'),
74: 'PasswordMustBeComplex' => new SettingsProperty('PasswordMustBeComplex', false, 'bool'),
75:
76: 'StoreAuthTokenInDB' => new SettingsProperty('StoreAuthTokenInDB', false, 'bool'),
77: 'AuthTokenExpirationLifetimeDays' => new SettingsProperty('AuthTokenExpirationLifetimeDays', 0, 'int'),
78: );
79: }
80:
81: /**
82: * @return bool
83: */
84: public function Load($bForceLoad = false)
85: {
86: $this->initDefaults();
87: if (!\file_exists($this->sPath)) {
88: $this->Save();
89: }
90:
91: return parent::Load($bForceLoad);
92: }
93:
94: public function SyncConfigs()
95: {
96: $this->initDefaults();
97: $aContainer = $this->aContainer;
98: if (!\file_exists($this->sPath)) {
99: $this->Save();
100: }
101: parent::Load(true);
102: $this->aContainer = \array_merge($aContainer, $this->aContainer);
103: $this->Save();
104: }
105: }
106: