Subversion Repositories Applications.papyrus

Rev

Rev 1186 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
448 ddelon 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
// +------------------------------------------------------------------------------------------------------+
1292 neiluj 22
// CVS : $Id: annuaire.fonct.php,v 1.6 2007-04-06 08:35:46 neiluj Exp $
448 ddelon 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
1292 neiluj 34
*@version       $Revision: 1.6 $
448 ddelon 35
// +------------------------------------------------------------------------------------------------------+
36
*/
37
 
38
// +------------------------------------------------------------------------------------------------------+
39
// |                                            ENTETE du PROGRAMME                                       |
40
// +------------------------------------------------------------------------------------------------------+
41
 
1292 neiluj 42
include_once "HTML/QuickForm.php" ;
448 ddelon 43
 
44
// +------------------------------------------------------------------------------------------------------+
45
// |                                           LISTE de FONCTIONS                                         |
46
// +------------------------------------------------------------------------------------------------------+
47
 
1292 neiluj 48
/** function Annuaire_recherche ()  Moteur de recherche dans l'annuaire des inscrits
448 ddelon 49
*
50
*
51
*
52
*	@return string HTML
53
*/
54
 
805 florian 55
function Annuaire_recherche() {
56
	$res ='<h2>'.INS_RECHERCHE_ANNUAIRE_DES_INSCRITS.'</h2>'."\n";
57
	$form =& new HTML_QuickForm('form_recherche_annuaire', 'post', str_replace('&amp;', '&', $GLOBALS['ins_url']->getURL()));
58
    $squelette =& $form->defaultRenderer();
59
    $squelette->setFormTemplate("\n".'<form{attributes}>'."\n".'<table>'."\n".'{content}'."\n".'</table>'."\n".'</form>'."\n");
60
    $squelette->setElementTemplate( '<tr>'."\n".
61
                                    '<td style="padding:5px;text-align:right;">{label}'.
62
                                    '<!-- BEGIN required --><span class="symbole_obligatoire">*</span><!-- END required -->'."\n".
63
                                    '<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n".
64
									' : </td>'."\n".
65
                                    '<td style="padding:5px;text-align:left;">{element}</td>'."\n".
66
                                    '</tr>'."\n" );
67
    $squelette->setElementTemplate( '<tr>'."\n".'<td colspan=2 style="padding:5px;">{label}{element}</td>'."\n".'</tr>'."\n", 'bouton_rechercher');
68
 
1292 neiluj 69
    //$option_type=array ('0' => INS_PERSONNES_OU_STRUCTURES,
70
    //                    '1' => INS_PERSONNES,
71
    //                    '2' => INS_STRUCTURES);
72
    $form->addElement('hidden', 'nom_type', 0);
805 florian 73
 
74
    //requete pour recuperer la liste des pays
75
    $requete = 'SELECT '.INS_CHAMPS_ID_PAYS.', '.INS_CHAMPS_LABEL_PAYS.' FROM '.INS_TABLE_PAYS.' WHERE '.INS_CHAMPS_I18N_PAYS.'="fr-FR"';
76
	$resultat = $GLOBALS['ins_db']->query($requete) ;
77
	if (DB::isError($resultat)) {
78
	    die ("Echec de la requete : $requete<br />".$resultat->getMessage()) ;
79
	}
80
	$option_pays = array('zz' => INS_TOUS_PAYS) ;
81
	while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
82
	    $option_pays[$ligne[INS_CHAMPS_ID_PAYS]] = $ligne[INS_CHAMPS_LABEL_PAYS] ;
83
	}
84
    $form->addElement('select', 'nom_pays', INS_PAYS, $option_pays);
85
 
86
    //requete pour recuperer la liste des départements
87
    $requete = 'SELECT '.INS_CHAMPS_ID_DEPARTEMENT.', '.INS_CHAMPS_NOM_DEPARTEMENT.' FROM '.INS_TABLE_DPT;
88
	$resultat = $GLOBALS['ins_db']->query($requete) ;
89
	if (DB::isError($resultat)) {
90
	    die ("Echec de la requete : $requete<br />".$resultat->getMessage()) ;
91
	}
