Subversion Repositories Sites.obs-saisons.fr

Rev

Rev 98 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 98 Rev 210
1
<?php
1
<?php
2
// declare(encoding='UTF-8');
2
// declare(encoding='UTF-8');
3
/**
3
/**
4
 * Modèle d'accès à la base de données de saisies pour le module stations.
4
 * Modèle d'accès à la base de données de saisies pour le module stations.
5
 *
5
 *
6
 * @package ODS_saisie
6
 * @package ODS_saisie
7
 * @category    php 5.2
7
 * @category    php 5.2
8
 * @author      Aurélien Peronnet <aurelien@tela-botanica.org>
8
 * @author      Aurélien Peronnet <aurelien@tela-botanica.org>
9
 * @copyright   2010 Tela-Botanica
9
 * @copyright   2010 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
 * @license http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
11
 * @license http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
12
 * @version SVN: $Id: StationDao.php 154 2010-09-13 12:15:11Z aurelien $
12
 * @version SVN: $Id: StationDao.php 154 2010-09-13 12:15:11Z aurelien $
13
 *
13
 *
14
 */
14
 */
15
class StationDao extends Dao {
15
class StationDao extends Dao {
16
	
16
	
17
	const SERVICE_STATION = 'OdsStation';
17
	const SERVICE_STATION = 'OdsStation';
18
 
18
 
19
    /**
19
    /**
20
     * Retourne l'ensemble des stations d'un participant.
20
     * Retourne l'ensemble des stations d'un participant.
21
     *
21
     *
22
     * @return array un tableau contenant les informations sur les stations du participant.
22
     * @return array un tableau contenant les informations sur les stations du participant.
23
     */
23
     */
24
    public function getListeStations() {
24
    public function getListeStations() {
25
       	    	
25
       	    	
26
	    $url = $this->url_jrest.self::SERVICE_STATION.'/'.AppControleur::getIdUtilisateur().'/*/';
26
	    $url = $this->url_jrest.self::SERVICE_STATION.'/'.AppControleur::getIdUtilisateur().'/*/';
27
        $json = $this->envoyerRequeteConsultation($url);
27
        $json = $this->envoyerRequeteConsultation($url);
28
        $donnees = json_decode($json, true);
28
        $donnees = json_decode($json, true);
29
        
29
        
30
        return $donnees;
30
        return $donnees;
31
	}
31
	}
32
	
32
	
33
	public function getInformationsStation($id_station) {
33
	public function getInformationsStation($id_station) {
34
		
34
		
35
	    $url = $this->url_jrest.self::SERVICE_STATION.'/'.AppControleur::getIdUtilisateur().'/'.$id_station.'/';
35
	    $url = $this->url_jrest.self::SERVICE_STATION.'/'.AppControleur::getIdUtilisateur().'/'.$id_station.'/';
36
        $json = $this->envoyerRequeteConsultation($url);
36
        $json = $this->envoyerRequeteConsultation($url);
37
        $donnees = json_decode($json, true);
37
        $donnees = json_decode($json, true);
38
        
38
        
39
        return $donnees;
39
        return $donnees;
40
	}
40
	}
41
	
41
	
42
	public function ajouterStation($valeurs_station_verifiees) {
42
	public function ajouterStation($valeurs_station_verifiees) {
43
		
43
		
44
		$donnees = $valeurs_station_verifiees;
44
		$donnees = $valeurs_station_verifiees;
45
		$donnees['id_participant'] = AppControleur::getIdUtilisateur();
45
		$donnees['id_participant'] = AppControleur::getIdUtilisateur();
46
		
46
		
47
        $url = $this->url_jrest.self::SERVICE_STATION."/";
47
        $url = $this->url_jrest.self::SERVICE_STATION."/";
48
        $json = $this->envoyerRequeteAjout($url, $donnees);
48
        $json = $this->envoyerRequeteAjout($url, $donnees);
49
        
49
        
50
        $donnees_retour = json_decode($json, true);
50
        $donnees_retour = json_decode($json, true);
51
		
51
		
52
		return $donnees_retour;
52
		return $donnees_retour;
53
	}
53
	}
54
	
54
	
55
	public function modifierStation($id_station, $valeurs_station_verifiees) {
55
	public function modifierStation($id_station, $valeurs_station_verifiees) {
56
		
56
		
57
		$donnees = $valeurs_station_verifiees;
57
		$donnees = $valeurs_station_verifiees;
58
		$donnees['id_participant'] = AppControleur::getIdUtilisateur();
58
		$donnees['id_participant'] = AppControleur::getIdUtilisateur();
59
		
59
		
60
        if (is_numeric($id_station)) {
60
        if (is_numeric($id_station)) {
61
            $url = $this->url_jrest.self::SERVICE_STATION."/$id_station";
61
            $url = $this->url_jrest.self::SERVICE_STATION."/$id_station";
62
            $json = $this->envoyerRequeteModif($url, $donnees);
62
            $json = $this->envoyerRequeteModif($url, $donnees);
63
            
63
            
64
           	$donnees_retour = json_decode($json, true);
64
           	$donnees_retour = json_decode($json, true);
65
           	
65
           	
66
           	if($donnees_retour['reponse'] == 'OK') {
66
           	if($donnees_retour['reponse'] == 'OK') {
67
           		return true;
67
           		return true;
68
           	}
68
           	}
69
                   
69
                   
70
        }
70
        }
71
		
71
		
72
		return false;
72
		return false;
73
	}
73
	}
-
 
74
	
-
 
75
	public function supprimerStation($id_station) {
-
 
76
 
-
 
77
		$donnees['id_station'] = $id_station;
-
 
78
		$donnees['id_participant'] = AppControleur::getIdUtilisateur();
-
 
79
		
-
 
80
        if (is_numeric($id_station)) {
-
 
81
            $url = $this->url_jrest.self::SERVICE_STATION."/".AppControleur::getIdUtilisateur()."/".$id_station;
-
 
82
            $json = $this->envoyerRequeteSuppression($url, $donnees);
-
 
83
            
-
 
84
           	$donnees_retour = json_decode($json, true);
-
 
85
           	
-
 
86
           	if($donnees_retour['reponse'] == 'OK') {
-
 
87
           		return true;
-
 
88
           	}
-
 
89
                   
-
 
90
        }
-
 
91
		
-
 
92
		return false;
-
 
93
	}
74
}
94
}
75
?>
95
?>