Rev 11 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?phprequire_once GTT_CHEMIN_METIER.'Projet.class.php';require_once GTT_CHEMIN_METIER.'ProjetCategorie.class.php';require_once GTT_CHEMIN_METIER.'UtilisateurAProjet.class.php';class GttActionPreferences extends aAction {public function __construct(){print_r($this->getResultat());$Resultats = $this->getResultat();$Resultats->ajouterEspace('Preferences', 'preferences');$Resultats->ajouterSquelette('preferences', 'preferences.tpl.html');}public function executer(Resultat $Resultat){$aso_preferences = array();$Resultat->setTitre('Modifier mes préférences');$Projet = new Projet();$tab_projets = $Projet->consulter(Projet::GP_TOUS);$aso_preferences['nbre_projets'] = count($tab_projets);// Parcourt du tableau de projetsforeach ($tab_projets as $Projet) {// Vérification de la présence du projet dans les préférences de l'utilisateur$UtilisateurAProjet = new UtilisateurAProjet();$cmd = UtilisateurAProjet::GUAP_ID;$param = array($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur(), $Projet->getIdProjet());$coche = false;if ($present = $UtilisateurAProjet->consulter($cmd, $param)) {$coche = true;}// Récupération de la catégorie du projet$ProjetCategorie = new ProjetCategorie();$cmd = ProjetCategorie::GPC_ID;$param = $Projet->getCeCategorie();$Categorie = $ProjetCategorie->consulter($cmd, $param);// Récupération de toutes les infos$aso_preferences['preferences'][$Categorie->getLibelle()][] = array('id' => $Projet->getIdProjet(),'valeur' => $Projet->getIdProjet(),'nom' => $Projet->getNomProjet(),'coche' => $coche);}ksort($aso_preferences['preferences']);//echo '<pre>'.print_r($aso_preferences, true).'</pre>';$Resultat->ajouterDonnee('preferences', $aso_preferences);}public function executerValider(Resultat $Resultat){// Mise à jour des Préférences$UtilisateurAProjet = new UtilisateurAProjet();$UtilisateurAProjet->setIdUtilisateur($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur());$UtilisateurAProjet->supprimer();//echo '<pre>'.print_r($_POST, true).'</pre>';foreach ($_POST['pr'] as $pr_id) {$UtilisateurAProjet = new UtilisateurAProjet();$UtilisateurAProjet->setIdUtilisateur($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur());$UtilisateurAProjet->setIdProjet($pr_id);$UtilisateurAProjet->ajouter();}// Action suivante$this->setSuivant('__defaut__');}}?>