92
	$option_departements = array('0' => INS_TOUS_DEPARTEMENTS) ;
93
	while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
94
	    $option_departements[$ligne[INS_CHAMPS_ID_DEPARTEMENT]] = $ligne[INS_CHAMPS_NOM_DEPARTEMENT] ;
95
	}
96
    $form->addElement('select', 'nom_departement', INS_DEPARTEMENT_POUR_LA_FRANCE, $option_departements);
97
 
98
	$form->addElement('text', 'nom_annuaire', INS_NOM_ANNUAIRE);
99
 
100
	$form->addElement('submit', 'bouton_rechercher', INS_RECHERCHER);
101
 
102
	//valeurs par defaut
103
	$defauts=array('nom_pays'=>'fr','nom_departement'=>'0');
104
	$form->setDefaults($defauts);
105
 
106
	//affichage du formulaire
107
	$res .=$form->toHtml();
108
 
109
	//on teste si l'on affiche le resultat de la recherche ou
110
	if (isset($_POST['nom_type'])) {
111
		$requete = 'SELECT '.INS_CHAMPS_ID.', '.INS_CHAMPS_NOM.', '.INS_CHAMPS_PRENOM.', '.INS_CHAMPS_VILLE.', '.INS_CHAMPS_CODE_POSTAL;
485 alexandre_ 112
		$requete .= ' FROM '.INS_ANNUAIRE.' WHERE ';
805 florian 113
		$req_where=0;
114
		if ($_POST['nom_type']==1) {
115
			$requete .= INS_CHAMPS_EST_STRUCTURE.'=0 ';
116
			$req_where=1;
117
		} elseif ($_POST['nom_type']==2) {
118
			$requete .= INS_CHAMPS_EST_STRUCTURE.'=1 ';
119
			$req_where=1;
485 alexandre_ 120
		}
805 florian 121
		if ($_POST['nom_pays']!='0'and$_POST['nom_pays']!='zz') {
122
			if ($req_where) {
123
				$requete .= 'AND ';
124
			} else {
125
				$req_where=1;
126
			}
127
			$requete .= INS_CHAMPS_PAYS.'="'.$_POST['nom_pays'].'" ';
128
		}
129
		if ($_POST['nom_departement']!='0') {
130
			if ($req_where) {
131
				$requete .= 'AND ';
132
			} else {
133
				$req_where=1;
134
			}
135
			$requete .= INS_CHAMPS_DEPARTEMENT.'="'.$_POST['nom_departement'].'" ';
136
		}
137
		if ($_POST['nom_annuaire']!='') {
138
			if ($req_where) {
139
				$requete .= 'AND ';
140
			} else {
141
				$req_where=1;
142
			}
143
			$requete .= '('.INS_CHAMPS_NOM.' LIKE "%'.$_POST['nom_annuaire'].'%"'.
144
						' OR '.INS_CHAMPS_PRENOM.' LIKE "%'.$_POST['nom_annuaire'].'%"'.
145
						' OR '.INS_CHAMPS_SIGLE_STRUCTURE.' LIKE "%'.$_POST['nom_annuaire'].'%"'.
146
						' OR '.INS_CHAMPS_DESCRIPTION.' LIKE "%'.$_POST['nom_annuaire'].'%") ';
147
		}
148
		if (!$req_where) $requete .= '1';
149
		$requete .=' ORDER BY '.INS_CHAMPS_NOM;
485 alexandre_ 150
		$resultat = $GLOBALS['ins_db']->query($requete);
151
		if ($resultat->numRows()>0) {
805 florian 152
			$res .='<h2>'.INS_RESULTATS_RECHERCHE.' ('.$resultat->numRows().' '.INS_ENTREES.')</h2>'."\n";
153
			$res .='<p class="zone_info">'.INS_CLIQUER_ELEMENT_LISTE.'</p>'."\n";
485 alexandre_ 154
			$i=0;
155
			while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
156
				$donnees_membres[$i++]=$ligne;
157
			}
805 florian 158
		    $res .= listes_inscrit($donnees_membres);
448 ddelon 159
		}
