Subversion Repositories Applications.papyrus

Rev

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

Rev Author Line No. Line
448 ddelon 1
<?php
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */
3
// +------------------------------------------------------------------------------------------------------+
4
// | PHP version 4.1                                                                                      |
5
// +------------------------------------------------------------------------------------------------------+
6
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
7
// +------------------------------------------------------------------------------------------------------+
8
// | This library is free software; you can redistribute it and/or                                        |
9
// | modify it under the terms of the GNU Lesser General Public                                           |
10
// | License as published by the Free Software Foundation; either                                         |
11
// | version 2.1 of the License, or (at your option) any later version.                                   |
12
// |                                                                                                      |
13
// | This library is distributed in the hope that it will be useful,                                      |
14
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
15
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
16
// | Lesser General Public License for more details.                                                      |
17
// |                                                                                                      |
18
// | You should have received a copy of the GNU Lesser General Public                                     |
19
// | License along with this library; if not, write to the Free Software                                  |
20
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
21
// +------------------------------------------------------------------------------------------------------+
1292 neiluj 22
// CVS : $Id: inscription.php,v 1.22 2007-04-06 08:35:46 neiluj 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
1292 neiluj 35
*@version       $Revision: 1.22 $ $Date: 2007-04-06 08:35:46 $
448 ddelon 36
// +------------------------------------------------------------------------------------------------------+
37
*/
38
 
39
// +------------------------------------------------------------------------------------------------------+
40
// |                                            ENTETE du PROGRAMME                                       |
41
// +------------------------------------------------------------------------------------------------------+
471 alexandre_ 42
include_once 'configuration/bottin.config.inc.php';
1292 neiluj 43
include_once INS_CHEMIN_APPLI.'bibliotheque/inscription.fonct.php';
44
include_once INS_CHEMIN_APPLI.'bibliotheque/inscription.class.php';
448 ddelon 45
 
46
// +------------------------------------------------------------------------------------------------------+
47
// |                                           LISTE de FONCTIONS                                         |
48
// +------------------------------------------------------------------------------------------------------+
49
 
1292 neiluj 50
 
