Skip to content
Snippets Groups Projects
Commit 073766c6 authored by matthiasgrimm's avatar matthiasgrimm
Browse files

change only changed data

This patch changed the modifyUser function of the user manager
so that it only forward data fields to the backend that the
user really changed. Unchanged or empty fields will be skipped.

darcs-hash:20060202192030-7ef76-a221f16cafd24eef632b6554ada90aee8b500b8b.gz
parent 42250238
No related branches found
No related tags found
No related merge requests found
......@@ -340,28 +340,35 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin {
function _modifyUser(){
if (!$this->_auth->canDo('UserMod')) return false;
list($user,$pass,$name,$mail,$grps) = $this->_retrieveUser();
if (empty($user)) return false;
/* get currently valid user data */
$olduser = cleanID(preg_replace('/.*:/','',$_REQUEST['userid_old']));
$oldinfo = $this->_auth->getUserData($olduser);
/* get new user data subject to change */
list($newuser,$newpass,$newname,$newmail,$newgrps) = $this->_retrieveUser();
if (empty($newuser)) return false;
$changes = array();
$user_old = cleanID(preg_replace('/.*:/','',$_REQUEST['userid_old']));
if ($user != $user_old) {
// check $user doesn't already exist
if ($this->_auth->getUserData($user)) {
msg(sprintf($this->lang['update_exists'],$user),-1);
$this->_edit_user = $user = $user_old;
if ($newuser != $olduser) {
/* check if $newuser already exist */
if ($this->_auth->getUserData($newuser)) {
msg(sprintf($this->lang['update_exists'],$newuser),-1);
$this->_edit_user = $olduser;
} else {
$changes['user'] = $user;
$user = $user_old;
$changes['user'] = $newuser;
}
}
if (!empty($pass)) $changes['pass'] = $pass;
if (!empty($name)) $changes['name'] = $name;
if (!empty($mail)) $changes['mail'] = $mail;
if (!empty($grps)) $changes['grps'] = $grps;
if (!empty($newpass))
$changes['pass'] = $newpass;
if (!empty($newname) && $newname != $oldinfo['name'])
$changes['name'] = $newname;
if (!empty($newmail) && $newmail != $oldinfo['mail'])
$changes['mail'] = $newmail;
if (!empty($newgrps) && $newgrps != $oldinfo['grps'])
$changes['grps'] = $newgrps;
if ($this->_auth->modifyUser($user, $changes)) {
if ($this->_auth->modifyUser($olduser, $changes)) {
msg($this->lang['update_ok'],1);
} else {
msg($this->lang['update_fail'],-1);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment