Subversion Repositories Applications.gtt

Rev

Rev 80 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 80 Rev 103
1
<?php
1
<?php
2
 
2
 
3
class GttCtrlActionIdentification extends aControlleurAction {
3
class GttCtrlActionIdentification extends aControlleurAction {
4
 
4
 
5
	public function __construct(Registre $Registre)
5
	public function __construct(Registre $Registre)
6
    {
6
    {
7
    	$Registre->ajouterEspace('Identification', 'identification');
7
    	$Registre->ajouterEspace('Identification', 'identification');
8
    }
8
    }
9
 
9
 
10
    public function executer()
10
    public function executer()
11
    {
11
    {
12
    	$aso_identification = array();
12
    	$aso_identification = array();
13
		$params = array('dsn' => GTT_BDD_DSN,
13
		$params = array('dsn' => GTT_BDD_DSN,
14
						'table' => 'gestion_utilisateur',
14
						'table' => 'gestion_utilisateur',
15
						'usernamecol' => 'gu_email',
15
						'usernamecol' => 'gu_email',
16
						'passwordcol' => 'gu_password',
16
						'passwordcol' => 'gu_password',
17
						'cryptype' => 'md5',
17
						'cryptype' => 'md5',
18
						'db_fields' => '*');
18
						'db_fields' => '*');
19
		// Création de l'objet auth
19
		// Création de l'objet auth
20
		$GLOBALS['_GTT_']['identification'] = new Auth('DB', $params, null, false);
20
		$GLOBALS['_GTT_']['identification'] = new Auth('DB', $params, null, false);
21
		$GLOBALS['_GTT_']['identification']->setSessionname(GTT_AUTH_SESSION_NOM);
21
		$GLOBALS['_GTT_']['identification']->setSessionname(GTT_AUTH_SESSION_NOM);
22
		$GLOBALS['_GTT_']['identification']->setExpire(time()+(int)GTT_AUTH_SESSION_DUREE);
22
		$GLOBALS['_GTT_']['identification']->setExpire(time()+(int)GTT_AUTH_SESSION_DUREE);
23
		$GLOBALS['_GTT_']['identification']->start();
23
		$GLOBALS['_GTT_']['identification']->start();
24
		setcookie(session_name(),session_id(), time()+(int)GTT_AUTH_SESSION_DUREE, "/");
24
		setcookie(session_name(),session_id(), time()+(int)GTT_AUTH_SESSION_DUREE, "/");
25
		if ($GLOBALS['_GTT_']['identification']->getAuth()) {
25
		if ($GLOBALS['_GTT_']['identification']->getAuth()) {
26
			require_once GTT_CHEMIN_METIER.'Utilisateur.class.php';
26
			require_once GTT_CHEMIN_METIER.'Utilisateur.class.php';
27
			$GLOBALS['_GTT_']['Utilisateur'] = new Utilisateur(Utilisateur::GU_MAIL, array($GLOBALS['_GTT_']['identification']->getUserName()));
27
			$GLOBALS['_GTT_']['Utilisateur'] = new Utilisateur(Utilisateur::GU_MAIL, array($GLOBALS['_GTT_']['identification']->getUserName()));
28
    		$aso_identification['nom'] = $GLOBALS['_GTT_']['Utilisateur']->getNom();
28
    		$aso_identification['nom'] = $GLOBALS['_GTT_']['Utilisateur']->getNom();
29
    		$aso_identification['prenom'] = $GLOBALS['_GTT_']['Utilisateur']->getPrenom();
29
    		$aso_identification['prenom'] = $GLOBALS['_GTT_']['Utilisateur']->getPrenom();
30
	    	// Récupération des infos sur l'utilisateur
30
	    	// Récupération des infos sur l'utilisateur
31
	 		$aso_identification['cp'] = $GLOBALS['_GTT_']['Utilisateur']->getCongesPayes();
31
	 		$aso_identification['cp'] = $GLOBALS['_GTT_']['Utilisateur']->getCongesPayes();
32
	 		$cp = $aso_identification['cp'] / $GLOBALS['_GTT_']['Utilisateur']->getTempsDeTravailJour();
32
	 		$cp = $aso_identification['cp'] / $GLOBALS['_GTT_']['Utilisateur']->getTempsDeTravailJour();
33
	 		$aso_identification['cp_j'] = round($cp, 1);
33
	 		$aso_identification['cp_j'] = round($cp, 1);
34
	 		$aso_identification['rtt'] = $GLOBALS['_GTT_']['Utilisateur']->getQuotaHeuresSupp();
34
	 		$aso_identification['rtt'] = $GLOBALS['_GTT_']['Utilisateur']->getQuotaHeuresSupp();
35
	 		$rtt = $aso_identification['rtt'] / $GLOBALS['_GTT_']['Utilisateur']->getTempsDeTravailJour();
35
	 		$rtt = $aso_identification['rtt'] / $GLOBALS['_GTT_']['Utilisateur']->getTempsDeTravailJour();
36
	 		$aso_identification['rtt_j'] = round($rtt, 1);
36
	 		$aso_identification['rtt_j'] = round($rtt, 1);
37
 			$aso_identification['tps_w'] = $GLOBALS['_GTT_']['Utilisateur']->getTempsDeTravailJour();
37
 			$aso_identification['tps_w'] = $GLOBALS['_GTT_']['Utilisateur']->getTempsDeTravailJour();
38
 
38
 
39
			$this->getRegistre()->ajouterSquelette('identification', 'identite.tpl.html');
39
			$this->getRegistre()->ajouterSquelette('identification', 'identite.tpl.html');
40
    		//echo '<pre>'.print_r($aso_identification, true).'</pre>';
40
    		//echo '<pre>'.print_r($aso_identification, true).'</pre>';
41
			$this->getRegistre()->ajouterDonnee('identification', $aso_identification);
41
			$this->getRegistre()->ajouterDonnee('identification', $aso_identification);
42
    	} else {
42
    	} else {
43
    		$this->setSuivant('Deconnexion', 1);
43
    		$this->setSuivant('Deconnexion', 1);
44
    	}
44
    	}
45
    }
45
    }
46
 
46
 
47
    public function executerDeconnexion()
47
    public function executerDeconnexion()
48
    {
48
    {
49
    	$aso_connexion = array();
49
    	$aso_connexion = array();
50
		$this->getRegistre()->setTitre('Bienvenue sur GTT!');
50
		$this->getRegistre()->setTitre('Bienvenue sur GTT!');
51
    	$this->getRegistre()->ajouterSquelette('identification', 'connexion.tpl.html');
51
    	$this->getRegistre()->ajouterSquelette('identification', 'connexion.tpl.html');
52
    	// Création de l'url de réponse du formulaire
52
    	// Création de l'url de réponse du formulaire
53
		$aso_connexion['url'] = 'index.php?action='.GTT_ACTION_CONNEXION;
53
		$aso_connexion['url'] = 'index.php?action='.GTT_ACTION_CONNEXION;
54
    	$GLOBALS['_GTT_']['identification']->logout();
54
    	$GLOBALS['_GTT_']['identification']->logout();
55
 
55
 
56
    	//echo '<pre>'.print_r($aso_connexion, true).'</pre>';
56
    	//echo '<pre>'.print_r($aso_connexion, true).'</pre>';
57
		$this->getRegistre()->ajouterDonnee('identification', $aso_connexion);
57
		$this->getRegistre()->ajouterDonnee('identification', $aso_connexion);
58
		$this->getRegistre()->set('action_finale', true);
58
		$this->getRegistre()->set('action_finale', true);
59
    }
59
    }
60
}
60
}
61
?>
61
?>