Subversion Repositories Applications.referentiel

Compare Revisions

Ignore whitespace Rev 225 → Rev 224

/trunk/scripts/modules/versionnage/Versionnage.php
19,7 → 19,7
class Versionnage extends ScriptCommande {
const SCRIPT_NOM = 'versionnage';
const MANUEL_VERSION = '4.3';
const MANUEL_VERSION = '4.2';
private $projet = null;
private $traitement = null;
450,16 → 450,30
$this->champs_courants = $this->champs_nom;
$diff = array();
foreach ($this->noms as $id => $nom) {
$this->supprimerNomAExclurePartiel($this->noms, $id);
if ($this->noms[$id]['exclure_taxref'] == '1') {
unset($this->noms[$id]);
} else {
foreach ($this->noms[$id] as $champ => $valeur) {
if (! in_array($champ, $this->champs_nom_partiel)) {
unset($this->noms[$id][$champ]);
}
}
}
$infos = array();
if ($this->etreSupprime($id)) {
$infos = $this->traiterDiffSuppression($nom);
} else if ($this->etreAjoute($id)) {
if (!isset($this->noms_precedents[$id])) {
$infos = $this->traiterDiffAjout($nom);
} else {
$nom_precedent = $this->noms_precedents[$id];
$this->supprimerNomAExclurePartiel($this->noms_precedents, $id);
$nom_precedent = $this->nettoyerEspacesTableau($nom_precedent);
if ($this->noms_precedents[$id]['exclure_taxref'] == '1') {
unset($this->noms_precedents[$id]);
} else {
foreach ($this->noms_precedents[$id] as $champ => $valeur) {
if (! in_array($champ, $this->champs_nom_partiel)) {
unset($this->noms_precedents[$id][$champ]);
}
}
}
array_walk($nom_precedent, create_function('&$val', '$val = trim($val);'));
$infos = $this->traiterDiffModif($nom, $nom_precedent);
}
480,31 → 494,8
"précédentes pour l'édition $edition. Cela concerne les noms : ".implode(', ', array_keys($this->noms_supprimes));
Debug::printr($e);
$this->ajouterMessage($e);
}
}
private function supprimerNomAExclurePartiel(&$tableau, $id) {
if ($tableau[$id]['exclure_taxref'] == '1') {
unset($tableau[$id]);
}
}
private function nettoyerNomAExclurePartiel($nom) {
foreach ($nom as $champ => $valeur) {
if (! in_array($champ, $this->champs_nom_partiel)) {
unset($nom[$champ]);
}
}
return $nom;
}
private function etreSupprime($id) {
$supprime = false;
if (array_key_exists($id, $this->noms_supprimes)) {
$supprime = true;
}
return $supprime;
}
private function traiterDiffSuppression(&$nom) {
$infos = $nom;
$infos['modification_type'] = 'S';
514,19 → 505,6
return $infos;
}
private function etreAjoute($id) {
$ajoute = false;
if (! array_key_exists($id, $this->noms_precedents)) {
$ajoute = true;
}
return $ajoute;
}
private function nettoyerEspacesTableau($tableau) {
array_walk($tableau, create_function('&$val', '$val = trim($val);'));
return $tableau;
}
private function traiterDiffAjout(&$nom) {
$infos = $nom;
$infos['modification_type'] = 'A';
615,11 → 593,9
// Ajout de champs spécifique à Taxref généré depuis les données BDNT
$nom['taxref_rang'] = $this->attribuerRangTaxref($nom['rang']);
$nom['taxref_statut'] = $this->attribuerStatutTaxref($nom);
$nom = $this->nettoyerNomAExclurePartiel($nom);
$infos = array();
if ($this->etreSupprime($id)) {
$infos = $this->traiterDiffSuppression($nom);
} elseif ($this->etreAjoute($id)) {
if (!isset($this->noms_precedents[$id])) {
$infos = $this->traiterDiffAjout($nom);
} else {
$nom_precedent = $this->noms_precedents[$id];
628,8 → 604,8
// Ajout de champs spécifique à Taxref généré depuis les données BDNT
$nom_precedent['taxref_rang'] = $this->attribuerRangTaxref($nom_precedent['rang']);
$nom_precedent['taxref_statut'] = $this->attribuerStatutTaxref($nom_precedent);
$nom_precedent = $this->nettoyerNomAExclurePartiel($nom_precedent);
$nom_precedent = $this->nettoyerEspacesTableau($nom_precedent);
array_walk($nom_precedent, create_function('&$val', '$val = trim($val);'));
$infos = $this->traiterDiffModif($nom, $nom_precedent);
}