Subversion Repositories Applications.papyrus

Rev

Rev 979 | 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
// +------------------------------------------------------------------------------------------------------+
1081 florian 22
// CVS : $Id: inscription.php,v 1.20 2006-12-01 13:23:17 florian Exp $
448 ddelon 23
/**
24
* Inscription
25
*
26
* Un module d'inscription, en général ce code est spécifique à
27
* un site web
28
*
29
*@package inscription
30
//Auteur original :
31
*@author        Alexandre GRANIER <alexandre@tela-botanica.org>
32
//Autres auteurs :
33
*@author        Florian SCHMITT <florian@ecole-et-nature.org>
34
*@copyright     Tela-Botanica 2000-2004
1081 florian 35
*@version       $Revision: 1.20 $ $Date: 2006-12-01 13:23:17 $
448 ddelon 36
// +------------------------------------------------------------------------------------------------------+
37
*/
38
 
39
// +------------------------------------------------------------------------------------------------------+
40
// |                                            ENTETE du PROGRAMME                                       |
41
// +------------------------------------------------------------------------------------------------------+
471 alexandre_ 42
include_once 'configuration/bottin.config.inc.php';
979 florian 43
include_once INS_CHEMIN_APPLI.'bibliotheque/bottin.fonct.php';
448 ddelon 44
 
739 alexandre_ 45
// Inclusion d'une classe personnalisé si elle existe
46
if (file_exists (INS_CHEMIN_APPLI.'bibliotheque/inscription.class.local.php')) {
47
	include_once INS_CHEMIN_APPLI.'bibliotheque/inscription.class.local.php' ;
48
} else {
49
	include_once INS_CHEMIN_APPLI.'bibliotheque/inscription.class.php';
50
}
51
 
448 ddelon 52
// +------------------------------------------------------------------------------------------------------+
53
// |                                           LISTE de FONCTIONS                                         |
54
// +------------------------------------------------------------------------------------------------------+
1081 florian 55
if ( isset($_GET['voir_fiche']) or isset($_GET['voir_abonnement']) or isset($_GET['voir_actus']) or isset($_GET['voir_ressources']) or isset($_GET['voir_competences'])
56
or (isset($_REQUEST['action'])&&($_REQUEST['action']=='modifier_v'||$_REQUEST['action']=='modifier_v'))
57
or ($GLOBALS['AUTH']->getAuth() && ($_REQUEST['action']!='modifier')) ) {
979 florian 58
	//---------------le menu de l'appli-----------
59
	function afficherContenuNavigation () {
60
		$res =inscription_onglets();
61
		return $res ;
62
	}
63
}
448 ddelon 64
 
65
function afficherContenuCorps() {
66
    $res = '<h1>'.INS_TITRE_INSCRIPTION.'</h1>'."\n" ;
67
    if (!isset($_REQUEST['action'])) {
603 florian 68
    	$_REQUEST['action']='';
448 ddelon 69
    }
70
 
603 florian 71
//cas de la déconnexion----------------------------------------------------------------------------------
72
    if ($_REQUEST['action'] == 'deconnexion') {
448 ddelon 73
        $GLOBALS['AUTH']->logout() ;
74
        $_POST['username'] = '' ;
75
        $_POST['password'] = '' ;
1081 florian 76
        return $res.inscription_AUTH_formulaire_login() ;
448 ddelon 77
    }
78
 
603 florian 79
//cas de la désinscription-------------------------------------------------------------------------------
80
    if ($_REQUEST['action'] == 'supprimer') {
670 alexandre_ 81
    	$id_utilisateur = $GLOBALS['AUTH']->getAuthData(INS_CHAMPS_ID) ;
758 alexandre_ 82
    	// Suppression dans SPIP
448 ddelon 83
        if (INS_UTILISE_SPIP) {
603 florian 84
            desinscription_spip($GLOBALS['AUTH']->getAuthData(INS_CHAMPS_ID)) ;
448 ddelon 85
        }
484 alexandre_ 86
		// Suppression dans Wikini
448 ddelon 87
        if (INS_UTILISE_WIKINI) {
758 alexandre_ 88
			$nom_wiki = $GLOBALS['AUTH']->getAuthData(INS_CHAMPS_NOM_WIKINI) ;
484 alexandre_ 89
			desinscription_interwikini_users($nom_wiki) ;
448 ddelon 90
        }
484 alexandre_ 91
        // Appel des actions desinscriptions des applications clientes
92
        $d = dir(GEN_CHEMIN_CLIENT);
93
		while (false !== ($repertoire = $d->read())) {
94
			if (file_exists(GEN_CHEMIN_CLIENT.$repertoire.GEN_SEP.$repertoire.'.desinscription.inc.php'))
95
			include_once GEN_CHEMIN_CLIENT.$repertoire.GEN_SEP.$repertoire.'.desinscription.inc.php' ;
96
		}
97
		$d->close();
854 alexandre_ 98
 
99
    	$resultat = $GLOBALS['AUTH']->removeUser($GLOBALS['AUTH']->getUsername()) ;
100
        if (PEAR::isError($resultat)) {
101
        	die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
102
        }
103
 
104
 
603 florian 105
		// Deconnection
448 ddelon 106
        $GLOBALS['AUTH']->logout() ;
1081 florian 107
        return $res.inscription_AUTH_formulaire_login() ;
448 ddelon 108
    }
109
 
603 florian 110
//cas de l'envoi de mot de passe par mail----------------------------------------------------------------
448 ddelon 111
    if ($_REQUEST['action'] == 'sendpasswd') {
1081 florian 112
        return inscription_envoie_passe()."\n".inscription_formulaire_envoi_passe() ;
448 ddelon 113
    }
114
 
603 florian 115
//cas de la saisie ou la modification de l'inscription individuelle ou structure
606 florian 116
    if (($_REQUEST['action'] == 'modifier')or($_REQUEST['action'] == 'modifier_v')or($_REQUEST['action'] == 'inscription')or($_REQUEST['action'] == 'inscription_v')) {
603 florian 117
        $formulaire = new HTML_formulaireInscription('formulaire_inscription', 'post', preg_replace('/&amp;/', '&', $GLOBALS['ins_url']->getURL()), '_self', '', 0) ;
118
        $formulaire->construitFormulaire(preg_replace('/&amp;/', '&', $GLOBALS['ins_url']->getURL()));
606 florian 119
        if (isset($_REQUEST['form_structure'])) {
120
        	if ($_REQUEST['form_structure']==1) {
121
        		$formulaire->formulaireStructure() ;
122
        	}
448 ddelon 123
        }
603 florian 124
 
896 alexandre_ 125
        // On ajoute la règle de vérification mail uniquement lors de l inscription
126
        if ($_REQUEST['action'] == 'inscription') {
906 alexandre_ 127
	        $formulaire->registerRule('doublonmail', 'callback', 'verif_doublonMail');
128
	        $formulaire->addRule('email', INS_MAIL_DOUBLE, 'doublonmail', true);
896 alexandre_ 129
        }
603 florian 130
        //pour la modification d'une inscription, on charge les valeurs par défauts
131
        if ($_REQUEST['action'] == 'modifier') {
448 ddelon 132
            $formulaire->addElement('hidden', 'action', 'modifier_v') ;
1081 florian 133
            $formulaire->setDefaults(inscription_formulaire_defaults()) ;
448 ddelon 134
        }
135
 
136
        if ($_REQUEST['action'] == 'inscription') {
484 alexandre_ 137
            if ($GLOBALS['AUTH']->getAuth()) {
138
 
603 florian 139
            } else {
484 alexandre_ 140
            	$formulaire->addElement('hidden', 'action', 'inscription_v') ;
805 florian 141
            	$formulaire->setDefaults(array('pays' => 'fr', 'visible' => 1,'lettre'=>1));
484 alexandre_ 142
            }
448 ddelon 143
        }
144
 
145
        if ($_REQUEST['action'] == 'inscription_v') {
146
            if ($formulaire->validate()) {
743 alexandre_ 147
			    if (INS_MAIL_VALIDATION_INSCRIPTION) {
1081 florian 148
				    $formulaire->process('inscription_demande', false) ;
743 alexandre_ 149
				    return $res.INS_MESSAGE_INSCRIPTION;
150
			    } else {
1081 florian 151
				    $formulaire->process('inscription_validee', false) ;
152
				    $id_utilisateur = $GLOBALS['ins_db']->getOne('SELECT MAX('.INS_CHAMPS_ID.') FROM '.INS_ANNUAIRE) ;
979 florian 153
				    // Appel des actions des inscriptions des applications clientes
743 alexandre_ 154
			        $d = dir(GEN_CHEMIN_CLIENT);
155
					while (false !== ($repertoire = $d->read())) {
156
						if (file_exists(GEN_CHEMIN_CLIENT.$repertoire.GEN_SEP.$repertoire.'.inscription.inc.php'))
157
						include_once GEN_CHEMIN_CLIENT.$repertoire.GEN_SEP.$repertoire.'.inscription.inc.php' ;
158
					}
159
					$d->close();
160
				    return $res.info();
161
			    }
780 alexandre_ 162
            } else {
163
            	// Si le formulaire n'est pas bon on remet l'action à inscription_v
164
            	$formulaire->addElement('hidden', 'action', 'inscription_v') ;
448 ddelon 165
            }
166
        }
167
        if ($_REQUEST['action'] == 'modifier_v') {
168
            if ($formulaire->validate()) {
1081 florian 169
                $formulaire->process('inscription_mise_a_jour', false) ;
915 alexandre_ 170
            } else {
171
            	return $formulaire->toHTML();
448 ddelon 172
            }
603 florian 173
            return $res.info();
448 ddelon 174
        }
175
 
176
        return $res.$formulaire->toHTML() ;
177
    }
178
 
603 florian 179
//cas de la validation par mail d'une inscription--------------------------------------------------------
448 ddelon 180
    if ((INS_MAIL_VALIDATION_INSCRIPTION)and(isset($_GET['id']))) {
603 florian 181
	    $requete = 'SELECT id_donnees FROM inscription_demande WHERE id_identifiant_session="'.$_GET['id'].'"' ;
448 ddelon 182
	    $resultat = $GLOBALS['ins_db']->query($requete) ;
183
	    if (DB::isError ($resultat)) {
184
		    die ("Echec de la requete : $requete<br />".$resultat->getMessage()) ;
185
	    }
186
	    if ($resultat->numRows() == 0) {
187
		    return $res.INS_MESSAGE_EXPIRATION;
188
	    }
189
	    $ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT) ;
190
	    $donnees = unserialize (stripslashes($ligne->id_donnees)) ;
1081 florian 191
	    $id_utilisateur = inscription_insertion($donnees) ;
448 ddelon 192
	    $GLOBALS['AUTH']->username = $donnees['email'] ;
193
	    $GLOBALS['AUTH']->password = $donnees['mot_de_passe'] ;
194
 
195
	    // On loggue l'utilisateur
196
	    $GLOBALS['AUTH']->login() ;
197
 
198
	    // inscription à la lettre d'information
199
	    if (isset ($donnees['lettre'])) {
200
		    inscription_lettre(INS_MAIL_INSCRIPTION_LISTE) ;
201
	    }
202
	    // On supprime la demande d'inscription
203
	    $requete = 'delete from inscription_demande where id_identifiant_session="'.$_GET['id'].'"' ;
204
	    $resultat = $GLOBALS['ins_db']->query($requete) ;
205
	    if (DB::isError($resultat)) {
206
		    die ("Echec de la requete : $requete<br />".$resultat->getMessage()) ;
207
	    }
743 alexandre_ 208
	    // Appel des actions desinscriptions des applications clientes
209
        $d = dir(GEN_CHEMIN_CLIENT);
210
		while (false !== ($repertoire = $d->read())) {
211
			if (file_exists(GEN_CHEMIN_CLIENT.$repertoire.GEN_SEP.$repertoire.'.inscription.inc.php'))
212
			include_once GEN_CHEMIN_CLIENT.$repertoire.GEN_SEP.$repertoire.'.inscription.inc.php' ;
213
		}
214
		$d->close();
448 ddelon 215
	    envoie_mail() ;
216
    }
