Subversion Repositories Applications.papyrus

Rev

Rev 299 | Go to most recent revision | Blame | Last modification | View Log | RSS feed

<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */ 
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1                                                                                      |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or                                        |
// | modify it under the terms of the GNU Lesser General Public                                           |
// | License as published by the Free Software Foundation; either                                         |
// | version 2.1 of the License, or (at your option) any later version.                                   |
// |                                                                                                      |
// | This library is distributed in the hope that it will be useful,                                      |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
// | Lesser General Public License for more details.                                                      |
// |                                                                                                      |
// | You should have received a copy of the GNU Lesser General Public                                     |
// | License along with this library; if not, write to the Free Software                                  |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: inscription.php,v 1.4 2005-03-21 16:57:30 florian Exp $
/**
* Inscription
*
* Un module d'inscription, en général ce code est spécifique à
* un site web
*
*@package inscription
//Auteur original :
*@author        Alexandre GRANIER <alexandre@tela-botanica.org>
//Autres auteurs :
*@copyright     Tela-Botanica 2000-2004
*@version       $Revision: 1.4 $ $Date: 2005-03-21 16:57:30 $
// +------------------------------------------------------------------------------------------------------+
*/

// +------------------------------------------------------------------------------------------------------+
// |                                            ENTETE du PROGRAMME                                       |
// +------------------------------------------------------------------------------------------------------+

include_once "client/inscription/configuration/ins_config.inc.php";
if (!isset($GLOBALS['lang'])) {
    $GLOBALS['lang'] = INS_LANGUE_DEFAUT ;
}
include_once INS_CHEMIN_FICHIER."langues/ins_langue_".$GLOBALS['lang'].".inc.php" ;
include_once INS_CHEMIN_FICHIER."bibliotheque/inscription.fonct.php" ;
include_once INS_CHEMIN_FICHIER."classes/inscription.class.php" ;

if (!isset($GLOBALS['logout'])) {$GLOBALS['logout']=0;}

// Ajout d'une feuille de style externe
GEN_stockerStyleExterne('inscription', INS_CHEMIN_FICHIER.'inscription.css') ;

// +------------------------------------------------------------------------------------------------------+
// |                                           LISTE de FONCTIONS                                         |
// +------------------------------------------------------------------------------------------------------+


