Subversion Repositories Sites.tela-botanica.org

Rev

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

Rev Author Line No. Line
5 david 1
<?php
2
// +------------------------------------------------------------------------------------------------------+
409 jpm 3
// | PHP version 4.1																					  |
5 david 4
// +------------------------------------------------------------------------------------------------------+
409 jpm 5
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)							   	          |
5 david 6
// +------------------------------------------------------------------------------------------------------+
409 jpm 7
// | This library is free software; you can redistribute it and/or										  |
8
// | modify it under the terms of the GNU Lesser General Public										      |
9
// | License as published by the Free Software Foundation; either										  |
10
// | version 2.1 of the License, or (at your option) any later version.								      |
11
// |																									  |
12
// | This library is distributed in the hope that it will be useful,									  |
13
// | but WITHOUT ANY WARRANTY; without even the implied warranty of									      |
14
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU									  |
15
// | Lesser General Public License for more details.													  |
16
// |																									  |
17
// | You should have received a copy of the GNU Lesser General Public									  |
18
// | License along with this library; if not, write to the Free Software								  |
19
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA							  |
5 david 20
// +------------------------------------------------------------------------------------------------------+
21
/**
22
* Fonctions du module inscription
23
*
24
* Fonctions du module inscription
25
*
26
*@package inscription
27
//Auteur original :
409 jpm 28
*@author		Alexandre Granier <alexandre@tela-botanica.org>
5 david 29
//Autres auteurs :
409 jpm 30
*@author	   	Jean-Pascal MILCENT <jpm@tela-botanica.org>
31
*@copyright		Tela-Botanica 2000-2004
32
*@version	   	$Id: inscription.class.php,v 1.3 2005/05/13 13:48:38 alex Exp $
5 david 33
// +------------------------------------------------------------------------------------------------------+
34
*/
35
 
36
// +------------------------------------------------------------------------------------------------------+
409 jpm 37
// |											ENTETE du PROGRAMME									   |
5 david 38
// +------------------------------------------------------------------------------------------------------+
39
 
40
 
41
// +------------------------------------------------------------------------------------------------------+
409 jpm 42
// |										   LISTE de FONCTIONS										 |
5 david 43
// +------------------------------------------------------------------------------------------------------+
44
 