805 florian 160
		else {
161
			$res .='<h2>'.INS_RESULTATS_RECHERCHE.'</h2>'."\n";
162
			$res .= '<p class="zone_alert">'.INS_PAS_DE_RESULTATS.'</p>'."\n";
163
		}
164
	} else {
165
		$res .='<h2>'.INS_DIX_DERNIERES_INSCRIPTIONS.'</h2>'."\n";
166
		$requete = 'SELECT '.INS_CHAMPS_ID.', '.INS_CHAMPS_NOM.', '.INS_CHAMPS_PRENOM.', '.INS_CHAMPS_VILLE.', '.INS_CHAMPS_CODE_POSTAL;
167
		$requete .= ' FROM '.INS_ANNUAIRE.' ORDER BY '.INS_CHAMPS_DATE.' DESC LIMIT 0 , 10';
168
		$resultat = $GLOBALS['ins_db']->query($requete);
169
		if ($resultat->numRows()>0) {
170
			$i=0;
171
			while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
172
				$donnees_membres[$i++]=$ligne;
173
			}
174
		    $res .= listes_inscrit($donnees_membres, 0);
175
		}
176
		else {
177
			$res .= '<p class="zone_alert">'.INS_PAS_DE_RESULTATS.'</p>'."\n";
178
		}
179
	}
448 ddelon 180
    return $res ;
181
}
182
 
183
/**
184
 *  Renvoie le code HTML de la liste des inscrits
185
 *  en fonction de la requete passé en parametre
186
 *
187
 * @return  Renvoie le code HTML de la liste des inscrits
188
 */
189
 
805 florian 190
function listes_inscrit(& $donnees_membres, $affiche_form_mail=1) {
191
    $res = '';
192
    if ($GLOBALS['AUTH']->getAuth()&&$affiche_form_mail) {$res .= '<form action="'.$GLOBALS['ins_url']->getURL().'" method="post" name="formmail">'."\n";}
193
    $res .= '<ul>'."\n";
448 ddelon 194
    for ($i=0;$i<count($donnees_membres);$i++) {
805 florian 195
    	$id = array_shift($donnees_membres[$i]);
196
    	$GLOBALS['ins_url']->addQueryString('voir_fiche', $id);
197
    	$res .= '<li><a href="'.$GLOBALS['ins_url']->getURL().'">'."\n";
198
    	if ($GLOBALS['AUTH']->getAuth()&&$affiche_form_mail) {
199
    		$res.='<input type="checkbox" name="select[]" value="'.$id.'">'."\n";
200
    	}
201
    	$res .= '<strong>'.$donnees_membres[$i][INS_CHAMPS_NOM].
202
				'&nbsp;'.$donnees_membres[$i][INS_CHAMPS_PRENOM].'</strong>'."\n".
203
    	        '&nbsp;'.$donnees_membres[$i][INS_CHAMPS_CODE_POSTAL].
204
    	        '&nbsp;'.$donnees_membres[$i][INS_CHAMPS_VILLE];
205
    	$res .= '</a></li>'."\n";
448 ddelon 206
    }
805 florian 207
    $res .= '</ul>'."\n";
208
    if ($GLOBALS['AUTH']->getAuth()&&$affiche_form_mail) {
209
    	$res .= INS_CHECK_UNCHECK ;
210
    	$res .= '&nbsp;<input type="checkbox" name="selecttotal" onclick="javascript:setCheckboxes(\'formmail\');"><br />';
211
    	$res .= '<h3>'.INS_ENVOYER_MAIL.'</h3>'."\n";
212
    	$res .= '<p style="text-align:right;">'.INS_SUJET.'&nbsp;:&nbsp;<input style="border:1px solid #000;width:450px;" type="text" name="titre_mail"><br />'."\n".
213
           		INS_MESSAGE.'&nbsp;:&nbsp;<textarea style="border:1px solid #000;width:450px;" name="corps" rows="5" cols="60"></textarea></p>'."\n".
214
           		'<p style="width:100px;margin:4px auto;text-align:center;"><input type="submit" value="'.INS_ENVOYER.'" /></p>'."\n".
215
				'</form>'."\n";
216
	} else {
217
		if ($affiche_form_mail) $res .='<br /><p class="zone_info">'.INS_PAS_IDENTIFIE.'</p>'."\n";
448 ddelon 218
    }
219
    return $res ;
220
}
221
 
