diff options
-rw-r--r-- | _test/tests/inc/parser/parser_table.test.php | 19 | ||||
-rw-r--r-- | inc/lang/el/lang.php | 7 | ||||
-rw-r--r-- | inc/lang/pt-br/editrev.txt | 2 | ||||
-rw-r--r-- | inc/lang/pt-br/index.txt | 2 | ||||
-rw-r--r-- | inc/lang/pt-br/lang.php | 8 | ||||
-rw-r--r-- | inc/lang/sl/lang.php | 7 | ||||
-rw-r--r-- | inc/parser/parser.php | 4 | ||||
-rw-r--r-- | lib/exe/css.php | 39 | ||||
-rw-r--r-- | lib/plugins/authad/lang/el/settings.php | 8 | ||||
-rw-r--r-- | lib/plugins/authad/lang/pt-br/settings.php | 2 | ||||
-rw-r--r-- | lib/plugins/usermanager/_test/csv_export.test.php | 59 | ||||
-rw-r--r-- | lib/plugins/usermanager/_test/csv_import.test.php | 185 | ||||
-rw-r--r-- | lib/plugins/usermanager/_test/mocks.class.php | 58 | ||||
-rw-r--r-- | lib/plugins/usermanager/admin.php | 44 | ||||
-rw-r--r-- | lib/plugins/usermanager/lang/pt-br/lang.php | 6 |
15 files changed, 438 insertions, 12 deletions
diff --git a/_test/tests/inc/parser/parser_table.test.php b/_test/tests/inc/parser/parser_table.test.php index 542a307b8..bc19ebff9 100644 --- a/_test/tests/inc/parser/parser_table.test.php +++ b/_test/tests/inc/parser/parser_table.test.php @@ -626,5 +626,24 @@ def'); ); $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); } + + function testTable_FS1833() { + $syntax = " \n| Row 0 Col 1 |\n"; + $this->P->addMode('table',new Doku_Parser_Mode_Table()); + $this->P->parse($syntax); + $calls = array ( + array('document_start',array()), + array('table_open',array(1, 1, 2)), + array('tablerow_open',array()), + array('tablecell_open',array(1,'left',1)), + array('cdata',array(' Row 0 Col 1 ')), + array('tablecell_close',array()), + array('tablerow_close',array()), + array('table_close',array(strlen($syntax))), + array('document_end',array()), + ); + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + } + } diff --git a/inc/lang/el/lang.php b/inc/lang/el/lang.php index 61b2fda9d..8007f2b23 100644 --- a/inc/lang/el/lang.php +++ b/inc/lang/el/lang.php @@ -2,7 +2,7 @@ /** * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) - * + * * @author Thanos Massias <tm@thriasio.gr> * @author Αθανάσιος Νταής <homunculus@wana.gr> * @author Konstantinos Koryllos <koryllos@gmail.com> @@ -10,6 +10,7 @@ * @author Petros Vidalis <pvidalis@gmail.com> * @author Vasileios Karavasilis vasileioskaravasilis@gmail.com * @author Constantinos Xanthopoulos <conx@xanthopoulos.info> + * @author chris taklis <ctaklis@gmail.com> */ $lang['encoding'] = 'utf-8'; $lang['direction'] = 'ltr'; @@ -85,6 +86,7 @@ $lang['profchanged'] = 'Το προφίλ χρήστη τροποπο $lang['profnodelete'] = 'Το wiki δεν υποστηρίζει την διαγραφή χρηστών'; $lang['profdeleteuser'] = 'Διαγραφή λογαριασμού'; $lang['profdeleted'] = 'Ο λογαριασμός διαγράφηκε από αυτό το wiki'; +$lang['profconfdelete'] = 'Επιθυμώ να διαγράψω τον λογαριασμό μου από αυτό το wiki. <br/> Αυτή η επιλογή δεν μπορεί να αναιρεθεί.'; $lang['pwdforget'] = 'Ξεχάσατε το κωδικό σας; Αποκτήστε νέο.'; $lang['resendna'] = 'Αυτό το wiki δεν υποστηρίζει την εκ\' νέου αποστολή κωδικών.'; $lang['resendpwd'] = 'Εισαγωγή νέου ωδικού για'; @@ -291,6 +293,7 @@ $lang['i_policy'] = 'Αρχική πολιτική Λίστας Δ $lang['i_pol0'] = 'Ανοιχτό Wiki (όλοι μπορούν να διαβάσουν ή να δημιουργήσουν/τροποποιήσουν σελίδες και να μεταφορτώσουν αρχεία)'; $lang['i_pol1'] = 'Δημόσιο Wiki (όλοι μπορούν να διαβάσουν σελίδες αλλά μόνο οι εγγεγραμμένοι χρήστες μπορούν να δημιουργήσουν/τροποποιήσουν σελίδες και να μεταφορτώσουν αρχεία)'; $lang['i_pol2'] = 'Κλειστό Wiki (μόνο οι εγγεγραμμένοι χρήστες μπορούν να διαβάσουν ή να δημιουργήσουν/τροποποιήσουν σελίδες και να μεταφορτώσουν αρχεία)'; +$lang['i_allowreg'] = 'Οι χρήστες επιτρέπεται να εγγραφούν μόνοι τους'; $lang['i_retry'] = 'Νέα προσπάθεια'; $lang['i_license'] = 'Παρακαλώ επιλέξτε την άδεια που θα χρησιμοποιήσετε για την διάθεση του περιεχομένου σας:'; $lang['recent_global'] = 'Βλέπετε τις αλλαγές εντός του φακέλου <b>%s</b>. Μπορείτε επίσης να <a href="%s">δείτε τις πρόσφατες αλλαγές σε όλο το wiki</a>.'; @@ -319,8 +322,10 @@ $lang['media_search'] = 'Αναζήτηση στο <strong>%s</strong> $lang['media_view'] = '%s'; $lang['media_viewold'] = '%s στα %s'; $lang['media_edit'] = 'Επεξεργασία %s'; +$lang['media_history'] = 'Ιστορικό των %s'; $lang['media_meta_edited'] = 'τα μεταδεδομένα επεξεργάστηκαν'; $lang['media_perm_read'] = 'Συγνώμη, δεν έχετε επαρκή διακαιώματα για να διαβάσετε αυτά τα αρχεία.'; $lang['media_perm_upload'] = 'Συγνώμη, δεν έχετε επαρκή διακαιώματα για να φορτώσετε αυτά τα αρχεία.'; $lang['media_update'] = 'Φόρτωση νέας έκδοσης'; $lang['media_restore'] = 'Επαναφορά αυτή της έκδοσης'; +$lang['searchresult'] = 'Αποτέλεσμα έρευνας'; diff --git a/inc/lang/pt-br/editrev.txt b/inc/lang/pt-br/editrev.txt index c7aa47878..df6413525 100644 --- a/inc/lang/pt-br/editrev.txt +++ b/inc/lang/pt-br/editrev.txt @@ -1,4 +1,4 @@ -**Você carregou uma revisão antiga desse documento!** Se você salvá-la, irá criar uma nova versão em esses dados. +**Você carregou uma revisão antiga desse documento!** Se você salvá-la, irá criar uma nova versão com esses dados. ---- diff --git a/inc/lang/pt-br/index.txt b/inc/lang/pt-br/index.txt index a7d17a2bc..816a49952 100644 --- a/inc/lang/pt-br/index.txt +++ b/inc/lang/pt-br/index.txt @@ -1,3 +1,3 @@ ====== Índice ====== -Esse é um índice de todas as páginas disponíveis, ordenadas por [[doku>namespaces|espaços de nomes]].
\ No newline at end of file +Esse é um índice de todas as páginas disponíveis, ordenadas por [[doku>namespaces|domínios]].
\ No newline at end of file diff --git a/inc/lang/pt-br/lang.php b/inc/lang/pt-br/lang.php index 812799f04..6845e792d 100644 --- a/inc/lang/pt-br/lang.php +++ b/inc/lang/pt-br/lang.php @@ -22,6 +22,7 @@ * @author Victor Westmann <victor.westmann@gmail.com> * @author Leone Lisboa Magevski <leone1983@gmail.com> * @author Dário Estevão <darioems@gmail.com> + * @author Juliano Marconi Lanigra <juliano.marconi@gmail.com> */ $lang['encoding'] = 'utf-8'; $lang['direction'] = 'ltr'; @@ -97,6 +98,8 @@ $lang['profchanged'] = 'O perfil do usuário foi atualizado com sucess $lang['profnodelete'] = 'Esse wiki não suporta a exclusão de usuários '; $lang['profdeleteuser'] = 'Excluir a conta'; $lang['profdeleted'] = 'Sua conta de usuário foi excluída desse wiki'; +$lang['profconfdelete'] = 'Eu desejo remover minha conta dessa wiki. <br/> Essa ação não pode ser desfeita.'; +$lang['profconfdeletemissing'] = 'Caixa de confirmação não marcada'; $lang['pwdforget'] = 'Esqueceu sua senha? Solicite outra'; $lang['resendna'] = 'Esse wiki não tem suporte para o reenvio de senhas.'; $lang['resendpwd'] = 'Definir a nova senha para'; @@ -304,6 +307,7 @@ $lang['i_policy'] = 'Política inicial de permissões'; $lang['i_pol0'] = 'Wiki aberto (leitura, escrita e envio de arquivos por todos)'; $lang['i_pol1'] = 'Wiki público (leitura por todos, escrita e envio de arquivos por usuários registrados)'; $lang['i_pol2'] = 'Wiki fechado (leitura, escrita e envio de arquivos somente por usuários registrados)'; +$lang['i_allowreg'] = 'Permite usuários se registrarem'; $lang['i_retry'] = 'Tentar novamente'; $lang['i_license'] = 'Por favor escolha a licença que voce deseja utilizar para seu conteúdo:'; $lang['i_license_none'] = 'Não mostrar nenhuma informação da licença'; @@ -341,3 +345,7 @@ $lang['media_perm_read'] = 'Desculpe, mas você não tem privilégios sufi $lang['media_perm_upload'] = 'Desculpe, mas você não tem privilégios suficientes para enviar arquivos.'; $lang['media_update'] = 'Enviar uma nova versão'; $lang['media_restore'] = 'Restaurar esta versão'; +$lang['currentns'] = 'Domínio atual'; +$lang['searchresult'] = 'Resultado da Busca'; +$lang['plainhtml'] = 'HTML simples'; +$lang['wikimarkup'] = 'Marcação wiki'; diff --git a/inc/lang/sl/lang.php b/inc/lang/sl/lang.php index 2f69163f5..371b6659d 100644 --- a/inc/lang/sl/lang.php +++ b/inc/lang/sl/lang.php @@ -2,7 +2,7 @@ /** * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) - * + * * @author Jaka Kranjc <lynxlupodian@hotmail.com> * @author Boštjan Seničar <senicar@gmail.com> * @author Dejan Levec <webphp@gmail.com> @@ -195,6 +195,7 @@ $lang['user_tools'] = 'Uporabniška orodja'; $lang['site_tools'] = 'Orodja spletišča'; $lang['page_tools'] = 'Orodja strani'; $lang['skip_to_content'] = 'preskoči na vsebino'; +$lang['sidebar'] = 'Stranska vrstica'; $lang['mail_newpage'] = '[DokuWiki] stran dodana:'; $lang['mail_changed'] = '[DokuWiki] stran spremenjena:'; $lang['mail_subscribe_list'] = 'strani s spremenjenim imenom:'; @@ -284,6 +285,7 @@ $lang['i_policy'] = 'Začetna določila ACL'; $lang['i_pol0'] = 'Odprt Wiki (branje, zapis, nalaganje datotek je javno za vse)'; $lang['i_pol1'] = 'Javni Wiki (branje za vse, zapis in nalaganje datotek za prijavljene uporabnike)'; $lang['i_pol2'] = 'Zaprt Wiki (berejo in urejajo lahko le prijavljeni uporabniki)'; +$lang['i_allowreg'] = 'Dovoli uporabnikom vpis'; $lang['i_retry'] = 'Ponovni poskus'; $lang['i_license'] = 'Izbor dovoljenja objave vsebine:'; $lang['i_license_none'] = 'Ne pokaži podrobnosti dovoljenja.'; @@ -319,3 +321,6 @@ $lang['media_perm_read'] = 'Ni ustreznih dovoljenj za branje datotek.'; $lang['media_perm_upload'] = 'Ni ustreznih dovoljenj za nalaganje datotek.'; $lang['media_update'] = 'Naloži novo različico'; $lang['media_restore'] = 'Obnovi to različico'; +$lang['currentns'] = 'Trenutni imenski prostor'; +$lang['searchresult'] = 'Rezultati iskanja'; +$lang['plainhtml'] = 'Zapis HTML'; diff --git a/inc/parser/parser.php b/inc/parser/parser.php index e39a4daf5..1f14b98a3 100644 --- a/inc/parser/parser.php +++ b/inc/parser/parser.php @@ -454,8 +454,8 @@ class Doku_Parser_Mode_table extends Doku_Parser_Mode { } function connectTo($mode) { - $this->Lexer->addEntryPattern('\s*\n\^',$mode,'table'); - $this->Lexer->addEntryPattern('\s*\n\|',$mode,'table'); + $this->Lexer->addEntryPattern('[\t ]*\n\^',$mode,'table'); + $this->Lexer->addEntryPattern('[\t ]*\n\|',$mode,'table'); } function postConnect() { diff --git a/lib/exe/css.php b/lib/exe/css.php index c2540cc03..c96dedd37 100644 --- a/lib/exe/css.php +++ b/lib/exe/css.php @@ -312,6 +312,11 @@ function css_styleini($tpl) { ); } +/** + * Amend paths used in replacement relative urls, refer FS#2879 + * + * @author Chris Smith <chris@jalakai.co.uk> + */ function css_fixreplacementurls($replacements, $location) { foreach($replacements as $key => $value) { $replacements[$key] = preg_replace('#(url\([ \'"]*)(?!/|data:|http://|https://| |\'|")#','\\1'.$location,$value); @@ -400,16 +405,29 @@ function css_loadfile($file,$location=''){ return $css_file->load($location); } +/** + * Helper class to abstract loading of css/less files + * + * @author Chris Smith <chris@jalakai.co.uk> + */ class DokuCssFile { - protected $filepath; - protected $location; + protected $filepath; // file system path to the CSS/Less file + protected $location; // base url location of the CSS/Less file private $relative_path = null; public function __construct($file) { $this->filepath = $file; } + /** + * Load the contents of the css/less file and adjust any relative paths/urls (relative to this file) to be + * relative to the dokuwiki root: the web root (DOKU_BASE) for most files; the file system root (DOKU_INC) + * for less files. + * + * @param string $location base url for this file + * @return string the CSS/Less contents of the file + */ public function load($location='') { if (!@file_exists($this->filepath)) return ''; @@ -424,10 +442,17 @@ class DokuCssFile { return $css; } + /** + * Get the relative file system path of this file, relative to dokuwiki's root folder, DOKU_INC + * + * @return string relative file system path + */ private function getRelativePath(){ if (is_null($this->relative_path)) { $basedir = array(DOKU_INC); + + // during testing, files may be found relative to a second base dir, TMP_DIR if (defined('DOKU_UNITTEST')) { $basedir[] = realpath(TMP_DIR); } @@ -439,16 +464,26 @@ class DokuCssFile { return $this->relative_path; } + /** + * preg_replace callback to adjust relative urls from relative to this file to relative + * to the appropriate dokuwiki root location as described in the code + * + * @param array see http://php.net/preg_replace_callback + * @return string see http://php.net/preg_replace_callback + */ public function replacements($match) { + // not a relative url? - no adjustment required if (preg_match('#^(/|data:|https?://)#',$match[3])) { return $match[0]; } + // a less file import? - requires a file system location else if (substr($match[3],-5) == '.less') { if ($match[3]{0} != '/') { $match[3] = $this->getRelativePath() . '/' . $match[3]; } } + // everything else requires a url adjustment else { $match[3] = $this->location . $match[3]; } diff --git a/lib/plugins/authad/lang/el/settings.php b/lib/plugins/authad/lang/el/settings.php new file mode 100644 index 000000000..9bf23ea1c --- /dev/null +++ b/lib/plugins/authad/lang/el/settings.php @@ -0,0 +1,8 @@ +<?php + +/** + * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) + * + * @author chris taklis <ctaklis@gmail.com> + */ +$lang['admin_password'] = 'Ο κωδικός του παραπάνω χρήστη.'; diff --git a/lib/plugins/authad/lang/pt-br/settings.php b/lib/plugins/authad/lang/pt-br/settings.php index 76fb419a6..cdc748055 100644 --- a/lib/plugins/authad/lang/pt-br/settings.php +++ b/lib/plugins/authad/lang/pt-br/settings.php @@ -5,6 +5,7 @@ * * @author Victor Westmann <victor.westmann@gmail.com> * @author Frederico Guimarães <frederico@teia.bio.br> + * @author Juliano Marconi Lanigra <juliano.marconi@gmail.com> */ $lang['account_suffix'] = 'Sufixo de sua conta. Eg. <code>@meu.domínio.org</code>'; $lang['base_dn'] = 'Sua base DN. Eg. <code>DC=meu,DC=domínio,DC=org</code>'; @@ -12,6 +13,7 @@ $lang['domain_controllers'] = 'Uma lista de controles de domínios separada p $lang['admin_username'] = 'Um usuário do Active Directory com privilégios para acessar os dados de todos os outros usuários. Opcional, mas necessário para realizar certas ações, tais como enviar mensagens de assinatura.'; $lang['admin_password'] = 'A senha do usuário acima.'; $lang['sso'] = 'Usar Single-Sign-On através do Kerberos ou NTLM?'; +$lang['sso_charset'] = 'A codificação de caracteres que seu servidor web passará o nome de usuário Kerberos ou NTLM. Vazio para UTF-8 ou latin-1. Requere a extensão iconv.'; $lang['real_primarygroup'] = 'O grupo primário real deve ser resolvido ao invés de assumirmos como "Usuários do Domínio" (mais lento)'; $lang['use_ssl'] = 'Usar conexão SSL? Se usar, não habilitar TLS abaixo.'; $lang['use_tls'] = 'Usar conexão TLS? se usar, não habilitar SSL acima.'; diff --git a/lib/plugins/usermanager/_test/csv_export.test.php b/lib/plugins/usermanager/_test/csv_export.test.php new file mode 100644 index 000000000..667fc71dc --- /dev/null +++ b/lib/plugins/usermanager/_test/csv_export.test.php @@ -0,0 +1,59 @@ +<?php + +/** + * @group plugin_usermanager + * @group admin_plugins + * @group plugins + * @group bundled_plugins + */ +require_once(dirname(__FILE__).'/mocks.class.php'); + +class plugin_usermanager_csv_export_test extends DokuWikiTest { + + protected $usermanager; + + function setUp() { + $this->usermanager = new admin_mock_usermanager(); + parent::setUp(); + } + + /** + * based on standard test user/conf setup + * + * users per _test/conf/users.auth.php + * expected to be: testuser:179ad45c6ce2cb97cf1029e212046e81:Arthur Dent:arthur@example.com + */ + function test_export() { + $expected = 'User,"Real Name",Email,Groups +testuser,"Arthur Dent",arthur@example.com, +'; + $this->assertEquals($expected, $this->usermanager->tryExport()); + } + + /** + * when configured to use a different locale, the column headings in the first line of the + * exported csv data should reflect the langauge strings of that locale + */ + function test_export_withlocale(){ + global $conf; + $old_conf = $conf; + $conf['lang'] = 'de'; + + $this->usermanager->localised = false; + $this->usermanager->setupLocale(); + + $conf = $old_conf; + + $expected = 'Benutzername,"Voller Name",E-Mail,Gruppen +testuser,"Arthur Dent",arthur@example.com, +'; + $this->assertEquals($expected, $this->usermanager->tryExport()); + } +/* + function test_export_withfilter(){ + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } +*/ +} diff --git a/lib/plugins/usermanager/_test/csv_import.test.php b/lib/plugins/usermanager/_test/csv_import.test.php new file mode 100644 index 000000000..3968356bc --- /dev/null +++ b/lib/plugins/usermanager/_test/csv_import.test.php @@ -0,0 +1,185 @@ +<?php + +/** + * @group plugin_usermanager + * @group admin_plugins + * @group plugins + * @group bundled_plugins + */ + +require_once(dirname(__FILE__).'/mocks.class.php'); + +/** + * !!!!! NOTE !!!!! + * + * At present, users imported in individual tests remain in the user list for subsequent tests + */ +class plugin_usermanager_csv_import_test extends DokuWikiTest { + + private $old_files; + protected $usermanager; + protected $importfile; + + function setUp() { + $this->importfile = tempnam(TMP_DIR, 'csv'); + + $this->old_files = $_FILES; + $_FILES = array( + 'import' => array( + 'name' => 'import.csv', + 'tmp_name' => $this->importfile, + 'type' => 'text/plain', + 'size' => 1, + 'error' => 0, + ), + ); + + $this->usermanager = new admin_mock_usermanager(); + parent::setUp(); + } + + function tearDown() { + $_FILES = $this->old_files; + parent::tearDown(); + } + + function doImportTest($importCsv, $expectedResult, $expectedNewUsers, $expectedFailures) { + global $auth; + $before_users = $auth->retrieveUsers(); + + io_savefile($this->importfile, $importCsv); + $result = $this->usermanager->tryImport(); + + $after_users = $auth->retrieveUsers(); + $import_count = count($after_users) - count($before_users); + $new_users = array_diff_key($after_users, $before_users); + $diff_users = array_diff_assoc($after_users, $before_users); + + $expectedCount = count($expectedNewUsers); + + $this->assertEquals($expectedResult, $result); // import result as expected + $this->assertEquals($expectedCount, $import_count); // number of new users matches expected number imported + $this->assertEquals($expectedNewUsers, $this->stripPasswords($new_users)); // new user data matches imported user data + $this->assertEquals($expectedCount, $this->countPasswords($new_users)); // new users have a password + $this->assertEquals($expectedCount, $this->usermanager->mock_email_notifications_sent); // new users notified of their passwords + $this->assertEquals($new_users, $diff_users); // no other users were harmed in the testing of this import + $this->assertEquals($expectedFailures, $this->usermanager->getImportFailures()); // failures as expected + } + + function test_cantImport(){ + global $auth; + $oldauth = $auth; + + $auth = new auth_mock_authplain(); + $auth->setCanDo('addUser', false); + + $csv = 'User,"Real Name",Email,Groups +importuser,"Ford Prefect",ford@example.com,user +'; + + $this->doImportTest($csv, false, array(), array()); + + $auth = $oldauth; + } + + function test_import() { + $csv = 'User,"Real Name",Email,Groups +importuser,"Ford Prefect",ford@example.com,user +'; + $expected = array( + 'importuser' => array( + 'name' => 'Ford Prefect', + 'mail' => 'ford@example.com', + 'grps' => array('user'), + ), + ); + + $this->doImportTest($csv, true, $expected, array()); + } + + function test_importExisting() { + $csv = 'User,"Real Name",Email,Groups +importuser,"Ford Prefect",ford@example.com,user +'; + $failures = array( + '2' => array( + 'error' => $this->usermanager->lang['import_error_create'], + 'user' => array( + 'importuser', + 'Ford Prefect', + 'ford@example.com', + 'user', + ), + 'orig' => 'importuser,"Ford Prefect",ford@example.com,user'.NL, + ), + ); + + $this->doImportTest($csv, true, array(), $failures); + } + + function test_importUtf8() { + $csv = 'User,"Real Name",Email,Groups +importutf8,"Førd Prefect",ford@example.com,user +'; + $expected = array( + 'importutf8' => array( + 'name' => 'Førd Prefect', + 'mail' => 'ford@example.com', + 'grps' => array('user'), + ), + ); + + $this->doImportTest($csv, true, $expected, array()); + } + + /** + * utf8: u+00F8 (ø) <=> 0xF8 :iso-8859-1 + */ + function test_importIso8859() { + $csv = 'User,"Real Name",Email,Groups +importiso8859,"F'.chr(0xF8).'rd Prefect",ford@example.com,user +'; + $expected = array( + 'importiso8859' => array( + 'name' => 'Førd Prefect', + 'mail' => 'ford@example.com', + 'grps' => array('user'), + ), + ); + + $this->doImportTest($csv, true, $expected, array()); + } + + /** + * Verify usermanager::str_getcsv() behaves identically to php 5.3's str_getcsv() + * within the context/parameters required by _import() + * + * @requires PHP 5.3 + * @deprecated remove when dokuwiki requires 5.3+ + * also associated usermanager & mock usermanager access methods + */ + function test_getcsvcompatibility() { + $line = 'importuser,"Ford Prefect",ford@example.com,user'.NL; + + $this->assertEquals(str_getcsv($line), $this->usermanager->access_str_getcsv($line)); + } + + private function stripPasswords($array){ + foreach ($array as $user => $data) { + unset($array[$user]['pass']); + } + return $array; + } + + private function countPasswords($array){ + $count = 0; + foreach ($array as $user => $data) { + if (!empty($data['pass'])) { + $count++; + } + } + return $count; + } + +} + diff --git a/lib/plugins/usermanager/_test/mocks.class.php b/lib/plugins/usermanager/_test/mocks.class.php new file mode 100644 index 000000000..91c74768c --- /dev/null +++ b/lib/plugins/usermanager/_test/mocks.class.php @@ -0,0 +1,58 @@ +<?php + +/** + * test wrapper to allow access to private/protected functions/properties + * + * NB: for plugin introspection methods, getPluginType() & getPluginName() to work + * this class name needs to start "admin_" and end "_usermanager". Internally + * these methods are used in setting up the class, e.g. for language strings + */ +class admin_mock_usermanager extends admin_plugin_usermanager { + + public $mock_email_notifications = true; + public $mock_email_notifications_sent = 0; + + public function getImportFailures() { + return $this->_import_failures; + } + + public function tryExport() { + ob_start(); + $this->_export(); + return ob_get_clean(); + } + + public function tryImport() { + return $this->_import(); + } + + /** + * @deprecated remove when dokuwiki requires php 5.3+ + * also associated unit test & usermanager methods + */ + public function access_str_getcsv($line){ + return $this->str_getcsv($line); + } + + // no need to send email notifications (mostly) + protected function _notifyUser($user, $password, $status_alert=true) { + if ($this->mock_email_notifications) { + $this->mock_email_notifications_sent++; + return true; + } else { + return parent::_notifyUser($user, $password, $status_alert); + } + } + + protected function _isUploadedFile($file) { + return file_exists($file); + } +} + +class auth_mock_authplain extends auth_plugin_authplain { + + public function setCanDo($op, $canDo) { + $this->cando[$op] = $canDo; + } + +} diff --git a/lib/plugins/usermanager/admin.php b/lib/plugins/usermanager/admin.php index c4d71cb22..156037f09 100644 --- a/lib/plugins/usermanager/admin.php +++ b/lib/plugins/usermanager/admin.php @@ -814,6 +814,8 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { fputcsv($fd, $line); } fclose($fd); + if (defined('DOKU_UNITTEST')){ return; } + die; } @@ -822,7 +824,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { * * csv file should have 4 columns, user_id, full name, email, groups (comma separated) * - * @return bool whether succesful + * @return bool whether successful */ protected function _import() { // check we are allowed to add users @@ -830,7 +832,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { 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'])) { + if (empty($_FILES['import']['size']) || !empty($_FILES['import']['error']) && $this->_isUploadedFile($_FILES['import']['tmp_name'])) { msg($this->lang['import_error_upload'],-1); return false; } @@ -845,7 +847,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { if (!utf8_check($csv)) { $csv = utf8_encode($csv); } - $raw = str_getcsv($csv); + $raw = $this->_getcsv($csv); $error = ''; // clean out any errors from the previous line // data checks... if (1 == ++$line) { @@ -867,6 +869,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { $import_success_count++; } else { $import_fail_count++; + array_splice($raw, 1, 1); // remove the spliced in password $this->_import_failures[$line] = array('error' => $error, 'user' => $raw, 'orig' => $csv); } } @@ -940,7 +943,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { * * @param array $user data of user * @param string &$error reference catched error message - * @return bool whether succesful + * @return bool whether successful */ protected function _addImportUser($user, & $error){ if (!$this->_auth->triggerUserMod('create', $user)) { @@ -973,4 +976,37 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { die; } + /** + * wrapper for is_uploaded_file to facilitate overriding by test suite + */ + protected function _isUploadedFile($file) { + return is_uploaded_file($file); + } + + /** + * wrapper for str_getcsv() to simplify maintaining compatibility with php 5.2 + * + * @deprecated remove when dokuwiki php requirement increases to 5.3+ + * also associated unit test & mock access method + */ + protected function _getcsv($csv) { + return function_exists('str_getcsv') ? str_getcsv($csv) : $this->str_getcsv($csv); + } + + /** + * replacement str_getcsv() function for php < 5.3 + * loosely based on www.php.net/str_getcsv#88311 + * + * @deprecated remove when dokuwiki php requirement increases to 5.3+ + */ + protected function str_getcsv($str) { + $fp = fopen("php://temp/maxmemory:1048576", 'r+'); // 1MiB + fputs($fp, $str); + rewind($fp); + + $data = fgetcsv($fp); + + fclose($fp); + return $data; + } } diff --git a/lib/plugins/usermanager/lang/pt-br/lang.php b/lib/plugins/usermanager/lang/pt-br/lang.php index 9bb37742a..356d139eb 100644 --- a/lib/plugins/usermanager/lang/pt-br/lang.php +++ b/lib/plugins/usermanager/lang/pt-br/lang.php @@ -20,6 +20,7 @@ * @author Victor Westmann <victor.westmann@gmail.com> * @author Leone Lisboa Magevski <leone1983@gmail.com> * @author Dário Estevão <darioems@gmail.com> + * @author Juliano Marconi Lanigra <juliano.marconi@gmail.com> */ $lang['menu'] = 'Gerenciamento de Usuários'; $lang['noauth'] = '(o gerenciamento de usuários não está disponível)'; @@ -43,6 +44,7 @@ $lang['search_prompt'] = 'Executar a pesquisa'; $lang['clear'] = 'Limpar o filtro de pesquisa'; $lang['filter'] = 'Filtro'; $lang['export_all'] = 'Exportar Todos Usuários (CSV)'; +$lang['export_filtered'] = 'Exportar lista de Usuários Filtrados (CSV)'; $lang['import'] = 'Importar Novos Usuários'; $lang['line'] = 'Linha Nº.'; $lang['error'] = 'Mensagem de Erro'; @@ -66,6 +68,8 @@ $lang['add_ok'] = 'O usuário foi adicionado com sucesso'; $lang['add_fail'] = 'O usuário não foi adicionado'; $lang['notify_ok'] = 'O e-mail de notificação foi enviado'; $lang['notify_fail'] = 'Não foi possível enviar o e-mail de notificação'; +$lang['import_userlistcsv'] = 'Arquivo de lista de usuários (CSV):'; +$lang['import_header'] = 'Importações Mais Recentes - Falhas'; $lang['import_success_count'] = 'Importação de Usuário: %d usuário (s) encontrado (s), %d importado (s) com sucesso.'; $lang['import_failure_count'] = 'Importação de Usuário: %d falhou. As falhas estão listadas abaixo.'; $lang['import_error_fields'] = 'Campos insuficientes, encontrado (s) %d, necessário 4.'; @@ -75,3 +79,5 @@ $lang['import_error_badmail'] = 'Endereço de email errado'; $lang['import_error_upload'] = 'Falha na Importação: O arquivo csv não pode ser carregado ou está vazio.'; $lang['import_error_readfail'] = 'Falha na Importação: Habilitar para ler o arquivo a ser carregado.'; $lang['import_error_create'] = 'Habilitar para criar o usuário.'; +$lang['import_notify_fail'] = 'Mensagem de notificação não pode ser enviada para o usuário importado, %s com email %s.'; +$lang['import_downloadfailures'] = 'Falhas no Download como CSV para correção'; |