Subversion Repositories Sites.tela-botanica.org

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4 david 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 :
30
*@author        Alexandre Granier <alexandre@tela-botanica.org>
31
//Autres auteurs :
32
*@author        Aucun
33
*@copyright     Tela-Botanica 2000-2004
34
*@version       $Revision: 1.1 $
35
// +------------------------------------------------------------------------------------------------------+
36
*/
37
 
38
// +------------------------------------------------------------------------------------------------------+
39
// |                                            ENTETE du PROGRAMME                                       |
40
// +------------------------------------------------------------------------------------------------------+
41
 
42
 
406 jpm 43
 
4 david 44
// +------------------------------------------------------------------------------------------------------+
45
// |                                           LISTE de FONCTIONS                                         |
46
// +------------------------------------------------------------------------------------------------------+
47
 
48
function AUTH_formulaire_login() {
49
    $res = '';
406 jpm 50
 
4 david 51
    $url = preg_replace ('/&amp;/', '&', $GLOBALS['ann_url']->getURL()) ;
406 jpm 52
 
53
    $res .= '<p>'.ANN_IDENTIFICATION_PRESENTATION_XHTML.'</p>'."\n" ;
54
 
4 david 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() ;
60
 
61
    return $res;
62
}
63
 
64
/** function parcourrirAnnu ()  Affiche l'annuaire à partir d'une lettre
65
*
66
*
67
*
68
*	@return string HTML
69
*/
483 jpm 70
function parcourrirAnnu() {
4 david 71
 
406 jpm 72
    $res = '<p id="annuaire_alphabet">';
4 david 73
 
406 jpm 74
    // Alphabet pour la rechercher par lettre du nom des inscrits
4 david 75
    for ($i = 65 ; $i <91 ; $i++) {
406 jpm 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";
4 david 80
    }
406 jpm 81
    if (ANN_TOUS_BOOL) {
82
    	$GLOBALS['ann_url']->addQueryString('lettre', 'tous');
83
    	$url_lettre = $GLOBALS['ann_url']->getURL();
84
		$GLOBALS['ann_url']->removeQueryString('lettre');
85
    	$res .= '<a href="'.$url_lettre.'">'.'Tous'.'</a>'."\n";
86
    }
87
    $res .= '</p>'."\n";
4 david 88
 
483 jpm 89
	// Si aucune lettre n'est sélectionnée, attribution de la lettre par défaut
406 jpm 90
    if (empty($_REQUEST['lettre'])) {
91
    	$_REQUEST['lettre'] = ANN_LETTRE_DEFAUT;
92
    }
483 jpm 93
	// Une lettre est disponible...
94
	$requete = 	'SELECT '.ANN_ANNUAIRE.'.*, '.ANN_TABLE_PAYS.'.* '.
95
				'FROM '.ANN_ANNUAIRE.','.ANN_TABLE_PAYS.' '.
96
				'WHERE '.ANN_CHAMPS_PAYS.' = '.ANN_GC_ID.' ';
97
	if ($_REQUEST['lettre'] != 'tous') {
98
		$requete .= ' AND '.ANN_CHAMPS_NOM.' LIKE "'.$_REQUEST['lettre'].'%" ' ;
99
	}
100
	$requete .= 'ORDER BY '.ANN_CHAMPS_NOM;
101
 
102
    $res .= listes_inscrit($requete, $GLOBALS['ann_url']->getURL(), '', $GLOBALS['ann_db'], $niveau = 'pays').
103
    		carto_texte_cocher().
104
            carto_formulaire();
105
 
406 jpm 106
    return $res;
4 david 107
}
108
 
109
/**
110
 *  Renvoie le code HTML de la liste des inscrits
111
 *  en fonction de la requete passé en parametre
112
 *
113
 * @return  Renvoie le code HTML de la liste des inscrits
114
 */
483 jpm 115
function listes_inscrit($requete, $url, $argument, &$db, $niveau = 'pays') {
116
	$resultat = $GLOBALS['ann_db']->query($requete);
117
	(DB::isError($resultat)) ? die($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) : '';
118
 
406 jpm 119
	if ($resultat->numRows() > 0) {
483 jpm 120
		$res = '<form action="'.$url.'?mailer=1&amp;lettre='.$_REQUEST['lettre'].'" method="post" name="formmail">'."\n";
121
		$res .= '<div id="annuaire" class="conteneur_table">
122
					<table id="table_inscrit" class="table_cadre">
123
						<colgroup>
124
							<col />
125
							<col />
126
							<col />
127
							<col />
128
							<col />
129
							<col />
130
							<col />
131
						</colgroup>
132
							<thead class="entete_fixe">
133
								<tr>
134
									<th>&nbsp;</th>
135
									<th>'.ANN_NOM.'</th>
136
									<th>'.ANN_PRENOM.'</th>
137
									<th>'.ANN_DATE_INS.'</th>
138
									<th>'.ANN_CP.'</th>
139
									<th>'.ANN_VILLE.'</th>
406 jpm 140
									<th>'.ANN_PAYS.'</th>
141
								</tr>
483 jpm 142
							</thead>
143
							<tbody class="contenu_deroulant">';
144
		$indic = 0;
145
		$i = 1;
146
		while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
147
			if ($indic == 0) {
148
				$res .= '<tr class="ligne_impaire">'."\n";
149
				$indic = 1;
150
			} else {
151
				$res .= '<tr class="ligne_paire">'."\n";
152
				$indic = 0;
153
			}
154
			$res.= '<td><input type="checkbox" name="select[]" value="'.$ligne[ANN_CHAMPS_MAIL].'" /></td>'."\n".
155
							'<td>'.strtoupper($ligne[ANN_CHAMPS_NOM]).'&nbsp;</td>'."\n".
156
							'<td>'.str_replace(' - ', '-', ucwords(strtolower(str_replace('-', ' - ', $ligne[ANN_CHAMPS_PRENOM])))).'&nbsp;</td>'."\n".
157
							'<td>'.date('d m Y', strtotime($ligne[ANN_CHAMPS_DATE_INS])).'&nbsp;</td>'."\n".
158
							'<td>'.$ligne[ANN_CHAMPS_CODE_POSTAL].'&nbsp;</td>'."\n".
159
							'<td>'.strtoupper($ligne[ANN_CHAMPS_VILLE]).'&nbsp;</td>'."\n".
160
							'<td>'.str_replace(' - ', '-', ucwords(strtolower(str_replace('-', ' - ', ($ligne[ANN_GC_NOM]))))).'&nbsp;</td>'."\n";
161
			$res .= '</tr>'."\n";
162
		}
163
		$res .= '</tbody></table></div>'."\n";
406 jpm 164
	} else {
483 jpm 165
		$res = '<p class="information">'.'Aucun inscrit n\'a de nom commençant par '.$_REQUEST['lettre'].'</p>'."\n";
406 jpm 166
	}
483 jpm 167
	return $res;
4 david 168
}
169
 
483 jpm 170
function carto_formulaire() {
406 jpm 171
    $res = '<div id="redaction">'."\n";
172
    $res .= '<div id="redaction_tete"></div>'."\n";
173
    $res .= '<h2 class="chapo">'.ANN_ENVOYER_MAIL.'</h2>'."\n";
483 jpm 174
	$res .= '<table>'."\n".
175
			'<tr><td class="texte">'.ANN_SUJET.' :</td>'."\n".
176
			'<td><input class="forml" type="text" name="titre_mail" size="60" value="'.$_POST['titre_mail'].'"/></td>'."\n".
177
			'</tr><tr><td class="texte" valign="top">'.ANN_MESSAGE.'&nbsp;:&nbsp;</td>'."\n".
178
			'<td><textarea class="forml" name="corps" rows="5" cols="60">'.$_POST['corps'].'</textarea></td>'."\n".
179
			'</tr><tr><td></td><td align="center">';
406 jpm 180
    $res .='<input class="spip_bouton" type="submit" value="'.ANN_ENVOYER.'" />';
181
    $res .= '</td>'."\n";
182
	$res .= '</tr>'."\n";
183
	$res .= '</table>'."\n";
184
	$res .= '</form>'."\n";
185
	$res .= '<div id="redaction_pied"/></div>'."\n";
186
	$res .= '</div>'."\n";
187
    $res .= '<p class="attention surveillance">'.ANN_SURVEILLANCE.'</p>' ;
188
    $res .= '<p class="information message_a_tous">'.sprintf(ANN_MESSAGE_A_TOUS, '<a href="'.ANN_URL_ACTUALITE.'">'.ANN_ACTUALITE.'</a>').'</p>' ;
4 david 189
    return $res ;
190
}
191
 
