diff --git a/service/mailservice.php b/service/mailservice.php index 39172a1..02cd682 100644 --- a/service/mailservice.php +++ b/service/mailservice.php @@ -106,11 +106,25 @@ class MailService { /** * @param string $userId + * @param string $userGroupId * @param bool $userIsEnabled */ - public function notifyAdmins($userId, $userIsEnabled) { + public function notifyAdmins($userId, $userIsEnabled, $userGroupId) { // Notify admin $admin_users = $this->groupManager->get('admin')->getUsers(); + + // if the user is disabled and belongs to a group + // add subadmins of this group to notification list + if (!$userIsEnabled and $userGroupId) { + $group = $this->groupManager->get($userGroupId); + $subadmin_users = $group->getSubAdmin()->getGroupsSubAdmins($group); + foreach ($subadmin_users as $user) { + if (!in_array($user, $admin_users)) { + $admin_users[] = $user; + } + } + } + $to_arr = array(); foreach ( $admin_users as $au ) { $au_email = $au->getEMailAddress(); diff --git a/service/registrationservice.php b/service/registrationservice.php index 0214550..ef7c0f9 100644 --- a/service/registrationservice.php +++ b/service/registrationservice.php @@ -288,9 +288,12 @@ class RegistrationService { try { $group = $this->groupManager->get($registered_user_group); $group->addUser($user); + $groupId = $group->gitGID(); } catch (\Exception $e) { throw new RegistrationException($e->getMessage()); } + } else { + $groupId = ""; } // disable user if this is requested by config @@ -307,7 +310,7 @@ class RegistrationService { } } - $this->mailService->notifyAdmins($userId, $user->isEnabled()); + $this->mailService->notifyAdmins($userId, $user->isEnabled(), $groupId); return $user; }