Subversion Repositories Applications.gtt

Rev

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

Rev Author Line No. Line
2 jpm 1
<?php
2
// +------------------------------------------------------------------------------------------------------+
3
// | PHP version 4.1                                                                                      |
4
// +------------------------------------------------------------------------------------------------------+
5
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
6
// +------------------------------------------------------------------------------------------------------+
7
// | This library is free software; you can redistribute it and/or                                        |
8
// | modify it under the terms of the GNU Lesser General Public                                           |
9
// | License as published by the Free Software Foundation; either                                         |
10
// | version 2.1 of the License, or (at your option) any later version.                                   |
11
// |                                                                                                      |
12
// | This library is distributed in the hope that it will be useful,                                      |
13
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
14
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
15
// | Lesser General Public License for more details.                                                      |
16
// |                                                                                                      |
17
// | You should have received a copy of the GNU Lesser General Public                                     |
18
// | License along with this library; if not, write to the Free Software                                  |
19
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
20
// +------------------------------------------------------------------------------------------------------+
21
// |@author ABDOOL RAHEEM shaheen   shaheenar50@hotmail.com                                                 |
22
// |@version 3                                                                                            |
23
 
24
// +------------------------------------------------------------------------------------------------------+
25
/*
28 jpm 26
*fichier contenant le menu principal de l'application de gestion du temps de travail
2 jpm 27
*@package gtt_general
28
//Auteur original :
29
*@author        Dorian Bannier <dbannier@aol.com>
30
//Autres auteurs :
31
*@author        Jean-Pascal MILCENT <jpm@tela-botanica.org>
32
*@copyright     Copyright (C) 2003 Tela-Botanica
33
*/
34
// +------------------------------------------------------------------------------------------------------+
35
// |                                            INCLUSION DE FICHIERS                                       |
36
// +------------------------------------------------------------------------------------------------------+
5 jpm 37
 
38
// Fichiers de la bibliotheque PEAR
27 jpm 39
include 'Auth/Auth.php';
40
include 'DB.php';
41
include 'gtt_config.inc.php';
42
include CHEMIN_LANGUES.'gtt_langue_fr.inc.php';
2 jpm 43
 
