summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2011-09-30 18:21:01 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2011-09-30 18:21:01 -0400
commit4152eefe0f93816cffa3d38c33638593d9e07f39 (patch)
tree3afdf8eac8db3518707b78d68cfb8b1d93842787
parentbe0d789259019c406f923ad81b2307c78e0deedc (diff)
Quick and ugly hack to safely allow multiple users to edit data at once
-rw-r--r--src/controllers/Users.class.php27
-rw-r--r--src/views/pages/users/index.html.php3
2 files changed, 29 insertions, 1 deletions
diff --git a/src/controllers/Users.class.php b/src/controllers/Users.class.php
index 57a585c..c30461f 100644
--- a/src/controllers/Users.class.php
+++ b/src/controllers/Users.class.php
@@ -258,8 +258,33 @@ class Users extends Controller {
foreach ($attribs as $attrib) {
$key = $attrib['key'];
if (isset($_POST[$key]) && is_array($_POST[$key])) {
+ $old = $_POST['_old'][$key];
foreach ($_POST[$key] as $uid => $value) {
- $this->setConf($uid, $key, $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>";
+
+ } else {
+ $this->setConf($uid,
+ $key,
+ $value);
+ }
+ }
}
}
}
diff --git a/src/views/pages/users/index.html.php b/src/views/pages/users/index.html.php
index c56d0b3..7f51592 100644
--- a/src/views/pages/users/index.html.php
+++ b/src/views/pages/users/index.html.php
@@ -52,6 +52,9 @@ foreach ($users as $user) {
$arr['type'] = 'text';
}
+ $t->tag('input', array('name'=>'_old['.$arr['name'].']',
+ 'value'=>$arr['value'],
+ 'type'=>'hidden'));
$t->tag('input', $arr);
$t->closeTag('td');
}