1: | <?php |
2: | |
3: | |
4: | |
5: | |
6: | |
7: | namespace Aurora\Modules\CoreMobileWebclient; |
8: | |
9: | |
10: | |
11: | |
12: | |
13: | |
14: | |
15: | |
16: | |
17: | class Module extends \Aurora\System\Module\AbstractLicensedModule |
18: | { |
19: | public function init() |
20: | { |
21: | $this->subscribeEvent('Core::UpdateSettings::after', array($this, 'onAfterUpdateSettings')); |
22: | } |
23: | |
24: | public function GetSettings() |
25: | { |
26: | \Aurora\System\Api::checkUserRoleIsAtLeast(\Aurora\System\Enums\UserRole::Anonymous); |
27: | |
28: | $oUser = \Aurora\System\Api::getAuthenticatedUser(); |
29: | |
30: | return array( |
31: | 'Theme' => $oUser && isset($oUser->{self::GetName().'::Theme'}) ? $oUser->{self::GetName().'::Theme'} : $this->getConfig('Theme', 'Default'), |
32: | 'ThemeList' => $this->getConfig('ThemeList', ['Default']), |
33: | ); |
34: | } |
35: | |
36: | |
37: | |
38: | |
39: | |
40: | |
41: | public function onAfterUpdateSettings($Args, &$Result) |
42: | { |
43: | \Aurora\System\Api::checkUserRoleIsAtLeast(\Aurora\System\Enums\UserRole::NormalUser); |
44: | |
45: | $oUser = \Aurora\System\Api::getAuthenticatedUser(); |
46: | if ($oUser && $oUser->isNormalOrTenant()) { |
47: | if (isset($Args['MobileTheme'])) { |
48: | $oUser->setExtendedProp(self::GetName().'::Theme', $Args['MobileTheme']); |
49: | } |
50: | |
51: | $oCoreDecorator = \Aurora\Modules\Core\Module::Decorator(); |
52: | $Result = $oCoreDecorator->UpdateUserObject($oUser); |
53: | } |
54: | |
55: | if ($oUser && $oUser->Role === \Aurora\System\Enums\UserRole::SuperAdmin) { |
56: | if (isset($Args['MobileTheme'])) { |
57: | $this->setConfig('Theme', $Args['MobileTheme']); |
58: | } |
59: | |
60: | $Result = $this->saveModuleConfig(); |
61: | } |
62: | } |
63: | } |
64: | |