diff options
author | ben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-02-15 18:21:35 +0000 |
---|---|---|
committer | ben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-02-15 18:21:35 +0000 |
commit | fac61fa985a0227a1746a671c0e54adedc96ec48 (patch) | |
tree | 2446259aa9aaa160a2b444c9e0f4583631d9cc84 /engine/lib/users.php | |
parent | a210406591f6a97d9f3d90df0dd375fcca3571f4 (diff) | |
download | elgg-fac61fa985a0227a1746a671c0e54adedc96ec48.tar.gz elgg-fac61fa985a0227a1746a671c0e54adedc96ec48.tar.bz2 |
All kinds of object and database stuff
git-svn-id: https://code.elgg.org/elgg/trunk@44 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/users.php')
-rw-r--r-- | engine/lib/users.php | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/engine/lib/users.php b/engine/lib/users.php new file mode 100644 index 000000000..9d5e40288 --- /dev/null +++ b/engine/lib/users.php @@ -0,0 +1,97 @@ +<?php
+
+ /**
+ * Elgg users
+ * User and session management
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.org/
+ */
+
+ // This is here as a dummy for now
+ function get_users($param, $param2) {
+ return false;
+ }
+
+ /**
+ * Session management
+ */
+
+ /**
+ * Returns whether or not the user is currently logged in
+ *
+ * @uses $_SESSION
+ * @return true|false
+ */
+ function isloggedin() {
+
+ if ($_SESSION['id'] > 0)
+ return true;
+ return false;
+
+ }
+
+ /**
+ * Initialises the system session and potentially logs the user in
+ *
+ * This function looks for:
+ *
+ * 1. $_SESSION['id'] - if not present, we're logged out, and this is set to -1
+ * 2. The cookie 'elggperm' - if present, checks it for an authentication token, validates it, and potentially logs the user in
+ *
+ * @uses $_SESSION
+ * @param unknown_type $event
+ * @param unknown_type $object_type
+ * @param unknown_type $object
+ */
+ function session_init($event, $object_type, $object) {
+ session_name('Elgg');
+ session_start();
+
+ if (empty($_SESSION['id'])) {
+ if (isset($_COOKIE['elggperm'])) {
+
+ $code = $_COOKIE['elggperm'];
+ $code = md5($code);
+ if ($users = get_users(array(
+ "code" =>$code
+ ), "id, username, name, password")) {
+ foreach($users as $user) {
+ $_SESSION['id'] = $user->id;
+ $_SESSION['username'] = $user->username;
+ $_SESSION['name'] = $user->name;
+ $_SESSION['code'] = $_COOKIE['elggperm'];
+ // set_login_fields($user->id);
+ }
+ } else {
+ $_SESSION['id'] = -1;
+ }
+ } else {
+ $_SESSION['id'] = -1;
+ }
+ } else {
+ if (!empty($_SESSION['code'])) {
+ $code = md5($_SESSION['code']);
+ if ($uid = get_users(array(
+ "code" =>$code
+ ), "id")) {
+ $id = $uid->id;
+ } else {
+
+ }
+ } else {
+ $_SESSION['id'] = -1;
+ }
+ }
+ if ($_SESSION['id'] > 0) {
+ // set_last_action($_SESSION['id']);
+ }
+ }
+
+ register_event_handler("init","system","session_init");
+
+?>
\ No newline at end of file |