From 7d484a70f73bd679e0dcf18d23d8124d8edf8f63 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Tue, 2 Feb 2016 19:52:07 -0500 Subject: Add helper function to Setting class Added a static helper function to replacing (or inserting) an option value in the database, longhand. --- app/class/setting.class.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'app/class/setting.class.php') diff --git a/app/class/setting.class.php b/app/class/setting.class.php index ea5fac3..b48f241 100644 --- a/app/class/setting.class.php +++ b/app/class/setting.class.php @@ -23,6 +23,23 @@ class Setting extends Framework return $res[0]['value']; } + + /* + * Helper function for setting setting values on the database + */ + static function setValue($key, $value) + { + $db = parent::getDbConnection(); + $escdKey = $db->esc($key); + $escdValue = $db->esc($value); + + if (self::getValue($key) === false) + $query = "INSERT INTO setting (`key`, value) VALUES('" . $escdKey . "', '" . $escdValue . "')"; + else + $query = "UPDATE setting SET value = '" . $escdValue . "' WHERE `key` = '" . $escdKey . "'"; + + $db->query($query); + } } ?> -- cgit v1.2.3 From 4496b56e3392ba8183c0e1764557d51a8633e7ca Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Tue, 2 Feb 2016 20:31:29 -0500 Subject: Add admin setting 'allowPublicSignup' This setting will be used to decide if the app should allow unauthenticated users to create their own user accounts or if an admin must create them. --- app/class/setting.class.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'app/class/setting.class.php') diff --git a/app/class/setting.class.php b/app/class/setting.class.php index b48f241..e3ef7f1 100644 --- a/app/class/setting.class.php +++ b/app/class/setting.class.php @@ -40,6 +40,19 @@ class Setting extends Framework $db->query($query); } + + /* + * Should the app allow the public to signup their own accounts with Scrott? + */ + static function allowPublicSignup($value = null) + { + $opt = "allowPublicSignup"; + + if ($value != null) + self::setValue($opt, $value); + + return self::getValue($opt); + } } ?> -- cgit v1.2.3