Skip to content

Commit

Permalink
Fix localization
Browse files Browse the repository at this point in the history
  • Loading branch information
annda committed May 16, 2019
1 parent 7097fb7 commit 247b5bf
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 24 deletions.
24 changes: 24 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Extended User Import Plugin for DokuWiki

You can import user passwords and set some defaults to , e.g. email

If you install this plugin manually, make sure it is installed in
lib/plugins/userimportextended/ - if the folder is called different it
will not work!

Please refer to http://www.dokuwiki.org/plugins for additional info
on how to install plugins in DokuWiki.

----
Copyright (C) Anna Dabrowska <dokuwiki@cosmocode.de>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

See the LICENSING file for details
48 changes: 25 additions & 23 deletions admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,23 +104,25 @@ protected function printFormHTML()
*/
protected function printFailuresHTML()
{
var_dump($this->lang);

global $ID;
$failure_download_link = wl($ID,array('do'=>'admin','page'=>'userimportextended','cmd[importfails]'=>1));

if ($this->_import_failures) {
$digits = strlen(count($this->_import_failures));
ptln('<div class="level3 import_failures">');
ptln(' <h3>'.$this->lang['import_header'].'</h3>');
ptln(' <h3>'.$this->getLang('import_header').'</h3>');
ptln(' <table class="import_failures">');
ptln(' <thead>');
ptln(' <tr>');
ptln(' <th class="line">'.$this->lang['line'].'</th>');
ptln(' <th class="error">'.$this->lang['error'].'</th>');
ptln(' <th class="userid">'.$this->lang['user_id'].'</th>');
ptln(' <th class="userpass">'.$this->lang['user_pass'].'</th>');
ptln(' <th class="username">'.$this->lang['user_name'].'</th>');
ptln(' <th class="usermail">'.$this->lang['user_mail'].'</th>');
ptln(' <th class="usergroups">'.$this->lang['user_groups'].'</th>');
ptln(' <th class="line">'.$this->getLang('line').'</th>');
ptln(' <th class="error">'.$this->getLang('error').'</th>');
ptln(' <th class="userid">'.$this->getLang('user_id').'</th>');
ptln(' <th class="userpass">'.$this->getLang('user_pass').'</th>');
ptln(' <th class="username">'.$this->getLang('user_name').'</th>');
ptln(' <th class="usermail">'.$this->getLang('user_mail').'</th>');
ptln(' <th class="usergroups">'.$this->getLang('user_groups').'</th>');
ptln(' </tr>');
ptln(' </thead>');
ptln(' <tbody>');
Expand All @@ -137,7 +139,7 @@ protected function printFailuresHTML()
}
ptln(' </tbody>');
ptln(' </table>');
ptln(' <p><a href="'.$failure_download_link.'">'.$this->lang['import_downloadfailures'].'</a></p>');
ptln(' <p><a href="'.$failure_download_link.'">'.$this->getLang('import_downloadfailures').'</a></p>');
ptln('</div>');
}
}
Expand Down Expand Up @@ -179,7 +181,7 @@ protected function _import() {
// check file uploaded ok.
$upl = $this->_isUploadedFile($_FILES['import']['tmp_name']);
if (empty($_FILES['import']['size']) || !empty($_FILES['import']['error']) && $upl) {
msg($this->lang['import_error_upload'],-1);
msg($this->getLang('import_error_upload'),-1);
return false;
}
// retrieve users from the file
Expand All @@ -197,12 +199,12 @@ protected function _import() {
$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 ($raw[0] == 'user_id' || $raw[0] == $this->getLang('user_id')) continue; // skip headers
}
// in contrast to User Manager, 5 columns are required
if (count($raw) < 5) { // need at least five fields
$import_fail_count++;
$error = sprintf($this->lang['import_error_fields'], count($raw));
$error = sprintf($this->getLang('import_error_fields'), count($raw));
$this->_import_failures[$line] = array('error' => $error, 'user' => $raw, 'orig' => $csv);
continue;
}
Expand All @@ -211,20 +213,20 @@ protected function _import() {
if ($clean && $this->_addImportUser($clean, $error)) {
$sent = $this->_notifyUser($clean[0],$clean[1],false);
if (!$sent){
msg(sprintf($this->lang['import_notify_fail'],$clean[0],$clean[3]),-1);
msg(sprintf($this->getLang('import_notify_fail'),$clean[0],$clean[3]),-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));
msg(sprintf($this->getLang('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);
msg(sprintf($this->getLang('import_failure_count'), $import_fail_count),-1);
}
} else {
msg($this->lang['import_error_readfail'],-1);
msg($this->getLang('import_error_readfail'),-1);
}

// save import failures into the session
Expand Down Expand Up @@ -280,25 +282,25 @@ protected function _cleanImportUser($candidate, &$error) {
$cleaned = $this->_retrieveUser();
list($user,/* $pass */,$name,$mail,/* $grps */) = $cleaned;
if (empty($user)) {
$error = $this->lang['import_error_baduserid'];
$error = $this->getLang('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'];
$error = $this->getLang('import_error_badname');
return false;
}

if ($this->_auth->canDo('modMail')) {
if (empty($mail) || !mail_isvalid($mail)) {
$error = $this->lang['import_error_badmail'];
$error = $this->getLang('import_error_badmail');
return false;
}
} else {
if (!empty($mail)) {
$error = $this->lang['import_error_badmail'];
$error = $this->getLang('import_error_badmail');
return false;
}
}
Expand All @@ -317,7 +319,7 @@ protected function _cleanImportUser($candidate, &$error) {
*/
protected function _addImportUser($user, & $error){
if (!$this->_auth->triggerUserMod('create', $user)) {
$error = $this->lang['import_error_create'];
$error = $this->getLang('import_error_create');
return false;
}

Expand Down Expand Up @@ -364,11 +366,11 @@ protected function _notifyUser($user, $password, $status_alert=true) {
$sent = auth_sendPassword($user,$password);
if ($sent) {
if ($status_alert) {
msg($this->lang['notify_ok'], 1);
msg($this->getLang('notify_ok'), 1);
}
} else {
if ($status_alert) {
msg($this->lang['notify_fail'], -1);
msg($this->getLang('notify_fail'), -1);
}
}

Expand Down
2 changes: 1 addition & 1 deletion plugin.info.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ base userimportextended
author Anna Dabrowska
email dokuwiki@cosmocode.de
date 2019-05-14
name userimport plugin
name User import extended
desc Extended CSV import with passwords and default values, based on User Manager
url http://www.dokuwiki.org/plugin:userimportextended

0 comments on commit 247b5bf

Please sign in to comment.