Subversion Repositories Applications.gtt

Rev

Rev 10 | Rev 27 | 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
/*
26
*fichier contenant le menu principal de l'application de gestion du temps de travail
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
39
include_once 'Auth/Auth.php';
40
include_once 'DB.php';
7 jpm 41
include_once 'HTML/QuickForm.php';
2 jpm 42
include_once 'gtt_config.inc.php';
43
include_once CHEMIN_LANGUES.'gtt_langue_fr.inc.php';
44
 
10 jpm 45
// Test des choix de menu a afficher
46
$action = 1;
47
if (!empty($_GET['action'])) {
48
	$action = $_GET['action'];
2 jpm 49
}
10 jpm 50
if (!preg_match('/^\d+$/', $action)) {
51
	// Connexion a la base de donnees
52
	$GLOBALS['db'] = DB::connect(GTT_BDD_DSN);
53
	if (DB::isError($GLOBALS['db'])) {
54
		$GLOBALS['db']->getMessage();
55
		echo "Echec connexion a la base de donnees";
56
	}
2 jpm 57
 
10 jpm 58
	$params = array('dsn' => GTT_BDD_DSN,
59
					'table' => GEST_UTILISATEUR,
60
					'usernamecol' => GEST_CHAMPS_EMAIL,
61
					'passwordcol' => GEST_CHAMPS_PASSWORD,
62
					'cryptype' => 'md5',
63
					'db_fields' => '*');
64
 
65
	// Création de l'objet auth
11 jpm 66
	$a = new Auth('DB', $params, null, false);
10 jpm 67
	$a->setSessionname('temps_travail');
68
	$a->setExpire(3600*24*30);
69
	$a->start();
11 jpm 70
	if (!$a->getAuth()) {
71
		$action = GTT_ACTION_DECONNEXION;
10 jpm 72
	}
11 jpm 73
 
74
	// Récuperation d'informations générales
75
	require_once GTT_CHEMIN_CLASSE.'GestionnaireErreur.class.php';
76
	require_once GTT_CHEMIN_METIER.'aGttSql.class.php';
77
	require_once GTT_CHEMIN_METIER.'Utilisateur.class.php';
78
	$GLOBALS['_GTT_']['Utilisateur'] = new Utilisateur(Utilisateur::GU_MAIL, array($a->getUserName()));
79
	$GLOBALS['_GTT_']['auth'] = $a;
80
 
81
	// Utilisation du mécanisme MVC avec Squelette PHP et objet
82
	require_once GTT_CHEMIN_CLASSE.'aControlleurAction.class.php';
83
	require_once GTT_CHEMIN_CLASSE.'Registre.class.php';
84
	$module = 'Preference';
85
	if (isset($_GET['module']) && !empty($_GET['module'])) {
86
		$module = $_GET['module'];
87
	}
88
	$nom_module = 'GttControlleur'.$module;
89
	$fichier_module = GTT_CHEMIN_MODULE.$nom_module.'.class.php';
90
	$nom_module_general = 'ControlleurFrontal';
91
	$fichier_module_general = GTT_CHEMIN_CLASSE.$nom_module_general.'.class.php';
92
	if (file_exists($fichier_module)) {
93
		require_once $fichier_module;
94
		$Controlleur = new $nom_module;
95
	} else if (file_exists($fichier_module_general)) {
96
		require_once $fichier_module_general;
97
		$Controlleur = new $nom_module_general;
98
	}
99
	echo $Controlleur->executer($action);
10 jpm 100
} else {
101
	include_once CHEMIN_CLASSES.'gtt_authentification.php';
102
	include_once CHEMIN_PRESENTATION.'gtt_fonctions_generique_affichage.php';
103
	// Connexion a la base de donnees
104
	$GLOBALS['db'] = DB::connect($GLOBALS['dsn_v3']);
105
	if (DB::isError($GLOBALS['db'])) {
106
		$GLOBALS['db']->getMessage();
107
		echo "Echec connexion a la base de donnees";
108
	}
109
 
110
	// Création de l'objet auth
111
	$params = array('dsn'=>$GLOBALS['dsn_v3'],
112
					'table'=>GEST_UTILISATEUR,
113
					'usernamecol'=>GEST_CHAMPS_EMAIL,
114
					'passwordcol'=>GEST_CHAMPS_PASSWORD,
115
					'cryptype'=>'md5',
116
					'db_fields'=>'*');
117
	$a = new Auth('DB', $params, 'afficherMenuConnexion', true);
118
	$a->setSessionname('temps_travail');
119
	$a->setExpire(3600*24*30);
120
	$a->start();
121
	echo $a->getStatus();
122
	if ($a->getAuth()) {
123
		// Récuperation de l'identifiant de la personne
124
		$mail = $a->getUserName();
125
		$utilisateur = Utilisateur::recupIDUtilisateurMail($mail);
126
		$GLOBALS['idCurrentUser'] = $utilisateur;
127
 
9 jpm 128
		// Utilisation de l'ancien mécanisme
129
		switch ($action) {
130
			// Cas affichage menu travail 1
131
			case GESTION_TRAVAIL :
132
				include_once CHEMIN_MENU.'gtt_menu_travail.php';
133
				include_once CHEMIN_CONTROLEUR.'gtt_controleur_travail.php';
134
	       		if (!isset($semaine)) {
135
					$semaine = date('W',mktime(0, 0, 0, date('m'), date('d') ,date('Y')));
136
				}
137
		 		if (!isset($annee)) {
138
					$annee = date('Y');
139
				}
140
	        	$text = traiterAdminTravail($_SERVER['PHP_SELF'], $semaine, $annee, $utilisateur);
141
				break;
142
 
143
			// Cas affichage du menu ajout autilisateurss 13
144
			case GESTION_ADMIN_UTILISATEUR :
145
				include_once CHEMIN_MENU.'gtt_menu_admin_utilisateur.php';
146
				include_once CHEMIN_CONTROLEUR.'gtt_controleur_admin_utilisateur.php';
147
				$text = traiterAdminUtilisateur('',0);
148
				break;
149
 
150
			// Cas editer des utilisateurs 14
151
			case GESTION_EDITER_UTILISATEUR :
152
				include_once CHEMIN_MENU.'gtt_menu_admin_utilisateur.php';
153
				include_once CHEMIN_CONTROLEUR.'gtt_controleur_admin_utilisateur.php';
154
				$text = traiterAdminUtilisateur(renvoyerDonneesUser(),1);
155
				break;
156
 
157
			// Cas afficher menu administration projet 15
158
			case GESTION_ADMIN_PROJET :
159
				include_once CHEMIN_CONTROLEUR.'gtt_controleur_admin_projet.php';
160
				$text = traiterAdminProjet();
161
				break;
162
 
163
			// Cas afficher menu administration categorie 16
164
			case GESTION_ADMIN_CATEGORIE :
165
				include_once CHEMIN_CONTROLEUR.'gtt_controleur_admin_categorie.php';
166
				$text = traiterAdminCategorie();
167
				break;
168
 
169
			// Cas afficher menu admin motif absence 17
170
			case GESTION_ADMIN_MOTIF_ABSENCE :
171
				include_once CHEMIN_CONTROLEUR.'gtt_controleur_admin_motif_absence.php';
172
				$text = traiterAdminMotif();
173
				break;
174
 
175
			// Cas afficher menu admin statut 18
176
			case GESTION_ADMIN_STATUT :
177
				include_once CHEMIN_CONTROLEUR.'gtt_controleur_admin_statut.php';
178
				$text = traiterAdminStatut();
179
				break;
180
 
181
			// Cas afficher admin editer frais 19
182
			case GESTION_ADMIN_FRAIS :
183
 
184
				$text = '';
185
				break;
186
 
187
			// Cas afficher admin editer taches 20
188
			case GESTION_ADMIN_TACHE :
189
				$text = '';
190
				break;
191
 
192
			// Cas editer preferences d'un utilisateur 21
193
			case GESTION_EDITER_PREFERENCES :
194
				include_once CHEMIN_MENU.'gtt_menu_editer_preferences.php';
195
				include_once CHEMIN_CONTROLEUR.'gtt_controleur_editer_preferences.php';
196
				$text = traiterEditerPreferences($GLOBALS['idCurrentUser']);
197
				break;
198
 
199
			// Cas deconnexion 22
200
			case GESTION_DECONNEXION :
201
				$a->logout();
202
				$text = afficherMenuConnexion();
203
				//$GLOBALS['db']->disconnect();
204
				break;
205
		}
206
		$text .= fermerBalisesFin();
207
		echo $text;
10 jpm 208
	} else {
209
		echo afficherMenuConnexion();
9 jpm 210
	}
2 jpm 211
}
5 jpm 212
?>