Subversion Repositories Applications.gtt

Rev

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

<?php
// +------------------------------------------------------------------------------------------------------+
// | 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                            |
// +------------------------------------------------------------------------------------------------------+
// |@author ABDOOL RAHEEM shaheen   shaheenar50@hotmail.com                                                 |
// |@version 3                                                                                            |

// +------------------------------------------------------------------------------------------------------+
/*
*fichier contenant le menu principal de l'application de gestion du temps de travail
*@package gtt_general
//Auteur original :
*@author        Dorian Bannier <dbannier@aol.com>
//Autres auteurs :
*@author        Jean-Pascal MILCENT <jpm@tela-botanica.org>
*@copyright     Copyright (C) 2003 Tela-Botanica
*/
// +------------------------------------------------------------------------------------------------------+
// |                                            INCLUSION DE FICHIERS                                       |
// +------------------------------------------------------------------------------------------------------+

// Fichiers de la bibliotheque PEAR
include 'Auth/Auth.php';
include 'DB.php';
include 'HTML/QuickForm.php';
include 'gtt_config.inc.php';
include CHEMIN_LANGUES.'gtt_langue_fr.inc.php';

// Test des choix de menu a afficher
$action = 1;
if (!empty($_GET['action'])) {
        $action = $_GET['action'];
}
if (!preg_match('/^\d+$/', $action)) {
        // Connexion a la base de donnees
        $GLOBALS['db'] = DB::connect(GTT_BDD_DSN);
        if (PEAR::isError($GLOBALS['db'])) {
                trigger_error("Echec connexion a la base de donnees : ".$GLOBALS['db']->getMessage(), E_USER_ERROR);
        }
        $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
        $a = new Auth('DB', $params, null, false);
        $a->setSessionname(GTT_AUTH_SESSION_NOM);
        $a->setExpire(time()+(int)GTT_AUTH_SESSION_DUREE);
        $a->start();
        setcookie(session_name(),session_id(), time()+(int)GTT_AUTH_SESSION_DUREE, "/");
        if (!$a->getAuth()) {
                $action = GTT_ACTION_DECONNEXION;
        }
        
        // Récuperation d'informations générales
        require_once GTT_CHEMIN_CLASSE.'GestionnaireErreur.class.php';
        require_once GTT_CHEMIN_METIER.'aGttSql.class.php';
        require_once GTT_CHEMIN_METIER.'Utilisateur.class.php';
        $GLOBALS['_GTT_']['Utilisateur'] = new Utilisateur(Utilisateur::GU_MAIL, array($a->getUserName()));
        $GLOBALS['_GTT_']['auth'] = $a;

        // Utilisation du mécanisme MVC avec Squelette PHP et objet
        require_once GTT_CHEMIN_CLASSE.'aControlleurAction.class.php';
        require_once GTT_CHEMIN_CLASSE.'Registre.class.php';
        $module = 'Gestion';
        if (isset($_GET['module']) && !empty($_GET['module'])) {
                $module = $_GET['module'];
        }
        $nom_module = 'GttControlleur'.$module;
        $fichier_module = GTT_CHEMIN_MODULE.$nom_module.'.class.php';
        $nom_module_general = 'ControlleurFrontal';
        $fichier_module_general = GTT_CHEMIN_CLASSE.$nom_module_general.'.class.php';
        if (file_exists($fichier_module)) {
                require_once $fichier_module;
                $Controlleur = new $nom_module;
        } else if (file_exists($fichier_module_general)) {
                require_once $fichier_module_general;
                $Controlleur = new $nom_module_general;
        }
        echo $Controlleur->executer($action);
} else {
        include_once CHEMIN_CLASSES.'gtt_authentification.php';
        include_once CHEMIN_PRESENTATION.'gtt_fonctions_generique_affichage.php';
        // Connexion a la base de donnees
        $GLOBALS['db'] = DB::connect($GLOBALS['dsn_v3']);
        if (DB::isError($GLOBALS['db'])) {
                $GLOBALS['db']->getMessage();
                echo "Echec connexion a la base de donnees";
        }

        // Création de l'objet auth
        $params = array('dsn'=>$GLOBALS['dsn_v3'],
                                        'table'=>GEST_UTILISATEUR,
                                        'usernamecol'=>GEST_CHAMPS_EMAIL,
                                        'passwordcol'=>GEST_CHAMPS_PASSWORD,
                                        'cryptype'=>'md5',
                                        'db_fields'=>'*');
        $a = new Auth('DB', $params, 'afficherMenuConnexion', true);
        $a->setSessionname('temps_travail');
        $a->setExpire(3600*24*30);
        $a->start();
        echo $a->getStatus();
        if ($a->getAuth()) {
                // Récuperation de l'identifiant de la personne
                $mail = $a->getUserName();
                $utilisateur = Utilisateur::recupIDUtilisateurMail($mail);
                $GLOBALS['idCurrentUser'] = $utilisateur;

                // Utilisation de l'ancien mécanisme
                switch ($action) {
                        // Cas affichage menu travail 1
                        case GESTION_TRAVAIL :
                                include_once CHEMIN_MENU.'gtt_menu_travail.php';
                                include_once CHEMIN_CONTROLEUR.'gtt_controleur_travail.php';
                        if (!isset($semaine)) {
                                        $semaine = date('W',mktime(0, 0, 0, date('m'), date('d') ,date('Y')));
                                }
                                if (!isset($annee)) {
                                        $annee = date('Y');
                                }
                        $text = traiterAdminTravail($_SERVER['PHP_SELF'], $semaine, $annee, $utilisateur);
                                break;

                        // Cas affichage du menu ajout autilisateurss 13
                        case GESTION_ADMIN_UTILISATEUR :
                                include_once CHEMIN_MENU.'gtt_menu_admin_utilisateur.php';
                                include_once CHEMIN_CONTROLEUR.'gtt_controleur_admin_utilisateur.php';
                                $text = traiterAdminUtilisateur('',0);
                                break;

                        // Cas editer des utilisateurs 14
                        case GESTION_EDITER_UTILISATEUR :
                                include_once CHEMIN_MENU.'gtt_menu_admin_utilisateur.php';
                                include_once CHEMIN_CONTROLEUR.'gtt_controleur_admin_utilisateur.php';
                                $text = traiterAdminUtilisateur(renvoyerDonneesUser(),1);
                                break;

                        // Cas afficher menu administration projet 15
                        case GESTION_ADMIN_PROJET :
                                include_once CHEMIN_CONTROLEUR.'gtt_controleur_admin_projet.php';
                                $text = traiterAdminProjet();
                                break;

                        // Cas afficher menu administration categorie 16
                        case GESTION_ADMIN_CATEGORIE :
                                include_once CHEMIN_CONTROLEUR.'gtt_controleur_admin_categorie.php';
                                $text = traiterAdminCategorie();
                                break;

                        // Cas afficher menu admin motif absence 17
                        case GESTION_ADMIN_MOTIF_ABSENCE :
                                include_once CHEMIN_CONTROLEUR.'gtt_controleur_admin_motif_absence.php';
                                $text = traiterAdminMotif();
                                break;

                        // Cas afficher menu admin statut 18
                        case GESTION_ADMIN_STATUT :
                                include_once CHEMIN_CONTROLEUR.'gtt_controleur_admin_statut.php';
                                $text = traiterAdminStatut();
                                break;

                        // Cas afficher admin editer frais 19
                        case GESTION_ADMIN_FRAIS :

                                $text = '';
                                break;

                        // Cas afficher admin editer taches 20
                        case GESTION_ADMIN_TACHE :
                                $text = '';
                                break;

                        // Cas editer preferences d'un utilisateur 21
                        case GESTION_EDITER_PREFERENCES :
                                include_once CHEMIN_MENU.'gtt_menu_editer_preferences.php';
                                include_once CHEMIN_CONTROLEUR.'gtt_controleur_editer_preferences.php';
                                $text = traiterEditerPreferences($GLOBALS['idCurrentUser']);
                                break;

                        // Cas deconnexion 22
                        case GESTION_DECONNEXION :
                                $a->logout();
                                $text = afficherMenuConnexion();
                                //$GLOBALS['db']->disconnect();
                                break;
                }
                $text .= fermerBalisesFin();
                echo $text;
        } else {
                echo afficherMenuConnexion();
        }
}
?>