diff options
author | Simon Rettberg | 2015-01-20 18:07:24 +0100 |
---|---|---|
committer | Simon Rettberg | 2015-01-20 18:07:24 +0100 |
commit | 1ff2bc4f3c694b7c76df8e57056c51ca39a23a34 (patch) | |
tree | 0eb19164af66b3d4e8bf639a710f323b631d23ee /inc/property.inc.php | |
parent | Rework config module class structure. Still some TODOs though.... (diff) | |
download | slx-admin-1ff2bc4f3c694b7c76df8e57056c51ca39a23a34.tar.gz slx-admin-1ff2bc4f3c694b7c76df8e57056c51ca39a23a34.tar.xz slx-admin-1ff2bc4f3c694b7c76df8e57056c51ca39a23a34.zip |
config module structure completed. Many other fixes. Hidden pw field support.
Diffstat (limited to 'inc/property.inc.php')
-rw-r--r-- | inc/property.inc.php | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/inc/property.inc.php b/inc/property.inc.php index c16c8ad7..7c3b7d37 100644 --- a/inc/property.inc.php +++ b/inc/property.inc.php @@ -41,12 +41,14 @@ class Property */ private static function set($key, $value, $minage = 0) { - Database::exec("INSERT INTO property (name, value, dateline) VALUES (:key, :value, :dateline)" - . " ON DUPLICATE KEY UPDATE value = VALUES(value), dateline = VALUES(dateline)", array( - 'key' => $key, - 'value' => $value, - 'dateline' => ($minage === 0 ? 0 : time() + ($minage * 60)) - )); + if (self::$cache === false || self::get($key) != $value) { // Simple compare, so it works for numbers accidentally casted to string somewhere + Database::exec("INSERT INTO property (name, value, dateline) VALUES (:key, :value, :dateline)" + . " ON DUPLICATE KEY UPDATE value = VALUES(value), dateline = VALUES(dateline)", array( + 'key' => $key, + 'value' => $value, + 'dateline' => ($minage === 0 ? 0 : time() + ($minage * 60)) + )); + } if (self::$cache !== false) { self::$cache[$key] = $value; } @@ -181,5 +183,15 @@ class Property { return self::get('password-type', 'password'); } + + public static function setNeedsCallback($value) + { + return self::set('need-callback', $value, 5); + } + + public static function getNeedsCallback() + { + return self::get('need-callback', 0); + } } |