From 7826324f85911aaef19fb780258c45a9df65a5d4 Mon Sep 17 00:00:00 2001 From: Marco De Donno Date: Sun, 17 May 2020 23:14:03 +0200 Subject: [PATCH] Add the 'only_user' as parameter for the getUserList() function --- backend/TE/AppDB.php | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/backend/TE/AppDB.php b/backend/TE/AppDB.php index a86eb87..10be2b7 100644 --- a/backend/TE/AppDB.php +++ b/backend/TE/AppDB.php @@ -1940,31 +1940,32 @@ class AppDB_TE extends AppDB /* * Admin view */ - public function getUserList() + public function getUserList( $only_users = 0 ) { if( ! $_SESSION[ 'user' ][ 'isadmin' ] ) { throw new Exception( "Access denied" ); } else { - $res = $this->query( " - SELECT - (CASE WHEN pgroup.tutors THEN 'Tutor' ELSE 'User' END) as tutors, - person.id, - person.username, - person.name - FROM - public.pgroup, - public.person, - public.membership - WHERE - person.id = membership.person AND - membership.pgroup = pgroup.id AND - person.active = true - - ORDER BY person.name ASC; - " - ); - + $sql = " + SELECT + (CASE WHEN pgroup.tutors THEN 'Tutor' ELSE 'User' END) as tutors, + person.id, + person.username, + person.name + FROM + public.pgroup, + public.person, + public.membership + WHERE + person.id = membership.person AND + membership.pgroup = pgroup.id AND + person.active = true + "; + if( $only_users == 1 ) + $sql .= " AND tutors = false"; + + $sql .= " ORDER BY person.name ASC;"; + $res = $this->query( $sql ); return $res; } } -- GitLab