Add notification to subadmins of the default group
This commit is contained in:
parent
d933e78896
commit
1246ea24e5
|
|
@ -106,11 +106,25 @@ class MailService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $userId
|
* @param string $userId
|
||||||
|
* @param string $userGroupId
|
||||||
* @param bool $userIsEnabled
|
* @param bool $userIsEnabled
|
||||||
*/
|
*/
|
||||||
public function notifyAdmins($userId, $userIsEnabled) {
|
public function notifyAdmins($userId, $userIsEnabled, $userGroupId) {
|
||||||
// Notify admin
|
// Notify admin
|
||||||
$admin_users = $this->groupManager->get('admin')->getUsers();
|
$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();
|
$to_arr = array();
|
||||||
foreach ( $admin_users as $au ) {
|
foreach ( $admin_users as $au ) {
|
||||||
$au_email = $au->getEMailAddress();
|
$au_email = $au->getEMailAddress();
|
||||||
|
|
|
||||||
|
|
@ -288,9 +288,12 @@ class RegistrationService {
|
||||||
try {
|
try {
|
||||||
$group = $this->groupManager->get($registered_user_group);
|
$group = $this->groupManager->get($registered_user_group);
|
||||||
$group->addUser($user);
|
$group->addUser($user);
|
||||||
|
$groupId = $group->gitGID();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
throw new RegistrationException($e->getMessage());
|
throw new RegistrationException($e->getMessage());
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$groupId = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
// disable user if this is requested by config
|
// 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;
|
return $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue