From 7b3674bd7a2b20df3ba37b32b7cc33f574a95dc5 Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Wed, 31 Jul 2013 18:51:06 +0200 Subject: add html5 'email' type to the user manager forms --- lib/plugins/usermanager/admin.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/plugins/usermanager/admin.php') diff --git a/lib/plugins/usermanager/admin.php b/lib/plugins/usermanager/admin.php index 445836a50..ca4c6a650 100644 --- a/lib/plugins/usermanager/admin.php +++ b/lib/plugins/usermanager/admin.php @@ -311,6 +311,9 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { if($name == 'userpass'){ $fieldtype = 'password'; $autocomp = 'autocomplete="off"'; + }elseif($name == 'usermail'){ + $fieldtype = 'email'; + $autocomp = ''; }else{ $fieldtype = 'text'; $autocomp = ''; -- cgit v1.2.3 From 5c967d3d04622c1420313f1a514da5cda99827f3 Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Thu, 1 Aug 2013 18:04:01 +0200 Subject: add csv export functionality to the user manager --- lib/plugins/usermanager/admin.php | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'lib/plugins/usermanager/admin.php') diff --git a/lib/plugins/usermanager/admin.php b/lib/plugins/usermanager/admin.php index ca4c6a650..72ac47e15 100644 --- a/lib/plugins/usermanager/admin.php +++ b/lib/plugins/usermanager/admin.php @@ -101,6 +101,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { case "search" : $this->_setFilter($param); $this->_start = 0; break; + case "export" : $this->_export(); break; } $this->_user_total = $this->_auth->canDo('getUserCount') ? $this->_auth->getUserCount($this->_filter) : -1; @@ -133,6 +134,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { $delete_disable = $this->_auth->canDo('delUser') ? '' : 'disabled="disabled"'; $editable = $this->_auth->canDo('UserMod'); + $export_label = empty($this->_filter) ? $this->lang['export_all'] : $this->lang[export_filtered]; print $this->locale_xhtml('intro'); print $this->locale_xhtml('list'); @@ -196,7 +198,10 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { ptln(" lang['next']."\" />"); ptln(" lang['last']."\" />"); ptln(" "); - ptln(" lang['clear']."\" />"); + if (!empty($this->_filter)) { + ptln(" lang['clear']."\" />"); + } + ptln(" "); ptln(" "); ptln(" "); @@ -629,4 +634,36 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { return $buttons; } + + /* + * export a list of users in csv format using the current filter criteria + */ + function _export() { + // list of users for export - based on current filter criteria + $user_list = $this->_auth->retrieveUsers(0, 0, $this->_filter); + $column_headings = array( + $this->lang["user_id"], + $this->lang["user_name"], + $this->lang["user_mail"], + $this->lang["user_groups"] + ); + + // ============================================================================================== + // GENERATE OUTPUT + // normal headers for downloading... + header('Content-type: text/csv;charset=utf-8'); + header('Content-Disposition: attachment; filename="wikiusers.csv"'); +# // for debugging assistance, send as text plain to the browser +# header('Content-type: text/plain;charset=utf-8'); + + // output the csv + $fd = fopen('php://output','w'); + fputcsv($fd, $column_headings); + foreach ($user_list as $user => $info) { + $line = array($user, $info['name'], $info['mail'], join(',',$info['grps'])); + fputcsv($fd, $line); + } + fclose($fd); + die; + } } -- cgit v1.2.3 From ae1afd2f6529e4d07b18317304e5e2c302d783ce Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Fri, 2 Aug 2013 17:21:48 +0200 Subject: add csv import functionality to the user manager --- lib/plugins/usermanager/admin.php | 187 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 187 insertions(+) (limited to 'lib/plugins/usermanager/admin.php') diff --git a/lib/plugins/usermanager/admin.php b/lib/plugins/usermanager/admin.php index 72ac47e15..ddf10a115 100644 --- a/lib/plugins/usermanager/admin.php +++ b/lib/plugins/usermanager/admin.php @@ -30,6 +30,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { var $_edit_user = ''; // set to user selected for editing var $_edit_userdata = array(); var $_disabled = ''; // if disabled set to explanatory string + var $_import_failures = array(); /** * Constructor @@ -49,6 +50,11 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { $this->_auth = & $auth; } + + // attempt to retrieve any import failures from the session + if ($_SESSION['import_failures']){ + $this->_import_failures = $_SESSION['import_failures']; + } } /** @@ -102,6 +108,8 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { $this->_start = 0; break; case "export" : $this->_export(); break; + case "import" : $this->_import(); break; + case "importfails" : $this->_downloadImportFailures(); break; } $this->_user_total = $this->_auth->canDo('getUserCount') ? $this->_auth->getUserCount($this->_filter) : -1; @@ -238,6 +246,10 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { ptln(" "); ptln(""); } + + if ($this->_auth->canDo('addUser')) { + $this->_htmlImportForm(); + } ptln(""); } @@ -352,6 +364,59 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { } } + function _htmlImportForm($indent=0) { + global $ID; + + $failure_download_link = wl($ID,array('do'=>'admin','page'=>'usermanager','fn[importfails]'=>1)); + + ptln('
',$indent); + print $this->locale_xhtml('import'); + ptln('
',$indent); + formSecurityToken(); + ptln(' ',$indent); + ptln(' ',$indent); + ptln(' ',$indent); + ptln(' ',$indent); + + $this->_htmlFilterSettings($indent+4); + ptln('
',$indent); + ptln('
'); + + // list failures from the previous import + if ($this->_import_failures) { + $digits = strlen(count($this->_import_failures)); + ptln('
',$indent); + ptln('

Most Recent Import - Failures

'); + ptln(' ',$indent); + ptln(' ',$indent); + ptln(' ',$indent); + ptln(' ',$indent); + ptln(' ',$indent); + ptln(' ',$indent); + ptln(' ',$indent); + ptln(' ',$indent); + ptln(' ',$indent); + ptln(' ',$indent); + ptln(' ',$indent); + ptln(' ',$indent); + foreach ($this->_import_failures as $line => $failure) { + ptln(' ',$indent); + ptln(' ',$indent); + ptln(' ', $indent); + ptln(' ',$indent); + ptln(' ',$indent); + ptln(' ',$indent); + ptln(' ',$indent); + ptln(' ',$indent); + } + ptln(' ',$indent); + ptln('
'.$this->lang['line'].''.$this->lang['error'].''.$this->lang['user_id'].''.$this->lang['user_name'].''.$this->lang['user_mail'].''.$this->lang['user_groups'].'
'.sprintf('%0'.$digits.'d',$line).' ' .$failure['error'].' '.hsc($failure['user'][0]).' '.hsc($failure['user'][2]).' '.hsc($failure['user'][3]).' '.hsc($failure['user'][4]).'
',$indent); + ptln('

Download Failures as CSV for correction

'); + ptln('
'); + } + + } + function _addUser(){ global $INPUT; if (!checkSecurityToken()) return false; @@ -666,4 +731,126 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { fclose($fd); die; } + + /* + * import a file of users in csv format + * + * csv file should have 4 columns, user_id, full name, email, groups (comma separated) + */ + function _import() { + // check we are allowed to add users + if (!checkSecurityToken()) return false; + if (!$this->_auth->canDo('addUser')) return false; + + // check file uploaded ok. + if (empty($_FILES['import']['size']) || !empty($FILES['import']['error']) && is_uploaded_file($FILES['import']['tmp_name'])) { + msg($this->lang['import_error_upload'],-1); + return false; + } + // retrieve users from the file + $this->_import_failures = array(); + $import_success_count = 0; + $import_fail_count = 0; + $line = 0; + $fd = fopen($_FILES['import']['tmp_name'],'r'); + if ($fd) { + while($csv = fgets($fd)){ + $raw = str_getcsv($csv); + $error = ''; // clean out any errors from the previous line + // data checks... + if (1 == ++$line) { + if ($raw[0] == 'user_id' || $raw[0] == $this->lang['user_id']) continue; // skip headers + } + if (count($raw) < 4) { // need at least four fields + $import_fail_count++; + $error = sprintf($this->lang['import_error_fields'], count($raw)); + $this->_import_failures[$line] = array('error' => $error, 'user' => $raw, 'orig' => $csv); + continue; + } + array_splice($raw,1,0,auth_pwgen()); // splice in a generated password + $clean = $this->_cleanImportUser($raw, $error); + if ($clean && $this->_addImportUser($clean, $error)) { +# $this->_notifyUser($clean[0],$clean[1]); + $import_success_count++; + } else { + $import_fail_count++; + $this->_import_failures[$line] = array('error' => $error, 'user' => $raw, 'orig' => $csv); + } + } + msg(sprintf($this->lang['import_success_count'], ($import_success_count+$import_fail_count), $import_success_count),($import_success_count ? 1 : -1)); + if ($import_fail_count) { + msg(sprintf($this->lang['import_failure_count'], $import_fail_count),-1); + } + } else { + msg($this->lang['import_error_readfail'],-1); + } + + // save import failures into the session + if (!headers_sent()) { + session_start(); + $_SESSION['import_failures'] = $this->_import_failures; + session_write_close(); + } + } + + function _cleanImportUser($candidate, & $error){ + global $INPUT; + + // kludgy .... + $INPUT->set('userid', $candidate[0]); + $INPUT->set('userpass', $candidate[1]); + $INPUT->set('username', $candidate[2]); + $INPUT->set('usermail', $candidate[3]); + $INPUT->set('usergroups', $candidate[4]); + + $cleaned = $this->_retrieveUser(); + list($user,$pass,$name,$mail,$grps) = $cleaned; + if (empty($user)) { + $error = $this->lang['import_error_baduserid']; + return false; + } + + // no need to check password, handled elsewhere + + if (!($this->_auth->canDo('modName') xor empty($name))){ + $error = $this->lang['import_error_badname']; + return false; + } + + if (!($this->_auth->canDo('modMail') xor empty($mail))){ + $error = $this->lang['import_error_badmail']; + return false; + } + + return $cleaned; + } + + function _addImportUser($user, & $error){ + if (!$this->_auth->triggerUserMod('create', $user)) { + $error = $this->lang['import_error_create']; + return false; + } + + return true; + } + + function _downloadImportFailures(){ + + // ============================================================================================== + // GENERATE OUTPUT + // normal headers for downloading... + header('Content-type: text/csv;charset=utf-8'); + header('Content-Disposition: attachment; filename="importfails.csv"'); +# // for debugging assistance, send as text plain to the browser +# header('Content-type: text/plain;charset=utf-8'); + + // output the csv + $fd = fopen('php://output','w'); + foreach ($this->_import_failures as $line => $fail) { + fputs($fd, $fail['orig']); + } + fclose($fd); + die; + } + } -- cgit v1.2.3 From ee9498f56bb996332665780f790257bcd010ac3c Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Fri, 2 Aug 2013 17:28:45 +0200 Subject: usermanager: fix an issue where edit user table would incorrectly show the password blank message --- lib/plugins/usermanager/admin.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/plugins/usermanager/admin.php') diff --git a/lib/plugins/usermanager/admin.php b/lib/plugins/usermanager/admin.php index ca4c6a650..62d3b3e5e 100644 --- a/lib/plugins/usermanager/admin.php +++ b/lib/plugins/usermanager/admin.php @@ -270,7 +270,9 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { $this->_htmlInputField($cmd."_usergroups","usergroups",$this->lang["user_groups"],$groups,$this->_auth->canDo("modGroups"),$indent+6); if ($this->_auth->canDo("modPass")) { - $notes[] = $this->lang['note_pass']; + if ($cmd == 'add') { + $notes[] = $this->lang['note_pass']; + } if ($user) { $notes[] = $this->lang['note_notify']; } -- cgit v1.2.3 From 45c199029a4e9e615c042ca521c50b5aef6fc3db Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Fri, 2 Aug 2013 17:29:30 +0200 Subject: improve html structure and styling for add & edit user notes made necessary by PR#254 which adds content below these notes. --- lib/plugins/usermanager/admin.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'lib/plugins/usermanager/admin.php') diff --git a/lib/plugins/usermanager/admin.php b/lib/plugins/usermanager/admin.php index 62d3b3e5e..3c8d38c5e 100644 --- a/lib/plugins/usermanager/admin.php +++ b/lib/plugins/usermanager/admin.php @@ -298,11 +298,15 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { ptln(" ",$indent); ptln(" ",$indent); ptln(" ",$indent); - ptln(" ",$indent); - - foreach ($notes as $note) - ptln("
".$note."
",$indent); + if ($notes) { + ptln("
    "); + foreach ($notes as $note) { + ptln("
  • ".$note."
  • ",$indent); + } + ptln("
