Subversion Repositories Applications.referentiel

Compare Revisions

Ignore whitespace Rev 224 → Rev 225

/trunk/scripts/modules/versionnage/Versionnage.php
19,7 → 19,7
class Versionnage extends ScriptCommande {
const SCRIPT_NOM = 'versionnage';
const MANUEL_VERSION = '4.2';
const MANUEL_VERSION = '4.3';
private $projet = null;
private $traitement = null;
450,30 → 450,16
$this->champs_courants = $this->champs_nom;
$diff = array();
foreach ($this->noms as $id => $nom) {
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]);
}
}
}
$this->supprimerNomAExclurePartiel($this->noms, $id);
$infos = array();
if (!isset($this->noms_precedents[$id])) {
if ($this->etreSupprime($id)) {
$infos = $this->traiterDiffSuppression($nom);
} else if ($this->etreAjoute($id)) {
$infos = $this->traiterDiffAjout($nom);
} else {
$nom_precedent = $this->noms_precedents[$id];
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);'));
$this->supprimerNomAExclurePartiel($this->noms_precedents, $id);
$nom_precedent = $this->nettoyerEspacesTableau($nom_precedent);
$infos = $this->traiterDiffModif($nom, $nom_precedent);
}
494,8 → 480,31
"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';
505,6 → 514,19
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';
593,9 → 615,11
// 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 (!isset($this->noms_precedents[$id])) {
if ($this->etreSupprime($id)) {
$infos = $this->traiterDiffSuppression($nom);
} elseif ($this->etreAjoute($id)) {
$infos = $this->traiterDiffAjout($nom);
} else {
$nom_precedent = $this->noms_precedents[$id];
604,8 → 628,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);
array_walk($nom_precedent, create_function('&$val', '$val = trim($val);'));
$nom_precedent = $this->nettoyerNomAExclurePartiel($nom_precedent);
$nom_precedent = $this->nettoyerEspacesTableau($nom_precedent);
$infos = $this->traiterDiffModif($nom, $nom_precedent);
}