Skip to content
Snippets Groups Projects
Verified Commit 95944f37 authored by Damien's avatar Damien
Browse files

FIX #177 Get only available users

parent a6e63a4f
No related branches found
No related tags found
No related merge requests found
...@@ -48,7 +48,7 @@ class UserController ...@@ -48,7 +48,7 @@ class UserController
]); ]);
} else { } else {
$entities = EntityModel::getAllEntitiesByUserId(['userId' => $GLOBALS['userId']]); $entities = EntityModel::getAllEntitiesByUserId(['userId' => $GLOBALS['userId']]);
$users = UserModel::getByEntities([ $users = UserEntityModel::getUsersByEntities([
'select' => ['DISTINCT users.id', 'users.user_id', 'firstname', 'lastname', 'status', 'enabled', 'mail'], 'select' => ['DISTINCT users.id', 'users.user_id', 'firstname', 'lastname', 'status', 'enabled', 'mail'],
'entities' => $entities 'entities' => $entities
]); ]);
...@@ -850,7 +850,7 @@ class UserController ...@@ -850,7 +850,7 @@ class UserController
} }
if ($GLOBALS['userId'] != 'superadmin') { if ($GLOBALS['userId'] != 'superadmin') {
$entities = EntityModel::getAllEntitiesByUserId(['userId' => $GLOBALS['userId']]); $entities = EntityModel::getAllEntitiesByUserId(['userId' => $GLOBALS['userId']]);
$users = UserModel::getByEntities([ $users = UserEntityModel::getUsersByEntities([
'select' => ['users.id'], 'select' => ['users.id'],
'entities' => $entities 'entities' => $entities
]); ]);
......
...@@ -29,8 +29,8 @@ class UserEntityModelAbstract ...@@ -29,8 +29,8 @@ class UserEntityModelAbstract
'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'], 'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'],
'table' => ['users', 'users_entities'], 'table' => ['users', 'users_entities'],
'left_join' => ['users.user_id = users_entities.user_id'], 'left_join' => ['users.user_id = users_entities.user_id'],
'where' => ['users_entities IS NULL', 'users.user_id not in (?)'], 'where' => ['users_entities IS NULL', 'users.user_id not in (?)', 'status != ?'],
'data' => [$excludedUsers] 'data' => [$excludedUsers, 'DEL']
]); ]);
return $aUsersEntities; return $aUsersEntities;
...@@ -143,4 +143,19 @@ class UserEntityModelAbstract ...@@ -143,4 +143,19 @@ class UserEntityModelAbstract
return true; return true;
} }
public static function getUsersByEntities(array $aArgs)
{
ValidatorModel::notEmpty($aArgs, ['entities']);
ValidatorModel::arrayType($aArgs, ['entities', 'select']);
$aUsers = DatabaseModel::select([
'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'],
'table' => ['users, users_entities'],
'where' => ['users.user_id = users_entities.user_id', 'users_entities.entity_id in (?)', 'status != ?'],
'data' => [$aArgs['entities'], 'DEL']
]);
return $aUsers;
}
} }
...@@ -144,21 +144,6 @@ class UserModelAbstract ...@@ -144,21 +144,6 @@ class UserModelAbstract
return $aUser[0]; return $aUser[0];
} }
public static function getByEntities(array $aArgs = [])
{
ValidatorModel::notEmpty($aArgs, ['entities']);
ValidatorModel::arrayType($aArgs, ['entities']);
$aUsers = DatabaseModel::select([
'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'],
'table' => ['users, users_entities'],
'where' => ['users.user_id = users_entities.user_id', 'users_entities.entity_id in (?)'],
'data' => [$aArgs['entities']]
]);
return $aUsers;
}
public static function getByEmail(array $aArgs = []) public static function getByEmail(array $aArgs = [])
{ {
ValidatorModel::notEmpty($aArgs, ['mail']); ValidatorModel::notEmpty($aArgs, ['mail']);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment