Subversion Repositories Sites.obs-saisons.fr

Compare Revisions

Ignore whitespace Rev 104 → Rev 105

/trunk/applications/jrest/services/OdsStation.php
35,7 → 35,7
*/
public function createElement($params) {
$elements_requis = array('id_participant','station_nom', 'station_commune', 'station_lat', 'station_lon','station_milieu');
$elements_requis = array('id_participant','station_nom', 'station_commune', 'station_lat', 'station_lon','station_milieu','station_alt');
$erreurs = array();
foreach($elements_requis as $requis) {
48,8 → 48,6
$this->envoyer($erreurs);
}
$station['alt'] = '0';
$id_participant = $params['id_participant'];
$requete_creation_station = 'INSERT INTO ods_stations '.
81,16 → 79,25
*/
public function updateElement($uid, $params) {
if(!isset($uid[0])) {
$id_participant = $uid[0];
} else {
return;
$elements_requis = array('id_participant','station_nom', 'station_commune', 'station_lat', 'station_lon','station_milieu','station_alt');
$erreurs = array();
foreach($elements_requis as $requis) {
if(!isset($params[$requis])) {
$erreurs[$requis] = 'erreur ';
}
}
if(!isset($uid[1])) {
$id_station = $uid[1];
if(!empty($erreurs)) {
$this->envoyer($erreurs);
}
$id_participant = $params['id_participant'];
if(!isset($uid[0])) {
return;
} else {
return;
$id_station = $uid[0];;
}
$requete_modification_station = 'UPDATE ods_stations '.
102,16 → 109,20
'os_altitude ='.$this->proteger($params['station_alt']).','.
'os_ce_environnement ='.$this->proteger($params['station_milieu']).','.
'os_commentaire ='.$this->proteger($params['station_description']).' '.
'WHERE os_ce_particant = '.$this->proteger($id_participant).' '.
'WHERE os_ce_participant = '.$this->proteger($id_participant).' '.
'AND os_id_station = '.$this->proteger($id_station);
$modification_station = $this->executerRequeteSimple($requete_creation_station);
$modification_station = $this->executerRequeteSimple($requete_modification_station);
$retour = array();
if(!$modification_station) {
// TODO: comment gère t'on les erreurs ?
$retour['erreurs'] = 'Erreur lors de la modification de la station';
} else {
$retour['reponse'] = 'OK';
}
$this->envoyer();
 
$this->envoyer($retour);
}
/**
208,9 → 219,10
//$requete_infos_commune = 'SELECT * FROM ods_communes WHERE oc_id_commune = '.$this->proteger($id_commune);
//$infos_commune = $this->executerRequete($requete_infos_commune);
return '';
//TODO: en attendant de stocker les ids
return $id_commune;
return $infos_commune;
//return $infos_commune;
}
private function obtenirInformationsCommuneParCodeInsee($code_insee_commune) {
218,9 → 230,10
//$requete_infos_commune = 'SELECT * FROM ods_communes WHERE oc_code_insee = '.$this->proteger($code_insee_commune);
//$infos_commune = $this->executerRequete($requete_infos_commune);
return '';
//TODO: en attendant de stocker les ids
return $code_insee_commune;
return $infos_commune;
//return $infos_commune;
}
private function obtenirInformationsMilieuParId($id_milieu) {