summaryrefslogtreecommitdiffstats
path: root/app/class
diff options
context:
space:
mode:
authorMalf Furious <m@lfurio.us>2016-03-27 20:19:10 -0400
committerMalf Furious <m@lfurio.us>2016-03-27 20:19:10 -0400
commit4d69a5ecca13bbda5843c176e1bc4df514f079d7 (patch)
treef15454061b94928181c0a36cd48f0979b9dfc943 /app/class
parent7a2672164a73bb011a3d930df52c0643ee18457d (diff)
parente55a32c647cab450c2a6c6a3156c798dc0f70256 (diff)
downloadscrott-4d69a5ecca13bbda5843c176e1bc4df514f079d7.tar.gz
scrott-4d69a5ecca13bbda5843c176e1bc4df514f079d7.zip
Merge branch 'feature/setting-modal' into dev
Diffstat (limited to '')
-rw-r--r--app/class/form.class.php2
-rw-r--r--app/class/user.class.php75
2 files changed, 72 insertions, 5 deletions
diff --git a/app/class/form.class.php b/app/class/form.class.php
index 808de27..9f103ba 100644
--- a/app/class/form.class.php
+++ b/app/class/form.class.php
@@ -82,7 +82,7 @@ class Form
*/
function field_bool($name)
{
- $this->field_enum($name, array("true", "false"), "false");
+ $this->field_enum($name, array("1", "0"), "0");
}
/*
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";
+ }
}
?>