217
 
603 florian 218
    if ((!$GLOBALS['AUTH']->getAuth())&&($_REQUEST['action']!='inscription')&&($_REQUEST['action']!='inscription_v')) {
448 ddelon 219
        if (isset($_POST['username']) && $_POST['username'] != '') {
1081 florian 220
            $res .= '<p class="erreur">'.INS_ERREUR_LOGIN.'</p><br />'."\n".inscription_formulaire_envoi_passe();
448 ddelon 221
        } else {
1081 florian 222
            $res .= inscription_AUTH_formulaire_login() ;
448 ddelon 223
        }
224
    }
225
 
603 florian 226
//cas d'une authentification réussie---------------------------------------------------------------------
227
    if ($GLOBALS['AUTH']->getAuth() && ($_REQUEST['action']!='modifier')) {
228
            return info() ;
448 ddelon 229
    }
603 florian 230
 
448 ddelon 231
    return $res ;
232
}
233
 
234
/* +--Fin du code ----------------------------------------------------------------------------------------+
235
*
236
* $Log: not supported by cvs2svn $
1081 florian 237
* Revision 1.19  2006/10/05 13:53:54  florian
238
* amélioration des fichiers sql
239
*
979 florian 240
* Revision 1.18  2006/07/20 09:48:07  alexandre_tb
241
* réglages
242
*
915 alexandre_ 243
* Revision 1.17  2006/07/06 10:33:30  alexandre_tb
244
* correction bug du à dernière mise à jour
245
*
906 alexandre_ 246
* Revision 1.16  2006/07/04 09:38:31  alexandre_tb
247
* Ajout de la règle doublon email uniquement lors de création d'une entrée
248
*
896 alexandre_ 249
* Revision 1.15  2006/06/01 10:00:35  alexandre_tb
250
* correction bug désinscription des appli cliente
251
*
854 alexandre_ 252
* Revision 1.14  2006/04/10 09:48:16  alexandre_tb
253
* Correction de bug pour les inscriptions aux autres applications
254
*
806 alexandre_ 255
* Revision 1.13  2006/04/04 12:23:05  florian
256
* modifs affichage fiches, généricité de la carto, modification totale de l'appli annuaire
257
*
805 florian 258
* Revision 1.12  2006/03/15 11:05:45  alexandre_tb
259
* ajout de l'action caché inscription_v lors du réaffichage du formulaire après erreur de saisie.
260
*
780 alexandre_ 261
* Revision 1.11  2006/03/02 14:10:35  alexandre_tb
262
* correction du bug desinscription wikini
263
*
758 alexandre_ 264
* Revision 1.10  2006/03/02 13:03:45  alexandre_tb
265
* bug de désinscription interwikini_users
266
*
756 alexandre_ 267
* Revision 1.9  2006/02/28 14:08:27  alexandre_tb
268
* appel des inscriptions des autres appli, sous le format:
269
* client/appli/appli.inscription.php
270
*
743 alexandre_ 271
* Revision 1.8  2006/02/14 10:21:08  alexandre_tb
272
* ajout d'un appel à un fichier de classe personnalisé
273
*
739 alexandre_ 274
* Revision 1.7  2005/12/19 13:16:14  alexandre_tb
275
* correction d'un bug
276
*
670 alexandre_ 277
* Revision 1.6  2005/11/18 16:04:15  florian
278
* corrections de bugs, optimisations, tests pour rendre inscription stable.
279
*
606 florian 280
* Revision 1.5  2005/11/17 18:48:02  florian
281
* corrections bugs + amélioration de l'application d'inscription
282
*
603 florian 283
* Revision 1.4  2005/10/25 14:02:21  alexandre_tb
284
* le formulaire affiche la france par défaut
285
*
575 alexandre_ 286
* Revision 1.3  2005/09/29 16:07:51  alexandre_tb
287
* En cours de production.
288
*
484 alexandre_ 289
* Revision 1.2  2005/09/27 13:59:24  alexandre_tb
290
* correction de bogue, généralisation du code etc.
291
*
471 alexandre_ 292
* Revision 1.1  2005/09/22 14:02:49  ddelon
293
* nettoyage annuaire et php5
294
*
448 ddelon 295
* Revision 1.4  2005/09/22 13:30:49  florian
296
* modifs pour compatibilité XHTML Strict + corrections de bugs (mais ya encore du boulot!!)
297
*
298
* Revision 1.4  2005/03/21 16:57:30  florian
299
* correction de bug, mise à jour interface
300
*
301
* Revision 1.3  2005/03/08 17:44:02  alex
302
* suppression en utilisant removeUser de Auth plutôt qu'en requete directe
303
*
304
* Revision 1.2  2005/03/02 12:44:41  alex
305
* Correction du bug message d'erreur alors qu'on tente de s'inscrire simplement
306
*
307
* Revision 1.1  2004/12/15 13:32:15  alex
308
* version initiale
309
*
310
* Revision 1.2  2004/09/01 16:36:37  alex
311
* changement du chemin pour les include
312
*
313
* Revision 1.1  2004/07/06 15:42:28  alex
314
* en cours
315
*
316
* Revision 1.5  2004/07/06 15:28:56  alex
317
* en cours
318
*
319
* Revision 1.4  2004/06/25 14:26:03  alex
320
* modification de la suppression
321
*
322
* Revision 1.3  2004/06/23 12:41:44  alex
323
* amélioration de la gestion de la perte de mot de passe
324
*
325
* Revision 1.2  2004/06/18 09:18:23  alex
326
* version initiale
327
*
328
*
329
* +-- Fin du code ----------------------------------------------------------------------------------------+
330
*/
331
?>