Subversion Repositories Applications.papyrus

Rev

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