From 26fb387be54a4d50158a4fd1e16d5b96601c82f8 Mon Sep 17 00:00:00 2001 From: chris Date: Wed, 8 Feb 2006 03:06:57 +0100 Subject: usermanager update for enhanced canDo darcs-hash:20060208020657-9b6ab-4499d17f3e1b3b67c906b2f27a661cc9449a8d72.gz --- lib/plugins/usermanager/admin.php | 52 +++++++++++++++++++++++++-------------- lib/plugins/usermanager/style.css | 6 +++++ 2 files changed, 39 insertions(+), 19 deletions(-) create mode 100644 lib/plugins/usermanager/style.css (limited to 'lib/plugins') diff --git a/lib/plugins/usermanager/admin.php b/lib/plugins/usermanager/admin.php index f0af93b48..715833843 100644 --- a/lib/plugins/usermanager/admin.php +++ b/lib/plugins/usermanager/admin.php @@ -244,7 +244,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { } - /** + /** * @todo disable fields which the backend can't change */ function _htmlUserForm($cmd,$user=null,$indent=0) { @@ -262,11 +262,13 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { ptln(" ".$this->lang["field"]."".$this->lang["value"]."",$indent); ptln(" ",$indent); ptln(" ",$indent); - ptln(" ",$indent); - ptln(" ",$indent); - ptln(" ",$indent); - ptln(" ",$indent); - ptln(" ",$indent); + + $this->_htmlInputField($cmd."_userid", "userid", $this->lang["user_id"], $user, $this->_auth->canDo("modLogin"), $indent+6); + $this->_htmlInputField($cmd."_userpass", "userpass", $this->lang["user_pass"], "", $this->_auth->canDo("modPass"), $indent+6); + $this->_htmlInputField($cmd."_username", "username", $this->lang["user_name"], $name, $this->_auth->canDo("modName"), $indent+6); + $this->_htmlInputField($cmd."_usermail", "usermail", $this->lang["user_mail"], $mail, $this->_auth->canDo("modMail"), $indent+6); + $this->_htmlInputField($cmd."_usergroups","usergroups",$this->lang["user_groups"],$groups,$this->_auth->canDo("modGroups"),$indent+6); + ptln(" ",$indent); ptln(" ",$indent); ptln(" ",$indent); @@ -287,6 +289,12 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { ptln(" ",$indent); ptln("",$indent); } + + function _htmlInputField($id, $name, $label, $value, $cando, $indent=0) { + $disabled = $cando ? "" : " disabled=\"disabled\""; + $class = $cando ? "" : " class=\"disabled\""; + ptln("",$indent); + } function _htmlFilter($key) { if (empty($this->_filter)) return ''; @@ -340,17 +348,23 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { function _modifyUser(){ if (!$this->_auth->canDo('UserMod')) return false; - /* get currently valid user data */ + // get currently valid user data $olduser = cleanID(preg_replace('/.*:/','',$_REQUEST['userid_old'])); $oldinfo = $this->_auth->getUserData($olduser); - - /* get new user data subject to change */ + + // get new user data subject to change list($newuser,$newpass,$newname,$newmail,$newgrps) = $this->_retrieveUser(); if (empty($newuser)) return false; $changes = array(); if ($newuser != $olduser) { - /* check if $newuser already exist */ + + if (!$this->_auth->canDo('modLogin')) { // sanity check, shouldn't be possible + msg($this->lang['update_fail'],-1); + return false; + } + + // check if $newuser already exists if ($this->_auth->getUserData($newuser)) { msg(sprintf($this->lang['update_exists'],$newuser),-1); $this->_edit_user = $olduser; @@ -359,16 +373,16 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { } } - 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 (!empty($newpass) && $this->_auth->canDo('modPass')) + $changes['pass'] = $newpass; + if (!empty($newname) && $this->_auth->canDo('modName') && $newname != $oldinfo['name']) + $changes['name'] = $newname; + if (!empty($newmail) && $this->_auth->canDo('modMail') && $newmail != $oldinfo['mail']) + $changes['mail'] = $newmail; + if (!empty($newgrps) && $this->_auth->canDo('modGroups') && $newgrps != $oldinfo['grps']) + $changes['grps'] = $newgrps; - if ($this->_auth->modifyUser($olduser, $changes)) { + if ($this->_auth->modifyUser($olduser, $changes)) { msg($this->lang['update_ok'],1); } else { msg($this->lang['update_fail'],-1); diff --git a/lib/plugins/usermanager/style.css b/lib/plugins/usermanager/style.css new file mode 100644 index 000000000..011632f5e --- /dev/null +++ b/lib/plugins/usermanager/style.css @@ -0,0 +1,6 @@ +/* User Manager specific styles */ +.disabled { + color: #6f6f6f; + background: #e4e4e4; +} + -- cgit v1.2.3