diff options
Diffstat (limited to 'src/controllers/Users.class.php')
-rw-r--r-- | src/controllers/Users.class.php | 59 |
1 files changed, 19 insertions, 40 deletions
diff --git a/src/controllers/Users.class.php b/src/controllers/Users.class.php index 54e4675..df00663 100644 --- a/src/controllers/Users.class.php +++ b/src/controllers/Users.class.php @@ -273,49 +273,28 @@ class Users extends Controller { */ private function update_users() { $attribs = $this->getIndexAttribs(); + $form = new Form(null, null); 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) { - $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) { - $value_fork = DB::get('users', $uid, $key); - $value_fork = $value_fork['value']; - if ($value_fork===false) $value_fork = 'false'; - if ($value_fork===true) $value_fork = 'true'; - - $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) { - DB::set('users', $uid, $key, $value); - } - if ($forked) { + @$value_base = $old[$uid]; + $set = DB::set('users', $uid, $key, $value, $value_base); + if (is_string($set)) { echo "<pre>\n"; - echo "Error: Value changed elsewhere, and I don't have real handling for this yet.\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 "Value: Original : "; + var_dump($value_base); + echo "Value: Other edit: "; + var_dump($value_fork); + echo "Value: This edit : "; + var_dump($value); echo "</pre>"; } } @@ -349,16 +328,16 @@ class Users extends Controller { } $this->showView('users/index', $vars); } - - function attrib($key, $name) { - return array('key'=>$key, 'name'=>$name); + + function attrib($key, $name, $type='string') { + return array('key'=>$key, 'name'=>$name, 'type'=>$type); } private function getIndexAttribs() { $attribs = array(); - $attribs[] = $this->attrib('auth_user', 'Active'); + $attribs[] = $this->attrib('auth_user', 'Active', 'bool'); if (Auth::getObj(Login::isLoggedIn())->isAdmin()) { - $attribs[] = $this->attrib('auth_admin', 'Admin'); - $attribs[] = $this->attrib('auth_delete', 'Delete'); + $attribs[] = $this->attrib('auth_admin', 'Admin', 'bool'); + $attribs[] = $this->attrib('auth_delete', 'Delete', 'bool'); } $attribs[] = $this->attrib('lastname','Last'); $attribs[] = $this->attrib('firstname','First'); |