| 1: | <?php |
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | namespace Aurora\Modules\CoreMobileWebclient; |
| 8: | |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | |
| 15: | |
| 16: | |
| 17: | |
| 18: | |
| 19: | class Module extends \Aurora\System\Module\AbstractLicensedModule |
| 20: | { |
| 21: | public function init() |
| 22: | { |
| 23: | $this->subscribeEvent('Core::UpdateSettings::after', array($this, 'onAfterUpdateSettings')); |
| 24: | } |
| 25: | |
| 26: | |
| 27: | |
| 28: | |
| 29: | public static function getInstance() |
| 30: | { |
| 31: | return parent::getInstance(); |
| 32: | } |
| 33: | |
| 34: | |
| 35: | |
| 36: | |
| 37: | public static function Decorator() |
| 38: | { |
| 39: | return parent::Decorator(); |
| 40: | } |
| 41: | |
| 42: | |
| 43: | |
| 44: | |
| 45: | public function getModuleSettings() |
| 46: | { |
| 47: | return $this->oModuleSettings; |
| 48: | } |
| 49: | |
| 50: | public function GetSettings() |
| 51: | { |
| 52: | \Aurora\System\Api::checkUserRoleIsAtLeast(\Aurora\System\Enums\UserRole::Anonymous); |
| 53: | |
| 54: | $oUser = \Aurora\System\Api::getAuthenticatedUser(); |
| 55: | |
| 56: | return array( |
| 57: | 'Theme' => $oUser && null !== $oUser->getExtendedProp(self::GetName() . '::Theme') ? $oUser->getExtendedProp(self::GetName() . '::Theme') : $this->oModuleSettings->Theme, |
| 58: | 'ThemeList' => $this->oModuleSettings->ThemeList, |
| 59: | ); |
| 60: | } |
| 61: | |
| 62: | |
| 63: | |
| 64: | |
| 65: | |
| 66: | |
| 67: | public function onAfterUpdateSettings($Args, &$Result) |
| 68: | { |
| 69: | \Aurora\System\Api::checkUserRoleIsAtLeast(\Aurora\System\Enums\UserRole::NormalUser); |
| 70: | |
| 71: | $oUser = \Aurora\System\Api::getAuthenticatedUser(); |
| 72: | if ($oUser && $oUser->isNormalOrTenant()) { |
| 73: | if (isset($Args['MobileTheme'])) { |
| 74: | $oUser->setExtendedProp(self::GetName() . '::Theme', $Args['MobileTheme']); |
| 75: | } |
| 76: | |
| 77: | $oCoreDecorator = \Aurora\Modules\Core\Module::Decorator(); |
| 78: | $Result = $oCoreDecorator->UpdateUserObject($oUser); |
| 79: | } |
| 80: | |
| 81: | if ($oUser && $oUser->Role === \Aurora\System\Enums\UserRole::SuperAdmin) { |
| 82: | if (isset($Args['MobileTheme'])) { |
| 83: | $this->setConfig('Theme', $Args['MobileTheme']); |
| 84: | } |
| 85: | |
| 86: | $Result = $this->saveModuleConfig(); |
| 87: | } |
| 88: | } |
| 89: | } |
| 90: | |