Good afternoon,
I have code in CodeIgniter that should work as follows:
In an email rule, I select in groups which users should receive the emails and, in permissions, if that group has a specific permission called "view_all".
In action, what should occur is as follows:
The if should go through all selected groups in this rule, and in each group, do the following analysis:
If the group has the permission, it will add in the variable $ users all the users that are marked to receive the email
If the group does not have the permission, it will go through all the users that are marked and, along with another variable that I pass through the form, it checks if I have selected a user and that it is marked. If it is checked, it adds that user to the $ users variable
if ((int)$idJob > 0) {
$usersMail = $ci->jobUsuario->getUsers($idJob);
if (!empty($usersMail) && count($usersMail) > 0) {
$idGrupo = 0;
$permission = false;
foreach ($usersMail as $user) {
if ($idGrupo == 0) {
$idGrupo = $ci->grupo->getById($user['ID_GRUPO']);
$grupoPermissions = $ci->grupo->getPermission($idGrupo['ID_GRUPO'], 'ver_todos');
if (!empty($grupoPermissions) && count($grupoPermissions) > 0) {
$permission = true;
}
}
}
if ($permission) {
//recupera usuarios da regra
$usuarios = $ci->regraEmailProcessoEtapaUsuario->getByRegraEmail($regra['ID_REGRA_EMAIL_PROCESSO_ETAPA'], $idProcessoEtapa);
} else {
//Envia somente para os usuários responsáveis
$usuarios = $usersMail;
}
//$permission = $ci->job->getPermission($idJob);
}
}
The code problem is that it is only reading the users that I select, not adding the users of the other groups that have the "view_todos".