Subversion Repositories Applications.gtt

Rev

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