1: | <?php |
2: | |
3: | |
4: | |
5: | |
6: | |
7: | |
8: | namespace Aurora\Modules\MailWebclient; |
9: | |
10: | |
11: | |
12: | |
13: | |
14: | |
15: | |
16: | |
17: | |
18: | |
19: | class Module extends \Aurora\System\Module\AbstractWebclientModule |
20: | { |
21: | |
22: | |
23: | |
24: | |
25: | |
26: | public function init() |
27: | { |
28: | $this->subscribeEvent('Mail::UpdateSettings::after', array($this, 'onAfterUpdateSettings')); |
29: | } |
30: | |
31: | |
32: | |
33: | |
34: | public static function getInstance() |
35: | { |
36: | return parent::getInstance(); |
37: | } |
38: | |
39: | |
40: | |
41: | |
42: | public static function Decorator() |
43: | { |
44: | return parent::Decorator(); |
45: | } |
46: | |
47: | |
48: | |
49: | |
50: | public function getModuleSettings() |
51: | { |
52: | return $this->oModuleSettings; |
53: | } |
54: | |
55: | public function GetSettings() |
56: | { |
57: | \Aurora\System\Api::checkUserRoleIsAtLeast(\Aurora\System\Enums\UserRole::Anonymous); |
58: | |
59: | $aSettings = array( |
60: | 'AllowAppRegisterMailto' => $this->oModuleSettings->AllowAppRegisterMailto, |
61: | 'AllowChangeInputDirection' => $this->oModuleSettings->AllowChangeInputDirection, |
62: | 'FoldersExpandedByDefault' => $this->oModuleSettings->FoldersExpandedByDefault, |
63: | 'AllowSpamFolder' => $this->oModuleSettings->AllowSpamFolder, |
64: | 'AllowAddNewFolderOnMainScreen' => $this->oModuleSettings->AllowAddNewFolderOnMainScreen, |
65: | 'ComposeToolbarOrder' => $this->oModuleSettings->ComposeToolbarOrder, |
66: | 'DefaultFontName' => $this->oModuleSettings->DefaultFontName, |
67: | 'DefaultFontSize' => $this->oModuleSettings->DefaultFontSize, |
68: | 'AlwaysTryUseImageWhilePasting' => $this->oModuleSettings->AlwaysTryUseImageWhilePasting, |
69: | 'AllowHorizontalLineButton' => $this->oModuleSettings->AllowHorizontalLineButton, |
70: | 'AllowComposePlainText' => $this->oModuleSettings->AllowComposePlainText, |
71: | 'AllowEditHtmlSource' => $this->oModuleSettings->AllowEditHtmlSource, |
72: | 'JoinReplyPrefixes' => $this->oModuleSettings->JoinReplyPrefixes, |
73: | 'MailsPerPage' => $this->oModuleSettings->MailsPerPage, |
74: | 'AllowChangeStarredMessagesSource' => $this->oModuleSettings->AllowChangeStarredMessagesSource, |
75: | 'MaxMessagesBodiesSizeToPrefetch' => $this->oModuleSettings->MaxMessagesBodiesSizeToPrefetch, |
76: | 'MessageBodyTruncationThreshold' => $this->oModuleSettings->MessageBodyTruncationThreshold, |
77: | 'ShowEmailAsTabName' => $this->oModuleSettings->ShowEmailAsTabName, |
78: | 'AllowOtherModulesToReplaceTabsbarHeader' => $this->oModuleSettings->AllowOtherModulesToReplaceTabsbarHeader, |
79: | 'AllowShowMessagesCountInFolderList' => $this->oModuleSettings->AllowShowMessagesCountInFolderList, |
80: | 'AllowSearchMessagesBySubject' => $this->oModuleSettings->AllowSearchMessagesBySubject, |
81: | 'PrefixesToRemoveBeforeSearchMessagesBySubject' => $this->oModuleSettings->PrefixesToRemoveBeforeSearchMessagesBySubject, |
82: | 'AllowHorizontalLayout' => $this->oModuleSettings->AllowHorizontalLayout, |
83: | 'HorizontalLayoutByDefault' => $this->oModuleSettings->HorizontalLayoutByDefault, |
84: | 'DisableRtlRendering' => $this->oModuleSettings->DisableRtlRendering, |
85: | 'AllowQuickReply' => $this->oModuleSettings->AllowQuickReply, |
86: | 'AllowQuickSendOnCompose' => $this->oModuleSettings->AllowQuickSendOnCompose, |
87: | 'AllowUserGroupsInComposeAutocomplete' => $this->oModuleSettings->AllowUserGroupsInComposeAutocomplete, |
88: | 'MarkMessageSeenWhenViewing' => $this->oModuleSettings->MarkMessageSeenWhenViewing, |
89: | 'MarkMessageSeenWhenAnswerForward' => $this->oModuleSettings->MarkMessageSeenWhenAnswerForward, |
90: | 'UserLoginPartInAccountDropdown' => $this->oModuleSettings->UserLoginPartInAccountDropdown, |
91: | 'UseMeRecipientForMessages' => $this->oModuleSettings->UseMeRecipientForMessages, |
92: | 'HorizontalLayout' => $this->oModuleSettings->HorizontalLayoutByDefault, |
93: | 'ShowMessagesCountInFolderList' => $this->oModuleSettings->AllowShowMessagesCountInFolderList, |
94: | 'TextEditorImageResizerOptions' => $this->oModuleSettings->TextEditorImageResizerOptions, |
95: | ); |
96: | |
97: | $oUser = \Aurora\System\Api::getAuthenticatedUser(); |
98: | if ($oUser && $oUser->isNormalOrTenant()) { |
99: | if (null !== $oUser->getExtendedProp(self::GetName() . '::AllowChangeInputDirection')) { |
100: | $aSettings['AllowChangeInputDirection'] = $oUser->getExtendedProp(self::GetName() . '::AllowChangeInputDirection'); |
101: | } |
102: | if (null !== $oUser->getExtendedProp(self::GetName() . '::MailsPerPage')) { |
103: | $aSettings['MailsPerPage'] = $oUser->getExtendedProp(self::GetName() . '::MailsPerPage'); |
104: | } |
105: | if (null !== $oUser->getExtendedProp(self::GetName() . '::StarredMessagesSource')) { |
106: | $aSettings['StarredMessagesSource'] = $oUser->getExtendedProp(self::GetName() . '::StarredMessagesSource'); |
107: | } |
108: | if (null !== $oUser->getExtendedProp(self::GetName() . '::ShowMessagesCountInFolderList')) { |
109: | $aSettings['ShowMessagesCountInFolderList'] = $oUser->getExtendedProp(self::GetName() . '::ShowMessagesCountInFolderList'); |
110: | } |
111: | if ($this->oModuleSettings->AllowHorizontalLayout && null !== $oUser->getExtendedProp(self::GetName() . '::HorizontalLayout')) { |
112: | $aSettings['HorizontalLayout'] = $oUser->getExtendedProp(self::GetName() . '::HorizontalLayout'); |
113: | } |
114: | } |
115: | |
116: | return $aSettings; |
117: | } |
118: | |
119: | public function onAfterUpdateSettings($Args, &$Result) |
120: | { |
121: | \Aurora\System\Api::checkUserRoleIsAtLeast(\Aurora\System\Enums\UserRole::NormalUser); |
122: | |
123: | $oUser = \Aurora\System\Api::getAuthenticatedUser(); |
124: | if ($oUser) { |
125: | if ($oUser->isNormalOrTenant()) { |
126: | $oCoreDecorator = \Aurora\Modules\Core\Module::Decorator(); |
127: | if (isset($Args['MailsPerPage'])) { |
128: | $oUser->setExtendedProp(self::GetName() . '::MailsPerPage', $Args['MailsPerPage']); |
129: | } |
130: | if (isset($Args['StarredMessagesSource'])) { |
131: | $oUser->setExtendedProp(self::GetName() . '::StarredMessagesSource', $Args['StarredMessagesSource']); |
132: | } |
133: | if (isset($Args['AllowChangeInputDirection'])) { |
134: | $oUser->setExtendedProp(self::GetName() . '::AllowChangeInputDirection', $Args['AllowChangeInputDirection']); |
135: | } |
136: | if (isset($Args['ShowMessagesCountInFolderList'])) { |
137: | $oUser->setExtendedProp(self::GetName() . '::ShowMessagesCountInFolderList', $Args['ShowMessagesCountInFolderList']); |
138: | } |
139: | if ($this->oModuleSettings->AllowHorizontalLayout && isset($Args['HorizontalLayout'])) { |
140: | $oUser->setExtendedProp(self::GetName() . '::HorizontalLayout', $Args['HorizontalLayout']); |
141: | } |
142: | return $oCoreDecorator->UpdateUserObject($oUser); |
143: | } |
144: | if ($oUser->Role === \Aurora\System\Enums\UserRole::SuperAdmin) { |
145: | if (isset($Args['MailsPerPage'])) { |
146: | $this->setConfig('MailsPerPage', $Args['MailsPerPage']); |
147: | } |
148: | if (isset($Args['AllowChangeInputDirection'])) { |
149: | $this->setConfig('AllowChangeInputDirection', $Args['AllowChangeInputDirection']); |
150: | } |
151: | if ($this->oModuleSettings->AllowHorizontalLayout && isset($Args['HorizontalLayoutByDefault'])) { |
152: | $this->setConfig('HorizontalLayoutByDefault', $Args['HorizontalLayoutByDefault']); |
153: | } |
154: | return $this->saveModuleConfig(); |
155: | } |
156: | } |
157: | } |
158: | } |
159: | |