diff --git a/html/includes/authenticate.inc.php b/html/includes/authenticate.inc.php index 7b01b2c3d..f1d169e33 100644 --- a/html/includes/authenticate.inc.php +++ b/html/includes/authenticate.inc.php @@ -45,11 +45,7 @@ if (isset($_SESSION['username'])) { if (authenticate($_SESSION['username'],$_SESSION['password'])) { - #FIXME below should also come from auth module, get_userlevel, etc - $sql = "SELECT * FROM `users` WHERE `username`='".$_SESSION['username']."'"; - $query = mysql_query($sql); - $row = @mysql_fetch_array($query); - $_SESSION['userlevel'] = $row['level']; + $_SESSION['userlevel'] = get_userlevel($_SESSION['username']) $_SESSION['user_id'] = $row['user_id']; if(!$_SESSION['authenticated']) { diff --git a/html/includes/authentication/http-auth.inc.php b/html/includes/authentication/http-auth.inc.php index ebed1eb60..553a50553 100644 --- a/html/includes/authentication/http-auth.inc.php +++ b/html/includes/authentication/http-auth.inc.php @@ -51,4 +51,11 @@ function user_exists($username) return mysql_result(mysql_query("SELECT * FROM users WHERE username = '".mres($username)."'"),0); } +function get_userlevel($username) +{ + $sql = "SELECT level FROM `users` WHERE `username`='".mres($username)."'"; + $row = mysql_fetch_array(mysql_query($sql); + return $row['level']; +} + ?> \ No newline at end of file diff --git a/html/includes/authentication/ldap.inc.php b/html/includes/authentication/ldap.inc.php index 631143140..8d4bd521a 100644 --- a/html/includes/authentication/ldap.inc.php +++ b/html/includes/authentication/ldap.inc.php @@ -60,5 +60,12 @@ function user_exists($username) return 0; # FIXME to be implemented } - +function get_userlevel($username) +{ + # FIXME should come from LDAP + $sql = "SELECT level FROM `users` WHERE `username`='".mres($username)."'"; + $row = mysql_fetch_array(mysql_query($sql); + return $row['level']; +} + ?> \ No newline at end of file diff --git a/html/includes/authentication/mysql.inc.php b/html/includes/authentication/mysql.inc.php index 5d1e58914..627baf10c 100644 --- a/html/includes/authentication/mysql.inc.php +++ b/html/includes/authentication/mysql.inc.php @@ -42,4 +42,11 @@ function user_exists($username) return mysql_result(mysql_query("SELECT * FROM users WHERE username = '".mres($username)."'"),0); } +function get_userlevel($username) +{ + $sql = "SELECT level FROM `users` WHERE `username`='".mres($username)."'"; + $row = mysql_fetch_array(mysql_query($sql); + return $row['level']; +} + ?> \ No newline at end of file