45
class HTML_formulaireInscription extends HTML_Quickform {
409 jpm 46
 
47
	var $mode_ajout = true;
48
	/**
49
	 *  Constructeur
50
	 *
51
	 * @param string formName Le nom du formulaire
52
	 * @param string method Méthode post ou get
53
	 * @param string action L'action du formulaire.
54
	 * @param int target La cible.
55
	 * @param Array attributes Les attributs HTML en plus.
56
	 * @param bool trackSubmit ??
57
	 * @return void
58
	 * @access public
59
	 */
60
	function HTML_forumlaireInscription ( $formName,  $method = "post",  $action,  $target = "_self",  $attributes,  $trackSubmit = false ) {
61
		HTML_Quickform::HTML_Quickform($formName, $method, $action, $target, $attributes, $trackSubmit) ;
62
	}
5 david 63
 
409 jpm 64
	/**
65
	 *
66
	 *
67
	 * @return void
68
	 * @access public
69
	 */
70
	function construitFormulaire($url, $liste_pays) {
71
		$squelette =& $this->defaultRenderer();
72
		$squelette->setFormTemplate("\n".'<form{attributes}>'."\n".'{content}'."\n".'</form>'."\n");
73
 
74
		$modele_element_debut = '<li class="groupe_formulaire">'."\n".'<span class="inscription_label1">{label}<!-- BEGIN required --><span class="symbole_obligatoire">*</span><!-- END required --></span>'.
75
										"\n".'{element}'."\n".''."\n".
76
										'<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n".
77
										''."\n" ;
78
		$modele_element_fin = "\n".'<span class="inscription_label2">{label}<!-- BEGIN required --><span class="symbole_obligatoire">*</span><!-- END required --></span>'.
79
										"\n".'{element}'."\n".''."\n".
80
										'<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n".
81
										'</li>'."\n" ;
82
 
83
		$squelette->setElementTemplate( '<li class="liste_inscription">'."\n".'<span class="inscription_label">{label}<!-- BEGIN required --><span class="symbole_obligatoire">*</span><!-- END required --></span>'.
84
										"\n".'{element}'."\n".''."\n".
85
										'<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n".
86
										'</li>'."\n");
87
		//$squelette->setElementTemplate(, ) ;
88
		// Les modèles pour les champs qui se tienne 2 par ligne
89
		foreach (array('mot_de_passe', 'nom', 'cp') as $valeur) $squelette->setElementTemplate( $modele_element_debut, $valeur);
90
		foreach (array('password_repete', 'prenom', 'ville') as $valeur) $squelette->setElementTemplate( $modele_element_fin, $valeur);
91
 
92
		$squelette->setElementTemplate( '<ul><li class="groupe_bouton">{element}', 'annuler');
93
		$squelette->setElementTemplate( '{element}</li></ul>', 'valider');
94
 
95
		$squelette->setRequiredNoteTemplate("\n".'<p>'."\n".'<span class="symbole_obligatoire">*</span> {requiredNote}'."\n".'</p>'."\n");
96
 
97
		$fieldset_debut =	'<fieldset>'."\n".
98
								'<legend>'.(($this->mode_ajout) ? INS_AJOUT_MEMBRE : INS_MODIF_MEMBRE).'</legend>'."\n".
99
								'<ul>'."\n";
100
		$this->addElement('html', $fieldset_debut);
101
		$this->addElement ('text', 'email', INS_EMAIL) ;
102
		$this->addRule ('email', INS_EMAIL_REQUIS, 'required','', 'client') ;
103
		$this->addRule ('email', INS_MAIL_INCORRECT, 'email', '', 'client') ;
104
		$this->registerRule('doublon', 'callback', 'verif_doublonMail') ;
105
		$this->addRule ('email', INS_MAIL_DOUBLE, 'doublon', true) ;
106
 
107
		$this->addElement('password', 'mot_de_passe', INS_MOT_DE_PASSE);
108
		$this->addElement('password', 'password_repete', INS_REPETE_MOT_DE_PASSE);
109
		$this->addRule ('mot_de_passe', INS_MOT_DE_PASSE_REQUIS, 'required', '', 'client') ;
110
		$this->addRule ('password_repete', INS_MOT_DE_PASSE_REQUIS, 'required', '', 'client') ;
111
 
112
		$this->addElement('text', 'nom', INS_NOM);
113
		$this->addElement('text', 'prenom', INS_PRENOM);
114
		$this->addRule ('nom', INS_NOM_REQUIS, 'required', '', 'client') ;
115
		$this->addRule ('prenom', INS_PRENOM_REQUIS, 'required', '', 'client') ;
116
 
117
		$this->addElement ('text', 'adresse_1', INS_ADRESSE_1) ;
118
		$this->addElement ('text', 'adresse_2', INS_ADRESSE_2) ;
119
		$this->addElement ('text', 'region', INS_REGION) ;
120
 
121
		$this->addElement('text', 'cp', INS_CODE_POSTAL) ;
122
		$this->addElement('text', 'ville', INS_VILLE) ;
123
		$this->addRule ('cp', INS_CODE_POSTAL_REQUIS, 'required', '', 'client') ;
124
		$this->addRule ('ville', INS_VILLE_REQUIS, 'required', '', 'client') ;
125
 
126
		// L'élément pays est construit à partir de la table des pays
127
		$s =& $this->createElement('select','pays',INS_PAYS);
128
		$s->loadArray($liste_pays,'fr');
129
		$this->addElement($s);
130
 
131
		if (INS_UTILISE_LISTE) {
132
			$element_lettre = &new HTML_QuickForm_checkbox ('lettre', '', INS_LETTRE) ;
133
			$this->addElement($element_lettre) ;
134
		}
135
 
136
		$this->addElement ('text', 'site', INS_SITE_INTERNET) ;
137
 
138
		$fieldset_fin =	'</ul>'."\n".
139
							'</fieldset>'."\n";
140
		$this->addElement('html', $fieldset_fin);
141
 
142
		$fieldset_debut =	'<fieldset>'."\n".
143
								'<legend>'.INS_ADHERENT.'</legend>'."\n".
144
								'<ul>'."\n";
145
		$this->addElement('html', $fieldset_debut);
146
 
147
		$this->addElement ('text', 'organisme', INS_ORGANISME) ;
148
		$this->addElement ('text', 'fonction', INS_FONCTION) ;
149
		$fieldset_fin =	'</ul>'."\n".
150
							'</fieldset>'."\n";
151
		$this->addElement('html', $fieldset_fin);
152
 
153
		$fieldset_debut = '<fieldset>'."\n".
154
								'<legend>'.INS_ETES_BOTANISTE.'</legend>'."\n".
155
								'<ul>'."\n";
156
		$this->addElement('html', $fieldset_debut);
157
 
158
		// requete pour trouver les niveaux en botanique
159
		$requete = 'SELECT * FROM annuaire_LABEL_NIV';
160
		$resultat = $GLOBALS['ins_db']->query ($requete) ;
161
		if (DB::isError($resultat)) {
162
			die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
163
		}
164
		while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
165
			$this->addElement ('radio', 'niveau', '', $ligne->LABEL_NIV, $ligne->ID_LABEL_NIV) ;
166
		}
167
 
168
		$fieldset_fin =	'</ul>'."\n".
169
							'</fieldset>'."\n";
170
		$this->addElement('html', $fieldset_fin);
171
 
172
		// L'activité professionnelle
173
		$fieldset_debut = '<fieldset>'."\n".
174
								'<legend>'.INS_ACTIVITE_PROFESSIONNELLE.'</legend>'."\n".
175
								'<ul>'."\n";
176
		$this->addElement('html', $fieldset_debut);
177
 
178
 
179
		// Requete pour trouver les niveaux en botanique
180
		$requete = 'SELECT * FROM annuaire_LABEL_ACT';
181
		$resultat = $GLOBALS['ins_db']->query ($requete) ;
182
		if (DB::isError($resultat)) {
183
			die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
184
		}
185
		while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
186
			$this->addElement ('radio', 'activite', '', $ligne->LABEL_ACT, $ligne->ID_LABEL_ACT) ;
187
		}
