require_once('protected/required.php');
- class PdoInstanceManager extends AbstractPdoManager implements InstanceManager {
+ class PdoInstanceManager extends AbstractPdoManager {
public function createInstance($instance) {
fqdn_interne,
fqdn_externe,
systeme,
- disques
+ disques,
+ canal
) VALUES (
:nom,
:exploitant,
:fqdn_interne,
:fqdn_externe,
:systeme,
- :disques
+ :disques,
+ :canal
)'
);
$query -> bindValue(':nom', $instance -> getNom());
$query -> bindValue(':fqdn_externe', $instance -> getFqdnExterne());
$query -> bindValue(':systeme', $instance -> getSysteme());
$query -> bindValue(':disques', $instance -> getDisques());
+ $query -> bindValue(':canal', $instance -> getCanal());
$query -> execute();
$query -> closeCursor();
fqdn_interne = :fqdn_interne,
fqdn_externe = :fqdn_externe,
systeme = :systeme,
- disques = :disques
+ disques = :disques,
+ canal = :canal
WHERE id = :id'
);
$query -> bindValue(':id', $instance -> getId());
$query -> bindValue(':fqdn_externe', $instance -> getFqdnExterne());
$query -> bindValue(':systeme', $instance -> getSysteme());
$query -> bindValue(':disques', $instance -> getDisques());
+ $query -> bindValue(':canal', $instance -> getCanal());
$query -> execute();
$query -> closeCursor();
}
public function updateInstanceInfos($array) {
$instance = $this -> getInstanceByReference($array['reference']);
- // L'INSTANCE EXISTE
+
+ // IF APPLIANCE EXISTS
if($instance -> getId() > 0) {
- // INSTANCE MAINTENUE ?
+
+ // IF APPLIANCE IS MAINTAINED
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
+
+ // IN CASE OF MANAGER
if($array['usager_type'] === "exploitant") {
- // RECUPERATION DE L'EXPLOITANT DU INSTANCE
+
+ // GETTING MANAGER OF APPLIANCE
$exploitantManager = new PdoExploitantManager();
$exploitant = $exploitantManager -> getExploitantByReference($instance -> getExploitant());
- // MISE À JOUR DE TOUS LES INSTANCES EN CHARGE DE L'EXPLOITANT
+
+ // UPDATING ALL APPLIANCES OF THIS MANAGER
$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
+
+ // IN CASE OF CLIENT
} else if($array['usager_type'] === "client") {
- // VERIFICATION DU NOM DE L'INSTANCE
+
+ // CHECKING APPLIANCE NAME
if ($array['produit'] === $instance -> getNom()) {
- // LA VERSION DIFFÈRE DE LA DB ?
+
+ // IF VERSION DIFFERS FROM DB
if($array['version'] != $instance -> getVersion()) {
- // MANAGERS
+
+ // GETTING PDO MANAGERS
$versionManager = new PdoVersionManager();
$produitManager = new PdoProduitManager();
$alerteManager = new PdoAlerteManager();
- // RECUPÉRATION DE L'ID DE LA VERSION
+
+ // GETTING VERSION ID
$version_id = $versionManager->getIdByValeurAndProduitId($array['version'], $produitManager->getProduitByNom($array['produit'])->getId());
- // CREATION D'UNE NOUVELLE ALERTE DE TYPE VERSION
+
+ // NEW WARNING CREATION, VERSION TYPE
$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
+
+ // GETTING CHANGELOG OF APPLIANCE
$historiqueManager = new PdoHistoriqueManager();
$historique = $historiqueManager -> getHistorique($instance -> getHistorique());
- // AJOUT DANS UN HISTORIQUE DEJÀ EXISTANT
+
+ // IF CHANGELOG EXISTS, ADDING NEW WARNING TO IT
if($historique -> getId() > 0) {
$alertes = $historique -> getAlertes();
if((array_search("", $alertes)) !== false) {
}
$historique -> setAlertes($alertes);
$historiqueManager -> updateHistorique($historique);
- // CREATION D'UN NOUVEL HISTORIQUE
+
+ // IF CHANGELOG DOES NOT EXIST, CREATING NEW ONE
} else {
$historique = new Historique(null, null, array($alerteManager -> getLastAlerte() -> getId()), array($alerte -> getVersion()));
$historiqueManager -> createHistorique($historique);
$this -> updateInstance($instance);
}
}
- // MISE À JOUR DES INFOS DE L'INSTANCE
+
+ // UPDATING APPLIANCE INFORMATION
$query = $this -> pdo -> prepare(
'UPDATE instances SET version = :version WHERE reference = :reference'
);
echo "Le type d'usager est inconnu, merci de corriger la configuration.";
}
}
- // INSTANCE INEXISTANTE
+
+ // IF APPLIANCE DOES NOT EXISTS
} else {
- // MANAGERS
+
+ // GETTING PDO MANAGERS
$versionManager = new PdoVersionManager();
$produitManager = new PdoProduitManager();
$alerteManager = new PdoAlerteManager();
- // RECUPÉRATION DE L'ID DE LA VERSION
+
+ // GETTING VERSION ID
$version_id = $versionManager->getIdByValeurAndProduitId($array['version'], $produitManager->getProduitByNom($array['produit'])->getId());
- // CREATION D'UNE NOUVELLE ALERTE DE TYPE CRÉATION
+
+ // NEW WARNING CREATION, CREATION TYPE
$alerteManager = new PdoAlerteManager();
$alerte = new Alerte(null, null, "creation",
"Nouvelle instance declaree : ".$array['produit']." ; version : ".$array['version'], $version_id);
$alerteManager -> createAlerte($alerte);
- // CREATION D'UN NOUVEL HISTORIQUE
+
+ // NEW CHANGELOG CREATION
$historiqueManager = new PdoHistoriqueManager();
$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
+
+ // NEW APPLIANCE CREATION
+ // TO-DO : MANAGE APPLIANCE CREATION WITH MANAGER TYPE
$instance = new Instance(
// ID
null,
- // PRODUIT
+ // PRODUCT
$array['produit'],
- // EXPLOITANT
+ // MANAGER
null,
// REFERENCE
$array['reference'],
- // VERSION ACTUELLE
+ // VERSION
$array['version'],
- // HISTORIQUE
+ // CHANGELOG
$historiqueManager -> getLastHistorique() -> getId(),
- // MAINTIEN
+ // IS MAINTAINED
true,
// FQDNs
$array['fqdn_interne'],
// OS
$array['systeme'],
// UUIDs
- $array['disques']
+ $array['disques'],
+ // CHANNEL
+ $array['canal']
);
$this->createInstance($instance);
}
$result['fqdn_interne'],
$result['fqdn_externe'],
$result['systeme'],
- $result['disques']
+ $result['disques'],
+ $result['canal']
);
$query->closeCursor();
$result['fqdn_interne'],
$result['fqdn_externe'],
$result['systeme'],
- $result['disques']
+ $result['disques'],
+ $result['canal']
);
$query->closeCursor();
$result['fqdn_interne'],
$result['fqdn_externe'],
$result['systeme'],
- $result['disques']
+ $result['disques'],
+ $result['canal']
);
}
}
- // 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";
+
+ // CHECKING REFERENCE FORMAT
+ $regex = '#^[A-Z]{2}/[A-Z0-9]+_[0-9]{5}_[0-9]{10}$#';
+ if (preg_match($regex, $array['reference'])) {
+
+ // CHECKING PRODUCT EXISTENCE
+ $produitManager = new PdoProduitManager();
+ $produits = $produitManager -> getNomsOfProduits();
+ if(in_array($array['produit'], $produits)) {
+
+ // CHECKING VERSION VALIDITY
+ $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 = "Cette version n'est pas disponible pour ce produit";
+ $retour = "Le produit n'est pas valide";
}
} else {
- $retour = "Le produit n'est pas valide";
+ $retour = 'Le format de la référence est incorrect.';
}
return $retour;
}