reference,
version,
historique,
- maintenu
+ maintenu,
+ fqdn_interne,
+ fqdn_externe,
+ systeme,
+ disques
) VALUES (
:nom,
:exploitant,
:reference,
:version,
:historique,
- :maintenu
+ :maintenu,
+ :fqdn_interne,
+ :fqdn_externe,
+ :systeme,
+ :disques
)'
);
$query -> bindValue(':nom', $instance -> getNom());
$query -> bindValue(':version', $instance -> getVersion());
$query -> bindValue(':historique', $instance -> getHistorique());
$query -> bindValue(':maintenu', $instance -> estMaintenu());
+ $query -> bindValue(':fqdn_interne', $instance -> getFqdnInterne());
+ $query -> bindValue(':fqdn_externe', $instance -> getFqdnExterne());
+ $query -> bindValue(':systeme', $instance -> getSysteme());
+ $query -> bindValue(':disques', $instance -> getDisques());
$query -> execute();
$query -> closeCursor();
reference = :reference,
version = :version,
historique = :historique,
- maintenu = :maintenu
+ maintenu = :maintenu,
+ fqdn_interne = :fqdn_interne,
+ fqdn_externe = :fqdn_externe,
+ systeme = :systeme,
+ disques = :disques
WHERE id = :id'
);
$query -> bindValue(':id', $instance -> getId());
$query -> bindValue(':version', $instance -> getVersion());
$query -> bindValue(':historique', $instance -> getHistorique());
$query -> bindValue(':maintenu', $instance -> estMaintenu());
+ $query -> bindValue(':fqdn_interne', $instance -> getFqdnInterne());
+ $query -> bindValue(':fqdn_externe', $instance -> getFqdnExterne());
+ $query -> bindValue(':systeme', $instance -> getSysteme());
+ $query -> bindValue(':disques', $instance -> getDisques());
$query -> execute();
$query -> closeCursor();
}
public function updateInstanceInfos($array) {
$instance = $this -> getInstanceByReference($array['reference']);
- // L'INSTANCE EXISTE : MISE À JOUR DES INFORMATIONS DE VERSION
+ // L'INSTANCE EXISTE
if($instance -> getId() > 0) {
- // CAS EXPLOITANT
- if($array['usager_type'] === "exploitant") {
- // RECUPERATION DE L'EXPLOITANT DU INSTANCE
- $exploitantManager = new PdoExploitantManager();
- $exploitant = $exploitantManager -> getExploitantByReference($instance -> getExploitant());
- // MISE À JOUR DE TOUS LES INSTANCES EN CHARGE DE L'EXPLOITANT
- $array['usager_type'] = "client";
- $instances_id = $exploitant -> getInstances();
- foreach ($instances_id as $instance_id) {
- $array['reference'] = $this -> getInstance($instance_id) -> getReference();
- $this -> updateInstanceInfos($array);
- }
- // 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()) {
- $versionManager = new PdoVersionManager();
- $produitManager = new PdoProduitManager();
- $alerteManager = new PdoAlerteManager();
- // 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 = $historiqueManager -> getHistorique($instance -> getHistorique());
- // AJOUT DANS UN HISTORIQUE DEJÀ EXISTANT
- if($historique -> getId() > 0) {
- $alertes = $historique -> getAlertes();
- if((array_search("", $alertes)) !== false) {
- $alertes = array($alerteManager -> getLastAlerte() -> getId());
+ // INSTANCE MAINTENUE ?
+ if(!$instance -> estMaintenu()) {
+ echo "Votre application n'est plus maintenue par nos services, merci de vous renseigner auprès de votre contact ADULLACT Projet pour plus d'informations.";
+ } else {
+ // CAS EXPLOITANT
+ if($array['usager_type'] === "exploitant") {
+ // RECUPERATION DE L'EXPLOITANT DU INSTANCE
+ $exploitantManager = new PdoExploitantManager();
+ $exploitant = $exploitantManager -> getExploitantByReference($instance -> getExploitant());
+ // MISE À JOUR DE TOUS LES INSTANCES EN CHARGE DE L'EXPLOITANT
+ $array['usager_type'] = "client";
+ $instances_id = $exploitant -> getInstances();
+ foreach ($instances_id as $instance_id) {
+ $array['reference'] = $this -> getInstance($instance_id) -> getReference();
+ $this -> updateInstanceInfos($array);
+ }
+ // CAS CLIENT
+ } else if($array['usager_type'] === "client") {
+ // VERIFICATION DU NOM DE L'INSTANCE
+ if ($array['produit'] === $instance -> getNom()) {
+ // LA VERSION DIFFÈRE DE LA DB ?
+ if($array['version'] != $instance -> getVersion()) {
+ // MANAGERS
+ $versionManager = new PdoVersionManager();
+ $produitManager = new PdoProduitManager();
+ $alerteManager = new PdoAlerteManager();
+ // RECUPÉRATION DE L'ID DE LA VERSION
+ $version_id = $versionManager->getIdByValeurAndProduitId($array['version'], $produitManager->getProduitByNom($array['produit'])->getId());
+ // CREATION D'UNE NOUVELLE ALERTE DE TYPE VERSION
+ $alerte = new Alerte(null, null, "version",
+ "Version declaree ".$array['version']." differente de l'actuelle : ".$instance -> getVersion(), $version_id);
+ $alerteManager -> createAlerte($alerte);
+ // RECUPERATION DE L'HISTORIQUE DE L'INSTANCE
+ $historiqueManager = new PdoHistoriqueManager();
+ $historique = $historiqueManager -> getHistorique($instance -> getHistorique());
+ // AJOUT DANS UN HISTORIQUE DEJÀ EXISTANT
+ if($historique -> getId() > 0) {
+ $alertes = $historique -> getAlertes();
+ if((array_search("", $alertes)) !== false) {
+ $alertes = array($alerteManager -> getLastAlerte() -> getId());
+ } else {
+ $alertes[] = $alerteManager -> getLastAlerte() -> getId();
+ }
+ $historique -> setAlertes($alertes);
+ $historiqueManager -> updateHistorique($historique);
+ // CREATION D'UN NOUVEL HISTORIQUE
} else {
- $alertes[] = $alerteManager -> getLastAlerte() -> getId();
+ $historique = new Historique(null, null, array($alerteManager -> getLastAlerte() -> getId()), array($alerte -> getVersion()));
+ $historiqueManager -> createHistorique($historique);
+ $instance -> setHistorique($historiqueManager -> getLastHistorique() -> getId());
+ $this -> updateInstance($instance);
}
- $historique -> setAlertes($alertes);
- $historiqueManager -> updateHistorique($historique);
- // CREATION D'UN NOUVEL HISTORIQUE
- } else {
- $historique = new Historique(null, null, array($alerteManager -> getLastAlerte() -> getId()));
- $historiqueManager -> createHistorique($historique);
- $instance -> setHistorique($historiqueManager -> getLastHistorique() -> getId());
- $this -> updateInstance($instance);
}
+ // MISE À JOUR DES INFOS DE L'INSTANCE
+ $query = $this -> pdo -> prepare(
+ 'UPDATE instances SET version = :version WHERE reference = :reference'
+ );
+ $query -> bindValue(':reference', $array['reference']);
+ $query -> bindValue(':version', $array['version']);
+ $query -> execute();
+ } else {
+ echo "Le nom de l'instance est incorrect";
}
- // MISE À JOUR DES INFOS DE L'INSTANCE
- $query = $this -> pdo -> prepare(
- 'UPDATE instances SET version = :version WHERE reference = :reference'
- );
- $query -> bindValue(':reference', $array['reference']);
- $query -> bindValue(':version', $array['version']);
- $query -> execute();
} else {
- echo "Erreur de nom de l'instance";
+ echo "Le type d'usager est inconnu, merci de corriger la configuration.";
}
}
// INSTANCE INEXISTANTE
} else {
- // CREATION D'UNE NOUVELLE ALERTE
+ // MANAGERS
+ $versionManager = new PdoVersionManager();
+ $produitManager = new PdoProduitManager();
+ $alerteManager = new PdoAlerteManager();
+ // RECUPÉRATION DE L'ID DE LA VERSION
+ $version_id = $versionManager->getIdByValeurAndProduitId($array['version'], $produitManager->getProduitByNom($array['produit'])->getId());
+ // CREATION D'UNE NOUVELLE ALERTE DE TYPE CRÉATION
$alerteManager = new PdoAlerteManager();
$alerte = new Alerte(null, null, "creation",
- "Nouvelle instance declaree : ".$array['produit']." ; version : ".$array['version']);
+ "Nouvelle instance declaree : ".$array['produit']." ; version : ".$array['version'], $version_id);
$alerteManager -> createAlerte($alerte);
// CREATION D'UN NOUVEL HISTORIQUE
$historiqueManager = new PdoHistoriqueManager();
- $historique = new Historique(null, null, array($alerteManager -> getLastAlerte() -> getId()));
+ $historique = new Historique(null, null, array($alerteManager -> getLastAlerte() -> getId()), array($alerte -> getVersion()));
$historiqueManager -> createHistorique($historique);
// CRÉATION D'UNE NOUVELLE INSTANCE
// To-do : gestion des comptes exploitants
- $instance = new Instance(null, $array['produit'], null, $array['reference'], $array['version'], $historiqueManager -> getLastHistorique() -> getId(), true);
+ $instance = new Instance(
+ // ID
+ null,
+ // PRODUIT
+ $array['produit'],
+ // EXPLOITANT
+ null,
+ // REFERENCE
+ $array['reference'],
+ // VERSION ACTUELLE
+ $array['version'],
+ // HISTORIQUE
+ $historiqueManager -> getLastHistorique() -> getId(),
+ // MAINTIEN
+ true,
+ // FQDNs
+ $array['fqdn_interne'],
+ $array['fqdn_externe'],
+ // OS
+ $array['systeme'],
+ // UUIDs
+ $array['disques']
+ );
$this->createInstance($instance);
}
$result['reference'],
$result['version'],
$result['historique'],
- $result['maintenu']
+ $result['maintenu'],
+ $result['fqdn_interne'],
+ $result['fqdn_externe'],
+ $result['systeme'],
+ $result['disques']
);
$query->closeCursor();
$result['reference'],
$result['version'],
$result['historique'],
- $result['maintenu']
+ $result['maintenu'],
+ $result['fqdn_interne'],
+ $result['fqdn_externe'],
+ $result['systeme'],
+ $result['disques']
);
$query->closeCursor();
$result['reference'],
$result['version'],
$result['historique'],
- $result['maintenu']
+ $result['maintenu'],
+ $result['fqdn_interne'],
+ $result['fqdn_externe'],
+ $result['systeme'],
+ $result['disques']
);
}
}
return $retour;
}
+
+ public function desactiverMaintienById($id) {
+ $query = $this -> pdo -> prepare(
+ 'UPDATE instances SET maintenu = :maintenu WHERE id = :id'
+ );
+ $query -> bindValue(':id', $id);
+ $query -> bindValue(':maintenu', false);
+ $query -> execute();
+ $query -> closeCursor();
+ }
}
?>