This repository has been archived by the owner on Sep 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQRcodes.php
186 lines (153 loc) · 5.17 KB
/
QRcodes.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Configuration file for QRcodes plugin
*
* PHP version 5
*
* Copyright © 2013 The Galette Team
*
* This file is part of Galette (http://galette.eu).
*
* 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 QRcodes
*
* @author Frédéric LASSAVE <[email protected]>
* @copyright 2011 The Galette Team
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or later
* @version SVN: $Id$
* @link http://galette.eu
* @since Available since 0.8.2.3
*/
use Galette\Entity\Adherent;
use Galette\Entity\FieldsConfig;
use Galette\Entity\Texts;
use Galette\Repository\Members;
use Galette\Repository\PdfModels;
use Galette\Filters\MembersList;
define('GALETTE_BASE_PATH', '../../');
define('QRCODES_PREFIX', 'plugins|QRcodes');
require_once GALETTE_BASE_PATH . 'includes/galette.inc.php';
$modules = $plugins->getModules();
foreach ($modules as $key => $module) {
if ($module['name'] == 'Galette Grades') {
//Plugin PassagesDeGrades is installed, keep its path.
define('PASSAGESDEGRADES_PREFIX', '../' . $key . '/');
}
}
//Constants and classes from plugin
require_once '_config.inc.php';
//Chargement des fonctions
include("includes/t0k4rt-phpqrcode-d213c48/qrlib.php");
//create data directory
if (!file_exists(PLUGIN_QRCODE_DATA_PATH)) {
mkdir(PLUGIN_QRCODE_DATA_PATH);
}
//récupération du header de la page précédente
if (isset($_GET['id_adh']) AND isset($_GET['enr'])){
$id_adh = $_GET['id_adh'];
$deps = array(
'picture' => true,
'groups' => true,
'dues' => true,
'parent' => true,
'children' => true
);
$member = new Adherent((int)$id_adh, $deps);
$id_m = $member->id;
//Créer QRcode PassagesDeGrades
if (!file_exists(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);
}
}
//Créer QRcode Téléphone
$phone = $member->phone;
//if member phone is missing but there is a parent,
//take the parent phone
if (file_exists(PLUGIN_QRCODE_DATA_PATH . "$id_adh.tel.png")){
unlink(PLUGIN_QRCODE_DATA_PATH . "$id_adh.tel.png");
}
if (empty($phone) && $member->hasParent()){
$phone = $member->parent->phone;
}
if (!empty($phone)){
QRcode::png("tel:$phone", PLUGIN_QRCODE_DATA_PATH . "$id_adh.tel.png", "L", 4, 4);
}
//Créer QRcode Mail
$email = $member->email;
//if member email is missing but there is a parent,
//take the parent email
if (file_exists(PLUGIN_QRCODE_DATA_PATH . "$id_adh.mail.png")){
unlink(PLUGIN_QRCODE_DATA_PATH . "$id_adh.mail.png");
}
if (empty($email) && $member->hasParent()){
$email = $member->parent->email;
}
if (!empty($email)){
QRcode::png("mailto:$email", PLUGIN_QRCODE_DATA_PATH . "$id_adh.mail.png", "L", 4, 4);
}
} else {
$select = $zdb->select(Adherent::TABLE);
$result = $zdb->execute($select);
foreach ($result as $r){
$id_adh = $r->id_adh;
$deps = array(
'picture' => true,
'groups' => true,
'dues' => true,
'parent' => true,
'children' => true
);
$member = new Adherent((int)$id_adh, $deps);
$id_m = $member->id;
//Créer QRcode PassagesDeGrades
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);
}
}
//Créer QRcode Téléphone
$phone = $member->phone;
//if member phone is missing but there is a parent,
//take the parent phone
if (file_exists(PLUGIN_QRCODE_DATA_PATH . "$id_adh.tel.png")){
unlink(PLUGIN_QRCODE_DATA_PATH . "$id_adh.tel.png");
}
if (empty($phone) && $member->hasParent()){
$phone = $member->parent->phone;
}
if (!empty($phone)){
QRcode::png("tel:$phone", PLUGIN_QRCODE_DATA_PATH . "$id_adh.tel.png", "L", 4, 4);
}
//Créer QRcode Mail
$email = $member->email;
//if member email is missing but there is a parent,
//take the parent email
if (file_exists(PLUGIN_QRCODE_DATA_PATH . "$id_adh.mail.png")){
unlink(PLUGIN_QRCODE_DATA_PATH . "$id_adh.mail.png");
}
if (empty($email) && $member->hasParent()){
$email = $member->parent->email;
}
if (!empty($email)){
QRcode::png("mailto:$email", PLUGIN_QRCODE_DATA_PATH . "$id_adh.mail.png", "L", 4, 4);
}
}
}
header('location: ' .$_SERVER['HTTP_REFERER']);
die();