188
 
189
		$fieldset_fin =	'</ul>'."\n".
190
							'</fieldset>'."\n";
191
		$this->addElement('html', $fieldset_fin);
192
 
193
		// L'activité professionnelle
194
		$fieldset_debut = '<fieldset>'."\n".
195
								'<legend>'.INS_MEMBRE_ASSO.'</legend>'."\n".
196
								'<ul>'."\n";
197
		$this->addElement('html', $fieldset_debut);
198
 
199
		// Requete pour trouver les niveaux en botanique
200
		$requete = 'SELECT * FROM annuaire_LABEL_ASS';
201
		$resultat = $GLOBALS['ins_db']->query ($requete) ;
202
		if (DB::isError($resultat)) {
203
			die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
204
		}
205
		while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
206
			$this->addElement ('radio', 'asso', '', $ligne->LABEL_ASS, $ligne->ID_LABEL_ASS) ;
207
		}
208
 
209
		$fieldset_fin =	'</ul>'."\n".
210
							'</fieldset>'."\n";
211
		$this->addElement('html', $fieldset_fin);
212
 
213
		// Les spécialité
214
		$fieldset_debut = '<fieldset>'."\n".
215
								'<legend>'.INS_SPECIALISTE.'</legend>'."\n".
216
								'<ul>'."\n";
217
		$this->addElement('html', $fieldset_debut);
218
		$this->addElement ('textarea', 'specialite', '', array ('cols' => 50, 'rows' => 4)) ;
219
		$fieldset_fin =	'</ul>'."\n".
220
							'</fieldset>'."\n";
221
		$this->addElement('html', $fieldset_fin);
222
 
223
 
224
		// Les spécialité géographiques
225
		$fieldset_debut = '<fieldset>'."\n".
226
								'<legend>'.INS_SPE_ZONE.'</legend>'."\n".
227
								'<ul>'."\n";
228
		$this->addElement('html', $fieldset_debut);
229
		$this->addElement ('textarea', 'specialite_geo', '', array ('cols' => 50, 'rows' => 4)) ;
230
		$fieldset_fin =	'</ul>'."\n".
231
							'</fieldset>'."\n";
232
		$this->addElement('html', $fieldset_fin);
233
 
234
		if (!$this->mode_ajout)  {
235
			$this->addElement ('link', 'annuler', '', preg_replace ('/&amp;/', '&', $GLOBALS['ins_url']->getURL()), INS_ANNULER) ;
236
		}
237
		$this->addElement ('submit', 'valider', INS_VALIDER) ;
238
 
239
		$this->setRequiredNote(INS_NOTE_REQUIS) ;
240
	}
241
 