"); + } + ptln(" ",$indent); ptln("",$indent); } -- cgit v1.2.3 From 328143f8a20933744be51a2693c99f35234ce5b3 Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Fri, 2 Aug 2013 22:53:21 +0200 Subject: enable email notifications & alert messages for imported users --- lib/plugins/usermanager/admin.php | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'lib/plugins/usermanager/admin.php') diff --git a/lib/plugins/usermanager/admin.php b/lib/plugins/usermanager/admin.php index ddf10a115..395b91053 100644 --- a/lib/plugins/usermanager/admin.php +++ b/lib/plugins/usermanager/admin.php @@ -606,12 +606,16 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { /** * send password change notification email */ - function _notifyUser($user, $password) { + function _notifyUser($user, $password, $status_alert=true) { if ($sent = auth_sendPassword($user,$password)) { - msg($this->lang['notify_ok'], 1); + if ($status_alert) { + msg($this->lang['notify_ok'], 1); + } } else { - msg($this->lang['notify_fail'], -1); + if ($status_alert) { + msg($this->lang['notify_fail'], -1); + } } return $sent; @@ -770,7 +774,10 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { array_splice($raw,1,0,auth_pwgen()); // splice in a generated password $clean = $this->_cleanImportUser($raw, $error); if ($clean && $this->_addImportUser($clean, $error)) { -# $this->_notifyUser($clean[0],$clean[1]); + $sent = $this->_notifyUser($clean[0],$clean[1],false); + if (!$sent){ + msg(sprintf($this->lang['import_notify_fail'],$clean[0],$clean[3]),-1); + } $import_success_count++; } else { $import_fail_count++; @@ -817,9 +824,16 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { return false; } - if (!($this->_auth->canDo('modMail') xor empty($mail))){ - $error = $this->lang['import_error_badmail']; - return false; + if ($this->_auth->canDo('modMail')) { + if (empty($mail) || !mail_isvalid($mail)) { + $error = $this->lang['import_error_badmail']; + return false; + } + } else { + if (!empty($mail)) { + $error = $this->lang['import_error_badmail']; + return false; + } } return $cleaned; -- cgit v1.2.3 From efcec72bb2994a220c7885c5b6855a934e80b52d Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Sat, 3 Aug 2013 18:06:54 +0200 Subject: convert from iso-8859-1 if not utf8 --- lib/plugins/usermanager/admin.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/plugins/usermanager/admin.php') diff --git a/lib/plugins/usermanager/admin.php b/lib/plugins/usermanager/admin.php index 395b91053..4c555ba67 100644 --- a/lib/plugins/usermanager/admin.php +++ b/lib/plugins/usermanager/admin.php @@ -759,6 +759,9 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { $fd = fopen($_FILES['import']['tmp_name'],'r'); if ($fd) { while($csv = fgets($fd)){ + if (!utf8_check($csv)) { + $csv = utf8_encode($csv); + } $raw = str_getcsv($csv); $error = ''; // clean out any errors from the previous line // data checks... -- cgit v1.2.3 From 7ef8e99fe605c5da36ab6b5d317b22fcd17f665b Mon Sep 17 00:00:00 2001 From: Matt Perry Date: Thu, 22 Aug 2013 01:01:41 -0700 Subject: Fix CodeSniffer violations Change indentation to ensure code confirms to CodeSniffer rules. --- lib/plugins/usermanager/admin.php | 286 +++++++++++++++++++------------------- 1 file changed, 143 insertions(+), 143 deletions(-) (limited to 'lib/plugins/usermanager/admin.php') diff --git a/lib/plugins/usermanager/admin.php b/lib/plugins/usermanager/admin.php index 762daa6b9..a0e77065e 100644 --- a/lib/plugins/usermanager/admin.php +++ b/lib/plugins/usermanager/admin.php @@ -41,13 +41,13 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { $this->setupLocale(); if (!isset($auth)) { - $this->disabled = $this->lang['noauth']; + $this->disabled = $this->lang['noauth']; } else if (!$auth->canDo('getUsers')) { - $this->disabled = $this->lang['nosupport']; + $this->disabled = $this->lang['nosupport']; } else { - // we're good to go - $this->_auth = & $auth; + // we're good to go + $this->_auth = & $auth; } @@ -95,31 +95,31 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { } if ($cmd != "search") { - $this->_start = $INPUT->int('start', 0); - $this->_filter = $this->_retrieveFilter(); + $this->_start = $INPUT->int('start', 0); + $this->_filter = $this->_retrieveFilter(); } switch($cmd){ - case "add" : $this->_addUser(); break; - case "delete" : $this->_deleteUser(); break; - case "modify" : $this->_modifyUser(); break; - case "edit" : $this->_editUser($param); break; - case "search" : $this->_setFilter($param); - $this->_start = 0; - break; - case "export" : $this->_export(); break; - case "import" : $this->_import(); break; - case "importfails" : $this->_downloadImportFailures(); break; + case "add" : $this->_addUser(); break; + case "delete" : $this->_deleteUser(); break; + case "modify" : $this->_modifyUser(); break; + case "edit" : $this->_editUser($param); break; + case "search" : $this->_setFilter($param); + $this->_start = 0; + break; + case "export" : $this->_export(); break; + case "import" : $this->_import(); break; + case "importfails" : $this->_downloadImportFailures(); break; } $this->_user_total = $this->_auth->canDo('getUserCount') ? $this->_auth->getUserCount($this->_filter) : -1; // page handling switch($cmd){ - case 'start' : $this->_start = 0; break; - case 'prev' : $this->_start -= $this->_pagesize; break; - case 'next' : $this->_start += $this->_pagesize; break; - case 'last' : $this->_start = $this->_user_total; break; + case 'start' : $this->_start = 0; break; + case 'prev' : $this->_start -= $this->_pagesize; break; + case 'next' : $this->_start += $this->_pagesize; break; + case 'last' : $this->_start = $this->_user_total; break; } $this->_validatePagination(); } @@ -151,9 +151,9 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { ptln("
"); if ($this->_user_total > 0) { - ptln("

".sprintf($this->lang['summary'],$this->_start+1,$this->_last,$this->_user_total,$this->_auth->getUserCount())."

"); + ptln("

".sprintf($this->lang['summary'],$this->_start+1,$this->_last,$this->_user_total,$this->_auth->getUserCount())."

"); } else { - ptln("

".sprintf($this->lang['nonefound'],$this->_auth->getUserCount())."

"); + ptln("

".sprintf($this->lang['nonefound'],$this->_auth->getUserCount())."

