public function updateInstanceInfos($array) {
$instance = $this -> getInstanceByReference($array['reference']);
- // LE INSTANCE EXISTE : MISE À JOUR DES INFORMATIONS DE VERSION
+ // L'INSTANCE EXISTE : MISE À JOUR DES INFORMATIONS DE VERSION
if($instance -> getId() > 0) {
// CAS EXPLOITANT
if($array['usager_type'] === "exploitant") {
$array['reference'] = $this -> getInstance($instance_id) -> getReference();
$this -> updateInstanceInfos($array);
}
- // CAS CLIENT
+ // CAS CLIENT
} else if($array['usager_type'] === "client") {
// VERIFICATION DU NOM DE L'INSTANCE
if ($array['produit'] === $instance -> getNom()) {
// SI LA VERSION DIFFÈRE DE LA DB, CREATION D'UNE ALERTE
if($array['version'] != $instance -> getVersion()) {
- // CREATION D'UNE NOUVELLE ALERTE
+ $versionManager = new PdoVersionManager();
+ $produitManager = new PdoProduitManager();
$alerteManager = new PdoAlerteManager();
- // To-do : séparer patches des majs
- $alerte = new Alerte(null, null, "version",
- "Version declaree ".$array['version']." differente de l'actuelle : ".$instance -> getVersion());
+ // ANALYSE DU TYPE DE VERSION : PATCH OU MAJ
+ $type = $versionManager->getNatureOfVersionForValeurAndProduitId($array['version'], $produitManager->getProduitByNom($instance->getNom())->getId());
+ // CREATION D'UNE NOUVELLE ALERTE
+ $alerte = new Alerte(null, null, $type,
+ "Version declaree ".$array['version']." differente de l'actuelle : ".$instance -> getVersion(), $array['version']);
$alerteManager -> createAlerte($alerte);
// RECUPERATION DE L'HISTORIQUE DU INSTANCE
$historiqueManager = new PdoHistoriqueManager();
}
$historique -> setAlertes($alertes);
$historiqueManager -> updateHistorique($historique);
- // CREATION D'UN NOUVEL HISTORIQUE
+ // CREATION D'UN NOUVEL HISTORIQUE
} else {
$historique = new Historique(null, null, array($alerteManager -> getLastAlerte() -> getId()));
$historiqueManager -> createHistorique($historique);
echo "Erreur de nom de l'instance";
}
}
- // INSTANCE INEXISTANT
+ // INSTANCE INEXISTANTE
} else {
// CREATION D'UNE NOUVELLE ALERTE
$alerteManager = new PdoAlerteManager();
}
+ // FONCTIONS SUPPLÉMENTAIRES - HORS INTERFACE
+
+ public function testInformationsAvantUpload($array) {
+ // TEST D'EXISTENCE DU PRODUIT
+ $produitManager = new PdoProduitManager();
+ $produits = $produitManager -> getNomsOfProduits();
+ if(in_array($array['produit'], $produits)) {
+ // TEST DE VALIDITÉ DE LA VERSION
+ $versionManager = new PdoVersionManager();
+ $versions = $versionManager->findValeursOfVersionsByProduitId($produitManager->getProduitByNom($array['produit'])->getId());
+ if(in_array($array['version'], $versions)) {
+ $retour = "ok";
+ } else {
+ $retour = "Cette version n'est pas disponible pour ce produit";
+ }
+ } else {
+ $retour = "Le produit n'est pas valide";
+ }
+ return $retour;
+ }
}
?>