192
/** function carto_texte_cocher ()
193
*
194
*
195
*	@return string  HTML
196
*/
483 jpm 197
function carto_texte_cocher() {
198
	$res .= '<div class="texte">'.ANN_CHECK_UNCHECK."\n";
199
	$res .= '&nbsp;<input type="checkbox" name="selecttotal" onclick="javascript:setCheckboxes(\'formmail\');"/>'."\n";
200
	$res .= '</div>';
201
	return $res;
4 david 202
}
203
 
204
/** envoie_mail()
205
 *
206
 *
207
 * @return  envoie l'email
208
 */
483 jpm 209
function envoie_mail($selection, $titre_mail, $corps) {
210
	$requete = 	'SELECT '.ANN_CHAMPS_MAIL.' '.
211
				'FROM '.ANN_ANNUAIRE.' '.
212
				'WHERE '.ANN_CHAMPS_ID.' = "'.$GLOBALS['AUTH']->getAuthData(ANN_CHAMPS_ID).'" ';
213
	$resultat = $GLOBALS['ann_db']->query($requete);
214
	if (DB::isError($resultat)) {
215
		die($resultat->getMessage().'<br />'.$resultat->getDebugInfo());
216
	}
217
	$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
521 jpm 218
 
4 david 219
 
483 jpm 220
	$liste = '';
521 jpm 221
	$entete = '' ;
483 jpm 222
	foreach ($selection as $key => $value) {
521 jpm 223
 
224
		$liste .= $value."," ;
483 jpm 225
	}
521 jpm 226
	$precorps = $ligne[ANN_CHAMPS_MAIL]." ".ANN_EXPEDITEUR_ORIGINAL." \n"  ;
227
	$precorps .= ANN_LISTE_DESTINATAIRES." : ".$liste." \n" ;
228
	$precorps .= ANN_TITRE_MAIL.' : '.$titre_mail." \n" ;
229
	$precorps .= "\n------".ANN_CONTENU_MESSAGE."------\n";
483 jpm 230
 
521 jpm 231
	$corps = $precorps.$corps ;
232
	$corps .= "\n\n".ANN_PIED_MESSAGE."\n";
233
 
483 jpm 234
	$corps .= "\n----------------------------------------------------------------------------";
235
	$corps .= "\n".ANN_MESSAGE_APPLI."\n" ;
521 jpm 236
	//$corps .= "\n".ANN_MESSAGE_ENVOYE_A." :\n $liste" ;
483 jpm 237
 
521 jpm 238
	// Envoie du message au modérateur
239
	if(!mail(MAIL_MODERATION,ANN_TITRE_MAIL_MODERATION,$corps, $entete))
240
	{
241
		trigger_error("Le courriel n'a pas été envoyé à : $courriel", E_USER_WARNING);
242
	}
243
 
244
		/*foreach ($GLOBALS['mail_admin'] as $courriel) {
499 jpm 245
		if (!mail($courriel, $titre_mail, $corps, $entete)) {
246
			trigger_error("Le courriel n'a pas été envoyé à : $courriel", E_USER_WANRNING);
247
		}
521 jpm 248
	}*/
483 jpm 249
 
521 jpm 250
	return '<div class="information">'.ANN_MAIL_ATTENTE_MODERATION.'</div>' ;
4 david 251
}
483 jpm 252
 
253
/** translittererVersIso88591()
254
 *
255
 * Convertit les caractères CP1252 (= ANSI) non présent dans l'ISO-8859-1 par un équivalant ressemblant.
256
 *
257
 * @return  envoie l'email
258
 */