function afficherContenuCorps() {

    $url = preg_replace ('/&amp;/', '&', $GLOBALS['ins_url']->getURL()) ;
    if (!isset ($GLOBALS['action'])) $GLOBALS['action'] = '';
    $res = '<h1>'.INS_TITRE_INSCRIPTION.'</h1>'."\n" ;
    $est_loggue = true ;

    if ($GLOBALS['logout'] == 1) {
        $GLOBALS['AUTH']->logout() ;
        $GLOBALS['username'] = '';
        $GLOBALS['password'] = '';
        return $res.AUTH_formulaire_login() ;
    }

    // L'utilisateur a-t-il cliqué sur Supprimer inscription
    if (isset ($GLOBALS['supprimer'])) {
        $id_utilisateur = $GLOBALS['AUTH']->getAuthData(INS_CHAMPS_ID) ;
        //desinscription_interwikini_users ($GLOBALS['AUTH']->getAuthData(INS_CHAMPS_LOGIN)) ;
        $resultat = $GLOBALS['AUTH']->removeUser($id_utilisateur) ;

        if (PEAR::isError($resultat)) {
                die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
        }
        // Suppression dans SPIP
        if (INS_UTILISE_SPIP) {
            desinscription_spip($id_utilisateur) ;
        }
        // Suppression dans Wikini
        if (INS_UTILISE_WIKINI) {
                $nom_wiki = $GLOBALS['AUTH']->getAuthData(INS_NOM_WIKI) ;
                desinscription_interwikini_users($nom_wiki) ;
        }
        $GLOBALS['AUTH']->logout() ;
        return $res.AUTH_formulaire_login() ;
    }

    if ($GLOBALS['action'] == 'sendpasswd') {
        return $res.envoie_passe() ;
    }

    // L'utilisateur a cliqué sur Inscription ou Inscription structure ou 
    if ($GLOBALS['action'] != '' || isset($GLOBALS['modifier'])) {
        $action = preg_replace ("/&amp;/", "&", $GLOBALS['ins_url']->getURL()) ;
        $formulaire = new HTML_formulaireInscription('formulaire_inscription', 'post', $action, '_self', '', 0) ;
        // Construction de la liste des pays
        $liste_pays = new ListeDePays($GLOBALS['ins_db']) ;
        $formulaire->construitFormulaire($action, $liste_pays->getListePays($GLOBALS['lang'])) ;
        if (isset($GLOBALS['form_structure'])) {
            $formulaire->formulaireStructure() ;
        }
        if (isset($GLOBALS['modifier'])) {
            $formulaire->addElement ('hidden', 'action', 'modifier_v') ;
            $formulaire->setDefaults(formulaire_defaults()) ;
        }
        if ($GLOBALS['action'] == 'inscription') {
            $formulaire->addElement ('hidden', 'action', 'inscription_v') ;
        }
        if ($GLOBALS['action'] == 'inscription_v') {
            if ($formulaire->validate()) {
                $formulaire->process('demande_inscription', false) ;
                return $res.message_inscription() ;
            }
        }
        if ($GLOBALS['action'] == 'modifier_v') {
            if ($formulaire->validate()) {
                $formulaire->process('mise_a_jour', false) ;
            }
            return $res.info($GLOBALS['AUTH']->getAuthData(INS_CHAMPS_ID)).bouton(str_replace ("&amp;", "&", $GLOBALS['ins_url']->getURL())) ;
        }
        return $res.$formulaire->toHTML() ;
    }
    
    // L'inscription dans la base si l'utilisateur clique sur le lien du mail
    if (isset($GLOBALS['id']) && $GLOBALS['id'] == session_id()) {
        if (isset ($_SESSION['donnees_inscription'])) {
            insertion($_SESSION['donnees_inscription']) ;
            
            $GLOBALS['AUTH']->username = $_SESSION['donnees_inscription']['email'] ;
            $GLOBALS['AUTH']->password = $_SESSION['donnees_inscription']['mot_de_passe'] ;
            // On loggue l'utilisateur
            $GLOBALS['AUTH']->login() ;
            unset ($_SESSION['donnees_inscription']) ;
            envoie_mail() ;
        } else {
            return $res.INS_MESSAGE_EXPIRATION ;
        }
    }

    if (!$GLOBALS['AUTH']->getAuth() && $GLOBALS['action'] != "inscription" && $GLOBALS['action'] != 'inscription_v')    {
        if (isset($_POST['username']) && $_POST['username'] != '') {
            $res .= message_erreur() ;
        } else {
            $res .= AUTH_formulaire_login() ;
        }
    }
    if ($GLOBALS['AUTH']->getAuth() && !isset($GLOBALS['modifier'])) {
            return $res.info().bouton(str_replace ("&amp;", "&", $GLOBALS['ins_url']->getURL())).deconnexion($GLOBALS['ins_url']->getURL()) ;
    }
    return $res ;
}
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
* Revision 1.3  2005/03/08 17:44:02  alex
* suppression en utilisant removeUser de Auth plutôt qu'en requete directe
*
* Revision 1.2  2005/03/02 12:44:41  alex
* Correction du bug message d'erreur alors qu'on tente de s'inscrire simplement
*
* Revision 1.1  2004/12/15 13:32:15  alex
* version initiale
*
* Revision 1.2  2004/09/01 16:36:37  alex
* changement du chemin pour les include
*
* Revision 1.1  2004/07/06 15:42:28  alex
* en cours
*
* Revision 1.5  2004/07/06 15:28:56  alex
* en cours
*
* Revision 1.4  2004/06/25 14:26:03  alex
* modification de la suppression
*
* Revision 1.3  2004/06/23 12:41:44  alex
* amélioration de la gestion de la perte de mot de passe
*
* Revision 1.2  2004/06/18 09:18:23  alex
* version initiale
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>