222
 
223
 
224
/** envoie_mail_depuis_annuaire()
225
 *
226
 *
227
 * @return  envoie l'email
228
 */
229
 
230
function envoie_mail_depuis_annuaire() {
485 alexandre_ 231
    $requete = "select ".INS_CHAMPS_MAIL." from ".INS_ANNUAIRE.
232
            " where ".INS_CHAMPS_ID."='".$GLOBALS['AUTH']->getAuthData (INS_CHAMPS_ID)."'";
233
    $resultat = $GLOBALS['ins_db']->query($requete);
448 ddelon 234
    if (DB::isError($resultat)) {
235
        die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo());
236
    }
237
    $ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
485 alexandre_ 238
    $entete = "From: <".$ligne[INS_CHAMPS_MAIL].">\n";
448 ddelon 239
 
240
    $_POST['corps'] .= ANN_PIED_MESSAGE;
241
    $_POST['corps'] = stripslashes($_POST['corps']) ;
242
    $liste = "" ;
485 alexandre_ 243
    $liste_numero = implode (',', $_POST['select']) ;
244
    $requete_liste_mail = 'select '.INS_CHAMPS_MAIL.' from '.INS_ANNUAIRE.' where '.INS_CHAMPS_ID.
245
    						' in ('.$liste_numero.')' ;
246
    $resultat_liste_mail = $GLOBALS['ins_db']->query($requete_liste_mail);
247
 
248
    while ($ligne_liste_mail = $resultat_liste_mail->fetchRow(DB_FETCHMODE_ASSOC)) {
249
        mail ($ligne_liste_mail[INS_CHAMPS_MAIL], stripslashes($_POST['titre_mail']), $_POST['corps'] , $entete) ;
250
        $liste .= $ligne_liste_mail[INS_CHAMPS_MAIL]."\n" ;
448 ddelon 251
    }
252
 
253
    $_POST['corps'] .= "\n----------------------------------------------------------------------------";
254
    $_POST['corps'] .= "\n".ANN_MESSAGE_ENVOYE_A." :\n $liste" ;
255
 
485 alexandre_ 256
    mail (INS_MAIL_ADMIN_APRES_INSCRIPTION, stripslashes($_POST['titre_mail']), $_POST['corps'], $entete);
448 ddelon 257
    $_POST['corps'] = '';
258
    $_POST['titre_mail'] = '';
259
    return '<div>'.ANN_MAIL_ENVOYER.'</div>' ;
260
}
261
 
262
/* +--Fin du code ----------------------------------------------------------------------------------------+
263
*
264
* $Log: not supported by cvs2svn $
805 florian 265
* Revision 1.2  2005/09/29 16:13:54  alexandre_tb
266
* En cours de production.
267
*
485 alexandre_ 268
* Revision 1.1  2005/09/22 14:02:49  ddelon
269
* nettoyage annuaire et php5
270
*
448 ddelon 271
* Revision 1.4  2005/09/22 13:30:49  florian
272
* modifs pour compatibilité XHTML Strict + corrections de bugs (mais ya encore du boulot!!)
273
*
274
* Revision 1.3  2005/03/24 08:24:29  alex
275
* --
276
*
277
* Revision 1.2  2005/01/06 15:18:31  alex
278
* modification de la fonction de formulaire d'authentification
279
*
280
* Revision 1.1.1.1  2005/01/03 17:27:49  alex
281
* Import initial
282
*
283
* Revision 1.1  2005/01/03 17:18:49  alex
284
* retour vers la liste des participants après un ajout.
285
*
286
*
287
*
288
* +-- Fin du code ----------------------------------------------------------------------------------------+
289
*/
1292 neiluj 290
?>