Subversion Repositories Applications.gtt

Rev

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

Rev 46 Rev 82
1
<?php
1
<?php
2
class GttCtrlActionPreferences extends aControlleurAction {
2
class GttCtrlActionPreferences extends aControlleurAction {
3
 
3
 
4
    public function __construct(Registre $Registre)
4
    public function __construct(Registre $Registre)
5
    {
5
    {
6
    	$Registre->ajouterEspace('Preferences', 'preferences');
6
    	$Registre->ajouterEspace('Preferences', 'preferences');
7
    	$Registre->ajouterSquelette('preferences', 'preferences.tpl.html');
7
    	$Registre->ajouterSquelette('preferences', 'preferences.tpl.html');
8
    }
8
    }
9
 
9
 
10
    public function executer()
10
    public function executer()
11
    {
11
    {
12
    	$aso_preferences = array();
12
    	$aso_preferences = array();
13
    	$this->getRegistre()->setTitre('Modifier mes préférences');
13
    	$this->getRegistre()->setTitre('Modifier mes préférences');
14
    	$Projet = new Projet();
14
    	$Projet = new Projet();
15
    	$tab_projets = $Projet->consulter(Projet::GP_TOUS);
15
    	$tab_projets = $Projet->consulter(Projet::GP_TOUS);
16
    	$aso_preferences['nbre_projets'] = count($tab_projets);
16
    	$aso_preferences['nbre_projets'] = count($tab_projets);
17
		// Parcourt du tableau de projets
17
		// Parcourt du tableau de projets
18
    	foreach ($tab_projets as $Projet) {
18
    	foreach ($tab_projets as $Projet) {
19
			// Vérification de la présence du projet dans les préférences de l'utilisateur
19
			// Vérification de la présence du projet dans les préférences de l'utilisateur
20
			$UtilisateurAProjet = new UtilisateurAProjet();
20
			$UtilisateurAProjet = new UtilisateurAProjet();
21
			$cmd = UtilisateurAProjet::GUAP_ID;
21
			$cmd = UtilisateurAProjet::GUAP_ID;
22
			$param = array($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur(), $Projet->getIdProjet());
22
			$param = array($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur(), $Projet->getIdProjet());
23
			$coche = false;
23
			$coche = false;
24
			if ($present = $UtilisateurAProjet->consulter($cmd, $param)) {
24
			if ($present = $UtilisateurAProjet->consulter($cmd, $param)) {
25
				$coche = true;
25
				$coche = true;
26
			}
26
			}
27
 
27
 
28
			// Récupération de la catégorie du projet
28
			// Récupération de la catégorie du projet
29
			$ProjetCategorie = new ProjetCategorie();
29
			$ProjetCategorie = new ProjetCategorie();
30
			$cmd = ProjetCategorie::GPC_ID;
30
			$cmd = ProjetCategorie::GPC_ID;
31
			$param = $Projet->getCeCategorie();
31
			$param = $Projet->getCeCategorie();
32
			$Categorie = $ProjetCategorie->consulter($cmd, $param);
32
			$Categorie = $ProjetCategorie->consulter($cmd, $param);
33
 
33
 
34
			// Récupération de toutes les infos
34
			// Récupération de toutes les infos
35
			$aso_preferences['preferences'][$Categorie->getLibelle()][] = array(
35
			$aso_preferences['preferences'][$Categorie->getLibelle()][] = array(
36
				'id' => $Projet->getIdProjet(),
36
				'id' => $Projet->getIdProjet(),
37
				'valeur' => $Projet->getIdProjet(),
37
				'valeur' => $Projet->getIdProjet(),
38
				'nom' => $Projet->getNomProjet(),
38
				'nom' => $Projet->getNom(),
39
				'coche' => $coche);
39
				'coche' => $coche);
40
    	}
40
    	}
41
    	ksort($aso_preferences['preferences']);
41
    	ksort($aso_preferences['preferences']);
42
    	//echo '<pre>'.print_r($aso_preferences, true).'</pre>';
42
    	//echo '<pre>'.print_r($aso_preferences, true).'</pre>';
43
		$this->getRegistre()->ajouterDonnee('preferences', $aso_preferences);
43
		$this->getRegistre()->ajouterDonnee('preferences', $aso_preferences);
44
    }
44
    }
45
 
45
 
46
    public function executerValider()
46
    public function executerValider()
47
    {
47
    {
48
    	// Mise à jour des Préférences
48
    	// Mise à jour des Préférences
49
    	$UtilisateurAProjet = new UtilisateurAProjet();
49
    	$UtilisateurAProjet = new UtilisateurAProjet();
50
    	$UtilisateurAProjet->setIdUtilisateur($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur());
50
    	$UtilisateurAProjet->setIdUtilisateur($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur());
51
    	$UtilisateurAProjet->supprimer();
51
    	$UtilisateurAProjet->supprimer();
52
    	//echo '<pre>'.print_r($_POST, true).'</pre>';
52
    	//echo '<pre>'.print_r($_POST, true).'</pre>';
53
    	foreach ($_POST['pr'] as $pr_id) {
53
    	foreach ($_POST['pr'] as $pr_id) {
54
    		$UtilisateurAProjet = new UtilisateurAProjet();
54
    		$UtilisateurAProjet = new UtilisateurAProjet();
55
			$UtilisateurAProjet->setIdUtilisateur($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur());
55
			$UtilisateurAProjet->setIdUtilisateur($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur());
56
			$UtilisateurAProjet->setIdProjet($pr_id);
56
			$UtilisateurAProjet->setIdProjet($pr_id);
57
			$UtilisateurAProjet->ajouter();
57
			$UtilisateurAProjet->ajouter();
58
    	}
58
    	}
59
 
59
 
60
    	// Action suivante
60
    	// Action suivante
61
    	$this->setSuivant('__defaut__');
61
    	$this->setSuivant('__defaut__');
62
    }
62
    }
63
}
63
}
64
?>
64
?>