private static function getNotificationUsers($userIds)
{
$notifyUsers = [];
//get roles
$roleList = new User\Role\Listing();
$roleList->setCondition('id in (?)', [implode(',', $userIds)]);
foreach ($roleList->load() as $role) {
$userList = new User\Listing();
$userList->setCondition('FIND_IN_SET(?, roles) > 0', [$role->getId()]);
foreach ($userList->load() as $user) {
if ($user->getEmail()) {
$notifyUsers[] = $user;
}
}
}
unset($roleList, $user, $role);
//get users
$roleList = new User\Listing();
$roleList->setCondition('id in (?)', [implode(',', $userIds)]);
foreach ($roleList->load() as $user) {
/**
* @var User $user
*/
if ($user->getEmail()) {
$notifyUsers[] = $user;
}
}
return $notifyUsers;
}