* In production mode, flash messages redirect after a time interval.
* In development mode, you need to click the flash message to continue.
*/
- Configure::write('debug', 0);
+ Configure::write('debug', 2);
/**
* Configure the Error handler used to handle errors for your application. By default
$totalAlertes = array();
foreach($instances as $instance) {
$historique = $historiquesController->Historique->findById($instance['Instance']['historique']);
- if (!$historique) {
- throw new NotFoundException(__('Historique introuvable'));
- }
- // RÉCUPÉRATION DES ALERTES DE L'HISTORIQUE
- if($historique['Historique']['alertes']) {
- $alertes_id = explode('|', $historique['Historique']['alertes']);
- $alertes = array();
- foreach ($alertes_id as $alerte_id) {
- $alertes[] = $alertesController->Alerte->findById($alerte_id);
+ if ($historique) {
+ // RÉCUPÉRATION DES ALERTES DE L'HISTORIQUE
+ if($historique['Historique']['alertes']) {
+ $alertes_id = explode('|', $historique['Historique']['alertes']);
+ $alertes = array();
+ foreach ($alertes_id as $alerte_id) {
+ $alertes[] = $alertesController->Alerte->findById($alerte_id);
+ }
+ // AJOUT DANS LA LISTE DES ALERTES
+ $totalAlertes[$historique['Historique']['id']] = $alertes;
}
- // AJOUT DANS LA LISTE DES ALERTES
- $totalAlertes[$historique['Historique']['id']] = $alertes;
+ // AJOUT DANS LA LISTE DES HISTORIQUES
+ $historiques[$instance['Instance']['id']] = $historique;
}
- // AJOUT DANS LA LISTE DES HISTORIQUES
- $historiques[$instance['Instance']['id']] = $historique;
-
}
// ENVOI DES DONNÉES À LA VUE
}
public function add() {
- if ($this->request->is('instance')) {
+ if ($this->request->is('POST')) {
$this->Instance->create();
if ($this->Instance->save($this->request->data)) {
$this->Session->setFlash(__("L'instance a été enregistrée."));
if ($this->request->is('get')) {
throw new MethodNotAllowedException();
}
-
+ $instance = $this->Instance->findById($id);
+ if (!$instance) {
+ throw new NotFoundException(__('Instance introuvable'));
+ }
if ($this->Instance->delete($id)) {
$this->Session->setFlash(
- __("L'instance d'id: %s a été supprimée.", h($id))
+ __("L'instance %s a été supprimée.", h($instance['Instance']['reference']))
);
return $this->redirect(array('action' => 'index'));
}
public $components = array('RequestHandler');
public function index() {
- //$this->set('produits', $this->Produit->find('all'));
+ // RÉCUPÉRATION DES PRODUITS
$produits = $this->Produit->find('all');
+
+ // To-do : Récupérer versions de chaque produit
+
+ // ENVOI DES DONNÉES À LA VUE
$this->set(array(
'produits' => $produits,
'_serialize' => array('produits')
}
public function add() {
- if ($this->request->is('produit')) {
+ if ($this->request->is('POST')) {
$this->Produit->create();
if ($this->Produit->save($this->request->data)) {
- $this->Session->setFlash(__('Le produit a été enregistré.'));
+ $this->Session->setFlash(__("Le produit a été enregistré."));
return $this->redirect(array('action' => 'index'));
}
- $this->Session->setFlash(__('Enregistrement du produit impossible.'));
+ $this->Session->setFlash(__("Enregistrement du produit impossible."));
}
}
if ($this->request->is(array('produit', 'put'))) {
$this->Produit->id = $id;
if ($this->Produit->save($this->request->data)) {
- $this->Session->setFlash(__('Le produit a été mis à jour.'));
+ $this->Session->setFlash(__("La produit a été mis à jour."));
return $this->redirect(array('action' => 'index'));
}
- $this->Session->setFlash(__('Mise à jour du produit impossible.'));
+ $this->Session->setFlash(__("Mise à jour du produit impossible."));
}
if (!$this->request->data) {
if ($this->Produit->delete($id)) {
$this->Session->setFlash(
- __("Le produit d'id: %s a été supprimé.", h($id))
+ __("La produit d'id: %s a été supprimé.", h($id))
);
return $this->redirect(array('action' => 'index'));
}
}
-
- // API REST
-
- /*public function rest_get_all() {
- $produits = $this->Produit->find('all');
- $this->set(array(
- 'produits' => $produits,
- '_serialize' => array('produits')
- ));
- }
-
- public function rest_get($reference) {
- $produit = $this->Produit->findByReference($reference);
- $this->set(array(
- 'produit' => $produit,
- '_serialize' => array('produit')
- ));
- }
-
- public function rest_create() {
- if ($this->Produit->save($this->request->data)) {
- $message = array(
- 'text' => __('Saved'),
- 'type' => 'success'
- );
- } else {
- $message = array(
- 'text' => __('Error'),
- 'type' => 'error'
- );
- }
- $this->set(array(
- 'message' => $message,
- '_serialize' => array('message')
- ));
- }
-
- public function rest_update($reference) {
- $this->Produit->reference = $reference;
- if ($this->Produit->save($this->request->data)) {
- $message = array(
- 'text' => __('Saved'),
- 'type' => 'success'
- );
- } else {
- $message = array(
- 'text' => __('Error'),
- 'type' => 'error'
- );
- }
- $this->set(array(
- 'message' => $message,
- '_serialize' => array('message')
- ));
- }
-
- public function rest_delete($reference) {
- if ($this->Produit->delete($reference)) {
- $message = array(
- 'text' => __('Deleted'),
- 'type' => 'success'
- );
- } else {
- $message = array(
- 'text' => __('Error'),
- 'type' => 'error'
- );
- }
- $this->set(array(
- 'message' => $message,
- '_serialize' => array('message')
- ));
- }*/
}
?>
--- /dev/null
+<?php
+ class VersionsController extends AppController {
+ public $helpers = array('Html', 'Form');
+ public $components = array('RequestHandler');
+
+ public function index() {
+ // RÉCUPÉRATION DES VERSIONS
+ $versions = $this->Version->find('all');
+
+ // ENVOI DES DONNÉES À LA VUE
+ $this->set(array(
+ 'versions' => $versions,
+ '_serialize' => array('versions')
+ ));
+ }
+
+ public function view($id = null) {
+ if (!$id) {
+ throw new NotFoundException(__('Mauvaise version'));
+ }
+
+ $version = $this->Version->findById($id);
+ if (!$version) {
+ throw new NotFoundException(__('Mauvaise version'));
+ }
+ $this->set('version', $version);
+ }
+
+ public function add() {
+ if ($this->request->is('version')) {
+ $this->Version->create();
+ if ($this->Version->save($this->request->data)) {
+ $this->Session->setFlash(__("La version a été enregistrée."));
+ return $this->redirect(array('action' => 'index'));
+ }
+ $this->Session->setFlash(__("Enregistrement de la version impossible."));
+ }
+ }
+
+ public function edit($id = null) {
+ if (!$id) {
+ throw new NotFoundException(__('Version introuvable'));
+ }
+
+ $version = $this->Version->findById($id);
+ if (!$version) {
+ throw new NotFoundException(__('Version introuvable'));
+ }
+
+ if ($this->request->is(array('version', 'put'))) {
+ $this->Version->id = $id;
+ if ($this->Version->save($this->request->data)) {
+ $this->Session->setFlash(__("La version a été mise à jour."));
+ return $this->redirect(array('action' => 'index'));
+ }
+ $this->Session->setFlash(__("Mise à jour de la version impossible."));
+ }
+
+ if (!$this->request->data) {
+ $this->request->data = $version;
+ }
+ }
+
+ public function delete($id) {
+ if ($this->request->is('get')) {
+ throw new MethodNotAllowedException();
+ }
+
+ if ($this->Version->delete($id)) {
+ $this->Session->setFlash(
+ __("La version d'id: %s a été supprimée.", h($id))
+ );
+ return $this->redirect(array('action' => 'index'));
+ }
+ }
+ }
+?>
/*'nom' => array(
'rule' => 'notEmpty'
),*/
- 'version' => array(
+ 'valeur' => array(
'rule' => 'notEmpty'
)
);
+
+ public function value($field, $value = null) {
+ if(func_num_args() === 1){
+ $result = $this->field($field);
+ if($result){
+ return $result;
+ }
+ } else {
+ if($this->saveField($field, $value)) {
+ return true;
+ }
+ }
+ return false;
+ }
}
?>
--- /dev/null
+<?php
+ class Version extends AppModel {
+ public $validate = array(
+ /*'fqdn' => array(
+ 'rule' => 'notEmpty'
+ ),*/
+ /*'nom' => array(
+ 'rule' => 'notEmpty'
+ ),*/
+ 'valeur' => array(
+ 'rule' => 'notEmpty'
+ )
+ );
+
+ public function value($field, $value = null) {
+ if(func_num_args() === 1){
+ $result = $this->field($field);
+ if($result){
+ return $result;
+ }
+ } else {
+ if($this->saveField($field, $value)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+?>
-<h1>Liste d'alertes</h1>
<table>
<tr>
<th>Date de d'émission</th>
+ <th>Type</th>
+ <th>Message</th>
+ <th>Actions</th>
</tr>
<?php foreach ($alertes as $alerte): ?>
<tr>
+ <td><?php echo $alerte['Alerte']['creation']; ?></td>
+ <td><?php echo $alerte['Alerte']['nature']; ?></td>
+ <td><?php echo $alerte['Alerte']['message']; ?></td>
<td>
<?php echo $this->Html->link(
- $alerte['Alerte']['creation'],
+ 'Editer',
array('controller' => 'alertes', 'action' => 'edit', $alerte['Alerte']['id'])
- );
- ?>
- </td>
- <td>
- <?php
- echo $this->Form->postLink(
+ ).' - '.
+ $this->Form->postLink(
'Supprimer',
array('action' => 'delete', $alerte['Alerte']['id']),
array('confirm' => 'Etes-vous certain ?')
echo $this->Form->input('nom');
echo $this->Form->input('version');
echo $this->Form->input('reference');
+echo $this->Form->input('exploitant');
echo $this->Form->input('fqdn_interne');
echo $this->Form->input('fqdn_externe');
-echo $this->Form->input('clients');
-// TO-DO : Ajout de client
-echo $this->Form->input('exploitant');
echo $this->Form->input('systeme');
echo $this->Form->input('uid');
+echo $this->Form->input('historique');
+echo $this->Form->input('maintenu');
echo $this->Form->end("Enregistrer l'instance");
?>
\ No newline at end of file
echo $this->Form->input('nom');
echo $this->Form->input('reference');
echo $this->Form->input('exploitant');
-echo $this->Form->input('version');
+echo $this->Form->input('version', array('options' => array('4.1.02' => '4.1.02', '3.5.00' => '3.5.00')));
echo $this->Form->input('fqdn_interne');
-echo $this->Form->input('maintenu');
+echo $this->Form->input('maintenu', array('type' => 'radio', 'options' => array('0' => 'Faux', '1' => 'Vrai')));
//echo $this->Form->input('fqdn_externe');
//echo $this->Form->input('systeme');
//echo $this->Form->input('uid');
-<h1>Liste d'instances</h1>
+<h1>
+ <?php echo $this->Html->link(
+ 'Nouvelle instance',
+ array('controller' => 'instances', 'action' => 'add')
+); ?>
+</h1>
<table>
<tr>
- <th>Nom</th>
- <th>Historique</th>
- <th>Version</th>
<th>Référence</th>
+ <th>Produit</th>
+ <th>Version</th>
+ <th>Alertes</th>
<th>Actions</th>
</tr>
<?php foreach ($instances as $instance): ?>
<tr>
+ <td><?php echo $instance['Instance']['reference']; ?></td>
+ <td><?php echo $instance['Instance']['nom']; ?></td>
+ <td><?php echo $instance['Instance']['version']; ?></td>
<td>
- <?php echo $this->Html->link(
- $instance['Instance']['nom'],
- array('controller' => 'instances', 'action' => 'edit', $instance['Instance']['id'])
- );
+ <?php if(array_key_exists($instance['Instance']['id'], $historiques)) {
+ $historique = $historiques[$instance['Instance']['id']];
?>
- </td>
- <td>
<table>
- <?php $historique = $historiques[$instance['Instance']['id']]; ?>
<tr>
- <th>Création</th>
<?php if(array_key_exists($historique['Historique']['id'], $totalAlertes)) { ?>
- <th>Alertes</th>
+ <th>Message</th>
<th>Actions</th>
<?php } ?>
</tr>
<tr>
- <td>
- <?php echo $historique['Historique']['installation'] ?>
- </td>
<?php if(array_key_exists($historique['Historique']['id'], $totalAlertes)) { ?>
<?php foreach ($totalAlertes[$historiques[$instance['Instance']['id']]['Historique']['id']] as $alerte): ?>
<td>
} ?>
</tr>
</table>
+ <?php } else { echo "TEST"; } ?>
</td>
- <td><?php echo $instance['Instance']['version']; ?></td>
- <td><?php echo $instance['Instance']['reference']; ?></td>
<td>
- <?php
- echo $this->Form->postLink(
+ <?php echo $this->Html->link(
+ 'Editer',
+ array('controller' => 'instances', 'action' => 'edit', $instance['Instance']['id'])
+ ).' - '.
+ $this->Form->postLink(
'Supprimer',
array('action' => 'delete', $instance['Instance']['id']),
array('confirm' => 'Etes-vous certain ?')
</tr>
<?php endforeach; ?>
<?php unset($instance); ?>
- <?php echo $this->Html->link(
- 'Ajouter une instance',
- array('controller' => 'instances', 'action' => 'add')
- ); ?>
</table>
<head>
<?php echo $this->Html->charset(); ?>
<title>
- <?php echo $cakeDescription ?>:
- <?php echo $this->fetch('title'); ?>
+ <?php echo "ALLO - ".$this->fetch('title');?>
</title>
<?php
echo $this->Html->meta('icon');
<body>
<div id="container">
<div id="header">
- <h1><?php echo $this->Html->link($cakeDescription, 'http://cakephp.org'); ?></h1>
+ <div id="home">
+ <h1>ALLO Webadmin</h1>
+ </div>
+ <div id="menu">
+ <a href="/instances">INSTANCES</a>
+ <a href="/alertes">ALERTES</a>
+ <a href="/produits">PRODUITS</a>
+ </div>
</div>
<div id="content">
<?php echo $this->fetch('content'); ?>
</div>
<div id="footer">
- <?php echo $this->Html->link(
+ <?php /*echo $this->Html->link(
$this->Html->image('cake.power.gif', array('alt' => $cakeDescription, 'border' => '0')),
'http://www.cakephp.org/',
array('target' => '_blank', 'escape' => false, 'id' => 'cake-powered')
- );
+ );*/
?>
<p>
- <?php echo $cakeVersion; ?>
+ <?php //echo $cakeVersion; ?>
</p>
</div>
</div>
- <?php echo $this->element('sql_dump'); ?>
+ <?php //echo $this->element('sql_dump'); ?>
</body>
</html>
<?php
echo $this->Form->create('Produit');
echo $this->Form->input('nom');
-echo $this->Form->input('version');
-echo $this->Form->input('reference');
-echo $this->Form->input('fqdn_interne');
-echo $this->Form->input('fqdn_externe');
-echo $this->Form->input('clients');
-// TO-DO : Ajout de client
-echo $this->Form->input('exploitant');
-echo $this->Form->input('systeme');
-echo $this->Form->input('uid');
-echo $this->Form->end('Enregistrer le produit');
+echo $this->Form->end("Enregistrer le produit");
?>
\ No newline at end of file
<?php
echo $this->Form->create('Produit');
echo $this->Form->input('nom');
-echo $this->Form->input('reference');
-echo $this->Form->input('exploitant');
-echo $this->Form->input('version');
-echo $this->Form->input('fqdn_interne');
-//echo $this->Form->input('fqdn_externe');
-//echo $this->Form->input('systeme');
-//echo $this->Form->input('uid');
echo $this->Form->input('id', array('type' => 'hidden'));
-echo $this->Form->end('Mettre à jour le produit');
+echo $this->Form->end("Mettre à jour le produit");
?>
\ No newline at end of file
-<h1>Liste de produits</h1>
+<h1>
+ <?php echo $this->Html->link(
+ 'Nouveau produit',
+ array('controller' => 'produits', 'action' => 'add')
+); ?>
+</h1>
<table>
<tr>
<th>Nom</th>
- <th>Version</th>
- <th>Référence</th>
+ <th>Actions</th>
</tr>
<?php foreach ($produits as $produit): ?>
<tr>
+ <td><?php echo $produit['Produit']['nom']; ?></td>
<td>
<?php echo $this->Html->link(
- $produit['Produit']['nom'],
- array('controller' => 'produits', 'action' => 'edit', $produit['Produit']['id'])
- );
- ?>
- </td>
- <td><?php echo $produit['Produit']['version']; ?></td>
- <td><?php echo $produit['Produit']['reference']; ?></td>
- <td>
- <?php
- echo $this->Form->postLink(
+ 'Editer',
+ array('controller' => 'produits', 'action' => 'edit', $produit['Produit']['id'])
+ ).' - '.
+ $this->Form->postLink(
'Supprimer',
array('action' => 'delete', $produit['Produit']['id']),
array('confirm' => 'Etes-vous certain ?')
</tr>
<?php endforeach; ?>
<?php unset($produit); ?>
- <?php echo $this->Html->link(
- 'Ajouter un produit',
- array('controller' => 'produits', 'action' => 'add')
- ); ?>
</table>
-<h1>Produit : <?php echo h($produit['Produit']['nom']); ?></h1>
-
-<p>Version : <?php echo h($produit['Produit']['version']); ?></p>
-
-<p>FQDN : <?php echo h($produit['Produit']['fqdn_externe']); ?></p>
+<p>Nom : <?php echo h($produit['Produit']['nom']); ?></p>
--- /dev/null
+<h1>Ajout d'une version</h1>
+<?php
+echo $this->Form->create('Version');
+echo $this->Form->input('valeur');
+echo $this->Form->end("Enregistrer la version");
+?>
\ No newline at end of file
--- /dev/null
+<h1>Editer la version</h1>
+<?php
+echo $this->Form->create('Version');
+echo $this->Form->input('valeur');
+echo $this->Form->input('id', array('type' => 'hidden'));
+echo $this->Form->end("Mettre à jour la version");
+?>
\ No newline at end of file
--- /dev/null
+<h1>
+ <?php echo $this->Html->link(
+ 'Nouvelle version',
+ array('controller' => 'versions', 'action' => 'add')
+); ?>
+</h1>
+<table>
+ <tr>
+ <th>Valeur</th>
+ <th>Actions</th>
+ </tr>
+
+ <?php foreach ($versions as $version): ?>
+ <tr>
+ <td><?php echo $version['Version']['valeur']; ?></td>
+ <td>
+ <?php echo $this->Html->link(
+ 'Editer',
+ array('controller' => 'versions', 'action' => 'edit', $version['Version']['id'])
+ ).' - '.
+ $this->Form->postLink(
+ 'Supprimer',
+ array('action' => 'delete', $version['Version']['id']),
+ array('confirm' => 'Etes-vous certain ?')
+ );
+ ?>
+ </td>
+ </tr>
+ <?php endforeach; ?>
+ <?php unset($version); ?>
+</table>
--- /dev/null
+<p>Valeur : <?php echo h($version['Version']['valeur']); ?></p>
/** General Style Info **/
body {
- background: #003d4c;
+ background: white;
color: #fff;
font-family:'lucida grande',verdana,helvetica,arial,sans-serif;
font-size:90%;
}
#header{
- padding: 10px 20px;
+ line-height:40px;
+ width: 100%;
+ border: 1px solid #000000;
+ border-left: none;
+ border-right: none;
+ background: #4891bf;
+}
+#header #home {
+ padding-left: 30px;
+ float: left;
+ width: 25%;
+}
+#header #menu {
+ text-align: center;
+ height: 40px;
}
#header h1 {
- line-height:20px;
- background: #003d4c url('../img/cake.icon.png') no-repeat left;
+ background: #4891bf;
color: #fff;
- padding: 0px 30px;
}
-#header h1 a {
- color: #fff;
- background: #003d4c;
- font-weight: normal;
+#header a {
+ color: #fff;
+ background: #4891bf;
+ font-weight: normal;
+ text-decoration: none;
+ padding-left: 50px;
+ padding-right: 50px;
+ display: block;
+ height: 100%;
+ float: left;
+ text-align: center;
+}
+#header a:hover {
+ color: #4891bf;
+ background: white;
text-decoration: none;
}
-#header h1 a:hover {
- color: #fff;
- background: #003d4c;
- text-decoration: underline;
-}
#content{
background: #fff;
clear: both;
margin-bottom: 10px;
width: 100%;
}
+table table th{
+ border:0;
+}
+table table tr td{
+ border-bottom:0;
+}
+table table tr:nth-child(even){
+ background: transparent;
+}
th {
border:0;
border-bottom:2px solid #555;
table tr td {
padding: 6px;
text-align: left;
- vertical-align: top;
+ vertical-align: middle;
border-bottom:1px solid #ddd;
}
table tr:nth-child(even) {
###### CONFIGURATION ALLO AGENT ######
# Référence de l'instance sur ALLO
-produit_reference="IP/CDG01_0203150918"
+instance_reference="AS/AP_0903150846"
# Type d'usager (exploitant|client)
usager_type="client"
-# Type d'instance du produit (qualif|prod)
-produit_type="qualif"
+# Type d'instance (qualif|prod)
+instance_type="qualif"
# Fqdn interne
-produit_fqdn_interne="api_test"
+instance_fqdn_interne="api_test"
# Fqdn externe
-#produit.fqdn.externe="instance.mondomaine.fr"
+#instance_fqdn.externe="asalaedev.asalae.dev.adullact.org"
# ALLO Serveur
allo_serveur_url="allo_serveur"
# Type de données acceptées
HTTP/1.1 200 OK\r
-Date: Mon, 02 Mar 2015 10:21:27 GMT\r
+Date: Mon, 09 Mar 2015 10:32:40 GMT\r
Server: Apache/2.2.22 (Ubuntu)\r
X-Powered-By: PHP/5.3.10-1ubuntu3.16\r
Access-Control-Allow-Origin: *\r
usager="$REPLY"
fi
# To-do : choix entre générer ref client et utiliser une existante
-read -p "Type de la communauté [ville/ca/cr/cc/cg/cdg/sdis/AUTRE(laisser vide)] : "
+read -p "Type de la collectivité [ville/ca/cr/cc/cg/cdg/sdis/AUTRE(laisser vide)] : "
type_com="$REPLY"
-read -p "Nom de la communauté/du client [] : "
+read -p "Nom de la collectivité/du client [] : "
nom_com="$REPLY"
# To-do : ajout numéro de fin (code postal ?)
reference_client_mini="${type_com:0:5}${nom_com:0:4}"
echo "###### CONFIGURATION ALLO AGENT ######" >> $configuration
echo "" >> $configuration
echo "# Référence de l'instance sur ALLO" >> $configuration
-echo 'produit_reference="'${prefixe}'/'${reference_client}'_'${now}'"' >> $configuration
+echo 'instance_reference="'${prefixe}'/'${reference_client}'_'${now}'"' >> $configuration
echo "# Type d'usager (exploitant|client)" >> $configuration
echo 'usager_type="'${usager}'"' >> $configuration
-echo "# Type d'instance du produit (qualif|prod)" >> $configuration
-echo 'produit_type="'${canal}'"' >> $configuration
+echo "# Type d'instance (qualif|prod)" >> $configuration
+echo 'instance_type="'${canal}'"' >> $configuration
echo "# Fqdn interne" >> $configuration
-echo 'produit_fqdn_interne="'${fqdn_interne}'"' >> $configuration
+echo 'instance_fqdn_interne="'${fqdn_interne}'"' >> $configuration
echo "# Fqdn externe" >> $configuration
-echo '#produit.fqdn.externe="'${fqdn_externe}'"' >> $configuration
+echo '#instance_fqdn.externe="'${fqdn_externe}'"' >> $configuration
echo "# ALLO Serveur" >> $configuration
echo 'allo_serveur_url="allo_serveur"' >> $configuration
echo "# Type de données acceptées" >> $configuration
fi
# TEST DE CONNEXION
-code=$(curl -s -w "%{http_code}" --max-time 5 --output /dev/null "http://${produit_fqdn_interne}/api/rest/allo/version")
-echo ${produit_fqdn_interne}
+code=$(curl -s -w "%{http_code}" --max-time 5 --output /dev/null "http://${instance_fqdn_interne}/api/rest/allo/version")
+echo ${instance_fqdn_interne}
echo ${code}
if [ "${code}" == 200 ] || [ "${code}" == 301 ]
then
# REQUETE (en insecure pour le moment)
- curl --max-time 10 -k -X GET -H "${response_accept}" "http://${produit_fqdn_interne}/api/rest/allo/version/" --output "response.json" 2> /dev/null
+ curl --max-time 10 -k -X GET -H "${response_accept}" "http://${instance_fqdn_interne}/api/rest/allo/version/" --output "response.json" 2> /dev/null
# LOG DE LA REPONSE
#echo "$(cat response.json)" 2>&1 | tee -a $log_file
if [[ -z $isJSONCorrupted && ${isJSONCorrupted+x} ]]
then
# AJOUT DE LA REFERENCE PRODUIT (nécessite package jq)
- jq '. + { "reference": "'"${produit_reference}"'" }' response.json > tmp1.json
+ jq '. + { "reference": "'"${instance_reference}"'" }' response.json > tmp1.json
# AJOUT DU TYPE D'USAGER
jq '. + { "usager_type": "'"${usager_type}"'" }' tmp1.json > tmp2.json
# AJOUT DU TYPE DE PRODUIT
- jq '. + { "produit_type": "'"${produit_type}"'" }' tmp2.json > request.json
+ jq '. + { "instance_type": "'"${instance_type}"'" }' tmp2.json > request.json
# ENVOI DE L'UPDATE AU SERVEUR
curl -k -X PUT -H "${request_type}" -d "$(cat request.json)" -i "http://${allo_serveur_url}/?action=upload_info" --output "response_server" 2> /dev/null
-<?php\r
-\r
- require_once('protected/required.php');\r
-\r
- interface ProduitManager {\r
-\r
- function createProduit($produit);\r
- function updateProduit($produit);\r
- function updateProduitInfos($array);\r
- function getProduit($id);\r
- function getProduits();\r
- function removeProduit($produit);\r
- }\r
-\r
+<?php
+
+ require_once('protected/required.php');
+
+ interface ProduitManager {
+
+ function createProduit($produit);
+ function updateProduit($produit);
+ function getProduit($id);
+ function getProduitByNom($nom);
+ function getProduits();
+ function getNomsOfProduits();
+ function removeProduit($produit);
+ }
+
?>
\ No newline at end of file
--- /dev/null
+<?php
+
+ require_once('protected/required.php');
+
+ interface VersionManager {
+
+ function createVersion($version);
+ function updateVersion($version);
+ function getVersion($id);
+ function getNatureOfVersionForValeurAndProduitId($valeur, $produit_id);
+ function getVersions();
+ function findValeursOfVersionsByProduitId($produit_id);
+ function removeVersion($version);
+ }
+
+?>
\ No newline at end of file
public function createAlerte($alerte) {
$query = $this -> pdo -> prepare(
- 'INSERT INTO alertes (creation, nature, message) VALUES (NOW(), :nature, :message);'
+ 'INSERT INTO alertes (creation, nature, message, version) VALUES (NOW(), :nature, :message, :version);'
);
$query -> bindValue(':nature', $alerte -> getNature());
$query -> bindValue(':message', $alerte -> getMessage());
+ $query -> bindValue(':version', $alerte -> getVersion());
$query -> execute();
}
'UPDATE alertes
SET creation = :creation,
nature = :nature,
- message = :message
+ message = :message,
+ version = :version
WHERE id = :id'
);
$query -> bindValue(':id', $alerte -> getId());
$query -> bindValue(':creation', $alerte -> getCreation());
$query -> bindValue(':nature', $alerte -> getNature());
$query -> bindValue(':message', $alerte -> getMessage());
+ $query -> bindValue(':version', $alerte -> getVersion());
$query -> execute();
}
$query -> execute();
$result = $query -> fetch(PDO::FETCH_ASSOC);
- $alerte = new Alerte($result['id'], $result['creation'], $result['nature'], $result['message']);
+ $alerte = new Alerte($result['id'], $result['creation'], $result['nature'], $result['message'], $result['version']);
$query->closeCursor();
$query -> execute();
$result = $query -> fetch(PDO::FETCH_ASSOC);
- $alerte = new Alerte($result['id'], $result['creation'], $result['nature'], $result['message']);
+ $alerte = new Alerte($result['id'], $result['creation'], $result['nature'], $result['message'], $result['version']);
$query->closeCursor();
$results = $query -> fetchAll(PDO::FETCH_ASSOC);
$alertes = array();
foreach ($results as $result) {
- $alertes[] = new Alerte($result['id'], $result['creation'], $result['nature'], $result['message']);
+ $alertes[] = new Alerte($result['id'], $result['creation'], $result['nature'], $result['message'], $result['version']);
}
$query->closeCursor();
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;
+ }
}
?>
-<?php\r
-\r
- require_once('protected/required.php');\r
-\r
- class PdoProduitManager extends AbstractPdoManager implements ProduitManager {\r
-\r
- public function createProduit($produit) {\r
-\r
- $query = $this -> pdo -> prepare(\r
- 'INSERT INTO produits (\r
- nom, \r
- exploitant, \r
- reference, \r
- version, \r
- historique\r
- ) VALUES (\r
- :nom, \r
- :exploitant, \r
- :reference, \r
- :version, \r
- :historique\r
- )'\r
- );\r
- $query -> bindValue(':nom', $produit -> getNom());\r
- $query -> bindValue(':exploitant', $produit -> getExploitant());\r
- $query -> bindValue(':reference', $produit -> getReference());\r
- $query -> bindValue(':version', $produit -> getVersion());\r
- $query -> execute();\r
- $query -> closeCursor();\r
-\r
- }\r
-\r
- public function updateProduit($produit) {\r
-\r
- $query = $this -> pdo -> prepare(\r
- 'UPDATE produits \r
- SET nom = :nom, \r
- exploitant = :exploitant, \r
- reference = :reference, \r
- version = :version, \r
- historique = :historique\r
- WHERE id = :id'\r
- );\r
- $query -> bindValue(':id', $produit -> getId());\r
- $query -> bindValue(':nom', $produit -> getNom());\r
- $query -> bindValue(':exploitant', $produit -> getExploitant());\r
- $query -> bindValue(':reference', $produit -> getReference());\r
- $query -> bindValue(':version', $produit -> getVersion());\r
- $query -> bindValue(':historique', $produit -> getHistorique());\r
- $query -> execute();\r
-\r
- }\r
-\r
- public function updateProduitInfos($array) {\r
- $produit = $this -> getProduitByReference($array['reference']);\r
- // TO-DO :\r
- // AJOUT EVENEMENT À L'HISTORIQUE\r
- // DEMANDE DE VALIDATION\r
- // CAS EXPLOITANT\r
- if($array['usager_type'] === "exploitant") {\r
- // RECUPERATION DE L'EXPLOITANT DU PRODUIT\r
- $exploitantManager = new PdoExploitantManager();\r
- $exploitant = $exploitantManager -> getExploitantByReference($produit -> getExploitant());\r
-\r
- // MISE À JOUR DE TOUS LES PRODUITS EN CHARGE DE L'EXPLOITANT\r
- $array['usager_type'] = "client";\r
- $produits_id = $exploitant -> getProduits();\r
- foreach ($produits_id as $produit_id) {\r
- $array['reference'] = $this -> getProduit($produit_id) -> getReference();\r
- $this -> updateProduitInfos($array);\r
- }\r
- // CAS CLIENT\r
- } else if($array['usager_type'] === "client") {\r
- if ($array['produit'] === $produit -> getNom()) {\r
- $query = $this -> pdo -> prepare(\r
- 'UPDATE produits SET version = :version WHERE reference = :reference'\r
- );\r
- $query -> bindValue(':reference', $array['reference']);\r
- $query -> bindValue(':version', $array['version']);\r
- $query -> execute();\r
- } else {\r
- echo "Erreur de nom du produit";\r
- }\r
- }\r
- }\r
-\r
- public function getProduit($id) {\r
-\r
- $query = $this -> pdo -> prepare('SELECT * FROM produits WHERE id = :id');\r
- $query -> bindValue(':id', $id);\r
- $query -> execute();\r
-\r
- $result = $query -> fetch(PDO::FETCH_ASSOC);\r
- $produit = new Produit(\r
- $result['id'], \r
- $result['nom'], \r
- $result['exploitant'], \r
- $result['reference'], \r
- $result['version'],\r
- $result['historique']\r
- );\r
-\r
- $query->closeCursor();\r
-\r
- return $produit;\r
- }\r
-\r
- public function getProduitByReference($reference) {\r
-\r
- $query = $this -> pdo -> prepare('SELECT * FROM produits WHERE reference = :reference');\r
- $query -> bindValue(':reference', $reference);\r
- $query -> execute();\r
-\r
- $result = $query -> fetch(PDO::FETCH_ASSOC);\r
- $produit = new Produit(\r
- $result['id'], \r
- $result['nom'], \r
- $result['exploitant'], \r
- $result['reference'], \r
- $result['version'],\r
- $result['historique']\r
- );\r
-\r
- $query->closeCursor();\r
-\r
- return $produit;\r
- }\r
-\r
- public function getProduits() {\r
-\r
- $query = $this -> pdo -> prepare('SELECT * FROM produits');\r
- $query -> execute();\r
-\r
- $results = $query -> fetchAll(PDO::FETCH_ASSOC);\r
- $produits = array();\r
- foreach ($results as $result) {\r
- $produits[] = new Produit(\r
- $result['id'], \r
- $result['nom'], \r
- $result['exploitant'], \r
- $result['reference'], \r
- $result['version'],\r
- $result['historique']\r
- );\r
- }\r
-\r
- $query->closeCursor();\r
-\r
- return $produits;\r
- }\r
-\r
- public function removeProduit($produit) {\r
-\r
- $query = $this -> pdo -> prepare('DELETE FROM produits WHERE id = :id');\r
- $query -> bindValue('id', $produit -> getId());\r
- $query -> execute();\r
-\r
- }\r
-\r
- }\r
-\r
-?>\r
+<?php
+
+ require_once('protected/required.php');
+
+ class PdoProduitManager extends AbstractPdoManager implements ProduitManager {
+
+ public function createProduit($produit) {
+
+ $query = $this -> pdo -> prepare(
+ 'INSERT INTO produits (nom) VALUES (:nom);'
+ );
+ $query -> bindValue(':nom', $produit -> getNom());
+ $query -> execute();
+ }
+
+ public function updateProduit($produit) {
+
+ $query = $this -> pdo -> prepare(
+ 'UPDATE produits
+ SET nom = :nom
+ WHERE id = :id'
+ );
+ $query -> bindValue(':id', $produit -> getId());
+ $query -> bindValue(':nom', $produit -> getNom());
+ $query -> execute();
+ }
+
+ public function getProduit($id) {
+
+ $query = $this -> pdo -> prepare('SELECT * FROM produits WHERE id = :id');
+ $query -> bindValue(':id', $id);
+ $query -> execute();
+
+ $result = $query -> fetch(PDO::FETCH_ASSOC);
+ $produit = new Produit($result['id'], $result['nom']);
+
+ $query->closeCursor();
+
+ return $produit;
+ }
+
+ public function getProduitByNom($nom) {
+
+ $query = $this -> pdo -> prepare('SELECT * FROM produits WHERE nom = :nom');
+ $query -> bindValue(':nom', $nom);
+ $query -> execute();
+
+ $result = $query -> fetch(PDO::FETCH_ASSOC);
+ $produit = new Produit($result['id'], $result['nom']);
+
+ $query->closeCursor();
+
+ return $produit;
+ }
+
+ public function getProduits() {
+
+ $query = $this -> pdo -> prepare('SELECT * FROM produits');
+ $query -> execute();
+
+ $results = $query -> fetchAll(PDO::FETCH_ASSOC);
+ $produits = array();
+ foreach ($results as $result) {
+ $produits[] = new Produit($result['id'], $result['nom']);
+ }
+
+ $query->closeCursor();
+
+ return $produits;
+ }
+
+ public function getNomsOfProduits() {
+
+ $query = $this -> pdo -> prepare('SELECT nom FROM produits');
+ $query -> execute();
+
+ $results = $query -> fetchAll(PDO::FETCH_ASSOC);
+ $noms = array();
+ foreach ($results as $result) {
+ $noms[] = $result['nom'];
+ }
+
+ $query->closeCursor();
+
+ return $noms;
+ }
+
+ public function removeProduit($produit) {
+
+ $query = $this -> pdo -> prepare('DELETE FROM produits WHERE id = :id');
+ $query -> bindValue('id', $produit -> getId());
+ $query -> execute();
+ }
+
+ }
+
+?>
--- /dev/null
+<?php
+
+ require_once('protected/required.php');
+
+ class PdoTemplateManager extends AbstractPdoManager implements TemplateManager {
+
+ public function createTemplate($template) {
+
+ $query = $this -> pdo -> prepare(
+ 'INSERT INTO templates (
+ valeur1,
+ valeur2,
+ valeur3,
+ valeur4,
+ valeur5
+ ) VALUES (
+ :valeur1,
+ :valeur2,
+ :valeur3,
+ :valeur4,
+ :valeur5
+ );'
+ );
+ $query -> bindValue(':valeur1', $template -> getValeur1());
+ $query -> bindValue(':valeur2', $template -> getValeur2());
+ $query -> bindValue(':valeur3', $template -> getValeur3());
+ $query -> bindValue(':valeur4', $template -> getValeur4());
+ $query -> bindValue(':valeur5', $template -> getValeur5());
+ $query -> execute();
+ }
+
+ public function updateTemplate($template) {
+
+ $query = $this -> pdo -> prepare(
+ 'UPDATE templates
+ SET valeur1 = :valeur1,
+ valeur2 = :valeur2,
+ valeur3 = :valeur3,
+ valeur4 = :valeur4,
+ valeur5 = :valeur5
+ WHERE id = :id'
+ );
+ $query -> bindValue(':id', $template -> getId());
+ $query -> bindValue(':valeur1', $template -> getValeur1());
+ $query -> bindValue(':valeur2', $template -> getValeur2());
+ $query -> bindValue(':valeur3', $template -> getValeur3());
+ $query -> bindValue(':valeur4', $template -> getValeur4());
+ $query -> bindValue(':valeur5', $template -> getValeur5());
+ $query -> execute();
+ }
+
+ public function getTemplate($id) {
+
+ $query = $this -> pdo -> prepare('SELECT * FROM templates WHERE id = :id');
+ $query -> bindValue(':id', $id);
+ $query -> execute();
+
+ $result = $query -> fetch(PDO::FETCH_ASSOC);
+ $template = new Template($result['id'], $result['valeur1'], $result['valeur2'], $result['valeur3'], $result['valeur4'], $result['valeur5']);
+
+ $query->closeCursor();
+
+ return $template;
+ }
+
+ public function getTemplates() {
+
+ $query = $this -> pdo -> prepare('SELECT * FROM templates');
+ $query -> execute();
+
+ $results = $query -> fetchAll(PDO::FETCH_ASSOC);
+ $templates = array();
+ foreach ($results as $result) {
+ $templates[] = new Template($result['id'], $result['valeur1'], $result['valeur2'], $result['valeur3'], $result['valeur4'], $result['valeur5']);
+ }
+
+ $query->closeCursor();
+
+ return $templates;
+ }
+
+ public function removeTemplate($template) {
+
+ $query = $this -> pdo -> prepare('DELETE FROM templates WHERE id = :id');
+ $query -> bindValue('id', $template -> getId());
+ $query -> execute();
+ }
+
+ }
+
+?>
--- /dev/null
+<?php
+
+ require_once('protected/required.php');
+
+ class PdoVersionManager extends AbstractPdoManager implements VersionManager {
+
+ public function createVersion($version) {
+
+ $query = $this -> pdo -> prepare(
+ 'INSERT INTO versions (valeur, produit, nature) VALUES (:valeur, :produit, :nature);'
+ );
+ $query -> bindValue(':valeur', $version -> getValeur());
+ $query -> bindValue(':produit', $version -> getProduit());
+ $query -> bindValue(':nature', $version -> getNature());
+ $query -> execute();
+ }
+
+ public function updateVersion($version) {
+
+ $query = $this -> pdo -> prepare(
+ 'UPDATE versions
+ SET valeur = :valeur,
+ produit = :produit,
+ nature = :nature
+ WHERE id = :id'
+ );
+ $query -> bindValue(':id', $version -> getId());
+ $query -> bindValue(':valeur', $version -> getValeur());
+ $query -> bindValue(':produit', $version -> getProduit());
+ $query -> bindValue(':nature', $version -> getNature());
+ $query -> execute();
+ }
+
+ public function getVersion($id) {
+
+ $query = $this -> pdo -> prepare('SELECT * FROM versions WHERE id = :id');
+ $query -> bindValue(':id', $id);
+ $query -> execute();
+
+ $result = $query -> fetch(PDO::FETCH_ASSOC);
+ $version = new Version($result['id'], $result['valeur'], $result['produit'], $result['nature']);
+
+ $query->closeCursor();
+
+ return $version;
+ }
+
+ public function getNatureOfVersionForValeurAndProduitId($valeur, $produit_id) {
+
+ $query = $this -> pdo -> prepare('SELECT nature FROM versions WHERE valeur = :valeur AND produit = :produit');
+ $query -> bindValue(':valeur', $valeur);
+ $query -> bindValue(':produit', $produit_id);
+ $query -> execute();
+
+ $result = $query -> fetch(PDO::FETCH_ASSOC);
+
+ $query->closeCursor();
+
+ return $result['nature'];
+ }
+
+ public function getVersions() {
+
+ $query = $this -> pdo -> prepare('SELECT * FROM versions');
+ $query -> execute();
+
+ $results = $query -> fetchAll(PDO::FETCH_ASSOC);
+ $versions = array();
+ foreach ($results as $result) {
+ $versions[] = new Version($result['id'], $result['valeur'], $result['produit'], $result['nature']);
+ }
+
+ $query->closeCursor();
+
+ return $versions;
+ }
+
+ public function findValeursOfVersionsByProduitId($produit_id) {
+
+ $query = $this -> pdo -> prepare('SELECT valeur FROM versions WHERE produit = :produit');
+ $query -> bindValue('produit', $produit_id);
+ $query -> execute();
+
+ $results = $query -> fetchAll(PDO::FETCH_ASSOC);
+ $valeurs = array();
+ foreach ($results as $result) {
+ $valeurs[] = $result['valeur'];
+ }
+
+ $query->closeCursor();
+
+ return $valeurs;
+ }
+
+ public function removeVersion($version) {
+
+ $query = $this -> pdo -> prepare('DELETE FROM versions WHERE id = :id');
+ $query -> bindValue('id', $version -> getId());
+ $query -> execute();
+ }
+
+ }
+
+?>
class Alerte {
- protected $id, $creation, $nature, $message;
+ protected $id, $creation, $nature, $message, $version;
/// CONSTRUCTEUR
- function __construct($id = null, $creation = null, $nature = null, $message = null) {
+ function __construct($id = null, $creation = null, $nature = null, $message = null, $version = null) {
$this -> id = $id;
$this -> creation = $creation;
$this -> nature = $nature;
$this -> message = $message;
+ $this -> version = $version;
}
$array["creation"] = $this -> creation;
$array["nature"] = $this -> nature;
$array["message"] = $this -> message;
+ $array["version"] = $this -> version;
return json_encode($array);
}
public function getCreation() { return $this->creation; }
public function getNature() { return $this->nature; }
public function getMessage() { return $this->message; }
+ public function getVersion() { return $this->version; }
/// SETTERS
public function setId($id) { $this -> id = $id; }
public function setCreation($creation) { $this->creation = $creation; }
public function setNature($nature) { $this->nature = $nature; }
public function setMessage($message) { $this->message = $message; }
+ public function setVersion($version) { $this->version = $version; }
}
-<?php\r
-\r
- require_once('protected/required.php');\r
-\r
- class Produit {\r
-\r
- protected $id, $nom, $exploitant, $reference, $version, $historique;\r
- \r
- /// CONSTRUCTEUR\r
- function __construct($id = null, $nom = null, $exploitant = null, $reference = null, $version = null, $historique = null) {\r
-\r
- $this -> id = $id;\r
- $this -> nom = $nom;\r
- // Référence client de l'exploitant\r
- $this -> exploitant = $exploitant;\r
- // Référence / identifiant du produit\r
- $this -> reference = $reference;\r
- // Version actuelle\r
- $this -> version = $version;\r
- // Id de l'historique de màj / patchs\r
- $this -> historique = $historique;\r
-\r
- // TO-DO : AJOUT DE :\r
- /*\r
- - fqdnInterne\r
- - fqdnExterne\r
- - systeme\r
- - uid\r
- */\r
- }\r
-\r
- public function getJSON() {\r
- return json_encode(get_object_vars($this));\r
- }\r
- \r
- public function getJSONP() {\r
- $array["id"] = $this -> id;\r
- $array["nom"] = $this -> nom;\r
- $array["exploitant"] = $this -> exploitant;\r
- $array["reference"] = $this -> reference;\r
- $array["version"] = $this -> version;\r
- $array["historique"] = $this -> historique;\r
- \r
- return json_encode($array);\r
- }\r
-\r
- /// GETTERS\r
- public function getId() { return $this -> id; }\r
- public function getNom() { return $this->nom; }\r
- public function getExploitant() { return $this->exploitant; }\r
- public function getReference() { return $this->reference; }\r
- public function getVersion() { return $this->version; }\r
- public function getHistorique() { return $this->historique; }\r
- \r
- /// SETTERS\r
- public function setId($id) { $this -> id = $id; }\r
- public function setNom($nom) { $this->nom = $nom; }\r
- public function setExploitant($exploitant) { $this->exploitant = $exploitant; }\r
- public function setReference($reference) { $this->reference = $reference; }\r
- public function setVersion($version) { $this->version = $version; }\r
- public function setHistorique($historique) { $this->historique = $historique; }\r
-\r
- }\r
-\r
+<?php
+
+ require_once('protected/required.php');
+
+ class Produit {
+
+ protected $id, $nom;
+
+ /// CONSTRUCTEUR
+ function __construct($id = null, $nom = null) {
+
+ $this -> id = $id;
+ $this -> nom = $nom;
+
+ }
+
+ public function getJSON() {
+ return json_encode(get_object_vars($this));
+ }
+
+ public function getJSONP() {
+ $array["id"] = $this -> id;
+ $array["nom"] = $this -> nom;
+
+ return json_encode($array);
+ }
+
+ /// GETTERS
+ public function getId() { return $this -> id; }
+ public function getNom() { return $this->nom; }
+
+ /// SETTERS
+ public function setId($id) { $this -> id = $id; }
+ public function setNom($nom) { $this->nom = $nom; }
+
+ }
+
?>
\ No newline at end of file
--- /dev/null
+<?php
+
+ require_once('protected/required.php');
+
+ class Template {
+
+ protected $id, $valeur1, $valeur2, $valeur3, $valeur4, $valeur5;
+
+ /// CONSTRUCTEUR
+ function __construct($id = null, $valeur1 = null, $valeur2 = null, $valeur3 = null, $valeur4 = null, $valeur5 = null) {
+
+ $this -> id = $id;
+ $this -> valeur1 = $valeur1;
+ $this -> valeur2 = $valeur2;
+ $this -> valeur3 = $valeur3;
+ $this -> valeur4 = $valeur4;
+ $this -> valeur5 = $valeur5;
+
+ }
+
+ public function getJSON() {
+ return json_encode(get_object_vars($this));
+ }
+
+ public function getJSONP() {
+ $array["id"] = $this -> id;
+ $array["valeur1"] = $this -> valeur1;
+ $array["valeur2"] = $this -> valeur2;
+ $array["valeur3"] = $this -> valeur3;
+ $array["valeur4"] = $this -> valeur4;
+ $array["valeur5"] = $this -> valeur5;
+
+ return json_encode($array);
+ }
+
+ /// GETTERS
+ public function getId() { return $this -> id; }
+ public function getValeur1() { return $this->valeur1; }
+ public function getValeur2() { return $this->valeur2; }
+ public function getValeur3() { return $this->valeur3; }
+ public function getValeur4() { return $this->valeur4; }
+ public function getValeur5() { return $this->valeur5; }
+
+ /// SETTERS
+ public function setId($id) { $this -> id = $id; }
+ public function setValeur1($valeur1) { $this->valeur1 = $valeur1; }
+ public function setValeur2($valeur2) { $this->valeur2 = $valeur2; }
+ public function setValeur3($valeur3) { $this->valeur3 = $valeur3; }
+ public function setValeur4($valeur4) { $this->valeur4 = $valeur4; }
+ public function setValeur5($valeur5) { $this->valeur5 = $valeur5; }
+
+ }
+
+?>
\ No newline at end of file
--- /dev/null
+<?php
+
+ require_once('protected/required.php');
+
+ class Version {
+
+ protected $id, $valeur, $produit, $nature;
+
+ /// CONSTRUCTEUR
+ function __construct($id = null, $valeur = null, $produit = null, $nature = null) {
+
+ $this -> id = $id;
+ $this -> valeur = $valeur;
+ $this -> produit = $produit;
+ $this -> nature = $nature;
+
+ }
+
+ public function getJSON() {
+ return json_encode(get_object_vars($this));
+ }
+
+ public function getJSONP() {
+ $array["id"] = $this -> id;
+ $array["valeur"] = $this -> valeur;
+ $array["produit"] = $this -> produit;
+ $array["nature"] = $this -> nature;
+
+ return json_encode($array);
+ }
+
+ /// GETTERS
+ public function getId() { return $this -> id; }
+ public function getValeur() { return $this->valeur; }
+ public function getProduit() { return $this->produit; }
+ public function getNature() { return $this->nature; }
+
+ /// SETTERS
+ public function setId($id) { $this -> id = $id; }
+ public function setValeur($valeur) { $this->valeur = $valeur; }
+ public function setProduit($produit) { $this->produit = $produit; }
+ public function setNature($nature) { $this->nature = $nature; }
+
+ }
+
+?>
\ No newline at end of file
<?php\r
\r
function api_put() {\r
+ // RÉCUPÉRATION DES DONNÉES\r
$data = file_get_contents("php://input");\r
- //file_put_contents('uploads/data', $data);\r
-\r
- $instanceManager = new PdoInstanceManager();\r
-\r
+ // CAS DE DECLARATION D'INFOS\r
if ($_GET['action'] == 'upload_info') {\r
- // DECODE JSON\r
+ // DECODE DU JSON\r
$array = json_decode($data, true);\r
- //var_dump($array);\r
-\r
+ // TEST DE CHAINE VIDE / CORROMPUE\r
if (!is_null($array) && assert($array)) {\r
- // MISE A JOUR INSTANCE\r
- $instanceManager -> updateInstanceInfos($array);\r
+ $instanceManager = new PdoInstanceManager();\r
+ // TEST DES INFORMATIONS ENVOYEES\r
+ $retour = $instanceManager->testInformationsAvantUpload($array);\r
+ if($retour === 'ok') {\r
+ // MISE A JOUR DES INFORMATIONS DE L'INSTANCE\r
+ $instanceManager -> updateInstanceInfos($array);\r
+ } else {\r
+ echo $retour;\r
+ }\r
}\r
}\r
\r
require_once('classes/models/Instance.class.php');\r
require_once('classes/models/Historique.class.php');\r
require_once('classes/models/Alerte.class.php');\r
+ require_once('classes/models/Produit.class.php');\r
+ require_once('classes/models/Version.class.php');\r
\r
require_once('classes/manager/ExploitantManager.class.php');\r
require_once('classes/manager/InstanceManager.class.php');\r
require_once('classes/manager/HistoriqueManager.class.php');\r
require_once('classes/manager/AlerteManager.class.php');\r
+ require_once('classes/manager/ProduitManager.class.php');\r
+ require_once('classes/manager/VersionManager.class.php');\r
\r
require_once('classes/manager/pdo/AbstractPdoManager.php');\r
\r
require_once('classes/manager/pdo/PdoInstanceManager.php');\r
require_once('classes/manager/pdo/PdoHistoriqueManager.php');\r
require_once('classes/manager/pdo/PdoAlerteManager.php');\r
+ require_once('classes/manager/pdo/PdoProduitManager.php');\r
+ require_once('classes/manager/pdo/PdoVersionManager.php');\r
\r
?>
\ No newline at end of file