242
	/** Modifie le formulaire pour l'adapter au cas des structures
243
	 *
244
	 *
245
	 * @return void
246
	 * @access public
247
	 */
248
	function formulaireStructure() {
249
		$this->removeElement('email', false) ;
250
		$mail = & HTML_QuickForm::createElement ('text', 'email', INS_MAIL_STRUCTURE) ;
251
		$this->insertElementBefore ($mail, 'mot_de_passe') ;
252
		$nom_structure = & HTML_QuickForm::createElement ('text', 'nom', INS_NOM_STRUCTURE) ;
253
		$this->insertElementBefore ($nom_structure, 'email') ;
254
		$this->removeElement ('site', false) ;
255
		$site_structure = & HTML_QuickForm::createElement ('text', 'site', INS_SITE_STRUCTURE) ;
256
		$this->insertElementBefore ($site_structure, 'pays') ;
257
		$this->addElement ('hidden', 'est_structure', 1) ;
258
		$sigle_structure = & HTML_QuickForm::createElement ('text', 'sigle_structure', INS_SIGLE_STRUCTURE) ;
259
		$this->insertElementBefore ($sigle_structure, 'nom') ;
260
		$this->addRule ('sigle_structure', INS_SIGLE_REQUIS, 'required', '', 'client') ;
261
	}
262
	/**
263
	 *
264
	 *
265
	 * @return string
266
	 * @access public
267
	 */
268
	function toHTML( ) {
269
		$res = HTML_QuickForm::toHTML() ;
270
		return $res ;
271
	} // end of member function toHTML
5 david 272
}
273
 
274
class ListeDePays extends PEAR{
275
 
409 jpm 276
	var $_db ;
277
	/** Constructeur
278
	 *  Vérifie l'existance de la table gen_pays_traduction
279
	 *
280
	 * @param  DB  Un objet PEAR::DB
281
	 * @return
282
	 */
283
	function ListeDePays (&$objetDB) {
284
		$this->_db = $objetDB ;
285
		$requete = 'SHOW TABLES';
286
		$resultat = $objetDB->query($requete) ;
287
		if (DB::isError ($resultat)) {
288
			die ("Echec de la requete : $requete<br />".$resultat->getMessage()) ;
289
		}
290
		while ($ligne = $resultat->fetchRow()) {
291
			if ($ligne[0] == INS_TABLE_PAYS) {
292
				return ;
293
			}
294
		}
295
		return $this->raiseError('La table '.INS_TABLE_PAYS.' n\'est pas présente dans la base de donnée !') ;
296
	}
297
 
298
	/** Renvoie la liste des pays traduite
299
	 *
300
	 * @param  string  une chaine de type i18n ou une chaine code iso langue (fr_FR ou fr ou FR)
301
	 * @return  un tableau contenant en clé, le code iso du pays, en majuscule et en valeur le nom du pays traduit
302
	 */
303
	function getListePays ($i18n) {
304
		if (strlen($i18n) == 2) {
305
			$i18n = strtolower($i18n).'-'.strtoupper($i18n) ;
306
		}
307
		$requete = 	'SELECT '.INS_CHAMPS_ID_PAYS.', '.INS_CHAMPS_LABEL_PAYS.' '.
308
					'FROM '.INS_TABLE_PAYS.' '.
309
					'WHERE '.INS_CHAMPS_PAYS_LG.' = "fr" '.
310
					'ORDER BY '.INS_CHAMPS_LABEL_PAYS.' ';
311
		$resultat = $this->_db->query($requete);
312
		if (DB::isError($resultat)) {
313
			die ("Echec de la requete : $requete<br />".$resultat->getMessage()) ;
314
		}
315
		if ($resultat->numRows() == 0) {
316
			return $this->raiseError('Le code fourni ne correspond à aucun pays ou n\'est pas dans la table!') ;
317
		}
318
		$retour = array() ;
319
		while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
320
			$retour[$ligne[INS_CHAMPS_ID_PAYS]] = $ligne[INS_CHAMPS_LABEL_PAYS];
321
		}
322
		return $retour;
323
	}
5 david 324
}
325
 
326
 
327
 
328
/* +--Fin du code ----------------------------------------------------------------------------------------+
329
* Revision 1.1  2004/06/18 09:20:47  alex
330
* version initiale
331
*
332
*
333
* +-- Fin du code ----------------------------------------------------------------------------------------+
334
*/
335
 
336
?>