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 |
}
|
89 |
jpm |
91 |
// Une lettre est disponible...
|
|
|
92 |
$requete = 'SELECT '.ANN_ANNUAIRE.'.*, '.ANN_TABLE_PAYS.'.* '.
|
|
|
93 |
'FROM '.ANN_ANNUAIRE.','.ANN_TABLE_PAYS.' '.
|
|
|
94 |
'WHERE '.ANN_CHAMPS_PAYS.' = '.ANN_GC_ID.' ';
|
|
|
95 |
if ($_REQUEST['lettre'] != 'tous') {
|
|
|
96 |
$requete .= ' AND '.ANN_CHAMPS_NOM.' LIKE "'.$_REQUEST['lettre'].'%" ' ;
|
86 |
jpm |
97 |
}
|
89 |
jpm |
98 |
$requete .= 'ORDER BY '.ANN_CHAMPS_NOM;
|
|
|
99 |
|
|
|
100 |
$res .= listes_inscrit ($requete, $GLOBALS['ann_url']->getURL(), '', $GLOBALS['ann_db'], $niveau = 'pays').
|
|
|
101 |
carto_texte_cocher().
|
|
|
102 |
carto_formulaire();
|
|
|
103 |
|
86 |
jpm |
104 |
return $res;
|
43 |
jpm |
105 |
}
|
|
|
106 |
|
|
|
107 |
/**
|
|
|
108 |
* Renvoie le code HTML de la liste des inscrits
|
|
|
109 |
* en fonction de la requete passé en parametre
|
|
|
110 |
*
|
|
|
111 |
* @return Renvoie le code HTML de la liste des inscrits
|
|
|
112 |
*/
|
87 |
jpm |
113 |
function listes_inscrit($requete, $url, $argument, &$db, $niveau = 'pays') {
|
86 |
jpm |
114 |
$resultat = $GLOBALS['ann_db']->query($requete);
|
|
|
115 |
(DB::isError($resultat)) ? die($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) : '';
|
|
|
116 |
|
43 |
jpm |
117 |
if ($resultat->numRows() > 0) {
|
87 |
jpm |
118 |
$res = '<form action="'.$url.'?mailer=1&lettre='.$_REQUEST['lettre'].'" method="post" name="formmail">'."\n";
|
86 |
jpm |
119 |
$res .= '<div id="annuaire" class="conteneur_table">
|
|
|
120 |
<table id="table_inscrit" class="table_cadre">
|
|
|
121 |
<colgroup>
|
|
|
122 |
<col />
|
|
|
123 |
<col />
|
|
|
124 |
<col />
|
|
|
125 |
<col />
|
|
|
126 |
<col />
|
|
|
127 |
<col />
|
|
|
128 |
<col />
|
|
|
129 |
</colgroup>
|
|
|
130 |
<thead class="entete_fixe">
|
|
|
131 |
<tr>
|
|
|
132 |
<th> </th>
|
|
|
133 |
<th>'.ANN_NOM.'</th>
|
|
|
134 |
<th>'.ANN_PRENOM.'</th>
|
|
|
135 |
<th>'.ANN_DATE_INS.'</th>
|
|
|
136 |
<th>'.ANN_CP.'</th>
|
|
|
137 |
<th>'.ANN_VILLE.'</th>
|
43 |
jpm |
138 |
<th>'.ANN_PAYS.'</th>
|
|
|
139 |
</tr>
|
86 |
jpm |
140 |
</thead>
|
|
|
141 |
<tbody class="contenu_deroulant">';
|
|
|
142 |
$indic = 0;
|
|
|
143 |
$i = 1;
|
|
|
144 |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
|
87 |
jpm |
145 |
if ($indic == 0) {
|
|
|
146 |
$res .= '<tr class="ligne_impaire">'."\n";
|
|
|
147 |
$indic = 1;
|
86 |
jpm |
148 |
} else {
|
87 |
jpm |
149 |
$res .= '<tr class="ligne_paire">'."\n";
|
|
|
150 |
$indic = 0;
|
86 |
jpm |
151 |
}
|
87 |
jpm |
152 |
$res.= '<td><input type="checkbox" name="select[]" value="'.$ligne[ANN_CHAMPS_MAIL].'" /></td>'."\n".
|
|
|
153 |
'<td>'.strtoupper($ligne[ANN_CHAMPS_NOM]).' </td>'."\n".
|
|
|
154 |
'<td>'.str_replace(' - ', '-', ucwords(strtolower(str_replace('-', ' - ', $ligne[ANN_CHAMPS_PRENOM])))).' </td>'."\n".
|
|
|
155 |
'<td>'.date('d m Y', strtotime($ligne[ANN_CHAMPS_DATE_INS])).' </td>'."\n".
|
|
|
156 |
'<td>'.$ligne[ANN_CHAMPS_CODE_POSTAL].' </td>'."\n".
|
|
|
157 |
'<td>'.strtoupper($ligne[ANN_CHAMPS_VILLE]).' </td>'."\n".
|
|
|
158 |
'<td>'.str_replace(' - ', '-', ucwords(strtolower(str_replace('-', ' - ', ($ligne[ANN_GC_NOM]))))).' </td>'."\n";
|
|
|
159 |
$res .= '</tr>'."\n";
|
86 |
jpm |
160 |
}
|
87 |
jpm |
161 |
$res .= '</tbody></table></div>'."\n";
|
43 |
jpm |
162 |
} else {
|
87 |
jpm |
163 |
$res = '<p class="information">'.'Aucun inscrit n\'a de nom commençant par '.$_REQUEST['lettre'].'</p>'."\n";
|
43 |
jpm |
164 |
}
|
86 |
jpm |
165 |
return $res;
|
43 |
jpm |
166 |
}
|
|
|
167 |
|
|
|
168 |
|
87 |
jpm |
169 |
function carto_formulaire() {
|
86 |
jpm |
170 |
$res = '<h2 class="chapo">'.ANN_ENVOYER_MAIL.'</h2>'."\n";
|
|
|
171 |
$res .= '<p class="attention surveillance">'.ANN_SURVEILLANCE.'</p>'."\n";
|
|
|
172 |
$res .= '<p class="information message_a_tous">'.sprintf(ANN_MESSAGE_A_TOUS, '<a href="'.ANN_URL_ACTUALITE.'">'.ANN_ACTUALITE.'</a>').'</p>'."\n";
|
|
|
173 |
$res .= '<table>'."\n".
|
|
|
174 |
'<tr><td class="texte">'.ANN_SUJET.' :</td>'."\n".
|
87 |
jpm |
175 |
'<td><input class="forml" type="text" name="titre_mail" size="60" value="'.$_POST['titre_mail'].'"/></td>'."\n".
|
86 |
jpm |
176 |
'</tr><tr><td class="texte" valign="top">'.ANN_MESSAGE.' : </td>'."\n".
|
87 |
jpm |
177 |
'<td><textarea class="forml" name="corps" rows="5" cols="60">'.$_POST['corps'].'</textarea></td>'."\n".
|
86 |
jpm |
178 |
'</tr><tr><td></td><td align="center">';
|
|
|
179 |
$res .= '<input class="spip_bouton" type="submit" value="'.ANN_ENVOYER.'" />'."\n";
|
|
|
180 |
$res .= '</td>'."\n";
|
43 |
jpm |
181 |
$res .= '</tr>'."\n";
|
|
|
182 |
$res .= '</table>'."\n";
|
|
|
183 |
$res .= '</form>'."\n";
|
86 |
jpm |
184 |
return $res;
|
43 |
jpm |
185 |
}
|
|
|
186 |
|
|
|
187 |
|
|
|
188 |
/** function carto_texte_cocher ()
|
|
|
189 |
*
|
|
|
190 |
*
|
|
|
191 |
* @return string HTML
|
|
|
192 |
*/
|
87 |
jpm |
193 |
function carto_texte_cocher() {
|
86 |
jpm |
194 |
$res .= '<div class="texte">'.ANN_CHECK_UNCHECK."\n";
|
|
|
195 |
$res .= ' <input type="checkbox" name="selecttotal" onclick="javascript:setCheckboxes(\'formmail\');"/>'."\n";
|
|
|
196 |
$res .= '</div>';
|
|
|
197 |
return $res;
|
43 |
jpm |
198 |
}
|
|
|
199 |
|
|
|
200 |
|
|
|
201 |
/** envoie_mail()
|
|
|
202 |
*
|
|
|
203 |
*
|
|
|
204 |
* @return envoie l'email
|
|
|
205 |
*/
|
87 |
jpm |
206 |
function envoie_mail($selection, $titre_mail, $corps) {
|
86 |
jpm |
207 |
$requete = 'SELECT '.ANN_CHAMPS_MAIL.' '.
|
|
|
208 |
'FROM '.ANN_ANNUAIRE.' '.
|
|
|
209 |
'WHERE '.ANN_CHAMPS_ID.' = "'.$GLOBALS['AUTH']->getAuthData(ANN_CHAMPS_ID).'" ';
|
|
|
210 |
$resultat = $GLOBALS['ann_db']->query($requete);
|
|
|
211 |
if (DB::isError($resultat)) {
|
|
|
212 |
die($resultat->getMessage().'<br />'.$resultat->getDebugInfo());
|
|
|
213 |
}
|
|
|
214 |
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
|
|
|
215 |
$entete = 'From: <'.$ligne[ANN_CHAMPS_MAIL].">\n";
|
87 |
jpm |
216 |
|
|
|
217 |
$corps .= "\n".ANN_PIED_MESSAGE;
|
|
|
218 |
|
86 |
jpm |
219 |
$liste = '';
|
87 |
jpm |
220 |
foreach ($selection as $key => $value) {
|
|
|
221 |
mail($value, $titre_mail, $corps, $entete);
|
86 |
jpm |
222 |
$liste .= $value."\n";
|
|
|
223 |
}
|
|
|
224 |
|
87 |
jpm |
225 |
$corps .= "\n----------------------------------------------------------------------------";
|
|
|
226 |
$corps .= "\n".ANN_MESSAGE_APPLI."\n" ;
|
|
|
227 |
$corps .= "\n".ANN_MESSAGE_ENVOYE_A." :\n $liste" ;
|
86 |
jpm |
228 |
|
87 |
jpm |
229 |
mail(ANN_MAIL_ADMIN, $titre_mail, $corps, $entete);
|
|
|
230 |
|
86 |
jpm |
231 |
return '<div class="information">'.ANN_MAIL_ENVOYER.'</div>' ;
|
43 |
jpm |
232 |
}
|
87 |
jpm |
233 |
/** translittererVersIso88591()
|
|
|
234 |
*
|
|
|
235 |
* Convertit les caractères CP1252 (= ANSI) non présent dans l'ISO-8859-1 par un équivalant ressemblant.
|
|
|
236 |
*
|
|
|
237 |
* @return envoie l'email
|
|
|
238 |
*/
|
|
|
239 |
function translittererCp1252VersIso88591($str, $translit = true) {
|
|
|
240 |
$cp1252_entite_map = array(
|
|
|
241 |
'\x80' => '€', /* EURO SIGN */
|
|
|
242 |
'\x82' => '‚', /* SINGLE LOW-9 QUOTATION MARK */
|
88 |
jpm |
243 |
'\x83' => 'ƒ', /* LATIN SMALL LETTER F WITH HOOK */
|
87 |
jpm |
244 |
'\x84' => '„', /* DOUBLE LOW-9 QUOTATION MARK */
|
|
|
245 |
'\x85' => '…', /* HORIZONTAL ELLIPSIS */
|
|
|
246 |
'\x86' => '†', /* DAGGER */
|
|
|
247 |
'\x87' => '‡', /* DOUBLE DAGGER */
|
88 |
jpm |
248 |
'\x88' => 'ˆ', /* MODIFIER LETTER CIRCUMFLEX ACCENT */
|
87 |
jpm |
249 |
'\x89' => '‰', /* PER MILLE SIGN */
|
88 |
jpm |
250 |
'\x8a' => 'Š', /* LATIN CAPITAL LETTER S WITH CARON */
|
87 |
jpm |
251 |
'\x8b' => '‹', /* SINGLE LEFT-POINTING ANGLE QUOTATION */
|
88 |
jpm |
252 |
'\x8c' => 'Œ', /* LATIN CAPITAL LIGATURE OE */
|
|
|
253 |
'\x8e' => 'Ž', /* LATIN CAPITAL LETTER Z WITH CARON */
|
87 |
jpm |
254 |
'\x91' => '‘', /* LEFT SINGLE QUOTATION MARK */
|
|
|
255 |
'\x92' => '’', /* RIGHT SINGLE QUOTATION MARK */
|
|
|
256 |
'\x93' => '“', /* LEFT DOUBLE QUOTATION MARK */
|
|
|
257 |
'\x94' => '”', /* RIGHT DOUBLE QUOTATION MARK */
|
|
|
258 |
'\x95' => '•', /* BULLET */
|
|
|
259 |
'\x96' => '–', /* EN DASH */
|
|
|
260 |
'\x97' => '—', /* EM DASH */
|
88 |
jpm |
261 |
'\x98' => '˜', /* SMALL TILDE */
|
87 |
jpm |
262 |
'\x99' => '™', /* TRADE MARK SIGN */
|
88 |
jpm |
263 |
'\x9a' => 'š', /* LATIN SMALL LETTER S WITH CARON */
|
87 |
jpm |
264 |
'\x9b' => '›', /* SINGLE RIGHT-POINTING ANGLE QUOTATION*/
|
88 |
jpm |
265 |
'\x9c' => 'œ', /* LATIN SMALL LIGATURE OE */
|
|
|
266 |
'\x9e' => 'ž', /* LATIN SMALL LETTER Z WITH CARON */
|
|
|
267 |
'\x9f' => 'Ÿ' /* LATIN CAPITAL LETTER Y WITH DIAERESIS*/
|
87 |
jpm |
268 |
);
|
|
|
269 |
$translit_map = array(
|
88 |
jpm |
270 |
'€' => 'Euro', /* EURO SIGN */
|
|
|
271 |
'‚' => ',', /* SINGLE LOW-9 QUOTATION MARK */
|
|
|
272 |
'ƒ' => 'f', /* LATIN SMALL LETTER F WITH HOOK */
|
|
|
273 |
'„' => ',,', /* DOUBLE LOW-9 QUOTATION MARK */
|
|
|
274 |
'…' => '...', /* HORIZONTAL ELLIPSIS */
|
|
|
275 |
'†' => '+', /* DAGGER */
|
|
|
276 |
'‡' => '++', /* DOUBLE DAGGER */
|
|
|
277 |
'ˆ' => '^', /* MODIFIER LETTER CIRCUMFLEX ACCENT */
|
87 |
jpm |
278 |
'‰' => '0/00', /* PER MILLE SIGN */
|
88 |
jpm |
279 |
'Š' => 'S', /* LATIN CAPITAL LETTER S WITH CARON */
|
|
|
280 |
'‹' => '<', /* SINGLE LEFT-POINTING ANGLE QUOTATION */
|
|
|
281 |
'Œ' => 'OE', /* LATIN CAPITAL LIGATURE OE */
|
|
|
282 |
'Ž' => 'Z', /* LATIN CAPITAL LETTER Z WITH CARON */
|
|
|
283 |
'‘' => "'", /* LEFT SINGLE QUOTATION MARK */
|
|
|
284 |
'’' => "'", /* RIGHT SINGLE QUOTATION MARK */
|
|
|
285 |
'“' => '"', /* LEFT DOUBLE QUOTATION MARK */
|
|
|
286 |
'”' => '"', /* RIGHT DOUBLE QUOTATION MARK */
|
|
|
287 |
'•' => '*', /* BULLET */
|
|
|
288 |
'–' => '-', /* EN DASH */
|
|
|
289 |
'—' => '--', /* EM DASH */
|
|
|
290 |
'˜' => '~', /* SMALL TILDE */
|
87 |
jpm |
291 |
'™' => '(TM)', /* TRADE MARK SIGN */
|
88 |
jpm |
292 |
'š' => 's', /* LATIN SMALL LETTER S WITH CARON */
|
|
|
293 |
'›' => '>', /* SINGLE RIGHT-POINTING ANGLE QUOTATION*/
|
|
|
294 |
'œ' => 'oe', /* LATIN SMALL LIGATURE OE */
|
|
|
295 |
'ž' => 'z', /* LATIN SMALL LETTER Z WITH CARON */
|
|
|
296 |
'Ÿ' => 'Y' /* LATIN CAPITAL LETTER Y WITH DIAERESIS*/
|
87 |
jpm |
297 |
);
|
|
|
298 |
$str = strtr($str, $cp1252_entite_map);
|
|
|
299 |
if ($translit) {
|
|
|
300 |
$str = strtr($str, $translit_map);
|
|
|
301 |
}
|
|
|
302 |
return $str;
|
|
|
303 |
}
|
43 |
jpm |
304 |
?>
|