1: | <?php |
2: | |
3: | |
4: | |
5: | |
6: | |
7: | |
8: | namespace Aurora\Modules\OverrideUserSettings; |
9: | |
10: | |
11: | |
12: | |
13: | |
14: | |
15: | |
16: | |
17: | |
18: | |
19: | class Module extends \Aurora\System\Module\AbstractModule |
20: | { |
21: | public function init() |
22: | { |
23: | $this->subscribeEvent('Core::CreateUser::after', array($this, 'onAfterCreateUser')); |
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 onAfterCreateUser(&$aArgs, &$mResult) |
51: | { |
52: | $iUserId = isset($mResult) && (int) $mResult > 0 ? (int) $mResult : 0; |
53: | if ($iUserId > 0) { |
54: | $oUser = \Aurora\Modules\Core\Module::Decorator()->GetUserWithoutRoleCheck($iUserId); |
55: | |
56: | if ($oUser) { |
57: | $aDomains = $this->oModuleSettings->Domains; |
58: | if (is_array($aDomains) && !empty($aDomains)) { |
59: | $sUserDomain = \MailSo\Base\Utils::GetDomainFromEmail($oUser->PublicId); |
60: | foreach ($aDomains as $aDomain) { |
61: | if ($aDomain["name"] === $sUserDomain && isset($aDomain["modules"]) && is_array($aDomain["modules"])) { |
62: | foreach ($aDomain["modules"] as $sModuleName) { |
63: | $oUser->disableModule($sModuleName); |
64: | \Aurora\Modules\Core\Module::Decorator()->UpdateUserObject($oUser); |
65: | } |
66: | } |
67: | } |
68: | } |
69: | } |
70: | } |
71: | } |
72: | } |
73: | |