-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathModule.php
More file actions
89 lines (76 loc) · 2.39 KB
/
Module.php
File metadata and controls
89 lines (76 loc) · 2.39 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
/**
* This code is licensed under Afterlogic Software License.
* For full statements of the license see LICENSE file.
*/
namespace Aurora\Modules\CoreMobileWebclient;
/**
* Mobile webclient for core view models.
*
* @license https://afterlogic.com/products/common-licensing Afterlogic Software License
* @copyright Copyright (c) 2023, Afterlogic Corp.
*
* @property Settings $oModuleSettings
*
* @package Modules
*/
class Module extends \Aurora\System\Module\AbstractLicensedModule
{
public function init()
{
$this->subscribeEvent('Core::UpdateSettings::after', array($this, 'onAfterUpdateSettings'));
}
/**
* @return Module
*/
public static function getInstance()
{
return parent::getInstance();
}
/**
* @return Module
*/
public static function Decorator()
{
return parent::Decorator();
}
/**
* @return Settings
*/
public function getModuleSettings()
{
return $this->oModuleSettings;
}
public function GetSettings()
{
\Aurora\System\Api::checkUserRoleIsAtLeast(\Aurora\System\Enums\UserRole::Anonymous);
$oUser = \Aurora\System\Api::getAuthenticatedUser();
return array(
'Theme' => $oUser && null !== $oUser->getExtendedProp(self::GetName() . '::Theme') ? $oUser->getExtendedProp(self::GetName() . '::Theme') : $this->oModuleSettings->Theme,
'ThemeList' => $this->oModuleSettings->ThemeList,
);
}
/**
*
* @param array $Args
* @param mixed $Result
*/
public function onAfterUpdateSettings($Args, &$Result)
{
\Aurora\System\Api::checkUserRoleIsAtLeast(\Aurora\System\Enums\UserRole::NormalUser);
$oUser = \Aurora\System\Api::getAuthenticatedUser();
if ($oUser && $oUser->isNormalOrTenant()) {
if (isset($Args['MobileTheme'])) {
$oUser->setExtendedProp(self::GetName() . '::Theme', $Args['MobileTheme']);
}
$oCoreDecorator = \Aurora\Modules\Core\Module::Decorator();
$Result = $oCoreDecorator->UpdateUserObject($oUser);
}
if ($oUser && $oUser->Role === \Aurora\System\Enums\UserRole::SuperAdmin) {
if (isset($Args['MobileTheme'])) {
$this->setConfig('Theme', $Args['MobileTheme']);
}
$Result = $this->saveModuleConfig();
}
}
}