10 jpm 44
// Test des choix de menu a afficher
44 jpm 45
$action = 'gestion';
10 jpm 46
if (!empty($_GET['action'])) {
47
	$action = $_GET['action'];
2 jpm 48
}
10 jpm 49
if (!preg_match('/^\d+$/', $action)) {
44 jpm 50
	/**
51
	* La fonction __autoload() charge dynamiquement les classes trouvées dans le code.
52
	*
53
	* Cette fonction est appelée par php5 quand il trouve une instanciation de classe dans le code.
54
	*
55
	*@param string le nom de la classe appelée.
56
	*@return void le fichier contenant la classe doit être inclu par la fonction.
57
	*/
58
	function __autoload($classe)
59
	{
47 jpm 60
		$fichier_classe_pear = GTT_CHEMIN_PEAR.str_replace('_', '/', $classe).'.php';
61
		if (file_exists($fichier_classe_pear)) {
62
			require_once $fichier_classe_pear;
63
		} else {
64
			$nom_classe_gtt = $classe.'.class.php';
65
			foreach ($GLOBALS['_GTT_']['tab_chemin_autoload'] as $chemin) {
66
				$fichier = $chemin.$nom_classe_gtt;
67
				if (file_exists($fichier)) {
68
					require_once $fichier;
69
				}
44 jpm 70
			}
71
		}
72
	}
73
 
10 jpm 74
	// Connexion a la base de donnees
75
	$GLOBALS['db'] = DB::connect(GTT_BDD_DSN);
27 jpm 76
	if (PEAR::isError($GLOBALS['db'])) {
77
		trigger_error("Echec connexion a la base de donnees : ".$GLOBALS['db']->getMessage(), E_USER_ERROR);
10 jpm 78
	}
44 jpm 79
 
11 jpm 80
	// Récuperation d'informations générales
81
	require_once GTT_CHEMIN_CLASSE.'GestionnaireErreur.class.php';
82
	require_once GTT_CHEMIN_METIER.'aGttSql.class.php';
28 jpm 83
 
11 jpm 84
	// Utilisation du mécanisme MVC avec Squelette PHP et objet
85
	require_once GTT_CHEMIN_CLASSE.'aControlleurAction.class.php';
86
	require_once GTT_CHEMIN_CLASSE.'Registre.class.php';
87
	$nom_module_general = 'ControlleurFrontal';
88
	$fichier_module_general = GTT_CHEMIN_CLASSE.$nom_module_general.'.class.php';
44 jpm 89
	if (file_exists($fichier_module_general)) {
11 jpm 90
		require_once $fichier_module_general;
91
		$Controlleur = new $nom_module_general;
92
	}
93
	echo $Controlleur->executer($action);
10 jpm 94
} else {
44 jpm 95
	include 'HTML/QuickForm.php';
10 jpm 96
	include_once CHEMIN_CLASSES.'gtt_authentification.php';
97
	include_once CHEMIN_PRESENTATION.'gtt_fonctions_generique_affichage.php';
98
	// Connexion a la base de donnees
99
	$GLOBALS['db'] = DB::connect($GLOBALS['dsn_v3']);
100
	if (DB::isError($GLOBALS['db'])) {
101
		$GLOBALS['db']->getMessage();
102
		echo "Echec connexion a la base de donnees";
103
	}
28 jpm 104
 
105
	// Création de l'objet auth
10 jpm 106
	$params = array('dsn'=>$GLOBALS['dsn_v3'],
107
					'table'=>GEST_UTILISATEUR,
108
					'usernamecol'=>GEST_CHAMPS_EMAIL,
109
					'passwordcol'=>GEST_CHAMPS_PASSWORD,
110
					'cryptype'=>'md5',
111
					'db_fields'=>'*');
112
	$a = new Auth('DB', $params, 'afficherMenuConnexion', true);
113
	$a->setSessionname('temps_travail');
114
	$a->setExpire(3600*24*30);
115
	$a->start();
116
	echo $a->getStatus();
117
	if ($a->getAuth()) {
118
		// Récuperation de l'identifiant de la personne
119
		$mail = $a->getUserName();
120
		$utilisateur = Utilisateur::recupIDUtilisateurMail($mail);
121
		$GLOBALS['idCurrentUser'] = $utilisateur;
28 jpm 122
 
9 jpm 123
		// Utilisation de l'ancien mécanisme
124
		switch ($action) {
125
			// Cas affichage menu travail 1
126
			case GESTION_TRAVAIL :
127
				include_once CHEMIN_MENU.'gtt_menu_travail.php';
128
				include_once CHEMIN_CONTROLEUR.'gtt_controleur_travail.php';
129
	       		if (!isset($semaine)) {
130
					$semaine = date('W',mktime(0, 0, 0, date('m'), date('d') ,date('Y')));
131
				}
132
		 		if (!isset($annee)) {
133
					$annee = date('Y');
134
				}
135
	        	$text = traiterAdminTravail($_SERVER['PHP_SELF'], $semaine, $annee, $utilisateur);
136
				break;
28 jpm 137
 
9 jpm 138
			// Cas affichage du menu ajout autilisateurss 13
139
			case GESTION_ADMIN_UTILISATEUR :
140
				include_once CHEMIN_MENU.'gtt_menu_admin_utilisateur.php';
141
				include_once CHEMIN_CONTROLEUR.'gtt_controleur_admin_utilisateur.php';
142
				$text = traiterAdminUtilisateur('',0);
143
				break;
28 jpm 144
 
9 jpm 145
			// Cas editer des utilisateurs 14
146
			case GESTION_EDITER_UTILISATEUR :
147
				include_once CHEMIN_MENU.'gtt_menu_admin_utilisateur.php';
148
				include_once CHEMIN_CONTROLEUR.'gtt_controleur_admin_utilisateur.php';
149
				$text = traiterAdminUtilisateur(renvoyerDonneesUser(),1);
150
				break;
28 jpm 151
 
9 jpm 152
			// Cas afficher menu administration projet 15
153
			case GESTION_ADMIN_PROJET :
154
				include_once CHEMIN_CONTROLEUR.'gtt_controleur_admin_projet.php';
155
				$text = traiterAdminProjet();
156
				break;
28 jpm 157
 
9 jpm 158
			// Cas afficher menu administration categorie 16
159
			case GESTION_ADMIN_CATEGORIE :
160
				include_once CHEMIN_CONTROLEUR.'gtt_controleur_admin_categorie.php';
161
				$text = traiterAdminCategorie();
162
				break;
28 jpm 163
 
164
			// Cas afficher menu admin motif absence 17
9 jpm 165
			case GESTION_ADMIN_MOTIF_ABSENCE :
166
				include_once CHEMIN_CONTROLEUR.'gtt_controleur_admin_motif_absence.php';
167
				$text = traiterAdminMotif();
168
				break;
28 jpm 169
 
9 jpm 170
			// Cas afficher menu admin statut 18
171
			case GESTION_ADMIN_STATUT :
172
				include_once CHEMIN_CONTROLEUR.'gtt_controleur_admin_statut.php';
173
				$text = traiterAdminStatut();
174
				break;
28 jpm 175
 
176
			// Cas afficher admin editer frais 19
9 jpm 177
			case GESTION_ADMIN_FRAIS :
28 jpm 178
 
9 jpm 179
				$text = '';
180
				break;
28 jpm 181
 
9 jpm 182
			// Cas afficher admin editer taches 20
183
			case GESTION_ADMIN_TACHE :
184
				$text = '';
185
				break;
28 jpm 186
 
9 jpm 187
			// Cas editer preferences d'un utilisateur 21
188
			case GESTION_EDITER_PREFERENCES :
189
				include_once CHEMIN_MENU.'gtt_menu_editer_preferences.php';
190
				include_once CHEMIN_CONTROLEUR.'gtt_controleur_editer_preferences.php';
191
				$text = traiterEditerPreferences($GLOBALS['idCurrentUser']);
192
				break;
28 jpm 193
 
9 jpm 194
			// Cas deconnexion 22
195
			case GESTION_DECONNEXION :
196
				$a->logout();
197
				$text = afficherMenuConnexion();
198
				//$GLOBALS['db']->disconnect();
199
				break;
200
		}
201
		$text .= fermerBalisesFin();
202
		echo $text;
10 jpm 203
	} else {
204
		echo afficherMenuConnexion();
9 jpm 205
	}
2 jpm 206
}
5 jpm 207
?>