448 ddelon 51
function afficherContenuCorps() {
1292 neiluj 52
 
448 ddelon 53
    $res = '<h1>'.INS_TITRE_INSCRIPTION.'</h1>'."\n" ;
54
    if (!isset($_REQUEST['action'])) {
603 florian 55
    	$_REQUEST['action']='';
448 ddelon 56
    }
57
 
1292 neiluj 58
//cas de la dàconnexion----------------------------------------------------------------------------------
603 florian 59
    if ($_REQUEST['action'] == 'deconnexion') {
448 ddelon 60
        $GLOBALS['AUTH']->logout() ;
61
        $_POST['username'] = '' ;
62
        $_POST['password'] = '' ;
1188 alexandre_ 63
        return $res.AUTH_formulaire_login() ;
448 ddelon 64
    }
65
 
603 florian 66
//cas de la désinscription-------------------------------------------------------------------------------
67
    if ($_REQUEST['action'] == 'supprimer') {
670 alexandre_ 68
    	$id_utilisateur = $GLOBALS['AUTH']->getAuthData(INS_CHAMPS_ID) ;
1292 neiluj 69
    	$resultat = $GLOBALS['AUTH']->removeUser($GLOBALS['AUTH']->getUsername()) ;
70
        if (PEAR::isError($resultat)) {
71
        	die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
72
        }
73
        // Suppression dans SPIP
448 ddelon 74
        if (INS_UTILISE_SPIP) {
603 florian 75
            desinscription_spip($GLOBALS['AUTH']->getAuthData(INS_CHAMPS_ID)) ;
448 ddelon 76
        }
484 alexandre_ 77
		// Suppression dans Wikini
448 ddelon 78
        if (INS_UTILISE_WIKINI) {
1292 neiluj 79
			$nom_wiki = $GLOBALS['AUTH']->getAuthData(INS_NOM_WIKI) ;
484 alexandre_ 80
			desinscription_interwikini_users($nom_wiki) ;
448 ddelon 81
        }
484 alexandre_ 82
        // Appel des actions desinscriptions des applications clientes
83
        $d = dir(GEN_CHEMIN_CLIENT);
84
		while (false !== ($repertoire = $d->read())) {
85
			if (file_exists(GEN_CHEMIN_CLIENT.$repertoire.GEN_SEP.$repertoire.'.desinscription.inc.php'))
86
			include_once GEN_CHEMIN_CLIENT.$repertoire.GEN_SEP.$repertoire.'.desinscription.inc.php' ;
87
		}
88
		$d->close();
603 florian 89
		// Deconnection
448 ddelon 90
        $GLOBALS['AUTH']->logout() ;
1188 alexandre_ 91
        return $res.AUTH_formulaire_login() ;
448 ddelon 92
    }
93
 
603 florian 94
//cas de l'envoi de mot de passe par mail----------------------------------------------------------------
448 ddelon 95
    if ($_REQUEST['action'] == 'sendpasswd') {
1188 alexandre_ 96
        return envoie_passe()."\n".formulaire_envoi_passe() ;
448 ddelon 97
    }
98
 
603 florian 99
//cas de la saisie ou la modification de l'inscription individuelle ou structure
606 florian 100
    if (($_REQUEST['action'] == 'modifier')or($_REQUEST['action'] == 'modifier_v')or($_REQUEST['action'] == 'inscription')or($_REQUEST['action'] == 'inscription_v')) {
603 florian 101
        $formulaire = new HTML_formulaireInscription('formulaire_inscription', 'post', preg_replace('/&amp;/', '&', $GLOBALS['ins_url']->getURL()), '_self', '', 0) ;
102
        $formulaire->construitFormulaire(preg_replace('/&amp;/', '&', $GLOBALS['ins_url']->getURL()));
606 florian 103
        if (isset($_REQUEST['form_structure'])) {
104
        	if ($_REQUEST['form_structure']==1) {
105
        		$formulaire->formulaireStructure() ;
106
        	}
448 ddelon 107
        }
603 florian 108
 
109
        //pour la modification d'une inscription, on charge les valeurs par défauts
110
        if ($_REQUEST['action'] == 'modifier') {
448 ddelon 111
            $formulaire->addElement('hidden', 'action', 'modifier_v') ;
1188 alexandre_ 112
            $formulaire->setDefaults(formulaire_defaults()) ;
448 ddelon 113
        }
114
 
115
        if ($_REQUEST['action'] == 'inscription') {
484 alexandre_ 116
            if ($GLOBALS['AUTH']->getAuth()) {
117
 
603 florian 118
            } else {
484 alexandre_ 119
            	$formulaire->addElement('hidden', 'action', 'inscription_v') ;
1292 neiluj 120
            	$formulaire->setDefaults(array('pays' => 'FR', 'visible' => 1));
484 alexandre_ 121
            }
448 ddelon 122
        }
123
 
124
        if ($_REQUEST['action'] == 'inscription_v') {
125
            if ($formulaire->validate()) {
1292 neiluj 126
		    if (INS_MAIL_VALIDATION_INSCRIPTION) {
127
			    $formulaire->process('demande_inscription', false) ;
128
			    return $res.INS_MESSAGE_INSCRIPTION;
129
		    } else {
130
			    $formulaire->process('inscription_validee', false) ;
131
			    return $res.info();
132
		    }
448 ddelon 133
            }
134
        }
135
        if ($_REQUEST['action'] == 'modifier_v') {
136
            if ($formulaire->validate()) {
1292 neiluj 137
                $formulaire->process('mise_a_jour', false) ;
138
                return $res.info();
448 ddelon 139
            }
140
        }
141
 
142
        return $res.$formulaire->toHTML() ;
143
    }
144
 
603 florian 145
//cas de la validation par mail d'une inscription--------------------------------------------------------
448 ddelon 146
    if ((INS_MAIL_VALIDATION_INSCRIPTION)and(isset($_GET['id']))) {
603 florian 147
	    $requete = 'SELECT id_donnees FROM inscription_demande WHERE id_identifiant_session="'.$_GET['id'].'"' ;
448 ddelon 148
	    $resultat = $GLOBALS['ins_db']->query($requete) ;
149
	    if (DB::isError ($resultat)) {
150
		    die ("Echec de la requete : $requete<br />".$resultat->getMessage()) ;
151
	    }
152
	    if ($resultat->numRows() == 0) {
153
		    return $res.INS_MESSAGE_EXPIRATION;
154
	    }
155
	    $ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT) ;
156
	    $donnees = unserialize (stripslashes($ligne->id_donnees)) ;
1292 neiluj 157
	    insertion($donnees) ;
448 ddelon 158
	    $GLOBALS['AUTH']->username = $donnees['email'] ;
159
	    $GLOBALS['AUTH']->password = $donnees['mot_de_passe'] ;
160
 
161
	    // On loggue l'utilisateur
162
	    $GLOBALS['AUTH']->login() ;
163
 
164
	    // inscription à la lettre d'information
165
	    if (isset ($donnees['lettre'])) {
166
		    inscription_lettre(INS_MAIL_INSCRIPTION_LISTE) ;
167
	    }
168
	    // On supprime la demande d'inscription
169
	    $requete = 'delete from inscription_demande where id_identifiant_session="'.$_GET['id'].'"' ;
170
	    $resultat = $GLOBALS['ins_db']->query($requete) ;
171
	    if (DB::isError($resultat)) {
172
		    die ("Echec de la requete : $requete<br />".$resultat->getMessage()) ;
173
	    }
174
	    envoie_mail() ;
175
    }
