Subversion Repositories Applications.papyrus

Rev

Rev 1274 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1274 Rev 1292
1
<?php
1
<?php
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */ 
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */ 
3
// +------------------------------------------------------------------------------------------------------+
3
// +------------------------------------------------------------------------------------------------------+
4
// | PHP version 4.1                                                                                      |
4
// | PHP version 4.1                                                                                      |
5
// +------------------------------------------------------------------------------------------------------+
5
// +------------------------------------------------------------------------------------------------------+
6
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
6
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
7
// +------------------------------------------------------------------------------------------------------+
7
// +------------------------------------------------------------------------------------------------------+
8
// | This library is free software; you can redistribute it and/or                                        |
8
// | This library is free software; you can redistribute it and/or                                        |
9
// | modify it under the terms of the GNU Lesser General Public                                           |
9
// | modify it under the terms of the GNU Lesser General Public                                           |
10
// | License as published by the Free Software Foundation; either                                         |
10
// | License as published by the Free Software Foundation; either                                         |
11
// | version 2.1 of the License, or (at your option) any later version.                                   |
11
// | version 2.1 of the License, or (at your option) any later version.                                   |
12
// |                                                                                                      |
12
// |                                                                                                      |
13
// | This library is distributed in the hope that it will be useful,                                      |
13
// | This library is distributed in the hope that it will be useful,                                      |
14
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
14
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
15
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
15
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
16
// | Lesser General Public License for more details.                                                      |
16
// | Lesser General Public License for more details.                                                      |
17
// |                                                                                                      |
17
// |                                                                                                      |
18
// | You should have received a copy of the GNU Lesser General Public                                     |
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                                  |
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                            |
20
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
21
// +------------------------------------------------------------------------------------------------------+
21
// +------------------------------------------------------------------------------------------------------+
22
// CVS : $Id: inscription.class.php,v 1.16 2007-03-22 15:58:35 alexandre_tb Exp $
22
// CVS : $Id: inscription.class.php,v 1.17 2007-04-06 08:35:46 neiluj Exp $
23
/**
23
/**
24
* Inscription
24
* Inscription
25
*
25
*
26
* Un module d'inscription, en général ce code est spécifique à
26
* Un module d'inscription, en général ce code est spécifique à
27
* un site web
27
* un site web
28
*
28
*
29
*@package inscription
29
*@package inscription
30
//Auteur original :
30
//Auteur original :
31
*@author        Alexandre GRANIER <alexandre@tela-botanica.org>
31
*@author        Alexandre GRANIER <alexandre@tela-botanica.org>
32
//Autres auteurs :
32
//Autres auteurs :
33
*@copyright     Tela-Botanica 2000-2004
33
*@copyright     Tela-Botanica 2000-2004
34
*@version       $Revision: 1.16 $ $Date: 2007-03-22 15:58:35 $
34
*@version       $Revision: 1.17 $ $Date: 2007-04-06 08:35:46 $
35
// +------------------------------------------------------------------------------------------------------+
35
// +------------------------------------------------------------------------------------------------------+
36
*/
36
*/
37
 
37
 
38
// +------------------------------------------------------------------------------------------------------+
38
// +------------------------------------------------------------------------------------------------------+
39
// |                                            ENTETE du PROGRAMME                                       |
39
// |                                            ENTETE du PROGRAMME                                       |
40
// +------------------------------------------------------------------------------------------------------+
40
// +------------------------------------------------------------------------------------------------------+
41
 
41
 
42
require_once PAP_CHEMIN_RACINE.'api/pear/HTML/QuickForm.php' ;
42
require_once PAP_CHEMIN_RACINE.'api/pear/HTML/QuickForm.php' ;
43
 
43
 