259
function translittererCp1252VersIso88591($str, $translit = true) {
260
	$cp1252_entite_map = array(
261
	   '\x80' => '&#8364;', /* EURO SIGN */
262
	   '\x82' => '&#8218;', /* SINGLE LOW-9 QUOTATION MARK */
263
	   '\x83' => '&#402;',  /* LATIN SMALL LETTER F WITH HOOK */
264
	   '\x84' => '&#8222;', /* DOUBLE LOW-9 QUOTATION MARK */
265
	   '\x85' => '&#8230;', /* HORIZONTAL ELLIPSIS */
266
	   '\x86' => '&#8224;', /* DAGGER */
267
	   '\x87' => '&#8225;', /* DOUBLE DAGGER */
268
	   '\x88' => '&#710;',  /* MODIFIER LETTER CIRCUMFLEX ACCENT */
269
	   '\x89' => '&#8240;', /* PER MILLE SIGN */
270
	   '\x8a' => '&#352;',  /* LATIN CAPITAL LETTER S WITH CARON */
271
	   '\x8b' => '&#8249;', /* SINGLE LEFT-POINTING ANGLE QUOTATION */
272
	   '\x8c' => '&#338;',  /* LATIN CAPITAL LIGATURE OE */
273
	   '\x8e' => '&#381;',  /* LATIN CAPITAL LETTER Z WITH CARON */
274
	   '\x91' => '&#8216;', /* LEFT SINGLE QUOTATION MARK */
275
	   '\x92' => '&#8217;', /* RIGHT SINGLE QUOTATION MARK */
276
	   '\x93' => '&#8220;', /* LEFT DOUBLE QUOTATION MARK */
277
	   '\x94' => '&#8221;', /* RIGHT DOUBLE QUOTATION MARK */
278
	   '\x95' => '&#8226;', /* BULLET */
279
	   '\x96' => '&#8211;', /* EN DASH */
280
	   '\x97' => '&#8212;', /* EM DASH */
281
	   '\x98' => '&#732;',  /* SMALL TILDE */
282
	   '\x99' => '&#8482;', /* TRADE MARK SIGN */
283
	   '\x9a' => '&#353;',  /* LATIN SMALL LETTER S WITH CARON */
284
	   '\x9b' => '&#8250;', /* SINGLE RIGHT-POINTING ANGLE QUOTATION*/
285
	   '\x9c' => '&#339;',  /* LATIN SMALL LIGATURE OE */
286
	   '\x9e' => '&#382;',  /* LATIN SMALL LETTER Z WITH CARON */
287
	   '\x9f' => '&#376;'   /* LATIN CAPITAL LETTER Y WITH DIAERESIS*/
288
	);
289
	$translit_map = array(
290
	   '&#8364;' => 'Euro', /* EURO SIGN */
291
	   '&#8218;' => ',',    /* SINGLE LOW-9 QUOTATION MARK */
292
	   '&#402;' => 'f',     /* LATIN SMALL LETTER F WITH HOOK */
293
	   '&#8222;' => ',,',   /* DOUBLE LOW-9 QUOTATION MARK */
294
	   '&#8230;' => '...',  /* HORIZONTAL ELLIPSIS */
295
	   '&#8224;' => '+',    /* DAGGER */
296
	   '&#8225;' => '++',   /* DOUBLE DAGGER */
297
	   '&#710;' => '^',     /* MODIFIER LETTER CIRCUMFLEX ACCENT */
298
	   '&#8240;' => '0/00', /* PER MILLE SIGN */
299
	   '&#352;' => 'S',     /* LATIN CAPITAL LETTER S WITH CARON */
300
	   '&#8249;' => '<',    /* SINGLE LEFT-POINTING ANGLE QUOTATION */
301
	   '&#338;' => 'OE',    /* LATIN CAPITAL LIGATURE OE */
302
	   '&#381;' => 'Z',     /* LATIN CAPITAL LETTER Z WITH CARON */
303
	   '&#8216;' => "'",    /* LEFT SINGLE QUOTATION MARK */
304
	   '&#8217;' => "'",    /* RIGHT SINGLE QUOTATION MARK */
305
	   '&#8220;' => '"',    /* LEFT DOUBLE QUOTATION MARK */
306
	   '&#8221;' => '"',    /* RIGHT DOUBLE QUOTATION MARK */
307
	   '&#8226;' => '*',    /* BULLET */
308
	   '&#8211;' => '-',    /* EN DASH */
309
	   '&#8212;' => '--',   /* EM DASH */
310
	   '&#732;' => '~',     /* SMALL TILDE */
311
	   '&#8482;' => '(TM)', /* TRADE MARK SIGN */
312
	   '&#353;' => 's',     /* LATIN SMALL LETTER S WITH CARON */
313
	   '&#8250;' => '>',    /* SINGLE RIGHT-POINTING ANGLE QUOTATION*/
314
	   '&#339;' => 'oe',    /* LATIN SMALL LIGATURE OE */
315
	   '&#382;' => 'z',     /* LATIN SMALL LETTER Z WITH CARON */
316
	   '&#376;' => 'Y'      /* LATIN CAPITAL LETTER Y WITH DIAERESIS*/
317
	);
318
	$str = strtr($str, $cp1252_entite_map);
319
	if ($translit) {
320
		$str = strtr($str, $translit_map);
321
	}
322
	return $str;
323
}
4 david 324
?>