diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2011-10-01 15:31:08 -0700 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2011-10-01 15:31:08 -0700 |
commit | 2f1d74bdd48e3beaf6b52cad126de0271875e7ac (patch) | |
tree | 84cd9d89abac4f649674ecbd7acb99d0910fa4a4 /src/controllers | |
parent | 50bbd4a6a7294546c0fe3c455f4c728e5d0701d0 (diff) |
Fix the multiple-edit protection (I'd done this yesterday, but didn't commit)
Diffstat (limited to 'src/controllers')
-rw-r--r-- | src/controllers/Users.class.php | 60 |
1 files changed, 38 insertions, 22 deletions
diff --git a/src/controllers/Users.class.php b/src/controllers/Users.class.php index 1d947e1..a5d23fc 100644 --- a/src/controllers/Users.class.php +++ b/src/controllers/Users.class.php @@ -256,30 +256,46 @@ class Users extends Controller { if (isset($_POST[$key]) && is_array($_POST[$key])) { $old = $_POST['_old'][$key]; foreach ($_POST[$key] as $uid => $value) { - $have_old = !isset($old[$uid]); - @$change_it = $old[$uid]!==$value; - if (!$have_old || $change_it) { - $user = Auth::getObj($uid); - $oldvalue = $this->getConf($user,$key); - $oldvalue = $oldvalue['value']; - if ($oldvalue===false) $oldvalue = 'false'; - if ($oldvalue===true) $oldvalue = 'true'; - $changed = $value != $oldvalue; - if ($changed) { - echo "<pre>\n"; - echo "Error: Value changed elsewhere, and I don't have real handling for this yet.\n"; - echo "uid: $uid\n"; - echo "Name: ".$user->getName()."\n"; - echo "Key: $key\n"; - echo "oldvalue: "; var_dump($oldvalue); echo "\n"; - echo "newvalue: "; var_dump($value); echo "\n"; - echo "</pre>"; + $doit = true; + $forked = false; + $have_old = isset($old[$uid]); + if ($have_old) { + @$value_base = $old[$uid]; + $we_changed_it = $value_base != $value; + if ($we_changed_it) { + $user = Auth::getObj($uid); + $value_fork = $this->getConf($user,$key); + $value_fork = $value_fork['value']; + if ($value_fork===false) $value_fork = 'false'; + if ($value_fork===true) $value_fork = 'true'; - } else { - $this->setConf($uid, - $key, - $value); + $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) { + $this->setConf($uid, $key, $value); + } + if ($forked) { + echo "<pre>\n"; + echo "Error: Value changed elsewhere, and I don't have real handling for this yet.\n"; + echo "UID: $uid\n"; + echo "Name: ".$user->getName()."\n"; + echo "Key: $key\n"; + echo "Value: Original : "; var_dump($value_base); + echo "Value: Other edit: "; var_dump($value_fork); + echo "Value: This edit : "; var_dump($value); + echo "</pre>"; } } } |