Subversion Repositories Applications.papyrus

Rev

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