176
 
603 florian 177
    if ((!$GLOBALS['AUTH']->getAuth())&&($_REQUEST['action']!='inscription')&&($_REQUEST['action']!='inscription_v')) {
448 ddelon 178
        if (isset($_POST['username']) && $_POST['username'] != '') {
1188 alexandre_ 179
            $res .= '<p class="erreur">'.INS_ERREUR_LOGIN.'</p><br />'."\n".formulaire_envoi_passe();
448 ddelon 180
        } else {
1188 alexandre_ 181
            $res .= AUTH_formulaire_login() ;
448 ddelon 182
        }
183
    }
184
 
1292 neiluj 185
//cas d'une authentification ràussie---------------------------------------------------------------------
603 florian 186
    if ($GLOBALS['AUTH']->getAuth() && ($_REQUEST['action']!='modifier')) {
187
            return info() ;
448 ddelon 188
    }
603 florian 189
 
448 ddelon 190
    return $res ;
191
}
192
 
193
/* +--Fin du code ----------------------------------------------------------------------------------------+
194
*
195
* $Log: not supported by cvs2svn $
739 alexandre_ 196
* Revision 1.7  2005/12/19 13:16:14  alexandre_tb
197
* correction d'un bug
198
*
670 alexandre_ 199
* Revision 1.6  2005/11/18 16:04:15  florian
200
* corrections de bugs, optimisations, tests pour rendre inscription stable.
201
*
606 florian 202
* Revision 1.5  2005/11/17 18:48:02  florian
203
* corrections bugs + amélioration de l'application d'inscription
204
*
603 florian 205
* Revision 1.4  2005/10/25 14:02:21  alexandre_tb
206
* le formulaire affiche la france par défaut
207
*
575 alexandre_ 208
* Revision 1.3  2005/09/29 16:07:51  alexandre_tb
209
* En cours de production.
210
*
484 alexandre_ 211
* Revision 1.2  2005/09/27 13:59:24  alexandre_tb
212
* correction de bogue, généralisation du code etc.
213
*
471 alexandre_ 214
* Revision 1.1  2005/09/22 14:02:49  ddelon
215
* nettoyage annuaire et php5
216
*
448 ddelon 217
* Revision 1.4  2005/09/22 13:30:49  florian
218
* modifs pour compatibilité XHTML Strict + corrections de bugs (mais ya encore du boulot!!)
219
*
220
* Revision 1.4  2005/03/21 16:57:30  florian
221
* correction de bug, mise à jour interface
222
*
223
* Revision 1.3  2005/03/08 17:44:02  alex
224
* suppression en utilisant removeUser de Auth plutôt qu'en requete directe
225
*
226
* Revision 1.2  2005/03/02 12:44:41  alex
227
* Correction du bug message d'erreur alors qu'on tente de s'inscrire simplement
228
*
229
* Revision 1.1  2004/12/15 13:32:15  alex
230
* version initiale
231
*
232
* Revision 1.2  2004/09/01 16:36:37  alex
233
* changement du chemin pour les include
234
*
235
* Revision 1.1  2004/07/06 15:42:28  alex
236
* en cours
237
*
238
* Revision 1.5  2004/07/06 15:28:56  alex
239
* en cours
240
*
241
* Revision 1.4  2004/06/25 14:26:03  alex
242
* modification de la suppression
243
*
244
* Revision 1.3  2004/06/23 12:41:44  alex
245
* amélioration de la gestion de la perte de mot de passe
246
*
247
* Revision 1.2  2004/06/18 09:18:23  alex
248
* version initiale
249
*
250
*
251
* +-- Fin du code ----------------------------------------------------------------------------------------+
252
*/
253
?>