From 7df5bfb84ac979e26cd23042bc8bbcf53d3f6ae6 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sun, 6 Mar 2016 14:22:50 -0500 Subject: Add function getDisplayName() to User class If a user has an alias set, it should be displayed throughout the app instead of the username. --- app/class/user.class.php | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'app/class/user.class.php') diff --git a/app/class/user.class.php b/app/class/user.class.php index bd2e174..4f1bbfe 100644 --- a/app/class/user.class.php +++ b/app/class/user.class.php @@ -120,6 +120,17 @@ class User extends Object $key = $this->getKey($password, $this->salt); return $key == $this->key; } + + /* + * If a user has an alias set, display it instead of their username + */ + function getDisplayName() + { + if ($this->alias != "") + return $this->alias; + + return $this->name; + } } ?> -- cgit v1.2.3 From 798cd5d80385705503c81be269c008e163fcbdba Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Thu, 10 Mar 2016 18:36:46 -0500 Subject: Add function User::setPassword() This user function will update the salt and key for a user object to change its password. --- app/class/user.class.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'app/class/user.class.php') diff --git a/app/class/user.class.php b/app/class/user.class.php index 4f1bbfe..75b769a 100644 --- a/app/class/user.class.php +++ b/app/class/user.class.php @@ -99,8 +99,7 @@ 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->setPassword($password); $this->emailConf = 0; $this->emailConfKey = $this->getBlob(); @@ -121,6 +120,15 @@ class User extends Object return $key == $this->key; } + /* + * 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); + } + /* * If a user has an alias set, display it instead of their username */ -- cgit v1.2.3 From 2b8f6ae7ca3e8b18f80f2753d990425aa7fac820 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Thu, 10 Mar 2016 19:09:50 -0500 Subject: Add function User::setEmail() This function handles internal vars while updating a user's email address. --- app/class/user.class.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'app/class/user.class.php') diff --git a/app/class/user.class.php b/app/class/user.class.php index 75b769a..6c8f46f 100644 --- a/app/class/user.class.php +++ b/app/class/user.class.php @@ -100,8 +100,7 @@ class User extends Object $this->name = $username; $this->type = "user"; $this->setPassword($password); - $this->emailConf = 0; - $this->emailConfKey = $this->getBlob(); + $this->setEmail(""); $this->saveObj(); @@ -129,6 +128,16 @@ class User extends Object $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 */ -- cgit v1.2.3 From f270bc774776dd5733ed4d76095281fa9210bac2 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Thu, 10 Mar 2016 19:18:19 -0500 Subject: Add function User::confirmEmailKey() Validates the users supposed email key. If correct, sets the users emailConf flag. --- app/class/user.class.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'app/class/user.class.php') diff --git a/app/class/user.class.php b/app/class/user.class.php index 6c8f46f..7d8519e 100644 --- a/app/class/user.class.php +++ b/app/class/user.class.php @@ -119,6 +119,18 @@ class User extends Object 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 */ -- cgit v1.2.3 From 2936f0d151fb52bd2649edc37abd2e1d559d1f0f Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sat, 12 Mar 2016 23:38:18 -0500 Subject: Move getUserGlyphicon function from common model into user class --- app/class/user.class.php | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'app/class/user.class.php') diff --git a/app/class/user.class.php b/app/class/user.class.php index 7d8519e..f1f7ff1 100644 --- a/app/class/user.class.php +++ b/app/class/user.class.php @@ -160,6 +160,17 @@ class User extends Object return $this->name; } + + /* + * Get the glyphicon to use for this user + */ + function getGlyphicon() + { + if ($this->admin) + return "glyphicon glyphicon-sunglasses"; + + return "glyphicon glyphicon-user"; + } } ?> -- cgit v1.2.3 From 333351cbd18d12520fb0eae44e9805cb3b10e038 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sun, 13 Mar 2016 23:56:40 -0400 Subject: Add function User::getAddUsers_orderByAdminByName() Added function to retrive all users in system presorted first by admin status (Admins first), then by username in alpha order --- app/class/user.class.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'app/class/user.class.php') diff --git a/app/class/user.class.php b/app/class/user.class.php index f1f7ff1..1130396 100644 --- a/app/class/user.class.php +++ b/app/class/user.class.php @@ -58,6 +58,22 @@ class User extends Object return $users; } + /* + * 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 */ -- cgit v1.2.3