shifts filter own AngelTypes select only confirmed Angeltypes

This commit is contained in:
Xu 2021-05-11 21:43:40 +02:00 committed by Igor Scheller
parent 7f1f3a773a
commit 34b01fd37d
2 changed files with 13 additions and 3 deletions

View File

@ -240,13 +240,23 @@ function UserAngelType_by_User_and_AngelType($userId, $angeltype)
* @param int $userId
* @return array[]|null
*/
function UserAngelTypes_by_User($userId)
function UserAngelTypes_by_User($userId, $onlyConfirmed=false)
{
return DB::select('
SELECT *
FROM `UserAngelTypes`
'.($onlyConfirmed ? 'LEFT JOIN AngelTypes AS a ON a.id=UserAngelTypes.angeltype_id' : '').'
WHERE `user_id`=?
',
'
. (
$onlyConfirmed ? 'AND (
a.`restricted`=0
OR (
NOT `UserAngelTypes`.`confirm_user_id` IS NULL
OR `UserAngelTypes`.`id` IS NULL
)
)' : ''
),
[$userId]
);
}

View File

@ -195,7 +195,7 @@ function view_user_shifts()
$rooms = load_rooms();
$types = load_types();
$ownTypes = [];
foreach (UserAngelTypes_by_User($user->id) as $type) {
foreach (UserAngelTypes_by_User($user->id, FALSE) as $type) {
$ownTypes[] = (int)$type['angeltype_id'];
}