From f194f795df3573ab0bbbc14aa924d4597a15013f Mon Sep 17 00:00:00 2001 From: radiskull Date: Wed, 4 Jan 2012 21:18:04 +0000 Subject: [PATCH] =?UTF-8?q?SQL-Debug=20eingebaut=20isUserInGroup=20=C3=BCb?= =?UTF-8?q?erarbeitet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ag/include/usergroup.inc.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ag/include/usergroup.inc.php b/ag/include/usergroup.inc.php index 458c1f3..601ceae 100644 --- a/ag/include/usergroup.inc.php +++ b/ag/include/usergroup.inc.php @@ -8,6 +8,7 @@ include_once (ROOT_PATH . '/include/defines.inc.php'); include_once(ROOT_PATH.'/include/parse.inc.php'); +include_once(ROOT_PATH.'/include/sqlwrapper.inc.php'); //Konstanten defineIfNotDefined('ADMIN', 1); @@ -28,13 +29,13 @@ function getUserGroups($user) { $test = 'SELECT ug.gruppen_name, ug.gruppen_id FROM user_gruppe_zuordnung as ugz INNER JOIN user_gruppe as ug ON ugz.gruppen_id=ug.gruppen_id WHERE ugz.user_id = \''.$user.'\''; - $qry = mysql_query($test); + $qry = db_query($test); } else if (validateString($user) != null) { $test = 'SELECT ug.gruppen_name, ug.gruppen_id FROM user_gruppe_zuordnung as ugz INNER JOIN user_gruppe as ug ON ugz.gruppen_id=ug.gruppen_id INNER JOIN user as u ON u.id=ugz.user_id WHERE u.nickname = \''.$user.'\''; - $qry = mysql_query($test); + $qry = db_query($test); } $i = 0; @@ -46,6 +47,9 @@ function getUserGroups($user) { } function isUserInGroup(array $usergrouparray, $group) { + if($group == null || count($usergrouparray) == 0 || $usergrouparray == null) { + return false; + } for($i = 0; $i < count($usergrouparray); $i++) { if($usergrouparray[$i]['gruppen_id'] == $group) { return true; @@ -59,7 +63,7 @@ function removeUserFromGroup($user, $group) { if ($group !== NULL && $group >= 0) { $qry = 'DELETE FROM user_gruppe_zuordnung WHERE user_id in (SELECT id FROM user WHERE nickname = \''.$user. '\') AND gruppen_id = '.$group.';'; - mysql_query($qry); + db_query($qry); return true; } } @@ -71,7 +75,7 @@ function addUserToGroup($user, $group) { if ($group !== NULL && $group >= 0) { $qry = 'INSERT INTO user_gruppe_zuordnung(user_id, gruppen_id) VALUES((SELECT id FROM user WHERE nickname = \''.$user.'\'), '.$group.');'; - mysql_query($qry); + db_query($qry); return true; } }