44
   class ListeDePays extends PEAR{
44
   class ListeDePays extends PEAR{
45
 
45
 
46
    var $_db ;
46
    var $_db ;
47
    /** Constructeur
47
    /** Constructeur
48
     *  Vérifie l'existance de la table gen_pays_traduction
48
     *  Vérifie l'existance de la table gen_pays_traduction
49
     *
49
     *
50
     *  @param  DB  Un objet PEAR::DB
50
     *  @param  DB  Un objet PEAR::DB
51
     * @return
51
     * @return
52
     */
52
     */
53
    
53
    
54
    function ListeDePays(&$objetDB) {
54
    function ListeDePays(&$objetDB) {
55
        $this->_db = $objetDB ;
55
        $this->_db = $objetDB ;
56
        $requete = 'SHOW TABLES';
56
        $requete = 'SHOW TABLES';
57
        $resultat = $objetDB->query ($requete) ;
57
        $resultat = $objetDB->query ($requete) ;
58
        if (DB::isError ($resultat)) {
58
        if (DB::isError ($resultat)) {
59
            die ("Echec de la requete : $requete<br />".$resultat->getMessage()) ;
59
            die ("Echec de la requete : $requete<br />".$resultat->getMessage()) ;
60
        }
60
        }
61
        while ($ligne = $resultat->fetchRow()) {
61
        while ($ligne = $resultat->fetchRow()) {
62
            if ($ligne[0] == INS_TABLE_PAYS) {
62
            if ($ligne[0] == INS_TABLE_PAYS) {
63
                return ;
63
                return ;
64
            }
64
            }
65
        }
65
        }
66
        return $this->raiseError('La table gen_i18n_pays n\'est pas présente dans la base de donnée !') ;
66
        return $this->raiseError('La table gen_i18n_pays n\'est pas présente dans la base de donnée !') ;
67
    }
67
    }
68
    
68
    
69
    /** Renvoie la liste des pays traduite
69
    /** Renvoie la liste des pays traduite
70
     *
70
     *
71
     *  @param  string  une chaine de type i18n ou une chaine code iso langue (fr_FR ou fr ou FR)
71
     *  @param  string  une chaine de type i18n ou une chaine code iso langue (fr_FR ou fr ou FR)
72
     * @return  un tableau contenant en clé, le code iso du pays, en majuscule et en valeur le nom du pays traduit
72
     * @return  un tableau contenant en clé, le code iso du pays, en majuscule et en valeur le nom du pays traduit
73
     */
73
     */
74
    function getListePays($i18n) {
74
    function getListePays($i18n) {
75
	    if (strlen($i18n) == 2) {
75
	    if (strlen($i18n) == 2) {
76
		    $i18n = strtolower($i18n)."-".strtoupper($i18n) ;
76
		    $i18n = strtolower($i18n)."-".strtoupper($i18n) ;
77
	    }
77
	    }
78
	    $requete = 'select '.INS_CHAMPS_ID_PAYS.', '.INS_CHAMPS_LABEL_PAYS.' from '.INS_TABLE_PAYS
78
	    $requete = 'select '.INS_CHAMPS_ID_PAYS.', '.INS_CHAMPS_LABEL_PAYS.' from '.INS_TABLE_PAYS;
79
							.' where '.INS_CHAMPS_I18N_PAYS.'="'.$i18n.'"';
79
							//' where '.INS_CHAMPS_ID_PAYS.'="'.$i18n.'"';
80
	    $resultat = $this->_db->query($requete) ;
80
	    $resultat = $this->_db->query($requete) ;
81
	    
81
	    
82
	    if (DB::isError($resultat)) {
82
	    if (DB::isError($resultat)) {
83
		    die ("Echec de la requete : $requete<br />".$resultat->getMessage()) ;
83
		    die ("Echec de la requete : $requete<br />".$resultat->getMessage()) ;
84
	    }
84
	    }
85
	    if ($resultat->numRows() == 0) {
85
	    if ($resultat->numRows() == 0) {
86
		    return $this->raiseError('Le code fourni ne correspond à aucun pays ou n\'est pas dans la table!') ;
86
		    return $this->raiseError('Le code fourni ne correspond à aucun pays ou n\'est pas dans la table!') ;
87
	    }
87
	    }
88
	    $retour = array() ;
88
	    $retour = array() ;
89
	    while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
89
	    while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
90
		    $retour[$ligne[INS_CHAMPS_ID_PAYS]] = $ligne[INS_CHAMPS_LABEL_PAYS] ;
90
		    $retour[$ligne[INS_CHAMPS_ID_PAYS]] = $ligne[INS_CHAMPS_LABEL_PAYS] ;
91
	    }
91
	    }
92
	    return $retour ;
92
	    return $retour ;
93
    }
93
    }
94
    
94
    
95
    /** Renvoie le nom d'un pays traduit dans la langue passé en paramètre
95
    /** Renvoie le nom d'un pays traduit dans la langue passé en paramètre
96
     *
96
     *
97
     *  @param  string  une chaine de type i18n ou une chaine code iso langue (fr_FR ou fr ou FR)
97
     *  @param  string  une chaine de type i18n ou une chaine code iso langue (fr_FR ou fr ou FR)
98
     * @return  un tableau contenant en clé, le code iso du pays, en majuscule et en valeur le nom du pays traduit
98
     * @return  un tableau contenant en clé, le code iso du pays, en majuscule et en valeur le nom du pays traduit
99
     */
99
     */
100
    function getNomPays($codeIso, $i18n = INS_LANGUE_DEFAUT) {
100
    function getNomPays($codeIso, $i18n = INS_LANGUE_DEFAUT) {
101
	    if (strlen($i18n) == 2) {
101
	    if (strlen($i18n) == 2) {
102
		    $i18n = strtolower($i18n)."-".strtoupper($i18n) ;
102
		    $i18n = strtolower($i18n)."-".strtoupper($i18n) ;
103
	    }
103
	    }
104
	    $requete = 'select '.INS_CHAMPS_LABEL_PAYS.' from '.INS_TABLE_PAYS.
104
	    $requete = 'select '.INS_CHAMPS_LABEL_PAYS.' from '.INS_TABLE_PAYS.
105
							' where '.INS_CHAMPS_I18N_PAYS.'="'.$i18n.'" and '.
-
 
106
							INS_CHAMPS_ID_PAYS.'="'.$codeIso.'"';
105
							' where '.INS_CHAMPS_ID_PAYS.'="'.$codeIso.'"';
107
	    $resultat = $this->_db->query($requete) ;
106
	    $resultat = $this->_db->query($requete) ;
108
	    
107
	    
109
	    if (DB::isError($resultat)) {
108
	    if (DB::isError($resultat)) {
110
		    die ("Echec de la requete : $requete<br />".$resultat->getMessage()) ;
109
		    die ("Echec de la requete : $requete<br />".$resultat->getMessage()) ;
111
	    }
110
	    }
112
	    if ($resultat->numRows() == 0) {
111
	    if ($resultat->numRows() == 0) {
113
		    return $this->raiseError('Le code fourni ne correspond à aucun pays ou n\'est pas dans la table!') ;
112
		    return $this->raiseError('Le code fourni ne correspond à aucun pays ou n\'est pas dans la table!') ;
114
	    }
113
	    }
115
	    $ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC) ;
114
	    $ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC) ;
116
	    return $ligne[INS_CHAMPS_LABEL_PAYS] ;
115
	    return $ligne[INS_CHAMPS_LABEL_PAYS] ;
117
    }
116
    }
118
}
117
}
119
 
118
 
