Skip to content
This repository was archived by the owner on Sep 6, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion QRcodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
17 changes: 10 additions & 7 deletions _define.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
);
137 changes: 137 additions & 0 deletions _routes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
<?php

/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */

/**
* Fullcard routes
*
* PHP version 5
*
* Copyright © 2016 The Galette Team
*
* This file is part of Galette (http://galette.tuxfamily.org).
*
* Galette 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, either version 3 of the License, or
* (at your option) any later version.
*
* Galette 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.
*
* You should have received a copy of the GNU General Public License
* along with Galette. If not, see <http://www.gnu.org/licenses/>.
*
* @category Plugins
* @package GaletteMaps
*
* @author Johan Cwiklinski <johan@x-tnd.be>
* @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');
92 changes: 42 additions & 50 deletions lang/Makefile
Original file line number Diff line number Diff line change
@@ -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
Loading