43 |
jpm |
1 |
<?php
|
|
|
2 |
/*vim: set expandtab tabstop=4 shiftwidth=4: */
|
|
|
3 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
4 |
// | PHP version 4.1 |
|
|
|
5 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
6 |
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
|
|
|
7 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
8 |
// | This library is free software; you can redistribute it and/or |
|
|
|
9 |
// | modify it under the terms of the GNU Lesser General Public |
|
|
|
10 |
// | License as published by the Free Software Foundation; either |
|
|
|
11 |
// | version 2.1 of the License, or (at your option) any later version. |
|
|
|
12 |
// | |
|
|
|
13 |
// | This library is distributed in the hope that it will be useful, |
|
|
|
14 |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
|
15 |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
|
|
16 |
// | Lesser General Public License for more details. |
|
|
|
17 |
// | |
|
|
|
18 |
// | You should have received a copy of the GNU Lesser General Public |
|
|
|
19 |
// | License along with this library; if not, write to the Free Software |
|
|
|
20 |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
|
|
21 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
22 |
// CVS : $Id: annuaire.fonct.php,v 1.1 2005/03/24 08:46:07 alex Exp $
|
|
|
23 |
/**
|
|
|
24 |
* Fonctions du module annuaire
|
|
|
25 |
*
|
|
|
26 |
* Fonctions du module annuaire
|
|
|
27 |
*
|
|
|
28 |
*@package annuaire
|
|
|
29 |
//Auteur original :
|
86 |
jpm |
30 |
*@author Alexandre Granier <alexandre@tela-botanica.org>
|
43 |
jpm |
31 |
//Autres auteurs :
|
86 |
jpm |
32 |
*@author Aucun
|
|
|
33 |
*@copyright Tela-Botanica 2000-2004
|
|
|
34 |
*@version $Revision: 1.1 $
|
43 |
jpm |
35 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
36 |
*/
|
|
|
37 |
|
|
|
38 |
// +------------------------------------------------------------------------------------------------------+
|
86 |
jpm |
39 |
// | ENTETE du PROGRAMME |
|
43 |
jpm |
40 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
41 |
|
|
|
42 |
|
|
|
43 |
|
|
|
44 |
// +------------------------------------------------------------------------------------------------------+
|
86 |
jpm |
45 |
// | LISTE de FONCTIONS |
|
43 |
jpm |
46 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
47 |
|
|
|
48 |
function AUTH_formulaire_login() {
|
86 |
jpm |
49 |
$res = '';
|
|
|
50 |
|
|
|
51 |
$url = preg_replace ('/&/', '&', $GLOBALS['ann_url']->getURL()) ;
|
48 |
jpm |
52 |
|
86 |
jpm |
53 |
$res .= '<p>'.ANN_IDENTIFICATION_PRESENTATION_XHTML.'</p>'."\n" ;
|
|
|
54 |
|
|
|
55 |
$form = new HTML_QuickForm ('inscription', 'post', $url) ;
|
|
|
56 |
$form->addElement ('text', 'username', ANN_EMAIL) ;
|
|
|
57 |
$form->addElement ('password', 'password', ANN_MOT_DE_PASSE) ;
|
|
|
58 |
$form->addElement('submit', 'valider', ANN_VALIDER);
|
|
|
59 |
$res .= $form->toHTML() ;
|
43 |
jpm |
60 |
|
86 |
jpm |
61 |
return $res;
|
43 |
jpm |
62 |
}
|
|
|
63 |
|
|
|
64 |
/** function parcourrirAnnu () Affiche l'annuaire à partir d'une lettre
|
|
|
65 |
*
|
|
|
66 |
*
|
|
|
67 |
*
|
|
|
68 |
* @return string HTML
|
|
|
69 |
*/
|
87 |
jpm |
70 |
function parcourrirAnnu() {
|
43 |
jpm |
71 |
|
86 |
jpm |
72 |
$res = '<p id="annuaire_alphabet">';
|
43 |
jpm |
73 |
|
86 |
jpm |
74 |
// Alphabet pour la rechercher par lettre du nom des inscrits
|
|
|
75 |
for ($i = 65 ; $i < 91 ; $i++) {
|
|
|
76 |
$GLOBALS['ann_url']->addQueryString('lettre', chr($i));
|
|
|
77 |
$url_lettre = $GLOBALS['ann_url']->getURL();
|
|
|
78 |
$GLOBALS['ann_url']->removeQueryString('lettre');
|
|
|
79 |
$res .= '<a href="'.$url_lettre.'">'.chr($i).'</a> '."\n";
|
|
|
80 |
}
|
|
|
81 |
$GLOBALS['ann_url']->addQueryString('lettre', 'tous');
|
|
|
82 |
$url_lettre = $GLOBALS['ann_url']->getURL();
|
43 |
jpm |
83 |
$GLOBALS['ann_url']->removeQueryString('lettre');
|
86 |
jpm |
84 |
$res .= '<a href="'.$url_lettre.'">'.'Tous'.'</a>'."\n";
|
|
|
85 |
$res .= '</p>'."\n";
|
43 |
jpm |
86 |
|
86 |
jpm |
87 |
// Si aucune lettre n'est sélectionnée, attribution de la lettre par défaut
|
|
|
88 |
if (empty($_REQUEST['lettre'])) {
|
|
|
89 |
$_REQUEST['lettre'] = ANN_LETTRE_DEFAUT;
|
|
|
90 |
}
|
83 |
jpm |
91 |
// Si une lettre est sélectionnée
|
86 |
jpm |
92 |
if (!empty($_REQUEST['lettre'])) {
|
87 |
jpm |
93 |
$requete = 'SELECT '.ANN_ANNUAIRE.'.*, '.ANN_TABLE_PAYS.'.* '.
|
|
|
94 |
'FROM '.ANN_ANNUAIRE.','.ANN_TABLE_PAYS.' '.
|
|
|
95 |
'WHERE '.ANN_CHAMPS_PAYS.' = '.ANN_GC_ID.' ';
|
86 |
jpm |
96 |
if ($_REQUEST['lettre'] != 'tous') {
|
87 |
jpm |
97 |
$requete .= ' AND '.ANN_CHAMPS_NOM.' LIKE "'.$_REQUEST['lettre'].'%" ' ;
|
86 |
jpm |
98 |
}
|
87 |
jpm |
99 |
$requete .= 'ORDER BY '.ANN_CHAMPS_NOM;
|
86 |
jpm |
100 |
|
87 |
jpm |
101 |
$res .= listes_inscrit ($requete, $GLOBALS['ann_url']->getURL(), '', $GLOBALS['ann_db'], $niveau = 'pays').
|
86 |
jpm |
102 |
carto_texte_cocher().
|
87 |
jpm |
103 |
carto_formulaire();
|
86 |
jpm |
104 |
}
|
|
|
105 |
return $res;
|
43 |
jpm |
106 |
}
|
|
|
107 |
|
|
|
108 |
/**
|
|
|
109 |
* Renvoie le code HTML de la liste des inscrits
|
|
|
110 |
* en fonction de la requete passé en parametre
|
|
|
111 |
*
|
|
|
112 |
* @return Renvoie le code HTML de la liste des inscrits
|
|
|
113 |
*/
|
87 |
jpm |
114 |
function listes_inscrit($requete, $url, $argument, &$db, $niveau = 'pays') {
|
86 |
jpm |
115 |
$resultat = $GLOBALS['ann_db']->query($requete);
|
|
|
116 |
(DB::isError($resultat)) ? die($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) : '';
|
|
|
117 |
|
43 |
jpm |
118 |
if ($resultat->numRows() > 0) {
|
87 |
jpm |
119 |
$res = '<form action="'.$url.'?mailer=1&lettre='.$_REQUEST['lettre'].'" method="post" name="formmail">'."\n";
|
86 |
jpm |
120 |
$res .= '<div id="annuaire" class="conteneur_table">
|
|
|
121 |
<table id="table_inscrit" class="table_cadre">
|
|
|
122 |
<colgroup>
|
|
|
123 |
<col />
|
|
|
124 |
<col />
|
|
|
125 |
<col />
|
|
|
126 |
<col />
|
|
|
127 |
<col />
|
|
|
128 |
<col />
|
|
|
129 |
<col />
|
|
|
130 |
</colgroup>
|
|
|
131 |
<thead class="entete_fixe">
|
|
|
132 |
<tr>
|
|
|
133 |
<th> </th>
|
|
|
134 |
<th>'.ANN_NOM.'</th>
|
|
|
135 |
<th>'.ANN_PRENOM.'</th>
|
|
|
136 |
<th>'.ANN_DATE_INS.'</th>
|
|
|
137 |
<th>'.ANN_CP.'</th>
|
|
|
138 |
<th>'.ANN_VILLE.'</th>
|
43 |
jpm |
139 |
<th>'.ANN_PAYS.'</th>
|
|
|
140 |
</tr>
|
86 |
jpm |
141 |
</thead>
|
|
|
142 |
<tbody class="contenu_deroulant">';
|
|
|
143 |
$indic = 0;
|
|
|
144 |
$i = 1;
|
|
|
145 |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
|
87 |
jpm |
146 |
if ($indic == 0) {
|
|
|
147 |
$res .= '<tr class="ligne_impaire">'."\n";
|
|
|
148 |
$indic = 1;
|
86 |
jpm |
149 |
} else {
|
87 |
jpm |
150 |
$res .= '<tr class="ligne_paire">'."\n";
|
|
|
151 |
$indic = 0;
|
86 |
jpm |
152 |
}
|
87 |
jpm |
153 |
$res.= '<td><input type="checkbox" name="select[]" value="'.$ligne[ANN_CHAMPS_MAIL].'" /></td>'."\n".
|
|
|
154 |
'<td>'.strtoupper($ligne[ANN_CHAMPS_NOM]).' </td>'."\n".
|
|
|
155 |
'<td>'.str_replace(' - ', '-', ucwords(strtolower(str_replace('-', ' - ', $ligne[ANN_CHAMPS_PRENOM])))).' </td>'."\n".
|
|
|
156 |
'<td>'.date('d m Y', strtotime($ligne[ANN_CHAMPS_DATE_INS])).' </td>'."\n".
|
|
|
157 |
'<td>'.$ligne[ANN_CHAMPS_CODE_POSTAL].' </td>'."\n".
|
|
|
158 |
'<td>'.strtoupper($ligne[ANN_CHAMPS_VILLE]).' </td>'."\n".
|
|
|
159 |
'<td>'.str_replace(' - ', '-', ucwords(strtolower(str_replace('-', ' - ', ($ligne[ANN_GC_NOM]))))).' </td>'."\n";
|
|
|
160 |
$res .= '</tr>'."\n";
|
86 |
jpm |
161 |
}
|
87 |
jpm |
162 |
$res .= '</tbody></table></div>'."\n";
|
43 |
jpm |
163 |
} else {
|
87 |
jpm |
164 |
$res = '<p class="information">'.'Aucun inscrit n\'a de nom commençant par '.$_REQUEST['lettre'].'</p>'."\n";
|
43 |
jpm |
165 |
}
|
86 |
jpm |
166 |
return $res;
|
43 |
jpm |
167 |
}
|
|
|
168 |
|
|
|
169 |
|
87 |
jpm |
170 |
function carto_formulaire() {
|
86 |
jpm |
171 |
$res = '<h2 class="chapo">'.ANN_ENVOYER_MAIL.'</h2>'."\n";
|
|
|
172 |
$res .= '<p class="attention surveillance">'.ANN_SURVEILLANCE.'</p>'."\n";
|
|
|
173 |
$res .= '<p class="information message_a_tous">'.sprintf(ANN_MESSAGE_A_TOUS, '<a href="'.ANN_URL_ACTUALITE.'">'.ANN_ACTUALITE.'</a>').'</p>'."\n";
|
|
|
174 |
$res .= '<table>'."\n".
|
|
|
175 |
'<tr><td class="texte">'.ANN_SUJET.' :</td>'."\n".
|
87 |
jpm |
176 |
'<td><input class="forml" type="text" name="titre_mail" size="60" value="'.$_POST['titre_mail'].'"/></td>'."\n".
|
86 |
jpm |
177 |
'</tr><tr><td class="texte" valign="top">'.ANN_MESSAGE.' : </td>'."\n".
|
87 |
jpm |
178 |
'<td><textarea class="forml" name="corps" rows="5" cols="60">'.$_POST['corps'].'</textarea></td>'."\n".
|
86 |
jpm |
179 |
'</tr><tr><td></td><td align="center">';
|
|
|
180 |
$res .= '<input class="spip_bouton" type="submit" value="'.ANN_ENVOYER.'" />'."\n";
|
|
|
181 |
$res .= '</td>'."\n";
|
43 |
jpm |
182 |
$res .= '</tr>'."\n";
|
|
|
183 |
$res .= '</table>'."\n";
|
|
|
184 |
$res .= '</form>'."\n";
|
86 |
jpm |
185 |
return $res;
|
43 |
jpm |
186 |
}
|
|
|
187 |
|
|
|
188 |
|
|
|
189 |
/** function carto_texte_cocher ()
|
|
|
190 |
*
|
|
|
191 |
*
|
|
|
192 |
* @return string HTML
|
|
|
193 |
*/
|
87 |
jpm |
194 |
function carto_texte_cocher() {
|
86 |
jpm |
195 |
$res .= '<div class="texte">'.ANN_CHECK_UNCHECK."\n";
|
|
|
196 |
$res .= ' <input type="checkbox" name="selecttotal" onclick="javascript:setCheckboxes(\'formmail\');"/>'."\n";
|
|
|
197 |
$res .= '</div>';
|
|
|
198 |
return $res;
|
43 |
jpm |
199 |
}
|
|
|
200 |
|
|
|
201 |
|
|
|
202 |
/** envoie_mail()
|
|
|
203 |
*
|
|
|
204 |
*
|
|
|
205 |
* @return envoie l'email
|
|
|
206 |
*/
|
87 |
jpm |
207 |
function envoie_mail($selection, $titre_mail, $corps) {
|
86 |
jpm |
208 |
$requete = 'SELECT '.ANN_CHAMPS_MAIL.' '.
|
|
|
209 |
'FROM '.ANN_ANNUAIRE.' '.
|
|
|
210 |
'WHERE '.ANN_CHAMPS_ID.' = "'.$GLOBALS['AUTH']->getAuthData(ANN_CHAMPS_ID).'" ';
|
|
|
211 |
$resultat = $GLOBALS['ann_db']->query($requete);
|
|
|
212 |
if (DB::isError($resultat)) {
|
|
|
213 |
die($resultat->getMessage().'<br />'.$resultat->getDebugInfo());
|
|
|
214 |
}
|
|
|
215 |
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
|
|
|
216 |
$entete = 'From: <'.$ligne[ANN_CHAMPS_MAIL].">\n";
|
87 |
jpm |
217 |
|
|
|
218 |
$corps .= "\n".ANN_PIED_MESSAGE;
|
|
|
219 |
|
86 |
jpm |
220 |
$liste = '';
|
87 |
jpm |
221 |
foreach ($selection as $key => $value) {
|
|
|
222 |
mail($value, $titre_mail, $corps, $entete);
|
86 |
jpm |
223 |
$liste .= $value."\n";
|
|
|
224 |
}
|
|
|
225 |
|
87 |
jpm |
226 |
$corps .= "\n----------------------------------------------------------------------------";
|
|
|
227 |
$corps .= "\n".ANN_MESSAGE_APPLI."\n" ;
|
|
|
228 |
$corps .= "\n".ANN_MESSAGE_ENVOYE_A." :\n $liste" ;
|
86 |
jpm |
229 |
|
87 |
jpm |
230 |
mail(ANN_MAIL_ADMIN, $titre_mail, $corps, $entete);
|
|
|
231 |
|
86 |
jpm |
232 |
return '<div class="information">'.ANN_MAIL_ENVOYER.'</div>' ;
|
43 |
jpm |
233 |
}
|
87 |
jpm |
234 |
/** translittererVersIso88591()
|
|
|
235 |
*
|
|
|
236 |
* Convertit les caractères CP1252 (= ANSI) non présent dans l'ISO-8859-1 par un équivalant ressemblant.
|
|
|
237 |
*
|
|
|
238 |
* @return envoie l'email
|
|
|
239 |
*/
|
|
|
240 |
function translittererCp1252VersIso88591($str, $translit = true) {
|
|
|
241 |
$cp1252_entite_map = array(
|
|
|
242 |
'\x80' => '€', /* EURO SIGN */
|
|
|
243 |
'\x82' => '‚', /* SINGLE LOW-9 QUOTATION MARK */
|
|
|
244 |
'\x83' => 'ƒ', /* LATIN SMALL LETTER F WITH HOOK */
|
|
|
245 |
'\x84' => '„', /* DOUBLE LOW-9 QUOTATION MARK */
|
|
|
246 |
'\x85' => '…', /* HORIZONTAL ELLIPSIS */
|
|
|
247 |
'\x86' => '†', /* DAGGER */
|
|
|
248 |
'\x87' => '‡', /* DOUBLE DAGGER */
|
|
|
249 |
'\x88' => 'ˆ', /* MODIFIER LETTER CIRCUMFLEX ACCENT */
|
|
|
250 |
'\x89' => '‰', /* PER MILLE SIGN */
|
|
|
251 |
'\x8a' => 'Š', /* LATIN CAPITAL LETTER S WITH CARON */
|
|
|
252 |
'\x8b' => '‹', /* SINGLE LEFT-POINTING ANGLE QUOTATION */
|
|
|
253 |
'\x8c' => 'Œ', /* LATIN CAPITAL LIGATURE OE */
|
|
|
254 |
'\x8e' => 'Ž', /* LATIN CAPITAL LETTER Z WITH CARON */
|
|
|
255 |
'\x91' => '‘', /* LEFT SINGLE QUOTATION MARK */
|
|
|
256 |
'\x92' => '’', /* RIGHT SINGLE QUOTATION MARK */
|
|
|
257 |
'\x93' => '“', /* LEFT DOUBLE QUOTATION MARK */
|
|
|
258 |
'\x94' => '”', /* RIGHT DOUBLE QUOTATION MARK */
|
|
|
259 |
'\x95' => '•', /* BULLET */
|
|
|
260 |
'\x96' => '–', /* EN DASH */
|
|
|
261 |
'\x97' => '—', /* EM DASH */
|
|
|
262 |
'\x98' => '˜', /* SMALL TILDE */
|
|
|
263 |
'\x99' => '™', /* TRADE MARK SIGN */
|
|
|
264 |
'\x9a' => 'š', /* LATIN SMALL LETTER S WITH CARON */
|
|
|
265 |
'\x9b' => '›', /* SINGLE RIGHT-POINTING ANGLE QUOTATION*/
|
|
|
266 |
'\x9c' => 'œ', /* LATIN SMALL LIGATURE OE */
|
|
|
267 |
'\x9e' => 'ž', /* LATIN SMALL LETTER Z WITH CARON */
|
|
|
268 |
'\x9f' => 'Ÿ' /* LATIN CAPITAL LETTER Y WITH DIAERESIS*/
|
|
|
269 |
);
|
|
|
270 |
$translit_map = array(
|
|
|
271 |
'€' => 'Euro', /* EURO SIGN */
|
|
|
272 |
'‚' => ',', /* SINGLE LOW-9 QUOTATION MARK */
|
|
|
273 |
'ƒ' => 'f', /* LATIN SMALL LETTER F WITH HOOK */
|
|
|
274 |
'„' => ',,', /* DOUBLE LOW-9 QUOTATION MARK */
|
|
|
275 |
'…' => '...', /* HORIZONTAL ELLIPSIS */
|
|
|
276 |
'†' => '+', /* DAGGER */
|
|
|
277 |
'‡' => '++', /* DOUBLE DAGGER */
|
|
|
278 |
'ˆ' => '^', /* MODIFIER LETTER CIRCUMFLEX ACCENT */
|
|
|
279 |
'‰' => '0/00', /* PER MILLE SIGN */
|
|
|
280 |
'Š' => 'S', /* LATIN CAPITAL LETTER S WITH CARON */
|
|
|
281 |
'‹' => '<', /* SINGLE LEFT-POINTING ANGLE QUOTATION */
|
|
|
282 |
'Œ' => 'OE', /* LATIN CAPITAL LIGATURE OE */
|
|
|
283 |
'Ž' => 'Z', /* LATIN CAPITAL LETTER Z WITH CARON */
|
|
|
284 |
'‘' => "'", /* LEFT SINGLE QUOTATION MARK */
|
|
|
285 |
'’' => "'", /* RIGHT SINGLE QUOTATION MARK */
|
|
|
286 |
'“' => '"', /* LEFT DOUBLE QUOTATION MARK */
|
|
|
287 |
'”' => '"', /* RIGHT DOUBLE QUOTATION MARK */
|
|
|
288 |
'•' => '*', /* BULLET */
|
|
|
289 |
'–' => '-', /* EN DASH */
|
|
|
290 |
'—' => '--', /* EM DASH */
|
|
|
291 |
'˜' => '~', /* SMALL TILDE */
|
|
|
292 |
'™' => '(TM)', /* TRADE MARK SIGN */
|
|
|
293 |
'š' => 's', /* LATIN SMALL LETTER S WITH CARON */
|
|
|
294 |
'›' => '>', /* SINGLE RIGHT-POINTING ANGLE QUOTATION*/
|
|
|
295 |
'œ' => 'oe', /* LATIN SMALL LIGATURE OE */
|
|
|
296 |
'ž' => 'z', /* LATIN SMALL LETTER Z WITH CARON */
|
|
|
297 |
'Ÿ' => 'Y' /* LATIN CAPITAL LETTER Y WITH DIAERESIS*/
|
|
|
298 |
);
|
|
|
299 |
$str = strtr($str, $cp1252_entite_map);
|
|
|
300 |
if ($translit) {
|
|
|
301 |
$str = strtr($str, $translit_map);
|
|
|
302 |
}
|
|
|
303 |
return $str;
|
|
|
304 |
}
|
43 |
jpm |
305 |
?>
|