diff options
Diffstat (limited to 'app/class')
-rw-r--r-- | app/class/globals.php | 26 | ||||
-rw-r--r-- | app/class/user.class.php | 13 |
2 files changed, 33 insertions, 6 deletions
diff --git a/app/class/globals.php b/app/class/globals.php index 8a6efd7..468ad6d 100644 --- a/app/class/globals.php +++ b/app/class/globals.php @@ -19,7 +19,7 @@ require_once "class/obj.class.php"; * These are utility functions and constants for the Scrott application. */ -define("__VERSION__", "v0.2"); +define("__VERSION__", "v0.3"); /* * These global variables are arrays of strings logged by Scrott business @@ -50,6 +50,12 @@ $_SCROTT['PAGE_OBJECT'] = NULL; $_SCROTT['PAGE_NAME'] = ""; /* + * The auto modal variable holds the name (DOM ID) of a modal to automatically + * open on page load. The `stdpage` footer will reference this. + */ +$_SCROTT['AUTO_MODAL'] = ""; + +/* * Get the application root path. This is an absolute path on the server. */ function ar() : string @@ -182,6 +188,24 @@ function getPageName() : string } /* + * Set the auto modal. + */ +function setAutoModal(string $autoModal) : void +{ + global $_SCROTT; + $_SCROTT['AUTO_MODAL'] = $autoModal; +} + +/* + * Get the auto modal. + */ +function getAutoModal() : string +{ + global $_SCROTT; + return $_SCROTT['AUTO_MODAL']; +} + +/* * Produce a string, but only once. This function is useful * when dealing with some variable collection of markup and * you want to affect only the first one with a modifier. diff --git a/app/class/user.class.php b/app/class/user.class.php index 231111d..7d67257 100644 --- a/app/class/user.class.php +++ b/app/class/user.class.php @@ -46,11 +46,12 @@ class user extends agent * the username is not in use. Therefore, this function can be * used to test the existence of a user with the given username. */ - public static function getGuidByUname(string $uname) : ?string + public static function getGuidByUname(string $uname, bool $caseInsens = false) : ?string { $uname = database::esc($uname); - $query = "SELECT guid FROM objects WHERE objtype = 'user' AND name = '" . $uname . "'"; + $query = "SELECT guid FROM objects WHERE objtype = 'user' AND " . + ($caseInsens ? "" : "BINARY ") . "name = '" . $uname . "'"; $res = database::query($query); if (count($res) == 0) @@ -64,9 +65,9 @@ class user extends agent * is not in use. This function can be used to test the existence * of a user with the given username. */ - public static function getByUname(string $uname) : ?user + public static function getByUname(string $uname, bool $caseInsens = false) : ?user { - if (($guid = self::getGuidByUname($uname))) + if (($guid = self::getGuidByUname($uname, $caseInsens))) return new user($guid); return NULL; @@ -190,7 +191,9 @@ class user extends agent */ public static function initNew(string $uname, string $passwd) : ?user { - if (self::getByUname($uname)) + /* search is case-insensitive, to make sure no duplicates exist + * which differ _only_ by case */ + if (self::getByUname($uname, true)) return NULL; $user = new user(); |