120
class HTML_formulaireInscription extends HTML_Quickform {
119
class HTML_formulaireInscription extends HTML_Quickform {
121
 
120
 
122
    
121
    
123
    /**
122
    /**
124
     *  Constructeur
123
     *  Constructeur
125
     *
124
     *
126
     * @param string formName Le nom du formulaire
125
     * @param string formName Le nom du formulaire
127
     * @param string method Méthode post ou get
126
     * @param string method Méthode post ou get
128
     * @param string action L'action du formulaire.
127
     * @param string action L'action du formulaire.
129
     * @param int target La cible.
128
     * @param int target La cible.
130
     * @param Array attributes Les attributs HTML en plus.
129
     * @param Array attributes Les attributs HTML en plus.
131
     * @param bool trackSubmit ??
130
     * @param bool trackSubmit ??
132
     * @return void
131
     * @return void
133
     * @access public
132
     * @access public
134
     */
133
     */
135
    
134
    
136
    function HTML_formulaireInscription( $formName,  $method = "post",  $action,  $target = "_self",  $attributes,  $trackSubmit = false ) {
135
    function HTML_formulaireInscription( $formName,  $method = "post",  $action,  $target = "_self",  $attributes,  $trackSubmit = false ) {
137
        HTML_Quickform::HTML_Quickform($formName, $method, $action, $target, $attributes, $trackSubmit) ;
136
        HTML_Quickform::HTML_Quickform($formName, $method, $action, $target, $attributes, $trackSubmit) ;
138
    }
137
    }
139
   
138
   
140
    /**
139
    /**
141
     * 
140
     * 
142
     *
141
     *
143
     * @return void
142
     * @return void
144
     * @access public
143
     * @access public
145
     */
144
     */
146
    function construitFormulaire($url)
145
    function construitFormulaire($url)
147
    {
146
    {
148
		$squelette =& $this->defaultRenderer();
147
        $squelette =& $this->defaultRenderer();
149
   		$squelette->setFormTemplate("\n".'<form {attributes}>'."\n".'<table class="inscription_table">'."\n".'{content}'."\n".'</table>'."\n".'</form>'."\n");
148
        $squelette->setFormTemplate("\n".'<form {attributes}><table style="width:100%;">'."\n".'{content}'."\n".'</table></form>'."\n");
150
    	$squelette->setElementTemplate( '<tr>'."\n".
149
        $squelette->setElementTemplate( '<tr>'."\n".
151
										'<td class="inscription_cellule_gauche">'."\n".'{label}'.
150
		                        '<td style="font-size:12px;font-weight:bold;width:150px;text-align:right;">'."\n".'{label} :</td> '."\n".
152
										'<!-- BEGIN required --><span class="symbole_obligatoire">&nbsp;*</span><!-- END required -->'."\n".
151
		                        '<td style="font-size:12px;text-align:left;padding-left:20px;">'."\n".'{element}'."\n".
153
										' :</td>'."\n".
-
 
154
										'<td class="inscription_cellule_droite"> '."\n".'{element}'."\n".
152
                                        '<!-- BEGIN required --><span class="symbole_obligatoire">*</span><!-- END required -->'."\n".
155
										'<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n".
153
                                        '<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n".
156
										'</td>'."\n".
154
                                        '</td>'."\n".'</tr>'."\n");
157
										'</tr>'."\n");  	  	
155
	$squelette->setRequiredNoteTemplate("\n".'<tr>'."\n".'<td colspan="2" class="symbole_obligatoire">* {requiredNote}</td></tr>'."\n");
158
  	  	$squelette->setElementTemplate( '<tr><td colspan="2" style="font-size:12px;text-align:left;">{label}{element}</td></tr>'."\n", 'lettre');
156
        $squelette->setElementTemplate( '<tr>'."\n".'<td colspan="2">{label}{element}</td>'."\n".'</tr>', 'lettre');
159
        $squelette->setElementTemplate( '<tr><td colspan="2" style="font-size:12px;text-align:left;">{label}{element}</td></tr>'."\n", 'visible');
157
        $squelette->setElementTemplate( '<tr>'."\n".'<td colspan="2">{label}{element}</td>'."\n".'</tr>', 'visible');
160
        $squelette->setElementTemplate( '<tr><td colspan="2" class="bouton" id="bouton_annuler">{label}{element}</td></tr>'."\n", 'groupe_bouton');        
158
        $squelette->setElementTemplate( '<tr>'."\n".'<td colspan="2">{label}{element}</td>'."\n".'</tr>', 'annuler');
161
        $squelette->setGroupTemplate('<tr><td colspan="2">{content}</td></tr>'."\n", 'groupe_bouton');
159
        $squelette->setElementTemplate( '<tr>'."\n".'<td colspan="2">{label}{element}</td>'."\n".'</tr>', 'valider');
162
        $squelette->setRequiredNoteTemplate("\n".'<tr>'."\n".'<td colspan="2" class="symbole_obligatoire">* {requiredNote}</td></tr>'."\n");
160
        $squelette->setGroupElementTemplate('<tr>'."\n".'<td colspan="2">{label}{element}</td>'."\n".'</tr>', 'groupe_bouton') ;
163
		//Traduction de champs requis
161
        //Traduction de champs requis
164
		$this->setRequiredNote(INS_CHAMPS_REQUIS) ;
162
        $this->setRequiredNote(INS_CHAMPS_REQUIS) ;
165
		$this->setJsWarnings(INS_ERREUR_SAISIE,INS_VEUILLEZ_CORRIGER);
163
	    $this->setJsWarnings(INS_ERREUR_SAISIE,INS_VEUILLEZ_CORRIGER);
166
				
-
 
167
        $debut = '<h2>'.INS_AJOUT_MEMBRE.'</h2>'."\n";
164
        $debut = '<h2>'.INS_AJOUT_MEMBRE.'</h2>'."\n";
168
        $this->addElement('html', $debut);
165
        $this->addElement('html', $debut);
-
 
166
    	$this->addElement('text', 'nom', INS_NOM) ;
-
 
167
	    $this->addRule('nom', INS_NOM_REQUIS, 'required', '', 'client') ;	
169
        $this->addElement('text', 'email', INS_EMAIL) ;
168
    	$this->addElement('text', 'email', INS_EMAIL) ;
170
        $this->addRule('email', INS_EMAIL_REQUIS, 'required','', 'client') ;
169
    	$this->addRule('email', INS_EMAIL_REQUIS, 'required','', 'client') ;
171
        $this->addRule('email', INS_MAIL_INCORRECT, 'email', '', 'client') ;
170
    	$this->addRule('email', INS_MAIL_INCORRECT, 'email', '', 'client') ;
172
        
-
 
173
        // Le mot de passe
171
    	$this->registerRule('doublonmail', 'callback', 'verif_doublonMail');
174
        $this->addElement('html', '<tr><td colspan="2"><span class="commentaire">'.INS_LAIUS_MOT_DE_PASSE.'</span></td></tr>');     
172
    	$this->addRule('email', INS_MAIL_DOUBLE, 'doublonmail', (isset($GLOBALS['AUTH']) ? $GLOBALS['AUTH']->getAuthData(INS_CHAMPS_ID) : ''));
175
        $this->addElement('password', 'mot_de_passe', INS_MOT_DE_PASSE, array('size' => '10', 'onkeyup' => 'test_robustesse()')) ;
173
    	$this->addElement('password', 'mot_de_passe', INS_MOT_DE_PASSE, array('size' => '10')) ;
176
        $this->addElement('password', 'mot_de_passe_repete', INS_REPETE_MOT_DE_PASSE, array('size' => '10')) ;
174
        $this->addElement('password', 'mot_de_passe_repete', INS_REPETE_MOT_DE_PASSE, array('size' => '10')) ;
177
        $this->addRule('mot_de_passe', INS_MOT_DE_PASSE_REQUIS, 'required', '', 'client') ;
175
      	$this->addRule('mot_de_passe', INS_MOT_DE_PASSE_REQUIS, 'required', '', 'client') ;
178
        $this->addRule('mot_de_passe_repete', INS_MOT_DE_PASSE_REQUIS, 'required', '', 'client') ;
176
      	$this->addRule('mot_de_passe_repete', INS_MOT_DE_PASSE_REQUIS, 'required', '', 'client') ;
179
        $this->addRule(array ('mot_de_passe', 'mot_de_passe_repete'), INS_MOTS_DE_PASSE_DIFFERENTS, 'compare', '', 'client') ;
177
        $this->addRule(array ('mot_de_passe', 'mot_de_passe_repete'), INS_MOTS_DE_PASSE_DIFFERENTS, 'compare', '', 'client') ;
180
        
-
 
181
		// Un template special pour la ligne de mot de passe
-
 
182
		// avec le niveau de securite
-
 
183
        $squelette->setElementTemplate('<tr>'."\n".
-
 
184
										'<td class="inscription_cellule_gauche">'."\n".'{label}'.
-
 
185
										'<!-- BEGIN required --><span class="symbole_obligatoire">&nbsp;*</span><!-- END required -->'."\n".
-
 
186
										' :</td>'."\n".
-
 
187
										'<td class="inscription_cellule_droite"> '."\n".'{element}'."\n".
-
 
188
										'<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n".
-
 
189
										'&nbsp;'.INS_LAIUS_ROBUSTESSE.' <span id="histo_robustesse" style="font-weight:bold;"></span>'.
-
 
190
										'</td>'."\n".
-
 
191
										'</tr>'."\n", 'mot_de_passe'); 
-
 
192
        // Le javascript pour gérer la sécurité
-
 
193
        GEN_stockerCodeScript('
-
 
194
function test_robustesse() {
-
 
195
	msg="";
-
 
196
    cchi=1;cmaj=1;cmin=1;cdiv=1;cspe=1
-
 
197
	pw = document.formulaire_inscription.mot_de_passe.value;
-
 
198
	if (document.getElementById) {
-
 
199
		robustesse = document.getElementById(\'histo_robustesse\');
-
 
200
	} else if (document.all) {
-
 
201
		robustesse = document.all[\'histo_robustesse\'];
-
 
202
	}  else {
-
 
203
		robustesse = document.layers[\'histo_robustesse\'];
-
 
204
	} 
-
 
205
	
-
 
206
	pw = pw.replace(/(^\s+)|(\s+$)/g,\'\');
-
 
207
	lpw = pw.length;
-
 
208
	for (i = 0; i < lpw; i++) {
-
 
209
	 ac=pw.charCodeAt(i);
-
 
210
	 if(ac<128){
-
 
211
	  // Code ascii de 48 a 57 : les chiffres
-
 
212
	  if(ac>47 && ac<58){cchi+=1}
-
 
213
	  // de 65 a 90 lettres majuscules
-
 
214
	  else if(ac>64 && ac<91){cmaj+=1}
-
 
215
	  // 97 a 122 lettres minuscules
-
 
216
	  else if(ac>96 && ac<123){cmin+=1}
-
 
217
	  else cdiv+=1
-
 
218
	 } // les caracteres speciaux > 122
-
 
219
	 	else {cspe+=1}
-
 
220
    }
-
 
221
    // Formule de calcul de la robustesse
-
 
222
	cx = cchi * cmaj * cmin * cdiv * cspe;
-
 
223
	cx= Math.round(Math.log(cx*cx));
-
 
224
	
-
 
225
	if (lpw < 4) {
-
 
226
	  robustesse.style.color = "#FF0000";
-
 
227
	  msg = "Trop court" ;		
-
 
228
	} else {
-
 
229
	  switch (cx) {
-
 
230
	  	case 3: msg = "Faible";
-
 
231
	  	robustesse.style.color = "#AA00AA";
-
 
232
	  	  break;
-
 
233
	  	case 4:
-
 
234
	  	case 5: msg = "moyen";
-
 
235
	  	  robustesse.style.color = "#5500CC";
-
 
236
	  	  break;
-
 
237
	  	default : msg = "élevé";
-
 
238
	  	 robustesse.style.color = "#0000FF";
-
 
239
	  }
-
 
240
	}
-
 
241
	robustesse.innerHTML  = msg;
-
 
242
}
-
 
243
');        
-
 
244
        $this->addElement('text', 'nom', INS_NOM) ;
-
 
245
        $this->addRule('nom', INS_NOM_REQUIS, 'required', '', 'client') ;
-
 
246
        $this->addElement('text', 'prenom', INS_PRENOM) ;
-
 
247
        $this->addRule('prenom', INS_PRENOM_REQUIS, 'required', '', 'client') ;
-
 
248
        $this->addElement('text', 'adresse_1', INS_ADRESSE_1) ;
178
    	$this->addElement('text', 'adresse_1', INS_ADRESSE_1) ;
249
        $this->addElement('text', 'adresse_2', INS_ADRESSE_2) ;
179
        $this->addElement('text', 'adresse_2', INS_ADRESSE_2) ;
250
        $this->addElement('text', 'cp', INS_CODE_POSTAL) ;
180
        $this->addElement('text', 'cp', INS_CODE_POSTAL) ;
251
        $this->addRule('cp', INS_CODE_POSTAL_REQUIS, 'required', '', 'client') ;
181
        $this->addRule('cp', INS_CODE_POSTAL_REQUIS, 'required', '', 'client') ;
252
        $this->addElement('text', 'ville', INS_VILLE) ;
182
        $this->addElement('text', 'ville', INS_VILLE) ;
-
 
183
       	$this->addRule('ville', 'Vous devez indiquer votre ville', 'required', '', 'client') ;
253
        // L'élément pays est construit à partir du tableau liste_pays
184
        // L'élément pays est construit à partir du tableau liste_pays
254
        $liste_pays = new ListeDePays($GLOBALS['ins_db']) ;
185
        $liste_pays = new ListeDePays($GLOBALS['ins_db']) ;
255
        $this->addElement('select', 'pays', INS_PAYS, $liste_pays->getListePays(INS_LANGUE_DEFAUT)) ;
186
        $this->addElement('select', 'pays', INS_PAYS, $liste_pays->getListePays(INS_LANGUE_DEFAUT)) ;	    
256
        $this->addElement('text', 'telephone', INS_TELEPHONE, array('size' => '12')) ;
187
       	$this->addElement('file', 'image', 'Avatar <a href="http://fr.wikipedia.org/wiki/Avatar_%28informatique%29" title="voir la d&eacute;finition d\'avatar" target="_blank">(c\'est quoi avatar?)</a>  (facultatif, en .JPG, 20 ko maxi, 150*150 pixels maxi)');
257
        $this->addElement('text', 'fax', INS_FAX, array('size' => '12')) ;
188
    	$this->addRule('image', 'Le fichier choisi est trop gros', 'maxfilesize', 24288);
-
 
189
	    $this->addRule('image', 'Vous devez choisir un .JPG', 'mimetype', array('image/jpg', 'image/jpeg') );
-
 
190
        $this->addElement('html', '<tr><td colspan="2"><br /><br /><h2>Pour les groupes : </h2></td></tr>'."\n");        
-
 
191
        $agemin='<tr>
-
 
192
<td style="font-size: 12px; font-weight: bold; width: 150px; text-align: right;">
-
 
193
Age minimum des participants:</td>
-
 
194
<td style="padding-left: 20px; text-align: left;"> 
-
 
195
        <select style="width: 160px;" name="age_min" size="1">
-
 
196
	<option value="1">de 1 an</option>
-
 
197
	<option value="2">de 2 ans</option>
-
 
198
	<option value="3">de 3 ans</option>
-
 
199
	<option value="4">de 4 ans</option>
-
 
200
	<option value="5">de 5 ans</option>
-
 
201
	<option value="6">de 6 ans</option>
-
 
202
	<option value="7">de 7 ans</option>
-
 
203
	<option value="8">de 8 ans</option>
-
 
204
	<option value="9">de 9 ans</option>
-
 
205
	<option value="10">de 10 ans</option>
-
 
206
	<option value="11">de 11 ans</option>
-
 
207
	<option value="12">de 12 ans</option>
-
 
208
	<option value="13">de 13 ans</option>
-
 
209
	<option value="14">de 14 ans</option>
-
 
210
	<option value="15">de 15 ans</option>
-
 
211
	<option value="16">de 16 ans</option>
-
 
212
	<option value="17">de 17 ans</option>
-
 
213
	<option value="18">de 18 ans</option>
-
 
214
	<option value="19">de 19 ans</option>
-
 
215
	<option value="20">de 20 ans</option>
-
 
216
	<option value="21">de 21 ans</option>
-
 
217
	<option value="22">de 22 ans</option>
-
 
218
	<option value="23">de 23 ans</option>
-
 
219
	<option value="24">de 24 ans</option>
-
 
220
	<option value="25">de 25 ans</option>
-
 
221
	<option value="26">de 26 ans</option>
-
 
222
	<option value="27">de 27 ans</option>
-
 
223
	<option value="28">de 28 ans</option>
-
 
224
	<option value="29">de 29 ans</option>
-
 
225
	<option value="30">de 30 ans</option>
-
 
226
	<option value="31">de 31 ans</option>
-
 
227
	<option value="32">de 32 ans</option>
-
 
228
	<option value="33">de 33 ans</option>
-
 
229
	<option value="34">de 34 ans</option>
-
 
230
	<option value="35">de 35 ans</option>
-
 
231
	<option value="36">de 36 ans</option>
-
 
232
	<option value="37">de 37 ans</option>
-
 
233
	<option value="38">de 38 ans</option>
-
 
234
	<option value="39">de 39 ans</option>
-
 
235
	<option value="40">de 40 ans</option>
-
 
236
	<option value="41">de 41 ans</option>
-
 
237
	<option value="42">de 42 ans</option>
-
 
238
	<option value="43">de 43 ans</option>
-
 
239
	<option value="44">de 44 ans</option>
-
 
240
	<option value="45">de 45 ans</option>
-
 
241
	<option value="46">de 46 ans</option>
-
 
242
	<option value="47">de 47 ans</option>
-
 
243
	<option value="48">de 48 ans</option>
-
 
244
	<option value="49">de 49 ans</option>
-
 
245
	<option value="50">de 50 ans</option>
-
 
246
	<option value="51">de 51 ans</option>
-
 
247
	<option value="52">de 52 ans</option>
-
 
248
	<option value="53">de 53 ans</option>
-
 
249
	<option value="54">de 54 ans</option>
-
 
250
	<option value="55">de 55 ans</option>
-
 
251
	<option value="56">de 56 ans</option>
-
 
252
	<option value="57">de 57 ans</option>
-
 
253
	<option value="58">de 58 ans</option>
-
 
254
	<option value="59">de 59 ans</option>
-
 
255
	<option value="60">de 60 ans</option>
-
 
256
	<option value="61">de 61 ans</option>
-
 
257
	<option value="62">de 62 ans</option>
-
 
258
	<option value="63">de 63 ans</option>
-
 
259
	<option value="64">de 64 ans</option>
-
 
260
	<option value="65">de 65 ans</option>
-
 
261
	<option value="66">de 66 ans</option>
-
 
262
	<option value="67">de 67 ans</option>
-
 
263
	<option value="68">de 68 ans</option>
-
 
264
	<option value="69">de 69 ans</option>
-
 
265
	<option value="70">de 70 ans</option>
-
 
266
	<option value="71">de 71 ans</option>
-
 
267
	<option value="72">de 72 ans</option>
-
 
268
	<option value="73">de 73 ans</option>
-
 
269
	<option value="74">de 74 ans</option>
-
 
270
	<option value="75">de 75 ans</option>
-
 
271
	<option value="76">de 76 ans</option>
-
 
272
	<option value="77">de 77 ans</option>
-
 
273
	<option value="78">de 78 ans</option>
-
 
274
	<option value="79">de 79 ans</option>
-
 
275
	<option value="80">de 80 ans</option>
-
 
276
	<option value="81">de 81 ans</option>
-
 
277
	<option value="82">de 82 ans</option>
-
 
278
	<option value="83">de 83 ans</option>
-
 
279
	<option value="84">de 84 ans</option>
-
 
280
	<option value="85">de 85 ans</option>
-
 
281
	<option value="86">de 86 ans</option>
-
 
282
	<option value="87">de 87 ans</option>
-
 
283
	<option value="88">de 88 ans</option>
-
 
284
	<option value="89">de 89 ans</option>
-
 
285
	<option value="90">de 90 ans</option>
-
 
286
	<option value="91">de 91 ans</option>
-
 
287
	<option value="92">de 92 ans</option>
-
 
288
	<option value="93">de 93 ans</option>
-
 
289
	<option value="94">de 94 ans</option>
-
 
290
	<option value="95">de 95 ans</option>
-
 
291
	<option value="96">de 96 ans</option>
-
 
292
	<option value="97">de 97 ans</option>
-
 
293
	<option value="98">de 98 ans</option>
-
 
294
	<option value="99">de 99 ans</option>
-
 
295
	<option value="100">de 100 ans</option>
-
 
296
	<option value="101">de 101 ans</option>
-
 
297
	<option value="102">de 102 ans</option>
-
 
298
	<option value="103">de 103 ans</option>
-
 
299
	<option value="104">de 104 ans</option>
-
 
300
	<option value="105">de 105 ans</option>
-
 
301
	<option value="106">de 106 ans</option>
-
 
302
	<option value="107">de 107 ans</option>
-
 
303
	<option value="108">de 108 ans</option>
-
 
304
	<option value="109">de 109 ans</option>
-
 
305
	<option value="110">de 110 ans</option>
-
 
306
	<option value="111">de 111 ans</option>
-
 
307
	<option value="112">de 112 ans</option>
-
 
308
	<option value="113">de 113 ans</option>
-
 
309
	<option value="114">de 114 ans</option>
-
 
310
	<option value="115">de 115 ans</option>
-
 
311
	<option value="116">de 116 ans</option>
-
 
312
	<option value="117">de 117 ans</option>
-
 
313
	<option value="118">de 118 ans</option>
-
 
314
	<option value="119">de 119 ans</option>
-
 
315
	<option value="120">de 120 ans</option>
-
 
316
</select></td></tr>';
-
 
317
        $agemax='<tr>
-
 
318
<td style="font-size: 12px; font-weight: bold; width: 150px; text-align: right;">
-
 
319
Age maximum des participants:</td>
-
 
320
<td style="padding-left: 20px; text-align: left;"> 
-
 
321
        <select style="width: 160px;" name="age_max" size="1">
-
 
322
	<option value="1">à 1 an</option>
-
 
323
	<option value="2">à 2 ans</option>
-
 
324
	<option value="3">à 3 ans</option>
-
 
325
	<option value="4">à 4 ans</option>
-
 
326
	<option value="5">à 5 ans</option>
-
 
327
	<option value="6">à 6 ans</option>
-
 
328
	<option value="7">à 7 ans</option>
-
 
329
	<option value="8">à 8 ans</option>
-
 
330
	<option value="9">à 9 ans</option>
-
 
331
	<option value="10">à 10 ans</option>
-
 
332
	<option value="11">à 11 ans</option>
-
 
333
	<option value="12">à 12 ans</option>
-
 
334
	<option value="13">à 13 ans</option>
-
 
335
	<option value="14">à 14 ans</option>
-
 
336
	<option value="15">à 15 ans</option>
-
 
337
	<option value="16">à 16 ans</option>
-
 
338
	<option value="17">à 17 ans</option>
-
 
339
	<option value="18">à 18 ans</option>
-
 
340
	<option value="19">à 19 ans</option>
-
 
341
	<option value="20">à 20 ans</option>
-
 
342
	<option value="21">à 21 ans</option>
-
 
343
	<option value="22">à 22 ans</option>
-
 
344
	<option value="23">à 23 ans</option>
-
 
345
	<option value="24">à 24 ans</option>
-
 
346
	<option value="25">à 25 ans</option>
-
 
347
	<option value="26">à 26 ans</option>
-
 
348
	<option value="27">à 27 ans</option>
-
 
349
	<option value="28">à 28 ans</option>
-
 
350
	<option value="29">à 29 ans</option>
-
 
351
	<option value="30">à 30 ans</option>
-
 
352
	<option value="31">à 31 ans</option>
-
 
353
	<option value="32">à 32 ans</option>
-
 
354
	<option value="33">à 33 ans</option>
-
 
355
	<option value="34">à 34 ans</option>
-
 
356
	<option value="35">à 35 ans</option>
-
 
357
	<option value="36">à 36 ans</option>
-
 
358
	<option value="37">à 37 ans</option>
-
 
359
	<option value="38">à 38 ans</option>
-
 
360
	<option value="39">à 39 ans</option>
-
 
361
	<option value="40">à 40 ans</option>
-
 
362
	<option value="41">à 41 ans</option>
-
 
363
	<option value="42">à 42 ans</option>
-
 
364
	<option value="43">à 43 ans</option>
-
 
365
	<option value="44">à 44 ans</option>
-
 
366
	<option value="45">à 45 ans</option>
-
 
367
	<option value="46">à 46 ans</option>
-
 
368
	<option value="47">à 47 ans</option>
-
 
369
	<option value="48">à 48 ans</option>
-
 
370
	<option value="49">à 49 ans</option>
-
 
371
	<option value="50">à 50 ans</option>
-
 
372
	<option value="51">à 51 ans</option>
-
 
373
	<option value="52">à 52 ans</option>
-
 
374
	<option value="53">à 53 ans</option>
-
 
375
	<option value="54">à 54 ans</option>
-
 
376
	<option value="55">à 55 ans</option>
-
 
377
	<option value="56">à 56 ans</option>
-
 
378
	<option value="57">à 57 ans</option>
-
 
379
	<option value="58">à 58 ans</option>
-
 
380
	<option value="59">à 59 ans</option>
-
 
381
	<option value="60">à 60 ans</option>
-
 
382
	<option value="61">à 61 ans</option>
-
 
383
	<option value="62">à 62 ans</option>
-
 
384
	<option value="63">à 63 ans</option>
-
 
385
	<option value="64">à 64 ans</option>
-
 
386
	<option value="65">à 65 ans</option>
-
 
387
	<option value="66">à 66 ans</option>
-
 
388
	<option value="67">à 67 ans</option>
-
 
389
	<option value="68">à 68 ans</option>
-
 
390
	<option value="69">à 69 ans</option>
-
 
391
	<option value="70">à 70 ans</option>
-
 
392
	<option value="71">à 71 ans</option>
-
 
393
	<option value="72">à 72 ans</option>
-
 
394
	<option value="73">à 73 ans</option>
-
 
395
	<option value="74">à 74 ans</option>
-
 
396
	<option value="75">à 75 ans</option>
-
 
397
	<option value="76">à 76 ans</option>
-
 
398
	<option value="77">à 77 ans</option>
-
 
399
	<option value="78">à 78 ans</option>
-
 
400
	<option value="79">à 79 ans</option>
-
 
401
	<option value="80">à 80 ans</option>
-
 
402
	<option value="81">à 81 ans</option>
-
 
403
	<option value="82">à 82 ans</option>
-
 
404
	<option value="83">à 83 ans</option>
-
 
405
	<option value="84">à 84 ans</option>
-
 
406
	<option value="85">à 85 ans</option>
-
 
407
	<option value="86">à 86 ans</option>
-
 
408
	<option value="87">à 87 ans</option>
-
 
409
	<option value="88">à 88 ans</option>
-
 
410
	<option value="89">à 89 ans</option>
-
 
411
	<option value="90">à 90 ans</option>
-
 
412
	<option value="91">à 91 ans</option>
-
 
413
	<option value="92">à 92 ans</option>
-
 
414
	<option value="93">à 93 ans</option>
-
 
415
	<option value="94">à 94 ans</option>
-
 
416
	<option value="95">à 95 ans</option>
-
 
417
	<option value="96">à 96 ans</option>
-
 
418
	<option value="97">à 97 ans</option>
-
 
419
	<option value="98">à 98 ans</option>
-
 
420
	<option value="99">à 99 ans</option>
-
 
421
	<option value="100">à 100 ans</option>
-
 
422
	<option value="101">à 101 ans</option>
-
 
423
	<option value="102">à 102 ans</option>
-
 
424
	<option value="103">à 103 ans</option>
-
 
425
	<option value="104">à 104 ans</option>
-
 
426
	<option value="105">à 105 ans</option>
-
 
427
	<option value="106">à 106 ans</option>
-
 
428
	<option value="107">à 107 ans</option>
-
 
429
	<option value="108">à 108 ans</option>
-
 
430
	<option value="109">à 109 ans</option>
-
 
431
	<option value="110">à 110 ans</option>
-
 
432
	<option value="111">à 111 ans</option>
-
 
433
	<option value="112">à 112 ans</option>
-
 
434
	<option value="113">à 113 ans</option>
-
 
435
	<option value="114">à 114 ans</option>
-
 
436
	<option value="115">à 115 ans</option>
-
 
437
	<option value="116">à 116 ans</option>
-
 
438
	<option value="117">à 117 ans</option>
-
 
439
	<option value="118">à 118 ans</option>
-
 
440
	<option value="119">à 119 ans</option>
-
 
441
	<option value="120">à 120 ans</option>
-
 
442
</select></td></tr>';
258
        $this->addElement('text', 'site', INS_SITE_INTERNET) ;
443
        $this->addElement('html', $agemin);
259
        $this->addElement('file', 'image', INS_LOGO_OU_IMAGE) ;
444
        $this->addElement('html', $agemax);
-
 
445
        $formtexte= new HTML_QuickForm_textarea('description', 'Courte description des participants et de leurs projets', array('style'=>'white-space: normal;width:300px;height:180px;'));
-
 
446
	    $this->addElement($formtexte) ;
260
		$this->setMaxFileSize(150000); //logo de 15ko maximum
447
    	$this->applyFilter('description', 'addslashes') ;        
-
 
448
        $this->addElement('text', 'nom_ref', 'Nom du r&eacute;f&eacute;rent');
261
        if (INS_CHAMPS_LETTRE != '') $this->addElement('checkbox', 'lettre',INS_LETTRE, '<br />') ;
449
        if (INS_CHAMPS_LETTRE != '') $this->addElement('hidden', 'lettre',1) ;
262
        $this->addElement('checkbox', 'visible',INS_VISIBLE, '<br />') ;
450
        $this->addElement('hidden', 'visible',1) ;
263
        $this->addElement('hidden', 'est_structure', 0) ;
451
        $this->addElement('hidden', 'est_structure', 0) ;
264
        $defauts=array ('lettre'=>1,'pays'=>'FR');      
452
        $defauts=array ('lettre'=>1,'pays'=>'FR');      
265
        $this->setDefaults($defauts);	
453
        $this->setDefaults($defauts);	
266
        // on fait un groupe avec les boutons pour les mettres sur la même ligne
454
        // on fait un groupe avec les boutons pour les mettres sur la même ligne
267
        $boutons[] = &HTML_QuickForm::createElement('button', 'annuler', INS_ANNULER, array ("onclick" => "javascript:document.location.href='".$url."'",
455
        $this->addElement('button', 'annuler', INS_ANNULER, array ("onclick" => "javascript:document.location.href='".$url."'"));
268
        												'id' => 'annuler', 'class' => 'bouton'));
-
 
269
        $boutons[] = &HTML_QuickForm::createElement('submit', 'valider', INS_VALIDER, array ('id' => 'valider', 'class' =>'bouton'));
-
 
270
        $this->addGroup($boutons, 'groupe_bouton', '', "\n");
456
        $this->addElement('submit', 'valider', INS_VALIDER);
271
    } // end of member function construitFormulaire
457
    } // end of member function construitFormulaire
272
    
458
    
273
    /** Modifie le formulaire pour l'adapter au cas des structures
459
    /** Modifie le formulaire pour l'adapter au cas des structures
274
     * 
460
     * 
275
     *
461
     *
276
     * @return void
462
     * @return void
277
     * @access public
463
     * @access public
278
     */
464
     */
279
    function formulaireStructure()
465
    function formulaireStructure()
280
    {
466
    {
281
        $this->removeElement('nom', false) ;
467
        $this->removeElement('nom', false) ;
282
        $this->removeElement('prenom') ;
468
        $this->removeElement('prenom') ;
283
        $this->removeElement('email', false) ;
469
        $this->removeElement('email', false) ;
284
        $mail = & HTML_QuickForm::createElement('text', 'email', INS_MAIL_STRUCTURE) ;
470
        $mail = & HTML_QuickForm::createElement('text', 'email', INS_MAIL_STRUCTURE) ;
285
        $this->insertElementBefore($mail, 'mot_de_passe') ;
471
        $this->insertElementBefore($mail, 'mot_de_passe') ;
286
        $nom_structure = & HTML_QuickForm::createElement('text', 'nom', INS_NOM_STRUCTURE) ;
472
        $nom_structure = & HTML_QuickForm::createElement('text', 'nom', INS_NOM_STRUCTURE) ;
287
        $this->insertElementBefore($nom_structure, 'email') ;
473
        $this->insertElementBefore($nom_structure, 'email') ;
288
        $this->addRule('nom', INS_NOM_REQUIS, 'required', '', 'client') ;
474
        $this->addRule('nom', INS_NOM_REQUIS, 'required', '', 'client') ;
289
        $sigle_structure = & HTML_QuickForm::createElement('text', 'sigle_structure', INS_SIGLE_DE_LA_STRUCTURE) ;
475
        $sigle_structure = & HTML_QuickForm::createElement('text', 'sigle_structure', INS_SIGLE_DE_LA_STRUCTURE) ;
290
        $this->insertElementBefore($sigle_structure, 'email') ;
476
        $this->insertElementBefore($sigle_structure, 'email') ;
291
        $this->addRule('sigle_structure', INS_SIGLE_REQUIS, 'required', '', 'client') ;
477
        $this->addRule('sigle_structure', INS_SIGLE_REQUIS, 'required', '', 'client') ;
292
        $num_agrement = & HTML_QuickForm::createElement('text', 'num_agrement', INS_NUM_AGREMENT) ;
478
        $num_agrement = & HTML_QuickForm::createElement('text', 'num_agrement', INS_NUM_AGREMENT) ;
293
        $this->insertElementBefore($num_agrement, 'email') ;
479
        $this->insertElementBefore($num_agrement, 'email') ;
294
        $this->removeElement('site', false) ;
480
        $this->removeElement('site', false) ;
295
        $site_structure = & HTML_QuickForm::createElement('text', 'site', INS_SITE_STRUCTURE) ;
481
        $site_structure = & HTML_QuickForm::createElement('text', 'site', INS_SITE_STRUCTURE) ;
296
        $this->insertElementBefore($site_structure, 'lettre') ;
482
        $this->insertElementBefore($site_structure, 'lettre') ;
297
        $this->removeElement('est_structure', false) ;
483
        $this->removeElement('est_structure', false) ;
298
        $this->addElement('hidden', 'est_structure', 1) ;
484
        $this->addElement('hidden', 'est_structure', 1) ;
299
        $this->addElement('hidden', 'form_structure', 1) ;
485
        $this->addElement('hidden', 'form_structure', 1) ;
300
    }
486
    }
301
    /**
487
    /**
302
     * 
488
     * 
303
     *
489
     *
304
     * @return string
490
     * @return string
305
     * @access public
491
     * @access public
306
     */
492
     */
307
    function toHTML( )
493
    function toHTML( )
308
    {
494
    {
309
        $res = HTML_QuickForm::toHTML() ;
495
        $res = HTML_QuickForm::toHTML() ;
310
        return $res ;
496
        return $res ;
311
    } // end of member function toHTML
497
    } // end of member function toHTML
312
}
498
}
313
 
-
 
314
?>
499
 
-
 
500
?>