"); } ptln("
"); formSecurityToken(); @@ -174,25 +174,25 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { ptln(" "); if ($this->_user_total) { - ptln(" "); - foreach ($user_list as $user => $userinfo) { - extract($userinfo); - $groups = join(', ',$grps); - ptln(" "); - ptln(" "); - if ($editable) { - ptln(" 1, - 'do' => 'admin', - 'page' => 'usermanager', - 'sectok' => getSecurityToken())). - "\" title=\"".$this->lang['edit_prompt']."\">".hsc($user).""); - } else { - ptln(" ".hsc($user).""); + ptln(" "); + foreach ($user_list as $user => $userinfo) { + extract($userinfo); + $groups = join(', ',$grps); + ptln(" "); + ptln(" "); + if ($editable) { + ptln(" 1, + 'do' => 'admin', + 'page' => 'usermanager', + 'sectok' => getSecurityToken())). + "\" title=\"".$this->lang['edit_prompt']."\">".hsc($user).""); + } else { + ptln(" ".hsc($user).""); + } + ptln(" ".hsc($name)."".hsc($mail)."".hsc($groups).""); + ptln(" "); } - ptln(" ".hsc($name)."".hsc($mail)."".hsc($groups).""); - ptln(" "); - } - ptln(" "); + ptln(" "); } ptln(" "); @@ -226,29 +226,29 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { $style = $this->_edit_user ? " class=\"edit_user\"" : ""; if ($this->_auth->canDo('addUser')) { - ptln(""); - print $this->locale_xhtml('add'); - ptln("
"); + ptln(""); + print $this->locale_xhtml('add'); + ptln("
"); - $this->_htmlUserForm('add',null,array(),4); + $this->_htmlUserForm('add',null,array(),4); - ptln("
"); - ptln("
"); + ptln("
"); + ptln(""); } if($this->_edit_user && $this->_auth->canDo('UserMod')){ - ptln(""); - print $this->locale_xhtml('edit'); - ptln("
"); + ptln(""); + print $this->locale_xhtml('edit'); + ptln("
"); - $this->_htmlUserForm('modify',$this->_edit_user,$this->_edit_userdata,4); + $this->_htmlUserForm('modify',$this->_edit_user,$this->_edit_userdata,4); - ptln("
"); - ptln("
"); + ptln(" "); + ptln(""); } if ($this->_auth->canDo('addUser')) { - $this->_htmlImportForm(); + $this->_htmlImportForm(); } ptln(""); } @@ -265,10 +265,10 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { $notes = array(); if ($user) { - extract($userdata); - if (!empty($grps)) $groups = join(',',$grps); + extract($userdata); + if (!empty($grps)) $groups = join(',',$grps); } else { - $notes[] = sprintf($this->lang['note_group'],$conf['defaultgroup']); + $notes[] = sprintf($this->lang['note_group'],$conf['defaultgroup']); } ptln("",$indent); @@ -287,14 +287,14 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { $this->_htmlInputField($cmd."_usergroups","usergroups",$this->lang["user_groups"],$groups,$this->_auth->canDo("modGroups"),$indent+6); if ($this->_auth->canDo("modPass")) { - if ($cmd == 'add') { - $notes[] = $this->lang['note_pass']; - } - if ($user) { - $notes[] = $this->lang['note_notify']; - } + if ($cmd == 'add') { + $notes[] = $this->lang['note_pass']; + } + if ($user) { + $notes[] = $this->lang['note_notify']; + } - ptln("", $indent); + ptln("", $indent); } ptln(" ",$indent); @@ -317,11 +317,11 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { ptln(" ",$indent); if ($notes) { - ptln("
    "); - foreach ($notes as $note) { - ptln("
  • ".$note."
  • ",$indent); - } - ptln("
"); + ptln("
    "); + foreach ($notes as $note) { + ptln("
  • ".$note."
  • ",$indent); + } + ptln("
"); } ptln(" ",$indent); ptln("",$indent); @@ -366,7 +366,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { ptln("_start."\" />",$indent); foreach ($this->_filter as $key => $filter) { - ptln("",$indent); + ptln("",$indent); } } @@ -432,52 +432,52 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { if (empty($user)) return false; if ($this->_auth->canDo('modPass')){ - if (empty($pass)){ - if($INPUT->has('usernotify')){ - $pass = auth_pwgen($user); - } else { - msg($this->lang['add_fail'], -1); - return false; + if (empty($pass)){ + if($INPUT->has('usernotify')){ + $pass = auth_pwgen($user); + } else { + msg($this->lang['add_fail'], -1); + return false; + } } - } } else { - if (!empty($pass)){ - msg($this->lang['add_fail'], -1); - return false; - } + if (!empty($pass)){ + msg($this->lang['add_fail'], -1); + return false; + } } if ($this->_auth->canDo('modName')){ - if (empty($name)){ - msg($this->lang['add_fail'], -1); - return false; - } + if (empty($name)){ + msg($this->lang['add_fail'], -1); + return false; + } } else { - if (!empty($name)){ - return false; - } + if (!empty($name)){ + return false; + } } if ($this->_auth->canDo('modMail')){ - if (empty($mail)){ - msg($this->lang['add_fail'], -1); - return false; - } + if (empty($mail)){ + msg($this->lang['add_fail'], -1); + return false; + } } else { - if (!empty($mail)){ - return false; - } + if (!empty($mail)){ + return false; + } } if ($ok = $this->_auth->triggerUserMod('create', array($user,$pass,$name,$mail,$grps))) { - msg($this->lang['add_ok'], 1); + msg($this->lang['add_ok'], 1); - if ($INPUT->has('usernotify') && $pass) { - $this->_notifyUser($user,$pass); - } + if ($INPUT->has('usernotify') && $pass) { + $this->_notifyUser($user,$pass); + } } else { - msg($this->lang['add_fail'], -1); + msg($this->lang['add_fail'], -1); } return $ok; @@ -503,12 +503,12 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { $count = $this->_auth->triggerUserMod('delete', array($selected)); if ($count == count($selected)) { - $text = str_replace('%d', $count, $this->lang['delete_ok']); - msg("$text.", 1); + $text = str_replace('%d', $count, $this->lang['delete_ok']); + msg("$text.", 1); } else { - $part1 = str_replace('%d', $count, $this->lang['delete_ok']); - $part2 = str_replace('%d', (count($selected)-$count), $this->lang['delete_fail']); - msg("$part1, $part2",-1); + $part1 = str_replace('%d', $count, $this->lang['delete_ok']); + $part2 = str_replace('%d', (count($selected)-$count), $this->lang['delete_fail']); + msg("$part1, $part2",-1); } // invalidate all sessions @@ -529,8 +529,8 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { // no user found? if (!$userdata) { - msg($this->lang['edit_usermissing'],-1); - return false; + msg($this->lang['edit_usermissing'],-1); + return false; } $this->_edit_user = $user; @@ -559,18 +559,18 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { $changes = array(); if ($newuser != $olduser) { - if (!$this->_auth->canDo('modLogin')) { // sanity check, shouldn't be possible - msg($this->lang['update_fail'],-1); - return false; - } + 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); - $re_edit = true; - } else { - $changes['user'] = $newuser; - } + // check if $newuser already exists + if ($this->_auth->getUserData($newuser)) { + msg(sprintf($this->lang['update_exists'],$newuser),-1); + $re_edit = true; + } else { + $changes['user'] = $newuser; + } } // generate password if left empty and notification is on @@ -588,18 +588,18 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { $changes['grps'] = $newgrps; if ($ok = $this->_auth->triggerUserMod('modify', array($olduser, $changes))) { - msg($this->lang['update_ok'],1); + msg($this->lang['update_ok'],1); - if ($INPUT->has('usernotify') && $newpass) { - $notify = empty($changes['user']) ? $olduser : $newuser; - $this->_notifyUser($notify,$newpass); - } + if ($INPUT->has('usernotify') && $newpass) { + $notify = empty($changes['user']) ? $olduser : $newuser; + $this->_notifyUser($notify,$newpass); + } - // invalidate all sessions - io_saveFile($conf['cachedir'].'/sessionpurge',time()); + // invalidate all sessions + io_saveFile($conf['cachedir'].'/sessionpurge',time()); } else { - msg($this->lang['update_fail'],-1); + msg($this->lang['update_fail'],-1); } if (!empty($re_edit)) { @@ -615,13 +615,13 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { function _notifyUser($user, $password, $status_alert=true) { if ($sent = auth_sendPassword($user,$password)) { - if ($status_alert) { - msg($this->lang['notify_ok'], 1); - } + if ($status_alert) { + msg($this->lang['notify_ok'], 1); + } } else { - if ($status_alert) { - msg($this->lang['notify_fail'], -1); - } + if ($status_alert) { + msg($this->lang['notify_fail'], -1); + } } return $sent; @@ -656,12 +656,12 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { $this->_filter = array(); if ($op == 'new') { - list($user,$pass,$name,$mail,$grps) = $this->_retrieveUser(false); + list($user,$pass,$name,$mail,$grps) = $this->_retrieveUser(false); - if (!empty($user)) $this->_filter['user'] = $user; - if (!empty($name)) $this->_filter['name'] = $name; - if (!empty($mail)) $this->_filter['mail'] = $mail; - if (!empty($grps)) $this->_filter['grps'] = join('|',$grps); + if (!empty($user)) $this->_filter['user'] = $user; + if (!empty($name)) $this->_filter['name'] = $name; + if (!empty($mail)) $this->_filter['mail'] = $mail; + if (!empty($grps)) $this->_filter['grps'] = join('|',$grps); } } @@ -684,7 +684,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { function _validatePagination() { if ($this->_start >= $this->_user_total) { - $this->_start = $this->_user_total - $this->_pagesize; + $this->_start = $this->_user_total - $this->_pagesize; } if ($this->_start < 0) $this->_start = 0; @@ -701,10 +701,10 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { $buttons['start'] = $buttons['prev'] = ($this->_start == 0) ? $disabled : ''; if ($this->_user_total == -1) { - $buttons['last'] = $disabled; - $buttons['next'] = ''; + $buttons['last'] = $disabled; + $buttons['next'] = ''; } else { - $buttons['last'] = $buttons['next'] = (($this->_start + $this->_pagesize) >= $this->_user_total) ? $disabled : ''; + $buttons['last'] = $buttons['next'] = (($this->_start + $this->_pagesize) >= $this->_user_total) ? $disabled : ''; } return $buttons; @@ -803,9 +803,9 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { // save import failures into the session if (!headers_sent()) { - session_start(); - $_SESSION['import_failures'] = $this->_import_failures; - session_write_close(); + session_start(); + $_SESSION['import_failures'] = $this->_import_failures; + session_write_close(); } } -- cgit v1.2.3 From c404cb3b0b4946f6308f66b6324a24489b2ef5b8 Mon Sep 17 00:00:00 2001 From: Matt Perry Date: Fri, 23 Aug 2013 03:08:41 -0700 Subject: Fix CodeSniffer violations for PHP files Fix violations for Squiz.Commenting.DocCommentAlignment.SpaceBeforeTag Conflicts: inc/parser/xhtml.php --- lib/plugins/usermanager/admin.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/plugins/usermanager/admin.php') diff --git a/lib/plugins/usermanager/admin.php b/lib/plugins/usermanager/admin.php index a0e77065e..3dba5a86e 100644 --- a/lib/plugins/usermanager/admin.php +++ b/lib/plugins/usermanager/admin.php @@ -58,8 +58,8 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { } /** - * return prompt for admin menu - */ + * return prompt for admin menu + */ function getMenuText($language) { if (!is_null($this->_auth)) -- cgit v1.2.3 From 2f7a0e94cadfbc1ece3bd1d3ff23483b845cd420 Mon Sep 17 00:00:00 2001 From: Matt Perry Date: Tue, 10 Sep 2013 22:17:43 -0700 Subject: Fix CodeSniffer whitespace violoations Removed extraneous whitespace to eliminate errors reported by the Squiz.WhiteSpace.SuperfluousWhitespace sniff. --- lib/plugins/usermanager/admin.php | 1 - 1 file changed, 1 deletion(-) (limited to 'lib/plugins/usermanager/admin.php') diff --git a/lib/plugins/usermanager/admin.php b/lib/plugins/usermanager/admin.php index 3dba5a86e..266a7dd64 100644 --- a/lib/plugins/usermanager/admin.php +++ b/lib/plugins/usermanager/admin.php @@ -342,7 +342,6 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { $autocomp = ''; } - echo ""; echo ""; echo ""; -- cgit v1.2.3 From a102b1759a790dbefcb92ac83a988bf6b4ae7f08 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Fri, 20 Sep 2013 17:28:32 +0200 Subject: Use zero when getUserCount is unsupported. Fixes FS#2353 --- lib/plugins/usermanager/admin.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/plugins/usermanager/admin.php') diff --git a/lib/plugins/usermanager/admin.php b/lib/plugins/usermanager/admin.php index 3dba5a86e..8638692a1 100644 --- a/lib/plugins/usermanager/admin.php +++ b/lib/plugins/usermanager/admin.php @@ -153,7 +153,12 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { if ($this->_user_total > 0) { ptln("

".sprintf($this->lang['summary'],$this->_start+1,$this->_last,$this->_user_total,$this->_auth->getUserCount())."

"); } else { - ptln("

".sprintf($this->lang['nonefound'],$this->_auth->getUserCount())."

"); + if($this->_user_total < 0) { + $allUserTotal = 0; + } else { + $allUserTotal = $this->_auth->getUserCount(); + } + ptln("

".sprintf($this->lang['nonefound'], $allUserTotal)."

"); } ptln("
"); formSecurityToken(); -- cgit v1.2.3 From c5a7c0c6451b198dcb2782306aba2b22ff2d4170 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Sat, 21 Sep 2013 01:31:08 +0200 Subject: Improve PHPDocs and set visibility explicitly --- lib/plugins/usermanager/admin.php | 204 ++++++++++++++++++++++++++++---------- 1 file changed, 149 insertions(+), 55 deletions(-) (limited to 'lib/plugins/usermanager/admin.php') diff --git a/lib/plugins/usermanager/admin.php b/lib/plugins/usermanager/admin.php index 8638692a1..bea5de177 100644 --- a/lib/plugins/usermanager/admin.php +++ b/lib/plugins/usermanager/admin.php @@ -21,29 +21,30 @@ if(!defined('DOKU_PLUGIN_IMAGES')) define('DOKU_PLUGIN_IMAGES',DOKU_BASE.'lib/pl */ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { - var $_auth = null; // auth object - var $_user_total = 0; // number of registered users - var $_filter = array(); // user selection filter(s) - var $_start = 0; // index of first user to be displayed - var $_last = 0; // index of the last user to be displayed - var $_pagesize = 20; // number of users to list on one page - var $_edit_user = ''; // set to user selected for editing - var $_edit_userdata = array(); - var $_disabled = ''; // if disabled set to explanatory string - var $_import_failures = array(); + private $_auth = null; // auth object + private $_user_total = 0; // number of registered users + private $_filter = array(); // user selection filter(s) + private $_start = 0; // index of first user to be displayed + private $_last = 0; // index of the last user to be displayed + private $_pagesize = 20; // number of users to list on one page + private $_edit_user = ''; // set to user selected for editing + private $_edit_userdata = array(); + private $_disabled = ''; // if disabled set to explanatory string + private $_import_failures = array(); /** * Constructor */ - function admin_plugin_usermanager(){ + public function admin_plugin_usermanager(){ + /** @var DokuWiki_Auth_Plugin $auth */ global $auth; $this->setupLocale(); if (!isset($auth)) { - $this->disabled = $this->lang['noauth']; + $this->_disabled = $this->lang['noauth']; } else if (!$auth->canDo('getUsers')) { - $this->disabled = $this->lang['nosupport']; + $this->_disabled = $this->lang['nosupport']; } else { // we're good to go @@ -58,27 +59,27 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { } /** - * return prompt for admin menu + * Return prompt for admin menu */ - function getMenuText($language) { + public function getMenuText($language) { if (!is_null($this->_auth)) return parent::getMenuText($language); - return $this->getLang('menu').' '.$this->disabled; + return $this->getLang('menu').' '.$this->_disabled; } /** * return sort order for position in admin menu */ - function getMenuSort() { + public function getMenuSort() { return 2; } /** - * handle user request + * Handle user request */ - function handle() { + public function handle() { global $INPUT; if (is_null($this->_auth)) return false; @@ -122,12 +123,13 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { case 'last' : $this->_start = $this->_user_total; break; } $this->_validatePagination(); + return true; } /** - * output appropriate html + * Output appropriate html */ - function html() { + public function html() { global $ID; if(is_null($this->_auth)) { @@ -136,7 +138,6 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { } $user_list = $this->_auth->retrieveUsers($this->_start, $this->_pagesize, $this->_filter); - $users = array_keys($user_list); $page_buttons = $this->_pagination(); $delete_disable = $this->_auth->canDo('delUser') ? '' : 'disabled="disabled"'; @@ -182,6 +183,12 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { ptln(" "); foreach ($user_list as $user => $userinfo) { extract($userinfo); + /** + * @var string $name + * @var string $pass + * @var string $mail + * @var array $grps + */ $groups = join(', ',$grps); ptln(" "); ptln(" "); @@ -256,13 +263,18 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { $this->_htmlImportForm(); } ptln(""); + return true; } - /** - * @todo disable fields which the backend can't change + * Display form to add or modify a user + * + * @param string $cmd 'add' or 'modify' + * @param string $user id of user + * @param array $userdata array with name, mail, pass and grps + * @param int $indent */ - function _htmlUserForm($cmd,$user='',$userdata=array(),$indent=0) { + private function _htmlUserForm($cmd,$user='',$userdata=array(),$indent=0) { global $conf; global $ID; @@ -332,7 +344,17 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { ptln("",$indent); } - function _htmlInputField($id, $name, $label, $value, $cando, $indent=0) { + /** + * Prints a inputfield + * + * @param string $id + * @param string $name + * @param string $label + * @param string $value + * @param bool $cando whether auth backend is capable to do this action + * @param int $indent + */ + private function _htmlInputField($id, $name, $label, $value, $cando, $indent=0) { $class = $cando ? '' : ' class="disabled"'; echo str_pad('',$indent); @@ -361,12 +383,23 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { echo ""; } - function _htmlFilter($key) { + /** + * Returns htmlescaped filter value + * + * @param string $key name of search field + * @return string html escaped value + */ + private function _htmlFilter($key) { if (empty($this->_filter)) return ''; return (isset($this->_filter[$key]) ? hsc($this->_filter[$key]) : ''); } - function _htmlFilterSettings($indent=0) { + /** + * Print hidden inputs with the current filter values + * + * @param int $indent + */ + private function _htmlFilterSettings($indent=0) { ptln("_start."\" />",$indent); @@ -375,7 +408,12 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { } } - function _htmlImportForm($indent=0) { + /** + * Print import form and summary of previous import + * + * @param int $indent + */ + private function _htmlImportForm($indent=0) { global $ID; $failure_download_link = wl($ID,array('do'=>'admin','page'=>'usermanager','fn[importfails]'=>1)); @@ -428,7 +466,12 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { } - function _addUser(){ + /** + * Add an user to auth backend + * + * @return bool whether succesful + */ + private function _addUser(){ global $INPUT; if (!checkSecurityToken()) return false; if (!$this->_auth->canDo('addUser')) return false; @@ -489,9 +532,11 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { } /** - * Delete user + * Delete user from auth backend + * + * @return bool whether succesful */ - function _deleteUser(){ + private function _deleteUser(){ global $conf, $INPUT; if (!checkSecurityToken()) return false; @@ -524,8 +569,11 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { /** * Edit user (a user has been selected for editing) + * + * @param string $param id of the user + * @return bool whether succesful */ - function _editUser($param) { + private function _editUser($param) { if (!checkSecurityToken()) return false; if (!$this->_auth->canDo('UserMod')) return false; @@ -545,9 +593,11 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { } /** - * Modify user (modified user data has been recieved) + * Modify user in the auth backend (modified user data has been recieved) + * + * @return bool whether succesful */ - function _modifyUser(){ + private function _modifyUser(){ global $conf, $INPUT; if (!checkSecurityToken()) return false; @@ -615,9 +665,14 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { } /** - * send password change notification email + * Send password change notification email + * + * @param string $user id of user + * @param string $password plain text + * @param bool $status_alert whether status alert should be shown + * @return bool whether succesful */ - function _notifyUser($user, $password, $status_alert=true) { + private function _notifyUser($user, $password, $status_alert=true) { if ($sent = auth_sendPassword($user,$password)) { if ($status_alert) { @@ -633,11 +688,13 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { } /** - * retrieve & clean user data from the form + * Retrieve & clean user data from the form * + * @param bool $clean whether the cleanUser method of the authentication backend is applied * @return array (user, password, full name, email, array(groups)) */ - function _retrieveUser($clean=true) { + private function _retrieveUser($clean=true) { + /** @var DokuWiki_Auth_Plugin $auth */ global $auth; global $INPUT; @@ -656,7 +713,12 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { return $user; } - function _setFilter($op) { + /** + * Set the filter with the current search terms or clear the filter + * + * @param string $op 'new' or 'clear' + */ + private function _setFilter($op) { $this->_filter = array(); @@ -670,7 +732,12 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { } } - function _retrieveFilter() { + /** + * Get the current search terms + * + * @return array + */ + private function _retrieveFilter() { global $INPUT; $t_filter = $INPUT->arr('filter'); @@ -686,7 +753,10 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { return $filter; } - function _validatePagination() { + /** + * Validate and improve the pagination values + */ + private function _validatePagination() { if ($this->_start >= $this->_user_total) { $this->_start = $this->_user_total - $this->_pagesize; @@ -696,10 +766,12 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { $this->_last = min($this->_user_total, $this->_start + $this->_pagesize); } - /* - * return an array of strings to enable/disable pagination buttons + /** + * Return an array of strings to enable/disable pagination buttons + * + * @return array with enable/disable attributes */ - function _pagination() { + private function _pagination() { $disabled = 'disabled="disabled"'; @@ -715,10 +787,10 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { return $buttons; } - /* - * export a list of users in csv format using the current filter criteria + /** + * Export a list of users in csv format using the current filter criteria */ - function _export() { + private function _export() { // list of users for export - based on current filter criteria $user_list = $this->_auth->retrieveUsers(0, 0, $this->_filter); $column_headings = array( @@ -747,12 +819,14 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { die; } - /* - * import a file of users in csv format + /** + * Import a file of users in csv format * * csv file should have 4 columns, user_id, full name, email, groups (comma separated) + * + * @return bool whether succesful */ - function _import() { + private function _import() { // check we are allowed to add users if (!checkSecurityToken()) return false; if (!$this->_auth->canDo('addUser')) return false; @@ -812,9 +886,17 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { $_SESSION['import_failures'] = $this->_import_failures; session_write_close(); } + return true; } - function _cleanImportUser($candidate, & $error){ + /** + * Returns cleaned row data + * + * @param array $candidate raw values of line from input file + * @param $error + * @return array|bool cleaned data or false + */ + private function _cleanImportUser($candidate, & $error){ global $INPUT; // kludgy .... @@ -853,7 +935,16 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { return $cleaned; } - function _addImportUser($user, & $error){ + /** + * Adds imported user to auth backend + * + * Required a check of canDo('addUser') before + * + * @param array $user data of user + * @param string &$error reference catched error message + * @return bool whether succesful + */ + private function _addImportUser($user, & $error){ if (!$this->_auth->triggerUserMod('create', $user)) { $error = $this->lang['import_error_create']; return false; @@ -862,7 +953,10 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { return true; } - function _downloadImportFailures(){ + /** + * Downloads failures as csv file + */ + private function _downloadImportFailures(){ // ============================================================================================== // GENERATE OUTPUT @@ -874,7 +968,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { // output the csv $fd = fopen('php://output','w'); - foreach ($this->_import_failures as $line => $fail) { + foreach ($this->_import_failures as $fail) { fputs($fd, $fail['orig']); } fclose($fd); -- cgit v1.2.3 From b59cff8b714aa11b5b1afd209e9d73f6803883cd Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Sat, 21 Sep 2013 02:15:39 +0200 Subject: Move strings to language files. Fix lang key --- lib/plugins/usermanager/admin.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/plugins/usermanager/admin.php') diff --git a/lib/plugins/usermanager/admin.php b/lib/plugins/usermanager/admin.php index bea5de177..4abef37ff 100644 --- a/lib/plugins/usermanager/admin.php +++ b/lib/plugins/usermanager/admin.php @@ -143,7 +143,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { $delete_disable = $this->_auth->canDo('delUser') ? '' : 'disabled="disabled"'; $editable = $this->_auth->canDo('UserMod'); - $export_label = empty($this->_filter) ? $this->lang['export_all'] : $this->lang[export_filtered]; + $export_label = empty($this->_filter) ? $this->lang['export_all'] : $this->lang['export_filtered']; print $this->locale_xhtml('intro'); print $this->locale_xhtml('list'); @@ -422,7 +422,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { print $this->locale_xhtml('import'); ptln('
',$indent); formSecurityToken(); - ptln(' ',$indent); + ptln(' ',$indent); ptln(' ',$indent); ptln(' ',$indent); ptln(' ',$indent); @@ -435,7 +435,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { if ($this->_import_failures) { $digits = strlen(count($this->_import_failures)); ptln('
',$indent); - ptln('

Most Recent Import - Failures

'); + ptln('

'.$this->lang['import_header'].'

'); ptln(' ',$indent); ptln(' ',$indent); ptln(' ',$indent); @@ -460,7 +460,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { } ptln(' ',$indent); ptln('
',$indent); - ptln('

Download Failures as CSV for correction

'); + ptln('

'.$this->lang['import_downloadfailures'].'

'); ptln('
'); } -- cgit v1.2.3 From 786dfb0e75bc29b381ce487ba9564fcc0f0fbed0 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Sat, 21 Sep 2013 16:05:16 +0200 Subject: Use ->cleanUser everywhere in usermanager. Fixes FS#2849 Some auth backend have bad cleaning, but that is responsibility of these. --- lib/plugins/usermanager/admin.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'lib/plugins/usermanager/admin.php') diff --git a/lib/plugins/usermanager/admin.php b/lib/plugins/usermanager/admin.php index 4abef37ff..74eaee721 100644 --- a/lib/plugins/usermanager/admin.php +++ b/lib/plugins/usermanager/admin.php @@ -576,8 +576,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { private function _editUser($param) { if (!checkSecurityToken()) return false; if (!$this->_auth->canDo('UserMod')) return false; - - $user = cleanID(preg_replace('/.*:/','',$param)); + $user = $this->_auth->cleanUser(preg_replace('/.*[:\/]/','',$param)); $userdata = $this->_auth->getUserData($user); // no user found? @@ -604,7 +603,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { if (!$this->_auth->canDo('UserMod')) return false; // get currently valid user data - $olduser = cleanID(preg_replace('/.*:/','',$INPUT->str('userid_old'))); + $olduser = $this->_auth->cleanUser(preg_replace('/.*[:\/]/','',$INPUT->str('userid_old'))); $oldinfo = $this->_auth->getUserData($olduser); // get new user data subject to change @@ -890,7 +889,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { } /** - * Returns cleaned row data + * Returns cleaned user data * * @param array $candidate raw values of line from input file * @param $error -- cgit v1.2.3 From 3712ca9a1625d41832dda690dcf98bd75f955502 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Sun, 22 Sep 2013 23:34:44 +0200 Subject: change visibility of private to protected --- lib/plugins/usermanager/admin.php | 60 +++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 30 deletions(-) (limited to 'lib/plugins/usermanager/admin.php') diff --git a/lib/plugins/usermanager/admin.php b/lib/plugins/usermanager/admin.php index 74eaee721..0e677e394 100644 --- a/lib/plugins/usermanager/admin.php +++ b/lib/plugins/usermanager/admin.php @@ -21,16 +21,16 @@ if(!defined('DOKU_PLUGIN_IMAGES')) define('DOKU_PLUGIN_IMAGES',DOKU_BASE.'lib/pl */ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { - private $_auth = null; // auth object - private $_user_total = 0; // number of registered users - private $_filter = array(); // user selection filter(s) - private $_start = 0; // index of first user to be displayed - private $_last = 0; // index of the last user to be displayed - private $_pagesize = 20; // number of users to list on one page - private $_edit_user = ''; // set to user selected for editing - private $_edit_userdata = array(); - private $_disabled = ''; // if disabled set to explanatory string - private $_import_failures = array(); + protected $_auth = null; // auth object + protected $_user_total = 0; // number of registered users + protected $_filter = array(); // user selection filter(s) + protected $_start = 0; // index of first user to be displayed + protected $_last = 0; // index of the last user to be displayed + protected $_pagesize = 20; // number of users to list on one page + protected $_edit_user = ''; // set to user selected for editing + protected $_edit_userdata = array(); + protected $_disabled = ''; // if disabled set to explanatory string + protected $_import_failures = array(); /** * Constructor @@ -274,7 +274,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { * @param array $userdata array with name, mail, pass and grps * @param int $indent */ - private function _htmlUserForm($cmd,$user='',$userdata=array(),$indent=0) { + protected function _htmlUserForm($cmd,$user='',$userdata=array(),$indent=0) { global $conf; global $ID; @@ -354,7 +354,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { * @param bool $cando whether auth backend is capable to do this action * @param int $indent */ - private function _htmlInputField($id, $name, $label, $value, $cando, $indent=0) { + protected function _htmlInputField($id, $name, $label, $value, $cando, $indent=0) { $class = $cando ? '' : ' class="disabled"'; echo str_pad('',$indent); @@ -389,7 +389,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { * @param string $key name of search field * @return string html escaped value */ - private function _htmlFilter($key) { + protected function _htmlFilter($key) { if (empty($this->_filter)) return ''; return (isset($this->_filter[$key]) ? hsc($this->_filter[$key]) : ''); } @@ -399,7 +399,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { * * @param int $indent */ - private function _htmlFilterSettings($indent=0) { + protected function _htmlFilterSettings($indent=0) { ptln("_start."\" />",$indent); @@ -413,7 +413,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { * * @param int $indent */ - private function _htmlImportForm($indent=0) { + protected function _htmlImportForm($indent=0) { global $ID; $failure_download_link = wl($ID,array('do'=>'admin','page'=>'usermanager','fn[importfails]'=>1)); @@ -471,7 +471,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { * * @return bool whether succesful */ - private function _addUser(){ + protected function _addUser(){ global $INPUT; if (!checkSecurityToken()) return false; if (!$this->_auth->canDo('addUser')) return false; @@ -536,7 +536,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { * * @return bool whether succesful */ - private function _deleteUser(){ + protected function _deleteUser(){ global $conf, $INPUT; if (!checkSecurityToken()) return false; @@ -573,7 +573,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { * @param string $param id of the user * @return bool whether succesful */ - private function _editUser($param) { + protected function _editUser($param) { if (!checkSecurityToken()) return false; if (!$this->_auth->canDo('UserMod')) return false; $user = $this->_auth->cleanUser(preg_replace('/.*[:\/]/','',$param)); @@ -596,7 +596,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { * * @return bool whether succesful */ - private function _modifyUser(){ + protected function _modifyUser(){ global $conf, $INPUT; if (!checkSecurityToken()) return false; @@ -671,7 +671,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { * @param bool $status_alert whether status alert should be shown * @return bool whether succesful */ - private function _notifyUser($user, $password, $status_alert=true) { + protected function _notifyUser($user, $password, $status_alert=true) { if ($sent = auth_sendPassword($user,$password)) { if ($status_alert) { @@ -692,7 +692,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { * @param bool $clean whether the cleanUser method of the authentication backend is applied * @return array (user, password, full name, email, array(groups)) */ - private function _retrieveUser($clean=true) { + protected function _retrieveUser($clean=true) { /** @var DokuWiki_Auth_Plugin $auth */ global $auth; global $INPUT; @@ -717,7 +717,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { * * @param string $op 'new' or 'clear' */ - private function _setFilter($op) { + protected function _setFilter($op) { $this->_filter = array(); @@ -736,7 +736,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { * * @return array */ - private function _retrieveFilter() { + protected function _retrieveFilter() { global $INPUT; $t_filter = $INPUT->arr('filter'); @@ -755,7 +755,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { /** * Validate and improve the pagination values */ - private function _validatePagination() { + protected function _validatePagination() { if ($this->_start >= $this->_user_total) { $this->_start = $this->_user_total - $this->_pagesize; @@ -770,7 +770,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { * * @return array with enable/disable attributes */ - private function _pagination() { + protected function _pagination() { $disabled = 'disabled="disabled"'; @@ -789,7 +789,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { /** * Export a list of users in csv format using the current filter criteria */ - private function _export() { + protected function _export() { // list of users for export - based on current filter criteria $user_list = $this->_auth->retrieveUsers(0, 0, $this->_filter); $column_headings = array( @@ -825,7 +825,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { * * @return bool whether succesful */ - private function _import() { + protected function _import() { // check we are allowed to add users if (!checkSecurityToken()) return false; if (!$this->_auth->canDo('addUser')) return false; @@ -895,7 +895,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { * @param $error * @return array|bool cleaned data or false */ - private function _cleanImportUser($candidate, & $error){ + protected function _cleanImportUser($candidate, & $error){ global $INPUT; // kludgy .... @@ -943,7 +943,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { * @param string &$error reference catched error message * @return bool whether succesful */ - private function _addImportUser($user, & $error){ + protected function _addImportUser($user, & $error){ if (!$this->_auth->triggerUserMod('create', $user)) { $error = $this->lang['import_error_create']; return false; @@ -955,7 +955,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { /** * Downloads failures as csv file */ - private function _downloadImportFailures(){ + protected function _downloadImportFailures(){ // ============================================================================================== // GENERATE OUTPUT -- cgit v1.2.3