diff --git a/QRcodes.php b/QRcodes.php index 9530cd0..73a476c 100644 --- a/QRcodes.php +++ b/QRcodes.php @@ -141,7 +141,7 @@ $id_m = $member->id; //Créer QRcode PassagesDeGrades - if (!file_exists(PLUGIN_QRCODE_DATA_PATH . "$id_adh.png")){ + if (file_exists(PLUGIN_QRCODE_DATA_PATH . "$id_adh.png")){ unlink(PLUGIN_QRCODE_DATA_PATH . "$id_adh.png"); if (defined('PASSAGESDEGRADES_PREFIX')) { QRcode::png(PASSAGESDEGRADES_PREFIX . "PassagesDeGrades.php?id_adh=$id_adh", PLUGIN_QRCODE_DATA_PATH . "$id_adh.png", "L", 4, 4); diff --git a/_define.php b/_define.php index 57c9622..c7fc647 100644 --- a/_define.php +++ b/_define.php @@ -36,11 +36,14 @@ */ $this->register( - 'Galette QRCodes', //Name - 'Génération de QRcodes', //Short description - 'Frédéric LASSAVE', //Author - '1.2.1', //Version - '0.8.2.3', //Galette compatible version - '2017-03-29', //Release date - null //Permissions needed - not yet implemented + 'Galette QRCodes', //Name + 'Génération de QRcodes', //Short description + 'Frédéric LASSAVE', //Author + '1.3.0dev', //Version + '0.9', //Galette compatible version + 'qrcodes', //routing name and translation domain + '2017-12-23', //Release date + [ //Permissions needed + 'generate_qrcode_member' => 'groupmanager' //FIXME original code does not set access restrictions + ] ); diff --git a/_routes.php b/_routes.php new file mode 100644 index 0000000..92a98e7 --- /dev/null +++ b/_routes.php @@ -0,0 +1,137 @@ +. + * + * @category Plugins + * @package GaletteMaps + * + * @author Johan Cwiklinski + * @copyright 2016 The Galette Team + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version + * @version SVN: $Id$ + * @link http://galette.tuxfamily.org + * @since 0.9dev 2016-03-02 + */ + +use Galette\Entity\Adherent; + +//Constants and classes from plugin +require_once $module['root'] . '/_config.inc.php'; + +$this->get( + __('/member', 'qrcodes_routes') . __('/qrcode', 'qrcodes_routes') . '/{id:\d+}', + function ($request, $response, $args) use ($module, $module_id) { + $id = $args['id']; + include_once __DIR__ . '/includes/t0k4rt-phpqrcode-d213c48/qrlib.php'; + + $deps = array( + 'picture' => false, + 'groups' => false, + 'dues' => false, + 'parent' => true, + ); + $member = new Adherent($this->zdb, (int)$id, $deps); + + //generate phone QR code + $phone = $member->phone; + if (file_exists(PLUGIN_QRCODE_DATA_PATH . "$id.tel.png")) { + unlink(PLUGIN_QRCODE_DATA_PATH . "$id.tel.png"); + } + + //if member phone is missing but there is a parent, + //take the parent phone + if (empty($phone) && $member->hasParent()) { + $phone = $member->parent->phone; + } + + if (!empty($phone)) { + QRcode::png("tel:$phone", PLUGIN_QRCODE_DATA_PATH . "$id.tel.png", "L", 4, 4); + } + + //generate mail QR code + //Créer QRcode Mail + $email = $member->getEmail(); + if (file_exists(PLUGIN_QRCODE_DATA_PATH . "$id.mail.png")) { + unlink(PLUGIN_QRCODE_DATA_PATH . "$id.mail.png"); + } + + if (!empty($email)) { + QRcode::png("mailto:$email", PLUGIN_QRCODE_DATA_PATH . "$id.mail.png", "L", 4, 4); + } + + return $response + ->withStatus(301) + ->withHeader('Location', $this->router->pathFor('member', ['id' => $member->id])); + } +)->setName('generate_qrcode_member')->add($authenticate); + +$this->get( + __('/show', 'qrcodes_routes') . '/{type:' . __('phone', 'qrcodes_routes') . '|' + . __('email', 'qrcodes_routes') . '}/{id:\d+}', + function ($request, $response, $args) { + $id_adh = (int)$args['id']; + $deps = array( + 'picture' => false, + 'groups' => false, + 'dues' => false + ); + + //if loggedin user is a group manager, we have to check + //he manages a group requested member belongs to. + if ($this->login->isGroupManager() && $this->login->id != $id_adh) { + $deps['groups'] = true; + } + + $adh = new Galette\Entity\Adherent($this->zdb, $id_adh, $deps); + + $is_manager = false; + if (!$this->login->isAdmin() + && !$this->login->isStaff() + && $this->login->id != $id_adh + && $this->login->isGroupManager() + ) { + $groups = $adh->groups; + foreach ($groups as $group) { + if ($this->login->isGroupManager($group->getId())) { + $is_manager = true; + break; + } + } + } + + $picture = null; + if ($this->login->isAdmin() + || $this->login->isStaff() + || $adh->appearsInMembersList() + || $this->login->login == $adh->login + || $is_manager + ) { + $picture = new GaletteQRCodes\Picture($this->plugins, $id_adh, $args['type']); + } else { + $picture = new GaletteQRCodes\Picture(); + } + $picture->display(); + } +)->setName('show_qrcode'); diff --git a/lang/Makefile b/lang/Makefile index e9451bc..4f29011 100644 --- a/lang/Makefile +++ b/lang/Makefile @@ -1,68 +1,60 @@ -.SUFFIXES = .mo .po INSTALLDIR = . LANGUAGES = en_US fr_FR.utf8 -PACKAGE = galette_admintools +DOMAINS = qrcodes qrcodes_routes MKLANG = ../../../lang/make_lang_l12n.py PHP_SOURCES = $(shell find ../ -maxdepth 1 -name \*.php) \ + $(shell find ../lib/GaletteQRCodes/ -name \*.php) \ $(shell find ../templates -name \*.tpl) -all : messages.po lang - @echo "Génération des fichiers *.po :" +all : messages.po lang check + @echo "Generating PO files:" @for l in ${LANGUAGES}; do \ - echo -n " Mise à jour de $$l.po"; \ - msgmerge -U $$l.po messages.po >/dev/null ; \ - mkdir -p ${INSTALLDIR}/$$l/LC_MESSAGES; \ - echo " formatage de ${INSTALLDIR}/$$l/LC_MESSAGES/${PACKAGE}.mo."; \ - msgfmt $$l.po -o ${INSTALLDIR}/$$l/LC_MESSAGES/${PACKAGE}.mo.new; \ - if diff -qI 'PO-Revision-Date:.*' ${INSTALLDIR}/$$l/LC_MESSAGES/${PACKAGE}.mo.new ${INSTALLDIR}/$$l/LC_MESSAGES/${PACKAGE}.mo > /dev/null; then \ - echo " ${PACKAGE}.mo non mis à jour."; \ - rm ${INSTALLDIR}/$$l/LC_MESSAGES/${PACKAGE}.mo.new; \ - else \ - echo " ${PACKAGE}.mo mis à jour."; \ - mv ${INSTALLDIR}/$$l/LC_MESSAGES/${PACKAGE}.mo.new ${INSTALLDIR}/$$l/LC_MESSAGES/${PACKAGE}.mo; \ - fi; \ + for d in ${DOMAINS}; do \ + if [ -f $${d}_$${l}.po ]; then \ + echo -n " Updating $${d}_$${l}.po"; \ + msgmerge -U $${d}_$${l}.po $$d.pot >/dev/null ; \ + else \ + echo " Creating of $${d}_$${l}.po"; \ + msginit -o $${d}_$${l}.po -i $$d.pot >/dev/null ; \ + fi; \ + mkdir -p ${INSTALLDIR}/$${l}/LC_MESSAGES; \ + echo " formatting ${INSTALLDIR}/$${l}/LC_MESSAGES/$${d}.mo."; \ + msgfmt $${d}_$${l}.po -o ${INSTALLDIR}/$${l}/LC_MESSAGES/$${d}.mo.new; \ + if diff -qI 'PO-Revision-Date:.*' ${INSTALLDIR}/$${l}/LC_MESSAGES/$${d}.mo.new ${INSTALLDIR}/$${l}/LC_MESSAGES/$${d}.mo > /dev/null; then \ + echo " $${d}.mo NOT updated."; \ + rm ${INSTALLDIR}/$${l}/LC_MESSAGES/$${d}.mo.new; \ + else \ + echo " $${d}.mo UPDATED."; \ + mv ${INSTALLDIR}/$${l}/LC_MESSAGES/$${d}.mo.new ${INSTALLDIR}/$${l}/LC_MESSAGES/$${d}.mo; \ + fi; \ + done \ done lang : - @echo "Génération des fichiers lang_*.php" - @echo " Mise à jour de lang_english.php" - @echo " extraction des chaines..." - @${MKLANG} en_US.po lang_english.php.new - @if diff -qI 'This file was automatically generated.*' lang_english.php lang_english.php.new > /dev/null; then \ - echo " lang_english.php non mis à jour."; \ - rm lang_english.php.new; \ - else \ - echo " lang_english.php mis à jour."; \ - mv lang_english.php.new lang_english.php; \ - fi; - - @echo " Mise à jour de lang_french.php" - @echo " extraction des chaines..." - @${MKLANG} fr_FR.utf8.po lang_french.php.new - @if diff -qI 'This file was automatically generated.*' lang_french.php lang_french.php.new > /dev/null; then \ - echo " lang_french.php non mis à jour."; \ - rm lang_french.php.new; \ - else \ - echo " lang_french.php mis à jour."; \ - mv lang_french.php.new lang_french.php; \ - fi; + @echo "Generating PHP lang files:" + @for l in ${LANGUAGES}; do \ + for d in ${DOMAINS}; do \ + echo " extracting $${d} $${l} strings..."; \ + if [ ! -f $${d}_$${l}.php ]; then \ + touch $${d}_$${l}.php; \ + fi; \ + ${MKLANG} $${d}_$${l}.po $${d}_$${l}.php.new $${d}; \ + if diff -qI 'This file was automatically generated.*' $${d}_$${l}.php $${d}_$${l}.php.new > /dev/null; then \ + echo " $${d}_$${l}.php NOT updated."; \ + rm $${d}_$${l}.php.new; \ + else \ + echo " $${d}_$${l}.php UPDATED."; \ + mv $${d}_$${l}.php.new $${d}_$${l}.php; \ + fi; \ + done \ + done messages.po : ${PHP_SOURCES} Makefile xgettext.py ./xgettext.py ${PHP_SOURCES} check: - @for FILE in ${PHP_SOURCES}; do \ - test -f $$FILE || echo "Not found $$FILE"; \ - done - @for NFILE in ../*.php ../includes/*.php \ - ../templates/default/*.tpl; do \ - for OFILE in ${PHP_SOURCES}; do \ - if [ "$$NFILE" = "$$OFILE" ]; then \ - unset NFILE; \ - break; \ - fi; \ - done; \ - test -z "$$NFILE" || echo "Missing $$NFILE"; \ + @for NFILE in ./*.php; do \ + php -l $$NFILE; \ done diff --git a/lang/en_US.po b/lang/en_US.po deleted file mode 100644 index d33f799..0000000 --- a/lang/en_US.po +++ /dev/null @@ -1,149 +0,0 @@ -# Header entry was created by Lokalize. -# -# , 2013. -msgid "" -msgstr "" -"Project-Id-Version: \n" -"PO-Revision-Date: 2013-07-16 07:33+0200\n" -"Last-Translator: \n" -"Language-Team: French \n" -"Language: fr\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Lokalize 1.5\n" -"Plural-Forms: nplurals=2; plural=(n > 1);\n" - -#: ../admintools.php:87 -msgid "An error occured reinitializing fields configuration :(" -msgstr "An error occured reinitializing fields configuration :(" - -#: ../templates/default/admintools.tpl:36 -msgid "" -"You should use that function if you can see strange characters in your " -"datas; after a manual import, or if you've not used Galette's update scripts." -msgstr "" -"You should use that function if you can see strange characters in your " -"datas; after a manual import, or if you've not used Galette's update scripts." - -#: ../admintools.php:85 -msgid "Fields configuration has been successfully reinitialized." -msgstr "Fields configuration has been successfully reinitialized." - -#: ../admintools.php:65 -msgid "Database should have been successfully converted to UTF-8!" -msgstr "Database should have been successfully converted to UTF-8!" - -#: ../templates/default/admintools.tpl:6 -#: ../templates/default/admintools.tpl:30 -msgid "" -"Make sure you've done a backup of the database before using any of the " -"following tools!" -msgstr "" -"Make sure you've done a backup of the database before using any of the " -"following tools!" - -#: ../templates/default/menu.tpl:4 -msgid "Various administrative tools" -msgstr "Various administrative tools" - -#: ../templates/default/admintools.tpl:22 -msgid "Check PHP modules" -msgstr "Check PHP modules" - -#: ../templates/default/admintools.tpl:48 -msgid "Modules report" -msgstr "Modules report" - -#: ../templates/default/admintools.tpl:10 -msgid "Reinitialize emails contents" -msgstr "Reinitialize emails contents" - -#: ../templates/default/admintools.tpl:4 -msgid "Content tools" -msgstr "Content tools" - -#: ../admintools.php:75 -msgid "An error occured reinitializing texts :(" -msgstr "An error occured reinitializing texts :(" - -#: ../templates/default/admintools.tpl:35 -msgid "" -"Converts the whole database data to UTF-8, do not change anything on the " -"tables, just proceed data conversion." -msgstr "" -"Converts the whole database data to UTF-8, do not change anything on the " -"tables, just proceed data conversion." - -#: ../templates/default/admintools.tpl:28 -msgid "Database tools" -msgstr "Database tools" - -#: ../admintools.php:111 -msgid "Logins and passwords has been successfully filled (%i processed)." -msgstr "Logins and passwords has been successfully filled (%i processed)." - -#: ../templates/default/admintools.tpl:34 -msgid "That function is available for MySQL installations only!" -msgstr "That function is available for MySQL installations only!" - -#: ../templates/default/admintools.tpl:40 -msgid "Convert encoding" -msgstr "Convert encoding" - -#: ../admintools.php:122 -msgid "" -"Some PHP modules are missing. Please install them or contact your support." -"
More informations on required modules may be found in the documentation." -msgstr "" -"Some PHP modules are missing. Please install them or contact your support." -"
More informations on required modules may be found in the documentation." - -#: ../templates/default/admintools.tpl:17 -msgid "Generate values for empty logins and passwords" -msgstr "Generate values for empty logins and passwords" - -#: ../admintools.php:98 -msgid "An error occured reinitializing PDF models :(" -msgstr "An error occured reinitializing PDF models :(" - -#: ../templates/default/menu.tpl:4 -msgid "Admin tools" -msgstr "Admin tools" - -#: ../admintools.php:114 -msgid "An error occured filling empty logins and passwords :(" -msgstr "An error occured filling empty logins and passwords :(" - -#: ../admintools.php:149 -msgid "Administration tools" -msgstr "Administration tools" - -#: ../templates/default/admintools.tpl:12 -msgid "Reinitialize PDF models" -msgstr "Reinitialize PDF models" - -#: ../templates/default/menu.tpl:2 -msgid "Admin Tools" -msgstr "Admin Tools" - -#: ../templates/default/admintools.tpl:37 -msgid "" -"That conversion stuff will read your entire database, and write back each " -"non UTF-8 values after conversion; this may take a while." -msgstr "" -"That conversion stuff will read your entire database, and write back each " -"non UTF-8 values after conversion; this may take a while." - -#: ../admintools.php:73 -msgid "Texts has been successfully reinitialized." -msgstr "Texts has been successfully reinitialized." - -#: ../templates/default/admintools.tpl:11 -msgid "Reinitialize fields configuration" -msgstr "Reinitialize fields configuration" - -#: ../admintools.php:96 -msgid "PDF models has been successfully reinitialized." -msgstr "PDF models has been successfully reinitialized." - diff --git a/lang/en_US/LC_MESSAGES/galette_admintools.mo b/lang/en_US/LC_MESSAGES/galette_admintools.mo deleted file mode 100644 index f0c3f84..0000000 Binary files a/lang/en_US/LC_MESSAGES/galette_admintools.mo and /dev/null differ diff --git a/lang/en_US/LC_MESSAGES/qrcodes.mo b/lang/en_US/LC_MESSAGES/qrcodes.mo new file mode 100644 index 0000000..633d3d9 Binary files /dev/null and b/lang/en_US/LC_MESSAGES/qrcodes.mo differ diff --git a/lang/en_US/LC_MESSAGES/qrcodes_routes.mo b/lang/en_US/LC_MESSAGES/qrcodes_routes.mo new file mode 100644 index 0000000..aabd3f2 Binary files /dev/null and b/lang/en_US/LC_MESSAGES/qrcodes_routes.mo differ diff --git a/lang/fr_FR.utf8.po b/lang/fr_FR.utf8.po deleted file mode 100644 index 886fa53..0000000 --- a/lang/fr_FR.utf8.po +++ /dev/null @@ -1,157 +0,0 @@ -# Header entry was created by Lokalize. -# -# , 2013. -msgid "" -msgstr "" -"Project-Id-Version: \n" -"PO-Revision-Date: 2013-07-16 07:33+0200\n" -"Last-Translator: \n" -"Language-Team: French \n" -"Language: fr\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Lokalize 1.5\n" -"Plural-Forms: nplurals=2; plural=(n > 1);\n" - -#: ../admintools.php:87 -msgid "An error occured reinitializing fields configuration :(" -msgstr "" -"Une erreur est survenue lors de la réinitialisation de la configuration des " -"champs :(" - -#: ../templates/default/admintools.tpl:36 -msgid "" -"You should use that function if you can see strange characters in your " -"datas; after a manual import, or if you've not used Galette's update scripts." -msgstr "" -"Vous devriez utiliser cette fonctions si d'étranges caractères aparaissent " -"dans vos données ; après un import manuel, ou si vous n'avez pas utilisé les " -"scripts de mise à jour de Galette." - -#: ../admintools.php:85 -msgid "Fields configuration has been successfully reinitialized." -msgstr "La configuration des champs a été réinitialisée avec succès." - -#: ../admintools.php:65 -msgid "Database should have been successfully converted to UTF-8!" -msgstr "La base de données devrait avoir été convertie en UTF-8 !" - -#: ../templates/default/admintools.tpl:6 -#: ../templates/default/admintools.tpl:30 -msgid "" -"Make sure you've done a backup of the database before using any of the " -"following tools!" -msgstr "" -"Assurez-vous de faire une sauvegarde de votre base de données avant " -"d'utiliser l'un des outils suivants !" - -#: ../templates/default/menu.tpl:4 -msgid "Various administrative tools" -msgstr "Divers outils administratifs" - -#: ../templates/default/admintools.tpl:22 -msgid "Check PHP modules" -msgstr "Vérification des modules PHP" - -#: ../templates/default/admintools.tpl:48 -msgid "Modules report" -msgstr "Rapport sur les modules" - -#: ../templates/default/admintools.tpl:10 -msgid "Reinitialize emails contents" -msgstr "Réinitialiser les contenus des emails" - -#: ../templates/default/admintools.tpl:4 -msgid "Content tools" -msgstr "Outils de contenus" - -#: ../admintools.php:75 -msgid "An error occured reinitializing texts :(" -msgstr "Une erreur est survenue lors de la réinitialisation des textes :(" - -#: ../templates/default/admintools.tpl:35 -msgid "" -"Converts the whole database data to UTF-8, do not change anything on the " -"tables, just proceed data conversion." -msgstr "" -"Converti l'ensemble des données de la base en UTF-8, ne change rien sur les " -"tables, effectue juste la conversion." - -#: ../templates/default/admintools.tpl:28 -msgid "Database tools" -msgstr "Outils de base de données" - -#: ../admintools.php:111 -msgid "Logins and passwords has been successfully filled (%i processed)." -msgstr "Les login et mot de passe ont été correctement remplis (%i traités)." - -#: ../templates/default/admintools.tpl:34 -msgid "That function is available for MySQL installations only!" -msgstr "" -"Cette fonction n'est disponible que pour les installations sous MySQL !" - -#: ../templates/default/admintools.tpl:40 -msgid "Convert encoding" -msgstr "Conversion de l'encodage" - -#: ../admintools.php:122 -msgid "" -"Some PHP modules are missing. Please install them or contact your support." -"
More informations on required modules may be found in the documentation." -msgstr "" -"Certains modules PHP sont manquants. Veuillez les installer ou contacter " -"votre support.
Plus d'informations sur les modules requis sont " -"disponibles dans la documentation." - -#: ../templates/default/admintools.tpl:17 -msgid "Generate values for empty logins and passwords" -msgstr "Génère des valeurs pour les login et mot de passe vides" - -#: ../admintools.php:98 -msgid "An error occured reinitializing PDF models :(" -msgstr "Une erreur est survenue lors de la réinitialisation des modèles PDF :(" - -#: ../templates/default/menu.tpl:4 -msgid "Admin tools" -msgstr "Outils admin" - -#: ../admintools.php:114 -msgid "An error occured filling empty logins and passwords :(" -msgstr "" -"Une erreur est survenue lors de la création de valeurs pour les identifiants " -"vides :(" - -#: ../admintools.php:149 -msgid "Administration tools" -msgstr "Outils d'administration" - -#: ../templates/default/admintools.tpl:12 -msgid "Reinitialize PDF models" -msgstr "Réinitialiser les contenus des modèles PDF" - -#: ../templates/default/menu.tpl:2 -msgid "Admin Tools" -msgstr "Outils Admin" - -#: ../templates/default/admintools.tpl:37 -msgid "" -"That conversion stuff will read your entire database, and write back each " -"non UTF-8 values after conversion; this may take a while." -msgstr "" -"Cette conversion va lire l'intégralité de votre base de données, et ré-" -"écrire chaque valeur non UTF-8 après conversion. Cela peut prendre un " -"certain temps." - -#: ../admintools.php:73 -msgid "Texts has been successfully reinitialized." -msgstr "Les textes ont été réinitialisés avec succès." - -#: ../templates/default/admintools.tpl:11 -msgid "Reinitialize fields configuration" -msgstr "Réinitialiser la configuration des champs" - -#: ../admintools.php:96 -msgid "PDF models has been successfully reinitialized." -msgstr "Les modèles PDF ont été réinitialisés avec succès." - diff --git a/lang/fr_FR.utf8/LC_MESSAGES/galette_admintools.mo b/lang/fr_FR.utf8/LC_MESSAGES/galette_admintools.mo deleted file mode 100644 index f6bbe93..0000000 Binary files a/lang/fr_FR.utf8/LC_MESSAGES/galette_admintools.mo and /dev/null differ diff --git a/lang/fr_FR.utf8/LC_MESSAGES/qrcodes.mo b/lang/fr_FR.utf8/LC_MESSAGES/qrcodes.mo new file mode 100644 index 0000000..57ebdf1 Binary files /dev/null and b/lang/fr_FR.utf8/LC_MESSAGES/qrcodes.mo differ diff --git a/lang/fr_FR.utf8/LC_MESSAGES/qrcodes_routes.mo b/lang/fr_FR.utf8/LC_MESSAGES/qrcodes_routes.mo new file mode 100644 index 0000000..7b6b193 Binary files /dev/null and b/lang/fr_FR.utf8/LC_MESSAGES/qrcodes_routes.mo differ diff --git a/lang/lang_english.php b/lang/lang_english.php deleted file mode 100644 index d3af496..0000000 --- a/lang/lang_english.php +++ /dev/null @@ -1,90 +0,0 @@ -More informations on required modules may be found in the documentation.'] = 'Some PHP modules are missing. Please install them or contact your support.
More informations on required modules may be found in the documentation.'; - -// ../templates/default/admintools.tpl:22 -$lang['Check PHP modules'] = 'Check PHP modules'; - -// ../templates/default/admintools.tpl:28 -$lang['Database tools'] = 'Database tools'; - -// ../admintools.php:98 -$lang['An error occured reinitializing PDF models :('] = 'An error occured reinitializing PDF models :('; - -// ../admintools.php:73 -$lang['Texts has been successfully reinitialized.'] = 'Texts has been successfully reinitialized.'; - -// ../templates/default/admintools.tpl:4 -$lang['Content tools'] = 'Content tools'; - -// ../admintools.php:149 -$lang['Administration tools'] = 'Administration tools'; - -// ../templates/default/admintools.tpl:48 -$lang['Modules report'] = 'Modules report'; - -// ../templates/default/admintools.tpl:12 -$lang['Reinitialize PDF models'] = 'Reinitialize PDF models'; - -// ../templates/default/admintools.tpl:17 -$lang['Generate values for empty logins and passwords'] = 'Generate values for empty logins and passwords'; - -// ../templates/default/admintools.tpl:36 -$lang['You should use that function if you can see strange characters in your datas; after a manual import, or if you\'ve not used Galette\'s update scripts.'] = 'You should use that function if you can see strange characters in your datas; after a manual import, or if you\'ve not used Galette\'s update scripts.'; - -// ../templates/default/menu.tpl:4 -$lang['Various administrative tools'] = 'Various administrative tools'; - -// ../admintools.php:85 -$lang['Fields configuration has been successfully reinitialized.'] = 'Fields configuration has been successfully reinitialized.'; - -// ../templates/default/menu.tpl:2 -$lang['Admin Tools'] = 'Admin Tools'; - -// ../admintools.php:114 -$lang['An error occured filling empty logins and passwords :('] = 'An error occured filling empty logins and passwords :('; - -?> \ No newline at end of file diff --git a/lang/lang_french.php b/lang/lang_french.php deleted file mode 100644 index 1d668c7..0000000 --- a/lang/lang_french.php +++ /dev/null @@ -1,114 +0,0 @@ -More informations on required modules may be found in the documentation.'] = 'Certains modules PHP sont manquants. Veuillez les installer ou contacter votre support.
Plus d\'informations sur les modules requis sont disponibles dans la documentation.'; - -// ../templates/default/admintools.tpl:22 -$lang['Check PHP modules'] = 'Vérification des modules PHP'; - -// ../templates/default/admintools.tpl:28 -$lang['Database tools'] = 'Outils de base de données'; - -// ../admintools.php:98 -$lang['An error occured reinitializing PDF models :('] = 'Une erreur est survenue lors de la réinitialisation des modèles PDF :('; - -// ../admintools.php:73 -$lang['Texts has been successfully reinitialized.'] = 'Les textes ont été réinitialisés avec succès.'; - -// ../templates/default/admintools.tpl:4 -$lang['Content tools'] = 'Outils de contenus'; - -// ../admintools.php:149 -$lang['Administration tools'] = 'Outils d\'administration'; - -// ../templates/default/admintools.tpl:48 -$lang['Modules report'] = 'Rapport sur les modules'; - -// ../templates/default/admintools.tpl:12 -$lang['Reinitialize PDF models'] = 'Réinitialiser les contenus des modèles PDF'; - -// ../templates/default/admintools.tpl:17 -$lang['Generate values for empty logins and passwords'] = 'Génère des valeurs pour les login et mot de passe vides'; - -// ../templates/default/admintools.tpl:36 -$lang['You should use that function if you can see strange characters in your datas; after a manual import, or if you\'ve not used Galette\'s update scripts.'] = 'Vous devriez utiliser cette fonctions si d\'étranges caractères aparaissent dans vos données ; après un import manuel, ou si vous n\'avez pas utilisé les scripts de mise à jour de Galette.'; - -// ../templates/default/menu.tpl:4 -$lang['Various administrative tools'] = 'Divers outils administratifs'; - -// ../admintools.php:85 -$lang['Fields configuration has been successfully reinitialized.'] = 'La configuration des champs a été réinitialisée avec succès.'; - -// ../templates/default/menu.tpl:2 -$lang['Admin Tools'] = 'Outils Admin'; - -// ../admintools.php:114 -$lang['An error occured filling empty logins and passwords :('] = 'Une erreur est survenue lors de la création de valeurs pour les identifiants vides :('; - -$lang['Notes UVs'] = 'Notes UVs'; - -$lang['Notes Passage de Grades'] = 'Notes Passage de Grades'; - -$lang['Passages De Grades'] = 'Passages De Grades'; - -$lang[' Delete'] = ' Supprimer'; - -$lang['Moy.'] = 'Moy.'; - -$lang['Return'] = 'Retour'; - -$lang['Créer passage de grades'] = 'Créer passage de grades'; - -$lang['- '] = '- '; - -$lang['QRcodes'] = 'QRcodes'; - -$lang['QR codes'] = 'QR codes'; - -$lang['Générateur de QRcodes'] = 'Générateur de QRcodes'; - -$lang['Créer QRcodes Adhérents'] = 'Créer QRcodes Adhérents'; - -?> \ No newline at end of file diff --git a/lang/messages.po b/lang/messages.po deleted file mode 100644 index e85d092..0000000 --- a/lang/messages.po +++ /dev/null @@ -1,112 +0,0 @@ -#: ../admintools.php:87 -msgid "An error occured reinitializing fields configuration :(" -msgstr "" - -#: ../templates/default/admintools.tpl:36 -msgid "You should use that function if you can see strange characters in your datas; after a manual import, or if you've not used Galette's update scripts." -msgstr "" - -#: ../admintools.php:85 -msgid "Fields configuration has been successfully reinitialized." -msgstr "" - -#: ../admintools.php:65 -msgid "Database should have been successfully converted to UTF-8!" -msgstr "" - -#: ../templates/default/admintools.tpl:6 ../templates/default/admintools.tpl:30 -msgid "Make sure you've done a backup of the database before using any of the following tools!" -msgstr "" - -#: ../templates/default/menu.tpl:4 -msgid "Various administrative tools" -msgstr "" - -#: ../templates/default/admintools.tpl:22 -msgid "Check PHP modules" -msgstr "" - -#: ../templates/default/admintools.tpl:48 -msgid "Modules report" -msgstr "" - -#: ../templates/default/admintools.tpl:10 -msgid "Reinitialize emails contents" -msgstr "" - -#: ../templates/default/admintools.tpl:4 -msgid "Content tools" -msgstr "" - -#: ../admintools.php:75 -msgid "An error occured reinitializing texts :(" -msgstr "" - -#: ../templates/default/admintools.tpl:35 -msgid "Converts the whole database data to UTF-8, do not change anything on the tables, just proceed data conversion." -msgstr "" - -#: ../templates/default/admintools.tpl:28 -msgid "Database tools" -msgstr "" - -#: ../admintools.php:111 -msgid "Logins and passwords has been successfully filled (%i processed)." -msgstr "" - -#: ../templates/default/admintools.tpl:34 -msgid "That function is available for MySQL installations only!" -msgstr "" - -#: ../templates/default/admintools.tpl:40 -msgid "Convert encoding" -msgstr "" - -#: ../admintools.php:122 -msgid "Some PHP modules are missing. Please install them or contact your support.
More informations on required modules may be found in the documentation." -msgstr "" - -#: ../templates/default/admintools.tpl:17 -msgid "Generate values for empty logins and passwords" -msgstr "" - -#: ../admintools.php:98 -msgid "An error occured reinitializing PDF models :(" -msgstr "" - -#: ../templates/default/menu.tpl:4 -msgid "Admin tools" -msgstr "" - -#: ../admintools.php:114 -msgid "An error occured filling empty logins and passwords :(" -msgstr "" - -#: ../admintools.php:149 -msgid "Administration tools" -msgstr "" - -#: ../templates/default/admintools.tpl:12 -msgid "Reinitialize PDF models" -msgstr "" - -#: ../templates/default/menu.tpl:2 -msgid "Admin Tools" -msgstr "" - -#: ../templates/default/admintools.tpl:37 -msgid "That conversion stuff will read your entire database, and write back each non UTF-8 values after conversion; this may take a while." -msgstr "" - -#: ../admintools.php:73 -msgid "Texts has been successfully reinitialized." -msgstr "" - -#: ../templates/default/admintools.tpl:11 -msgid "Reinitialize fields configuration" -msgstr "" - -#: ../admintools.php:96 -msgid "PDF models has been successfully reinitialized." -msgstr "" - diff --git a/lang/qrcodes.pot b/lang/qrcodes.pot new file mode 100644 index 0000000..173f6ba --- /dev/null +++ b/lang/qrcodes.pot @@ -0,0 +1,16 @@ +#: ../templates/default/menu.tpl:5 +msgid "Create members QRcodes" +msgstr "" + +#: ../templates/default/menu.tpl:4 +msgid "QRcodes generator" +msgstr "" + +#: ../templates/default/menu.tpl:2 +msgid "QRcodes" +msgstr "" + +#: ../templates/default/adh_fiche_action.tpl:9 +msgid "QR codes" +msgstr "" + diff --git a/lang/qrcodes_en_US.php b/lang/qrcodes_en_US.php new file mode 100644 index 0000000..c390eff --- /dev/null +++ b/lang/qrcodes_en_US.php @@ -0,0 +1,17 @@ +\n" +"Language-Team: \n" +"Language: en_US\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=iso-8859-1\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 1.8.12\n" + +#: ../templates/default/menu.tpl:5 +msgid "Create members QRcodes" +msgstr "Create members QRcodes" + +#: ../templates/default/menu.tpl:4 +msgid "QRcodes generator" +msgstr "QRcodes generator" + +#: ../templates/default/menu.tpl:2 +msgid "QRcodes" +msgstr "QRcodes" + +#: ../templates/default/adh_fiche_action.tpl:9 +msgid "QR codes" +msgstr "QR codes" diff --git a/lang/qrcodes_fr_FR.utf8.php b/lang/qrcodes_fr_FR.utf8.php new file mode 100644 index 0000000..1afe61f --- /dev/null +++ b/lang/qrcodes_fr_FR.utf8.php @@ -0,0 +1,17 @@ +\n" +"Language-Team: \n" +"Language: fr_FR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 1.8.12\n" + +#: ../templates/default/menu.tpl:5 +msgid "Create members QRcodes" +msgstr "Créer les QRCodes des adhérents" + +#: ../templates/default/menu.tpl:4 +msgid "QRcodes generator" +msgstr "Générateur de QRCode" + +#: ../templates/default/menu.tpl:2 +msgid "QRcodes" +msgstr "QRcodes" + +#: ../templates/default/adh_fiche_action.tpl:9 +msgid "QR codes" +msgstr "QR codes" diff --git a/lang/qrcodes_routes.pot b/lang/qrcodes_routes.pot new file mode 100644 index 0000000..f0ef7ef --- /dev/null +++ b/lang/qrcodes_routes.pot @@ -0,0 +1,20 @@ +#: ../_routes.php:92 ../templates/default/adh_fiche_action.tpl:6 +msgid "email" +msgstr "" + +#: ../_routes.php:44 +msgid "/member" +msgstr "" + +#: ../_routes.php:91 +msgid "/show" +msgstr "" + +#: ../_routes.php:44 +msgid "/qrcode" +msgstr "" + +#: ../_routes.php:91 ../templates/default/adh_fiche_action.tpl:3 +msgid "phone" +msgstr "" + diff --git a/lang/qrcodes_routes_en_US.php b/lang/qrcodes_routes_en_US.php new file mode 100644 index 0000000..1027722 --- /dev/null +++ b/lang/qrcodes_routes_en_US.php @@ -0,0 +1,20 @@ +\n" +"Language-Team: \n" +"Language: en_US\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=iso-8859-1\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 1.8.12\n" + +#: ../_routes.php:92 ../templates/default/adh_fiche_action.tpl:6 +msgid "email" +msgstr "email" + +#: ../_routes.php:44 +msgid "/member" +msgstr "/member" + +#: ../_routes.php:91 +msgid "/show" +msgstr "/show" + +#: ../_routes.php:44 +msgid "/qrcode" +msgstr "/qrcode" + +#: ../_routes.php:91 ../templates/default/adh_fiche_action.tpl:3 +msgid "phone" +msgstr "phone" diff --git a/lang/qrcodes_routes_fr_FR.utf8.php b/lang/qrcodes_routes_fr_FR.utf8.php new file mode 100644 index 0000000..a50496e --- /dev/null +++ b/lang/qrcodes_routes_fr_FR.utf8.php @@ -0,0 +1,20 @@ +\n" +"Language-Team: \n" +"Language: fr_FR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 1.8.12\n" + +#: ../_routes.php:92 ../templates/default/adh_fiche_action.tpl:6 +msgid "email" +msgstr "email" + +#: ../_routes.php:44 +msgid "/member" +msgstr "/adherent" + +#: ../_routes.php:91 +msgid "/show" +msgstr "/afficher" + +#: ../_routes.php:44 +msgid "/qrcode" +msgstr "/qrcode" + +#: ../_routes.php:91 ../templates/default/adh_fiche_action.tpl:3 +msgid "phone" +msgstr "telephone" diff --git a/lang/xgettext.py b/lang/xgettext.py old mode 100644 new mode 100755 index b40d10e..6468441 --- a/lang/xgettext.py +++ b/lang/xgettext.py @@ -6,7 +6,7 @@ - generates message.po with the same symtax as regular xgettext - translatable string sort may differ from regular xgettext -Copyright © 2005-2014 The Galette Team +Copyright © 2005-2016 The Galette Team This file is part of Galette (http://galette.tuxfamily.org). @@ -30,51 +30,69 @@ import re # pattern definition -translatable= re.compile("_T\((\"[^\"]*\")\)") -tpl_translatable= re.compile("_T\ string=(\"[^\"]*\")") +translatable = re.compile("_(T|_)\((\"[^\"]*\")(, \"([^\"]*)\")?\)") +#same, with single quotes... +translatable_single = re.compile("_(T|_)\(('[^']*')(, '([^']*)')?\)") +tpl_translatable = re.compile("_(T|_)\ string=(\"[^\"]*\")( domain=\"([^\"]*)\")?") # constants string startLoc = "#: " nextLoc = " " # +domains = {} dico = {} -def location() : - return inputFileName + ":" + str(lineNum+1) +def location(): + """ + String location in file + """ + return inputFileName + ":" + str(lineNum+1) -# -for inputFileName in sys.argv[1:] : - inFile=open(inputFileName) - lines = inFile.readlines() - inFile.close() - # get line - for lineNum, line in enumerate(lines) : - # search translatable strings - matchs = translatable.findall(line) - for match in matchs: - if dico.has_key(match): - if dico[match][-1:] == "\n": - dico[match] += startLoc + location() - else : - dico[match] += nextLoc + location() + "\n" - else : - dico[match] = startLoc + location() - tpl_matchs = tpl_translatable.findall(line) - for tpl_match in tpl_matchs: - if dico.has_key(tpl_match): - if dico[tpl_match][-1:] == "\n": - dico[tpl_match] += startLoc + location() - else : - dico[tpl_match] += nextLoc + location() + "\n" - else : - dico[tpl_match] = startLoc + location() +def handleMatches(matches, repl_quotes=False): + for match in matches: + trans = match[1] + #handle single quotes + if repl_quotes == True: + trans = '"%s"' % trans[1:-1] + + #define domain + if match[3] != '' and match[3] != 'routes': + cur_domain = match[3] + else: + continue + + if not domains.has_key(cur_domain): + domains[cur_domain] = {} + + if domains[cur_domain].has_key(trans): + if domains[cur_domain][trans][-1:] == "\n": + domains[cur_domain][trans] += startLoc + location() + else: + domains[cur_domain][trans] += nextLoc + location() + "\n" + else: + domains[cur_domain][trans] = startLoc + location() # -outFile = open("messages.po",'w') -for k, v in dico.iteritems(): - outFile.write(v) - if v[-1:] != "\n" : - outFile.write("\n") - outFile.write("msgid " + k + "\nmsgstr \"\"\n\n") -outFile.close() +for inputFileName in sys.argv[1:]: + inFile = open(inputFileName) + lines = inFile.readlines() + inFile.close() + # get line + for lineNum, line in enumerate(lines): + # search translatable strings + matches = translatable.findall(line) + handleMatches(matches) + matches = translatable_single.findall(line) + handleMatches(matches, True) + matches = tpl_translatable.findall(line) + handleMatches(matches) + +for domain, strings in domains.iteritems(): + outFile = open("%s.pot" % domain, 'w') + for k, v in strings.iteritems(): + outFile.write(v) + if v[-1:] != "\n": + outFile.write("\n") + outFile.write("msgid " + k + "\nmsgstr \"\"\n\n") + outFile.close() diff --git a/lib/GaletteQRCodes/Picture.php b/lib/GaletteQRCodes/Picture.php index 324c400..f755da4 100644 --- a/lib/GaletteQRCodes/Picture.php +++ b/lib/GaletteQRCodes/Picture.php @@ -104,9 +104,10 @@ public function __construct(Plugins $plugins, $id_adh = '', $code = 'phone') */ protected function getDefaultPicture() { - global $plugins; - $this->file_path = $this->plugins->getTemplatesPathFromName('Galette QRCodes') . - '/images/empty.png'; + $this->file_path = realpath( + $this->plugins->getTemplatesPathFromName('Galette QRCodes') . + '/../../webroot/images/empty.png' + ); $this->format = 'png'; $this->mime = 'image/png'; $this->has_picture = false; diff --git a/picture.php b/picture.php deleted file mode 100644 index c2a5216..0000000 --- a/picture.php +++ /dev/null @@ -1,81 +0,0 @@ -. - * - * @category Main - * @package Galette - * - * @author Frédéric Jaqcuot - * @author Johan Cwiklinski - * @copyright 2004-2014 The Galette Team - * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version - * @version SVN: $Id: picture.php 877 2011-06-01 06:08:18Z trashy $ - * @link http://galette.tuxfamily.org - * @since Available since 0.62 - */ - -define('GALETTE_BASE_PATH', '../../'); -/** @ignore */ -require_once GALETTE_BASE_PATH . 'includes/galette.inc.php'; -require_once '_config.inc.php'; - -$id_adh = (int)$_GET['id_adh']; -$deps = array( - 'picture' => true, - 'groups' => false, - 'dues' => false -); - -//if loggedin user is a group manager, we have to check -//he manages a group requested member belongs to. -if ( $login->isGroupManager() ) { - $deps['groups'] = true; -} - -$adh = new Galette\Entity\Adherent($id_adh, $deps); - -$is_manager = false; -if ( !$login->isAdmin() && !$login->isStaff() && $login->isGroupManager() ) { - $groups = $adh->groups; - foreach ( $groups as $group ) { - if ( $login->isGroupManager($group->getId()) ) { - $is_manager = true; - break; - } - } -} - -$picture = null; -if ( $login->isAdmin() - || $login->isStaff() - || $adh->appearsInMembersList() - || $login->login == $adh->login - || $is_manager -) { - $picture = new GaletteQRCodes\Picture($plugins, $id_adh, $_GET['code']); -} else { - $picture = new GaletteQRCodes\Picture(); -} -$picture->display(); diff --git a/templates/default/adh_fiche_action.tpl b/templates/default/adh_fiche_action.tpl index a401f62..38a5adc 100644 --- a/templates/default/adh_fiche_action.tpl +++ b/templates/default/adh_fiche_action.tpl @@ -1,15 +1,11 @@ -
  • {if $login->isAdmin() or $login->isStaff()} - Tel. -{/if} +
  • + {_T string="phone" domain="qrcodes_routes"}, "id" => $member->id]}?rand={$time}" class="picture" alt=""/> Tel.
  • -{if $login->isAdmin() or $login->isStaff()} - Mail -{/if} + {_T string="email" domain="qrcodes_routes"}, "id" => $member->id]}?rand={$time}" class="picture" alt=""/> Mail
  • -{if $login->isAdmin() or $login->isStaff()} - {_T string="QR codes"} -{/if} + $member->id]}" id="btn_plugins_QRcodes">{_T string="QR codes" domain="qrcodes"}
  • +{/if} diff --git a/templates/default/headers.tpl b/templates/default/headers.tpl index f1da61c..2335397 100644 --- a/templates/default/headers.tpl +++ b/templates/default/headers.tpl @@ -1,3 +1 @@ - - - + $module_id, "path" => "galette_QRcodes.css"]}"/> diff --git a/templates/default/menu.tpl b/templates/default/menu.tpl index 22f4fac..5ce35da 100644 --- a/templates/default/menu.tpl +++ b/templates/default/menu.tpl @@ -1,7 +1,7 @@ {if $login->isAdmin()} -

    {_T string="QRcodes"}

    - +

    {_T string="QRcodes" domain="qrcodes"}

    + {/if} diff --git a/templates/default/galette_QRcodes.css b/webroot/galette_QRcodes.css similarity index 100% rename from templates/default/galette_QRcodes.css rename to webroot/galette_QRcodes.css diff --git a/templates/default/images/coucou.png b/webroot/images/coucou.png similarity index 100% rename from templates/default/images/coucou.png rename to webroot/images/coucou.png diff --git a/templates/default/images/empty.png b/webroot/images/empty.png similarity index 100% rename from templates/default/images/empty.png rename to webroot/images/empty.png