1: <?php
2: /**
3: * This code is licensed under AGPLv3 license or Afterlogic Software License
4: * if commercial version of the product was purchased.
5: * For full statements of the licenses see LICENSE-AFTERLOGIC and LICENSE-AGPL3 files.
6: */
7:
8: namespace Aurora\Modules\OverrideUserSettings;
9:
10: /**
11: * @license https://www.gnu.org/licenses/agpl-3.0.html AGPL-3.0
12: * @license https://afterlogic.com/products/common-licensing Afterlogic Software License
13: * @copyright Copyright (c) 2023, Afterlogic Corp.
14: *
15: * @package Modules
16: */
17: class Module extends \Aurora\System\Module\AbstractModule
18: {
19: public function init()
20: {
21: $this->subscribeEvent('Core::CreateUser::after', array($this, 'onAfterCreateUser'));
22: }
23:
24: public function onAfterCreateUser(&$aArgs, &$mResult)
25: {
26: $iUserId = isset($mResult) && (int) $mResult > 0 ? (int) $mResult : 0;
27: if ($iUserId > 0) {
28: $oUser = \Aurora\Modules\Core\Module::Decorator()->GetUserUnchecked($iUserId);
29:
30: if ($oUser) {
31: $aDomains = $this->getConfig('Domains', []);
32: if (is_array($aDomains) && !empty($aDomains)) {
33: $sUserDomain = \MailSo\Base\Utils::GetDomainFromEmail($oUser->PublicId);
34: foreach ($aDomains as $aDomain) {
35: if ($aDomain["name"] === $sUserDomain && isset($aDomain["modules"]) && is_array($aDomain["modules"])) {
36: foreach ($aDomain["modules"] as $sModuleName) {
37: $oUser->disableModule($sModuleName);
38: \Aurora\Modules\Core\Module::Decorator()->UpdateUserObject($oUser);
39: }
40: }
41: }
42: }
43: }
44: }
45: }
46: }
47: