| Line 11... |
Line 11... |
| 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);
|
- |
|
| 17 |
// Parcourt du tableau de projets
|
- |
|
| 18 |
foreach ($tab_projets as $Projet) {
|
- |
|
| 19 |
// Vérification de la présence du projet dans les préférences de l'utilisateur
|
- |
|
| 20 |
$UtilisateurAProjet = new UtilisateurAProjet();
|
- |
|
| 21 |
$cmd = UtilisateurAProjet::GUAP_ID;
|
- |
|
| 22 |
$param = array($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur(), $Projet->getIdProjet());
|
- |
|
| 23 |
$coche = false;
|
- |
|
| 24 |
if ($present = $UtilisateurAProjet->consulter($cmd, $param)) {
|
- |
|
| 25 |
$coche = true;
|
- |
|
| 26 |
}
|
- |
|
| Line -... |
Line 16... |
| - |
|
16 |
|
| - |
|
17 |
if (false == $tab_projets) {
|
| - |
|
18 |
$aso_preferences['messages'][] = "Veuillez commencer par ajouter des catégories de projet et des projets !";
|
| - |
|
19 |
$aso_preferences['preferences'] = false;
|
| - |
|
20 |
} else {
|
| 27 |
|
21 |
$aso_preferences['nbre_projets'] = count($tab_projets);
|
| - |
|
22 |
// Parcourt du tableau de projets
|
| - |
|
23 |
foreach ($tab_projets as $Projet) {
|
| 28 |
// Récupération de la catégorie du projet
|
24 |
// Vérification de la présence du projet dans les préférences de l'utilisateur
|
| 29 |
$ProjetCategorie = new ProjetCategorie();
|
25 |
$UtilisateurAProjet = new UtilisateurAProjet();
|
| - |
|
26 |
$cmd = UtilisateurAProjet::GUAP_ID;
|
| - |
|
27 |
$param = array($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur(), $Projet->getIdProjet());
|
| - |
|
28 |
$coche = false;
|
| - |
|
29 |
if ($present = $UtilisateurAProjet->consulter($cmd, $param)) {
|
| - |
|
30 |
$coche = true;
|
| - |
|
31 |
}
|
| - |
|
32 |
|
| 30 |
$cmd = ProjetCategorie::GPC_ID;
|
33 |
// Récupération de la catégorie du projet
|
| 31 |
$param = $Projet->getCeCategorie();
|
34 |
$ProjetCategorie = new ProjetCategorie();
|
| 32 |
$Categorie = $ProjetCategorie->consulter($cmd, $param);
|
35 |
$Categorie = current($ProjetCategorie->consulter(ProjetCategorie::GPC_ID, $Projet->getCeCategorie()));
|
| 33 |
|
36 |
|
| 34 |
// Récupération de toutes les infos
|
37 |
// Récupération de toutes les infos
|
| 35 |
$aso_preferences['preferences'][$Categorie->getLibelle()][] = array(
|
38 |
$aso_preferences['preferences'][$Categorie->getLibelle()][] = array(
|
| 36 |
'id' => $Projet->getIdProjet(),
|
39 |
'id' => $Projet->getIdProjet(),
|
| 37 |
'valeur' => $Projet->getIdProjet(),
|
40 |
'valeur' => $Projet->getIdProjet(),
|
| 38 |
'nom' => $Projet->getNom(),
|
41 |
'nom' => $Projet->getNom(),
|
| 39 |
'coche' => $coche);
|
42 |
'coche' => $coche);
|
| 40 |
}
|
43 |
}
|
| - |
|
44 |
ksort($aso_preferences['preferences']);
|
| - |
|
45 |
}
|
| 41 |
ksort($aso_preferences['preferences']);
|
46 |
|
| 42 |
//echo '<pre>'.print_r($aso_preferences, true).'</pre>';
|
47 |
//echo '<pre>'.print_r($aso_preferences, true).'</pre>';
|
| 43 |
$this->getRegistre()->ajouterDonnee('preferences', $aso_preferences);
|
48 |
$this->getRegistre()->ajouterDonnee('preferences', $aso_preferences);
|
| Line 44... |
Line 49... |
| 44 |
}
|
49 |
}
|
| Line 48... |
Line 53... |
| 48 |
// Mise à jour des Préférences
|
53 |
// Mise à jour des Préférences
|
| 49 |
$UtilisateurAProjet = new UtilisateurAProjet();
|
54 |
$UtilisateurAProjet = new UtilisateurAProjet();
|
| 50 |
$UtilisateurAProjet->setIdUtilisateur($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur());
|
55 |
$UtilisateurAProjet->setIdUtilisateur($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur());
|
| 51 |
$UtilisateurAProjet->supprimer();
|
56 |
$UtilisateurAProjet->supprimer();
|
| 52 |
//echo '<pre>'.print_r($_POST, true).'</pre>';
|
57 |
//echo '<pre>'.print_r($_POST, true).'</pre>';
|
| - |
|
58 |
if (isset($_POST['pr'])) {
|
| 53 |
foreach ($_POST['pr'] as $pr_id) {
|
59 |
foreach ($_POST['pr'] as $pr_id) {
|
| 54 |
$UtilisateurAProjet = new UtilisateurAProjet();
|
60 |
$UtilisateurAProjet = new UtilisateurAProjet();
|
| 55 |
$UtilisateurAProjet->setIdUtilisateur($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur());
|
61 |
$UtilisateurAProjet->setIdUtilisateur($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur());
|
| 56 |
$UtilisateurAProjet->setIdProjet($pr_id);
|
62 |
$UtilisateurAProjet->setIdProjet($pr_id);
|
| 57 |
$UtilisateurAProjet->ajouter();
|
63 |
$UtilisateurAProjet->ajouter();
|
| - |
|
64 |
}
|
| 58 |
}
|
65 |
}
|
| 59 |
|
66 |
|
| 60 |
// Action suivante
|
67 |
// Action suivante
|
| 61 |
$this->setSuivant('__defaut__');
|
68 |
$this->setSuivant('__defaut__');
|
| 62 |
}
|
69 |
}
|
| 63 |
}
|
70 |
}
|
| 64 |
?>
|
71 |
?>
|
| 65 |
|
72 |
|