summaryrefslogtreecommitdiffstats
path: root/app/class/user.class.php
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--app/class/user.class.php75
1 files changed, 71 insertions, 4 deletions
diff --git a/app/class/user.class.php b/app/class/user.class.php
index bd2e174..1130396 100644
--- a/app/class/user.class.php
+++ b/app/class/user.class.php
@@ -59,6 +59,22 @@ class User extends Object
}
/*
+ * Get all users -- ordered by admin DESC (admins first), then by name
+ */
+ function getAllUsers_orderByAdminByName()
+ {
+ $query = "SELECT o.guid FROM object o JOIN user u ON o.guid = u.guid WHERE o.type = 'user' ORDER BY u.admin DESC, o.name";
+ $result = $this->db->query($query);
+
+ $users = array();
+
+ foreach ($result as $u)
+ $users[] = new User($u['guid']);
+
+ return $users;
+ }
+
+ /*
* Check whether a given username is currently in use
*/
function usernameInUse($username)
@@ -99,10 +115,8 @@ class User extends Object
$this->perms = 0;
$this->name = $username;
$this->type = "user";
- $this->salt = $this->getBlob();
- $this->key = $this->getKey($password, $this->salt);
- $this->emailConf = 0;
- $this->emailConfKey = $this->getBlob();
+ $this->setPassword($password);
+ $this->setEmail("");
$this->saveObj();
@@ -120,6 +134,59 @@ class User extends Object
$key = $this->getKey($password, $this->salt);
return $key == $this->key;
}
+
+ /*
+ * Validate the email confirmation key for a user, returns true if correct, false otherwise. On success, $this->emailConf is also set to 1
+ */
+ function confirmEmailKey($key)
+ {
+ if ($key != $this->emailConfKey)
+ return false;
+
+ $this->emailConf = 1;
+ return true;
+ }
+
+ /*
+ * Overwrite the salt and key for this user, given a new plaintext password
+ */
+ function setPassword($password)
+ {
+ $this->salt = $this->getBlob();
+ $this->key = $this->getKey($password, $this->salt);
+ }
+
+ /*
+ * Overwrite the emailConfKey and flag, and change user's saved email address
+ */
+ function setEmail($email)
+ {
+ $this->email = $email;
+ $this->emailConf = 0;
+ $this->emailConfKey = $this->getBlob();
+ }
+
+ /*
+ * If a user has an alias set, display it instead of their username
+ */
+ function getDisplayName()
+ {
+ if ($this->alias != "")
+ return $this->alias;
+
+ return $this->name;
+ }
+
+ /*
+ * Get the glyphicon to use for this user
+ */
+ function getGlyphicon()
+ {
+ if ($this->admin)
+ return "glyphicon glyphicon-sunglasses";
+
+ return "glyphicon glyphicon-user";
+ }
}
?>