Subversion Repositories Applications.papyrus

Rev

Rev 915 | 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
// +------------------------------------------------------------------------------------------------------+
979 florian 22
// CVS : $Id: inscription.php,v 1.19 2006-10-05 13:53:54 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
979 florian 35
*@version       $Revision: 1.19 $ $Date: 2006-10-05 13:53:54 $
448 ddelon 36
// +------------------------------------------------------------------------------------------------------+
37
*/
38
 
39
// +------------------------------------------------------------------------------------------------------+
40
// |                                            ENTETE du PROGRAMME                                       |
41
// +------------------------------------------------------------------------------------------------------+
471 alexandre_ 42
include_once 'configuration/bottin.config.inc.php';
448 ddelon 43
include_once INS_CHEMIN_APPLI.'bibliotheque/inscription.fonct.php';
979 florian 44
include_once INS_CHEMIN_APPLI.'bibliotheque/bottin.fonct.php';
448 ddelon 45
 
739 alexandre_ 46
// Inclusion d'une classe personnalisé si elle existe
47
if (file_exists (INS_CHEMIN_APPLI.'bibliotheque/inscription.class.local.php')) {
48
	include_once INS_CHEMIN_APPLI.'bibliotheque/inscription.class.local.php' ;
49
} else {
50
	include_once INS_CHEMIN_APPLI.'bibliotheque/inscription.class.php';
51
}
52
 
448 ddelon 53
// +------------------------------------------------------------------------------------------------------+
54
// |                                           LISTE de FONCTIONS                                         |
55
// +------------------------------------------------------------------------------------------------------+
979 florian 56
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']) ) {
57
	//---------------le menu de l'appli-----------
58
	function afficherContenuNavigation () {
59
		$res =inscription_onglets();
60
		return $res ;
61
	}
62
}
448 ddelon 63
 
