diff --git a/html/class/user.inc b/html/class/user.inc new file mode 100644 index 0000000000..ebbc2c2111 --- /dev/null +++ b/html/class/user.inc @@ -0,0 +1,45 @@ + $value) + $this->$var = $$var; + } +} + +function getUser($userID) { + $sql = "SELECT * FROM user WHERE id = ".$userID; + return getNextUser(sql_query($sql)); +} + +function getUserByAuth($auth) { + $sql = "SELECT * FROM user WHERE authenticator = '$auth'"; + return getNextUser(sql_query($sql)); +} + +function getNextUser($result) { + $user = sql_fetch_array($result); + if (!$user) + return false; + foreach ($user as $var => $value) + $user[$var] = stripslashes($value); + + // Check whether or not this user has a profile. + $sql = "SELECT * FROM profile WHERE userid = " . $user['id']; + $result2 = sql_query($sql); + + if (sql_num_rows($result2) > 0) + $user['has_profile'] = 1; + + return new User($user['id'], $user['create_time'], $user['name'], $user['posts'], $user['has_profile']); +} + + +?> \ No newline at end of file