Example #1
0
 public function Modifier()
 {
     // On modifie le grade.
     $retour = parent::Modifier();
     $retourJoueur = true;
     // On modifie la liste de joueurs appartenant au grade.
     $listeGradesJoueurs = $this->ListeGradesJoueurs();
     if ($listeGradesJoueurs !== NULL) {
         // Suppression de l'ancienne liste.
         $retourJoueur = $listeGradesJoueurs->Supprimer();
         // Ajout de la nouvelle si tout s'est bien passé.
         if ($retourJoueur !== false) {
             $listeGradesJoueurs->SetListeChampValeur(COL_GRADE, $this->Id());
             $retourJoueur = $listeGradesJoueurs->Ajouter();
         }
     }
     return $retour && $retourJoueur;
 }
Example #2
0
 public function Modifier()
 {
     $langueId = GSession::Langue(COL_ID);
     $mLibelle = NULL;
     // On ne modifie le libellé que pour notre langue.
     if ($this->Libelle() !== NULL && $langueId !== NULL) {
         $mLibelle = $this->AjouterJointure(COL_LIBELLE, COL_ID);
         if ($mLibelle->Langue()->Id() !== NULL) {
             $langueId = $mLibelle->Langue()->Id();
         }
         $mLibelle->LangueOriginelle()->Id($langueId);
         $mLibelle->AjouterColModification(COL_LIBELLE);
         $mLibelle->AjouterColModification(COL_LANGUEORIGINELLE);
         $mLibelle->AjouterColCondition(COL_LANGUE, $langueId);
         $mLibelle->ModifierSurJointure(true);
     }
     $retour = parent::Modifier();
     if ($retour !== false && $mLibelle !== NULL && $langueId !== NULL) {
         // On modifie le libellé pour toutes les autres langues qui ont comme langue d'origine notre langue.
         $mListeLibelles = new MListeLibelles();
         $mListeLibelles->AjouterColModification(COL_LIBELLE, $mLibelle->Libelle());
         $mListeLibelles->AjouterFiltreEgal(COL_ID, $mLibelle->Id());
         $mListeLibelles->AjouterFiltreEgal(COL_LANGUEORIGINELLE, $langueId);
         $mListeLibelles->AjouterFiltreDifferent(COL_LANGUE, $langueId);
         $retour = $mListeLibelles->Modifier();
     }
     return $retour;
 }
Example #3
0
 public function Modifier()
 {
     // Ouverture de la transaction si on ne l'ai pas déjà.
     $dejaEnTransaction = GBase::EstEnTransaction();
     if ($dejaEnTransaction === false) {
         GBase::DemarrerTransaction();
     }
     $retour = true;
     $ancienOrdre = NULL;
     $nouvelOrdre = $this->Ordre();
     if ($nouvelOrdre !== NULL) {
         // On récupère l'ordre de l'élément et les colonnes dont dépend l'ordre.
         if (is_string($this->colOrdre)) {
             $this->AjouterColSelection($this->colOrdre);
         } else {
             if (is_array($this->colOrdre)) {
                 foreach ($this->colOrdre as $col) {
                     $this->AjouterColSelection($col);
                 }
             }
         }
         $this->AjouterColSelection(COL_ORDRE);
         $retour = $this->Charger();
         $ancienOrdre = $this->Ordre();
         $this->Ordre($nouvelOrdre);
     }
     if ($ancienOrdre === NULL && $nouvelOrdre !== NULL) {
         GLog::LeverException(EXM_0214, $this->GetNom() . '::Modifier, impossible de récupérer l\'ordre de l\'élément d\'id [' . $this->Id() . '].');
         $retour = false;
     }
     $log = true;
     // On modifie l'élément.
     if ($retour !== false) {
         $retour = parent::Modifier();
         // Si l'ordre de l'élément à changé, on modifie les éléments qui en sont impactés.
         if ($retour !== false && $nouvelOrdre !== NULL && $nouvelOrdre !== $ancienOrdre) {
             // On récupère la liste relative au type d'élément afin de modifier l'ordre si besoin.
             $mListe = $this->GetNouvelleListe();
             if ($mListe === NULL) {
                 GLog::LeverException(EXM_0213, $this->GetNom() . '::Modifier, impossible de récupérer un objet liste.');
                 $retour = false;
             } else {
                 // Si l'ancien ordre est supérieur au nouveau.
                 if ($nouvelOrdre < $ancienOrdre) {
                     $mListe->AjouterColModificationExt(0, COL_ORDRE, COL_ORDRE, 1);
                     $mListe->AjouterFiltreEntre(COL_ORDRE, $nouvelOrdre, $ancienOrdre - 1);
                     $mListe->AjouterFiltreDifferent(COL_ID, $this->Id());
                     if (is_string($this->colOrdre)) {
                         $mListe->AjouterFiltreEgal($colOrdre, $this->GetChampSQL($this->colOrdre));
                     } else {
                         if (is_array($this->colOrdre)) {
                             foreach ($this->colOrdre as $col) {
                                 $mListe->AjouterFiltreEgal($col, $this->GetChampSQL($col));
                             }
                         }
                     }
                     $retour = $mListe->Modifier();
                 } else {
                     $mListe->AjouterColModificationExt(0, COL_ORDRE, COL_ORDRE, -1);
                     $mListe->AjouterFiltreEntre(COL_ORDRE, $ancienOrdre + 1, $nouvelOrdre);
                     $mListe->AjouterFiltreDifferent(COL_ID, $this->Id());
                     if (is_string($colOrdre)) {
                         $mListe->AjouterFiltreEgal($this->colOrdre, $this->GetChampSQL($this->colOrdre));
                     } else {
                         if (is_array($this->colOrdre)) {
                             foreach ($this->colOrdre as $col) {
                                 $mListe->AjouterFiltreEgal($col, $this->GetChampSQL($col));
                             }
                         }
                     }
                     $retour = $mListe->Modifier();
                 }
             }
         } else {
             $log = false;
         }
     }
     // Si on a créé nous même la transaction dans cette fonction, on commit ou rollback suivant le résultat.
     if ($dejaEnTransaction === false) {
         if ($retour === false) {
             GBase::AnnulerTransaction();
         } else {
             GBase::ValiderTransaction();
         }
     }
     if ($retour === false && $log === true) {
         GLog::LeverException(EXM_0215, $this->GetNom() . '::Modification, échec de la modification en base.');
     }
     return $retour;
 }