64
function afficherContenuCorps() {
65
    $res = '<h1>'.INS_TITRE_INSCRIPTION.'</h1>'."\n" ;
66
    if (!isset($_REQUEST['action'])) {
603 florian 67
    	$_REQUEST['action']='';
448 ddelon 68
    }
69
 
603 florian 70
//cas de la déconnexion----------------------------------------------------------------------------------
71
    if ($_REQUEST['action'] == 'deconnexion') {
448 ddelon 72
        $GLOBALS['AUTH']->logout() ;
73
        $_POST['username'] = '' ;
74
        $_POST['password'] = '' ;
603 florian 75
        return $res.AUTH_formulaire_login() ;
448 ddelon 76
    }
77
 
603 florian 78
//cas de la désinscription-------------------------------------------------------------------------------
79
    if ($_REQUEST['action'] == 'supprimer') {
670 alexandre_ 80
    	$id_utilisateur = $GLOBALS['AUTH']->getAuthData(INS_CHAMPS_ID) ;
758 alexandre_ 81
    	// Suppression dans SPIP
448 ddelon 82
        if (INS_UTILISE_SPIP) {
603 florian 83
            desinscription_spip($GLOBALS['AUTH']->getAuthData(INS_CHAMPS_ID)) ;
448 ddelon 84
        }
484 alexandre_ 85
		// Suppression dans Wikini
448 ddelon 86
        if (INS_UTILISE_WIKINI) {
758 alexandre_ 87
			$nom_wiki = $GLOBALS['AUTH']->getAuthData(INS_CHAMPS_NOM_WIKINI) ;
484 alexandre_ 88
			desinscription_interwikini_users($nom_wiki) ;
448 ddelon 89
        }
484 alexandre_ 90
        // Appel des actions desinscriptions des applications clientes
91
        $d = dir(GEN_CHEMIN_CLIENT);
92
		while (false !== ($repertoire = $d->read())) {
93
			if (file_exists(GEN_CHEMIN_CLIENT.$repertoire.GEN_SEP.$repertoire.'.desinscription.inc.php'))
94
			include_once GEN_CHEMIN_CLIENT.$repertoire.GEN_SEP.$repertoire.'.desinscription.inc.php' ;
95
		}
96
		$d->close();
854 alexandre_ 97
 
98
    	$resultat = $GLOBALS['AUTH']->removeUser($GLOBALS['AUTH']->getUsername()) ;
99
        if (PEAR::isError($resultat)) {
100
        	die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
101
        }
102
 
103
 
603 florian 104
		// Deconnection
448 ddelon 105
        $GLOBALS['AUTH']->logout() ;
106
        return $res.AUTH_formulaire_login() ;
107
    }
108
 
603 florian 109
//cas de l'envoi de mot de passe par mail----------------------------------------------------------------
448 ddelon 110
    if ($_REQUEST['action'] == 'sendpasswd') {
606 florian 111
        return envoie_passe()."\n".formulaire_envoi_passe() ;
448 ddelon 112
    }
113
 
603 florian 114
//cas de la saisie ou la modification de l'inscription individuelle ou structure
606 florian 115
    if (($_REQUEST['action'] == 'modifier')or($_REQUEST['action'] == 'modifier_v')or($_REQUEST['action'] == 'inscription')or($_REQUEST['action'] == 'inscription_v')) {
603 florian 116
        $formulaire = new HTML_formulaireInscription('formulaire_inscription', 'post', preg_replace('/&amp;/', '&', $GLOBALS['ins_url']->getURL()), '_self', '', 0) ;
117
        $formulaire->construitFormulaire(preg_replace('/&amp;/', '&', $GLOBALS['ins_url']->getURL()));
606 florian 118
        if (isset($_REQUEST['form_structure'])) {
119
        	if ($_REQUEST['form_structure']==1) {
120
        		$formulaire->formulaireStructure() ;
121
        	}
448 ddelon 122
        }
603 florian 123
 
896 alexandre_ 124
        // On ajoute la règle de vérification mail uniquement lors de l inscription
125
        if ($_REQUEST['action'] == 'inscription') {
906 alexandre_ 126
	        $formulaire->registerRule('doublonmail', 'callback', 'verif_doublonMail');
127
	        $formulaire->addRule('email', INS_MAIL_DOUBLE, 'doublonmail', true);
896 alexandre_ 128
        }
603 florian 129
        //pour la modification d'une inscription, on charge les valeurs par défauts
130
        if ($_REQUEST['action'] == 'modifier') {
448 ddelon 131
            $formulaire->addElement('hidden', 'action', 'modifier_v') ;
132
            $formulaire->setDefaults(formulaire_defaults()) ;
133
        }
134
 
135
        if ($_REQUEST['action'] == 'inscription') {
484 alexandre_ 136
            if ($GLOBALS['AUTH']->getAuth()) {
137
 
603 florian 138
            } else {
484 alexandre_ 139
            	$formulaire->addElement('hidden', 'action', 'inscription_v') ;
805 florian 140
            	$formulaire->setDefaults(array('pays' => 'fr', 'visible' => 1,'lettre'=>1));
484 alexandre_ 141
            }
448 ddelon 142
        }
143
 
144
        if ($_REQUEST['action'] == 'inscription_v') {
145
            if ($formulaire->validate()) {
743 alexandre_ 146
			    if (INS_MAIL_VALIDATION_INSCRIPTION) {
147
				    $formulaire->process('demande_inscription', false) ;
148
				    return $res.INS_MESSAGE_INSCRIPTION;
149
			    } else {
150
				    $formulaire->process('inscription_validee', false) ;
806 alexandre_ 151
				    $id_utilisateur = $GLOBALS['ins_db']->getOne('select '.INS_CHAMPS_ID.' from '.INS_ANNUAIRE.' where '.
152
				    												INS_CHAMPS_MAIL.'="'.$GLOBALS['AUTH']->getAuthData(INS_CHAMSP_MAIL).'"') ;
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()) {
169
                $formulaire->process('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)) ;
743 alexandre_ 191
	    $id_utilisateur = 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'] != '') {
606 florian 220
            $res .= '<p class="erreur">'.INS_ERREUR_LOGIN.'</p><br />'."\n".formulaire_envoi_passe();
448 ddelon 221
        } else {
222
            $res .= AUTH_formulaire_login() ;
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 $
979 florian 237
* Revision 1.18  2006/07/20 09:48:07  alexandre_tb
238
* réglages
239
*
915 alexandre_ 240
* Revision 1.17  2006/07/06 10:33:30  alexandre_tb
241
* correction bug du à dernière mise à jour
242
*
906 alexandre_ 243
* Revision 1.16  2006/07/04 09:38:31  alexandre_tb
244
* Ajout de la règle doublon email uniquement lors de création d'une entrée
245
*
896 alexandre_ 246
* Revision 1.15  2006/06/01 10:00:35  alexandre_tb
247
* correction bug désinscription des appli cliente
248
*
854 alexandre_ 249
* Revision 1.14  2006/04/10 09:48:16  alexandre_tb
250
* Correction de bug pour les inscriptions aux autres applications
251
*
806 alexandre_ 252
* Revision 1.13  2006/04/04 12:23:05  florian
253
* modifs affichage fiches, généricité de la carto, modification totale de l'appli annuaire
254
*
805 florian 255
* Revision 1.12  2006/03/15 11:05:45  alexandre_tb
256
* ajout de l'action caché inscription_v lors du réaffichage du formulaire après erreur de saisie.
257
*
780 alexandre_ 258
* Revision 1.11  2006/03/02 14:10:35  alexandre_tb
259
* correction du bug desinscription wikini
260
*
758 alexandre_ 261
* Revision 1.10  2006/03/02 13:03:45  alexandre_tb
262
* bug de désinscription interwikini_users
263
*
756 alexandre_ 264
* Revision 1.9  2006/02/28 14:08:27  alexandre_tb
265
* appel des inscriptions des autres appli, sous le format:
266
* client/appli/appli.inscription.php
267
*
743 alexandre_ 268
* Revision 1.8  2006/02/14 10:21:08  alexandre_tb
269
* ajout d'un appel à un fichier de classe personnalisé
270
*
739 alexandre_ 271
* Revision 1.7  2005/12/19 13:16:14  alexandre_tb
272
* correction d'un bug
273
*
670 alexandre_ 274
* Revision 1.6  2005/11/18 16:04:15  florian
275
* corrections de bugs, optimisations, tests pour rendre inscription stable.
276
*
606 florian 277
* Revision 1.5  2005/11/17 18:48:02  florian
278
* corrections bugs + amélioration de l'application d'inscription
279
*
603 florian 280
* Revision 1.4  2005/10/25 14:02:21  alexandre_tb
281
* le formulaire affiche la france par défaut
282
*
575 alexandre_ 283
* Revision 1.3  2005/09/29 16:07:51  alexandre_tb
284
* En cours de production.
285
*
484 alexandre_ 286
* Revision 1.2  2005/09/27 13:59:24  alexandre_tb
287
* correction de bogue, généralisation du code etc.
288
*
471 alexandre_ 289
* Revision 1.1  2005/09/22 14:02:49  ddelon
290
* nettoyage annuaire et php5
291
*
448 ddelon 292
* Revision 1.4  2005/09/22 13:30:49  florian
293
* modifs pour compatibilité XHTML Strict + corrections de bugs (mais ya encore du boulot!!)
294
*
295
* Revision 1.4  2005/03/21 16:57:30  florian
296
* correction de bug, mise à jour interface
297
*
298
* Revision 1.3  2005/03/08 17:44:02  alex
299
* suppression en utilisant removeUser de Auth plutôt qu'en requete directe
300
*
301
* Revision 1.2  2005/03/02 12:44:41  alex
302
* Correction du bug message d'erreur alors qu'on tente de s'inscrire simplement
303
*
304
* Revision 1.1  2004/12/15 13:32:15  alex
305
* version initiale
306
*
307
* Revision 1.2  2004/09/01 16:36:37  alex
308
* changement du chemin pour les include
309
*
310
* Revision 1.1  2004/07/06 15:42:28  alex
311
* en cours
312
*
313
* Revision 1.5  2004/07/06 15:28:56  alex
314
* en cours
315
*
316
* Revision 1.4  2004/06/25 14:26:03  alex
317
* modification de la suppression
318
*
319
* Revision 1.3  2004/06/23 12:41:44  alex
320
* amélioration de la gestion de la perte de mot de passe
321
*
322
* Revision 1.2  2004/06/18 09:18:23  alex
323
* version initiale
324
*
325
*
326
* +-- Fin du code ----------------------------------------------------------------------------------------+
327
*/
328
?>