Subversion Repositories Applications.gtt

Rev

Rev 34 | Rev 73 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php

class GttCtrlActionIdentification extends aControlleurAction {

        public function __construct(Registre $Registre)
    {
        $Registre->ajouterEspace('Identification', 'identification');
    }

    public function executer()
    {
        $aso_identification = array();
                $params = array('dsn' => GTT_BDD_DSN,
                                                'table' => 'gestion_utilisateur',
                                                'usernamecol' => 'gu_email',
                                                'passwordcol' => 'gu_password',
                                                'cryptype' => 'md5',
                                                'db_fields' => '*');
                // Création de l'objet auth
                $GLOBALS['_GTT_']['identification'] = new Auth('DB', $params, null, false);
                $GLOBALS['_GTT_']['identification']->setSessionname(GTT_AUTH_SESSION_NOM);
                $GLOBALS['_GTT_']['identification']->setExpire(time()+(int)GTT_AUTH_SESSION_DUREE);
                $GLOBALS['_GTT_']['identification']->start();
                setcookie(session_name(),session_id(), time()+(int)GTT_AUTH_SESSION_DUREE, "/");
                if ($GLOBALS['_GTT_']['identification']->getAuth()) {
                        require_once GTT_CHEMIN_METIER.'Utilisateur.class.php';
                        $GLOBALS['_GTT_']['Utilisateur'] = new Utilisateur(Utilisateur::GU_MAIL, array($GLOBALS['_GTT_']['identification']->getUserName()));
                $aso_identification['nom'] = $GLOBALS['_GTT_']['Utilisateur']->getNom();
                $aso_identification['prenom'] = $GLOBALS['_GTT_']['Utilisateur']->getPrenom();
                        $this->getRegistre()->ajouterSquelette('identification', 'identite.tpl.html');
                //echo '<pre>'.print_r($aso_identification, true).'</pre>';
                        $this->getRegistre()->ajouterDonnee('identification', $aso_identification);
        } else {
                $this->setSuivant('Deconnexion', 1);
        }
    }

    public function executerDeconnexion()
    {
        $aso_connexion = array();
                $this->getRegistre()->setTitre('Bienvenue sur GTT!');
        $this->getRegistre()->ajouterSquelette('identification', 'connexion.tpl.html');
        // Création de l'url de réponse du formulaire
                $aso_connexion['url'] = 'index.php?action='.GTT_ACTION_CONNEXION;
        $GLOBALS['_GTT_']['identification']->logout();

        //echo '<pre>'.print_r($aso_connexion, true).'</pre>';
                $this->getRegistre()->ajouterDonnee('identification', $aso_connexion);
                $this->getRegistre()->set('action_finale', true);
    }
}
?>