summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2011-10-09 15:46:38 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2011-10-09 15:46:38 -0400
commit4d2de268b75f08e6fa774063a277c2c50f603ef7 (patch)
tree8384dd7fce75b9ba7e31181c93da16923cb59235 /src/lib
parent93b1163cba7edf1a0a7e7ae787e06434de119dad (diff)
parent2e769649abf4f9b3712287e24eb42c5a93a8035e (diff)
Merge branch 'anon-userlist'
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/DB.class.php43
1 files changed, 38 insertions, 5 deletions
diff --git a/src/lib/DB.class.php b/src/lib/DB.class.php
index 9f14161..5954726 100644
--- a/src/lib/DB.class.php
+++ b/src/lib/DB.class.php
@@ -4,6 +4,39 @@ require_once('Auth.class.php');
require_once('Login.class.php');
class DB {
+ public static function set($table, $unit, $key, $value, $orig_value) {
+ $value_base = $orig_value;
+
+ $doit = true;
+ $forked = false;
+ $have_old = ($value_base!==null);
+ if ($have_old) {
+ $we_changed_it = $value_base != $value;
+ if ($we_changed_it) {
+ $value_fork = $this->getConfString($key);
+ $someone_else_changed_it =
+ $value_fork != $value_base;
+ if ($someone_else_changed_it) {
+ if ($value == $value_fork) {
+ // we might as well not have
+ $we_changed_it = false;
+ } else {
+ $forked = true;
+ }
+ }
+ }
+ if (!$we_changed_it) {
+ $doit = false;// nothing to do
+ }
+ }
+ if ($doit) {
+ return $this->setConf($key, $value);
+ }
+ if ($forked) {
+ return $value_fork;
+ }
+ }
+
public static function get($table, $unit, $key) {
switch ($table) {
case 'conf':
@@ -17,7 +50,7 @@ class DB {
return false;
}
}
- public static function set($table, $unit, $key, $value) {
+ public static function raw_set($table, $unit, $key, $value) {
switch ($table) {
case 'conf':
case 'plugins':
@@ -49,15 +82,15 @@ class DB {
break;
case 'auth_user':
$editable = $editable && $logged_in_user->isAdmin();
- $value = $user->isUser();
+ $value = $user->isUser()?'true':'false';
break;
case 'auth_admin':
$editable = $editable && $logged_in_user->isAdmin();
- $value = $user->isAdmin();
+ $value = $user->isAdmin()?'true':'false';
break;
case 'auth_delete':
$editable = $editable && $logged_in_user->isAdmin();
- $value = false;
+ $value = 'false';
break;
default:
$value = $user->getConf($key);
@@ -128,4 +161,4 @@ class DB {
return $db->setPluginConf($plugin, $key, $value);
}
}
-} \ No newline at end of file
+}