aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/users.php
diff options
context:
space:
mode:
Diffstat (limited to 'engine/lib/users.php')
-rw-r--r--engine/lib/users.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/engine/lib/users.php b/engine/lib/users.php
index 8af060575..02a7773dd 100644
--- a/engine/lib/users.php
+++ b/engine/lib/users.php
@@ -406,5 +406,42 @@
function get_user_objects($user_guid, $subtype = "", $limit = 10, $offset = 0) {
return get_entities('object',$subtype, $user_guid, "time_created desc", $limit, $offset);
}
+
+ /**
+ * Get user by username
+ *
+ * @param string $username The user's username
+ * @return ElggUser|false Depending on success
+ */
+ function get_user_by_username($username)
+ {
+ global $CONFIG;
+ $username = sanitise_string($username);
+ $row = get_data_row("SELECT * from {$CONFIG->dbprefix}users_entity where username='$username'");
+
+ if ($row)
+ return new ElggUser($row);
+
+ return false;
+ }
+
+ /**
+ * Get user by session code
+ *
+ * @param string $code The session code
+ * @return ElggUser|false Depending on success
+ */
+ function get_user_by_code($code)
+ {
+ global $CONFIG;
+
+ $code = sanitise_string($code);
+ $row = get_data_row("SELECT * from {$CONFIG->dbprefix}users_entity where code='$code'");
+
+ if ($row)
+ return new ElggUser($row);
+
+ return false;
+ }
?> \ No newline at end of file