Add notification to subadmins of the default group

This commit is contained in:
Neraste 2017-10-21 16:43:39 +02:00
parent d933e78896
commit 1246ea24e5
2 changed files with 19 additions and 2 deletions

View File

@ -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();

View File

@ -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;
}