Subversion Repositories Sites.gentiana.org

Rev

Rev 88 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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 ('/&amp;/', '&', $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>&nbsp;'."\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&amp;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>&nbsp;</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]).'&nbsp;</td>'."\n".
154
							'<td>'.str_replace(' - ', '-', ucwords(strtolower(str_replace('-', ' - ', $ligne[ANN_CHAMPS_PRENOM])))).'&nbsp;</td>'."\n".
155
							'<td>'.date('d m Y', strtotime($ligne[ANN_CHAMPS_DATE_INS])).'&nbsp;</td>'."\n".
156
							'<td>'.$ligne[ANN_CHAMPS_CODE_POSTAL].'&nbsp;</td>'."\n".
157
							'<td>'.strtoupper($ligne[ANN_CHAMPS_VILLE]).'&nbsp;</td>'."\n".
158
							'<td>'.str_replace(' - ', '-', ucwords(strtolower(str_replace('-', ' - ', ($ligne[ANN_GC_NOM]))))).'&nbsp;</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.'&nbsp;:&nbsp;</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 .= '&nbsp;<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' => '&#8364;', /* EURO SIGN */
242
	   '\x82' => '&#8218;', /* SINGLE LOW-9 QUOTATION MARK */
88 jpm 243
	   '\x83' => '&#402;',  /* LATIN SMALL LETTER F WITH HOOK */
87 jpm 244
	   '\x84' => '&#8222;', /* DOUBLE LOW-9 QUOTATION MARK */
245
	   '\x85' => '&#8230;', /* HORIZONTAL ELLIPSIS */
246
	   '\x86' => '&#8224;', /* DAGGER */
247
	   '\x87' => '&#8225;', /* DOUBLE DAGGER */
88 jpm 248
	   '\x88' => '&#710;',  /* MODIFIER LETTER CIRCUMFLEX ACCENT */
87 jpm 249
	   '\x89' => '&#8240;', /* PER MILLE SIGN */
88 jpm 250
	   '\x8a' => '&#352;',  /* LATIN CAPITAL LETTER S WITH CARON */
87 jpm 251
	   '\x8b' => '&#8249;', /* SINGLE LEFT-POINTING ANGLE QUOTATION */
88 jpm 252
	   '\x8c' => '&#338;',  /* LATIN CAPITAL LIGATURE OE */
253
	   '\x8e' => '&#381;',  /* LATIN CAPITAL LETTER Z WITH CARON */
87 jpm 254
	   '\x91' => '&#8216;', /* LEFT SINGLE QUOTATION MARK */
255
	   '\x92' => '&#8217;', /* RIGHT SINGLE QUOTATION MARK */
256
	   '\x93' => '&#8220;', /* LEFT DOUBLE QUOTATION MARK */
257
	   '\x94' => '&#8221;', /* RIGHT DOUBLE QUOTATION MARK */
258
	   '\x95' => '&#8226;', /* BULLET */
259
	   '\x96' => '&#8211;', /* EN DASH */
260
	   '\x97' => '&#8212;', /* EM DASH */
88 jpm 261
	   '\x98' => '&#732;',  /* SMALL TILDE */
87 jpm 262
	   '\x99' => '&#8482;', /* TRADE MARK SIGN */
88 jpm 263
	   '\x9a' => '&#353;',  /* LATIN SMALL LETTER S WITH CARON */
87 jpm 264
	   '\x9b' => '&#8250;', /* SINGLE RIGHT-POINTING ANGLE QUOTATION*/
88 jpm 265
	   '\x9c' => '&#339;',  /* LATIN SMALL LIGATURE OE */
266
	   '\x9e' => '&#382;',  /* LATIN SMALL LETTER Z WITH CARON */
267
	   '\x9f' => '&#376;'   /* LATIN CAPITAL LETTER Y WITH DIAERESIS*/
87 jpm 268
	);
269
	$translit_map = array(
88 jpm 270
	   '&#8364;' => 'Euro', /* EURO SIGN */
271
	   '&#8218;' => ',',    /* SINGLE LOW-9 QUOTATION MARK */
272
	   '&#402;' => 'f',     /* LATIN SMALL LETTER F WITH HOOK */
273
	   '&#8222;' => ',,',   /* DOUBLE LOW-9 QUOTATION MARK */
274
	   '&#8230;' => '...',  /* HORIZONTAL ELLIPSIS */
275
	   '&#8224;' => '+',    /* DAGGER */
276
	   '&#8225;' => '++',   /* DOUBLE DAGGER */
277
	   '&#710;' => '^',     /* MODIFIER LETTER CIRCUMFLEX ACCENT */
87 jpm 278
	   '&#8240;' => '0/00', /* PER MILLE SIGN */
88 jpm 279
	   '&#352;' => 'S',     /* LATIN CAPITAL LETTER S WITH CARON */
280
	   '&#8249;' => '<',    /* SINGLE LEFT-POINTING ANGLE QUOTATION */
281
	   '&#338;' => 'OE',    /* LATIN CAPITAL LIGATURE OE */
282
	   '&#381;' => 'Z',     /* LATIN CAPITAL LETTER Z WITH CARON */
283
	   '&#8216;' => "'",    /* LEFT SINGLE QUOTATION MARK */
284
	   '&#8217;' => "'",    /* RIGHT SINGLE QUOTATION MARK */
285
	   '&#8220;' => '"',    /* LEFT DOUBLE QUOTATION MARK */
286
	   '&#8221;' => '"',    /* RIGHT DOUBLE QUOTATION MARK */
287
	   '&#8226;' => '*',    /* BULLET */
288
	   '&#8211;' => '-',    /* EN DASH */
289
	   '&#8212;' => '--',   /* EM DASH */
290
	   '&#732;' => '~',     /* SMALL TILDE */
87 jpm 291
	   '&#8482;' => '(TM)', /* TRADE MARK SIGN */
88 jpm 292
	   '&#353;' => 's',     /* LATIN SMALL LETTER S WITH CARON */
293
	   '&#8250;' => '>',    /* SINGLE RIGHT-POINTING ANGLE QUOTATION*/
294
	   '&#339;' => 'oe',    /* LATIN SMALL LIGATURE OE */
295
	   '&#382;' => 'z',     /* LATIN SMALL LETTER Z WITH CARON */
296
	   '&#376;' => '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
?>