Subversion Repositories eFlore/Applications.cel

Rev

Rev 1840 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1840 Rev 1914
Line 1... Line 1...
1
<?php
1
<?php
2
// ATTENTION ! Classe compatible uniquement avec nouveau format de bdd du cel //
-
 
3
/**
2
/**
4
* PHP Version 5
3
 * PHP Version 5.2
5
*
4
 *
6
* @category  PHP
5
 * @category  PHP
7
* @package   jrest
6
 * @package   jrest
-
 
7
 * @author    Raphaël Droz <raphael@tela-botanica.org>
8
* @author    Aurelien Peronnet <aurelien@tela-botanica.org>
8
 * @author    Aurelien Peronnet <aurelien@tela-botanica.org>
9
* @copyright 2010 Tela-Botanica
9
 * @copyright 2010, 2013 Tela-Botanica
10
* @license   http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
10
 * @license   http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
11
* @version   SVN: <svn_id>
11
 * @license  GPL v3 <http://www.gnu.org/licenses/gpl.txt>
12
* @link      /doc/jrest/
12
 * @link      /doc/jrest/
13
*/
-
 
14
 
-
 
15
/**
-
 
16
* InventoryObservationList.php
-
 
17
* 
-
 
18
* in=utf8
-
 
19
* out=utf8
-
 
20
*
13
 *
-
 
14
 * InventoryObservationList.php
21
* Cas d'utilisation :
15
 * Cas d'utilisation :
22
* 1: Service recherche d'observations a partir de divers critères
16
 * 1: Service recherche d'observations a partir de divers critères
23
*  a: Le service recherche les observations correspondant aux critères demandés
17
 *  a: Le service recherche les observations correspondant aux critères demandés
24
*  b: Le service renvoie la liste des observations correspondantes
18
 *  b: Le service renvoie la liste des observations correspondantes
25
* 
19
 * 
Line 82... Line 76...
82
		if (!isset($uid[1])) {
76
		if (!isset($uid[1])) {
83
			//TODO: envoyer un message d'erreur
77
			//TODO: envoyer un message d'erreur
84
			return;	
78
			return;	
85
		}
79
		}
Line -... Line 80...
-
 
80
 
86
		
81
        $obs = array_filter(array_map('intval', explode(',', $uid[1])));
-
 
82
        if(count($obs) == 0) {
-
 
83
            return;
Line 87... Line 84...
87
		$uid[1] = rtrim($uid[1],',');
84
        }
-
 
85
	
88
		
86
		$gestionnaire_observation = new GestionObservation($this->config);
-
 
87
        if(count($obs) == 1) {
Line -... Line 88...
-
 
88
            return $gestionnaire_observation->modifierObservation($uid[0], $obs[0], $pairs);	
-
 
89
        }
-
 
90
 
-
 
91
        // cas de mise à jour de multiples observations:
-
 
92
        $ret = GestionObservation::modifierMultiplesObservation($uid[0], $obs, $pairs);
89
		$gestionnaire_observation = new GestionObservation($this->config);
93
        if($ret === FALSE) return FALSE; // JRest::badRequest();
-
 
94
        if($ret === 0) {
-
 
95
            header('HTTP/1.0 304 Not Modified');
-
 
96
            die;
-
 
97
        }
-
 
98
 
-
 
99
        header('HTTP/1.0 200 OK'); // et non pas une 201 !
-
 
100
        // die(); // non, car incompatible avec PHPUnit
-
 
101
        // throw(new Exception()); // non, lance une 400 (cf JRest::updateElement())
-
 
102
        // return TRUE; // non, lance une 201
90
		$modification_observation = $gestionnaire_observation->modifierObservation($uid[0],$uid[1],$pairs);	
103
        // return FALSE; // non, lance une 400
Line 91... Line 104...
91
       	 
104
 
92
        return true;
105
        die; // tant pis
93
	}
106
	}