Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 2394 Rev 2458
Line 1... Line 1...
1
<?php
1
<?php
2
// ATTENTION ! Classe compatible uniquement avec nouveau format de bdd du cel //
2
// declare(encoding='UTF-8');
3
/**
3
/**
4
* PHP Version 5
4
 * Service CRUD sur une observation.
5
*
5
 *
-
 
6
 * @internal   Mininum PHP version : 5.2
6
* @category  PHP
7
 * @category   CEL
7
* @package   jrest
8
 * @package    Services
-
 
9
 * @subpackage Observations
-
 
10
 * @version    0.1
8
* @author    David Delon <david@tela-botanica.org>
11
 * @author     Mathias CHOUET <mathias@tela-botanica.org>
-
 
12
 * @author     Jean-Pascal MILCENT <jpm@tela-botanica.org>
9
* @author    Aurelien Peronnet <aurelien@tela-botanica.org>
13
 * @author     Aurelien PERONNET <aurelien@tela-botanica.org>
10
* @copyright 2010 Tela-Botanica
14
 * @license    GPL v3 <http://www.gnu.org/licenses/gpl.txt>
11
* @license   http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
15
 * @license    CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
12
* @version   SVN: <svn_id>
16
 * @copyright  1999-2014 Tela Botanica <accueil@tela-botanica.org>
13
* @link      /doc/jrest/
-
 
14
*/
17
 */
15
 
-
 
16
/**
-
 
17
* CRUD observation
-
 
18
* 
-
 
19
* in=utf8
-
 
20
* out=utf8
-
 
21
*
-
 
22
**/ 
-
 
23
class Inventory extends Cel {
18
class Inventory extends Cel {
Line 24... Line -...
24
	
-
 
25
	// TODO: faire un descriptif du service
19
 
Line 26... Line 20...
26
	function getRessource(){
20
	public function getRessource() {
Line 27... Line 21...
27
 
21
 
28
	}
-
 
29
 
22
	}
30
	function getElement($uid){
23
 
31
 
-
 
32
	   	// Controle detournement utilisateur
-
 
33
	 	$this->controleUtilisateur($uid[0]);
-
 
34
 
24
	public function getElement($uid){
35
		$value=array();
25
		// Controle detournement utilisateur
36
 
26
		$this->controleUtilisateur($uid[0]);
Line 37... Line 27...
37
		if(!isset($uid[0])) {
27
		if (!isset($uid[0])) {
Line 45... Line 35...
45
    	
35
 
46
    	$observation = array();
36
		$observation = array();
47
    	if(is_array($retour_recherche) && count($retour_recherche) > 0) {
37
		if (is_array($retour_recherche) && count($retour_recherche) > 0) {
48
    		$observation = $retour_recherche[0];
38
			$observation = $retour_recherche[0];
49
    	}
-
 
50
    	
39
		}
51
        $observation = $this->formaterObservationVersTableauSequentiel($observation);
40
		$observation = $this->formaterObservationVersTableauSequentiel($observation);
52
		$output = json_encode($observation);
-
 
53
		
41
		$sortie = json_encode($observation);
54
		$this->envoyerJson($output);			
42
		$this->envoyerJson($sortie);
55
		return true;	
43
		return true;
Line 56... Line 44...
56
	}
44
	}
57
	
-
 
58
	private function formaterObservationVersTableauSequentiel(&$observation) {
45
 
59
		
46
	private function formaterObservationVersTableauSequentiel(&$observation) {
60
    	if ($observation['date_observation']!="0000-00-00 00:00:00") {
47
		if ($observation['date_observation']!="0000-00-00 00:00:00") {
61
            list($year,$month,$day)= explode('-',$observation['date_observation']);
48
			list($year,$month,$day)= explode('-',$observation['date_observation']);
62
            list($day)= explode(' ',$day);
49
			list($day)= explode(' ',$day);
Line 69... Line 56...
69
     				$observation['ce_zone_geo'], $observation['ordre'],
56
					$observation['ce_zone_geo'], $observation['ordre'],
70
     				$observation['date_observation'], $observation['lieudit'],
57
					$observation['date_observation'], $observation['lieudit'],
71
     				$observation['station'], $observation['milieu'],
58
					$observation['station'], $observation['milieu'],
72
     				$observation['commentaire'], $observation['latitude'],
59
					$observation['commentaire'], $observation['latitude'],
73
     				$observation['longitude']);
60
					$observation['longitude']);
74
	    
-
 
75
	    return $observation;
61
		return $observation;
76
	}
62
	}
Line 77... Line 63...
77
 
63
 
78
	function updateElement($uid,$pairs) {
-
 
79
 
64
	public function updateElement($uid,$pairs) {
80
		// Controle detournement utilisateur
65
		// Controle detournement utilisateur
Line 81... Line 66...
81
	 	$this->controleUtilisateur($uid[0]);
66
		$this->controleUtilisateur($uid[0]);
82
 
67
 
Line 114... Line 99...
114
	 			$champ_etendu = $objet_champ_etendu;
99
				$champ_etendu = $objet_champ_etendu;
115
	 		}
100
			}
116
	 		// ajouterParLots modifie les champs et ajoute ceux qui existent déjà
101
			// ajouterParLots modifie les champs et ajoute ceux qui existent déjà
117
	 		$champs_supp = $gestion_champs_etendus->ajouterParLots($champs_etendus);
102
			$champs_supp = $gestion_champs_etendus->ajouterParLots($champs_etendus);
118
		}
103
		}
119
		       	 
-
 
120
        return true;
104
		return true;
121
	}
105
	}
Line 122... Line 106...
122
 
106
 
123
	function createElement($pairs) {
107
	public function createElement($pairs) {
124
	 	// Controle detournement utilisateur
108
	 	// Controle detournement utilisateur
Line 125... Line 109...
125
	 	$this->controleUtilisateur($pairs['ce_utilisateur']);
109
	 	$this->controleUtilisateur($pairs['ce_utilisateur']);
126
	 	
110
 
Line 147... Line 131...
147
	 			}
131
				}
148
	 			$objet_champ_etendu->cle = $champ_etendu['cle'];		
132
				$objet_champ_etendu->cle = $champ_etendu['cle'];
149
	 			$objet_champ_etendu->valeur = $champ_etendu['valeur'];	
133
				$objet_champ_etendu->valeur = $champ_etendu['valeur'];
150
	 			$champ_etendu = $objet_champ_etendu;
134
				$champ_etendu = $objet_champ_etendu;
151
	 		}
135
			}
152
 
-
 
153
	 		$champs_supp = $gestion_champs_etendus->ajouterParLots($champs_etendus);
136
			$champs_supp = $gestion_champs_etendus->ajouterParLots($champs_etendus);
154
	 	}
137
		}
155
	 	
-
 
156
        return true;
138
		return true;
157
	}
139
	}
Line 158... Line 140...
158
	
140
 
159
	/**
141
	/**
160
	* Supprime une observation
142
	* Supprime une observation
161
	* 
143
	*
162
	* uid[0] : utilisateur obligatoire
144
	* uid[0] : utilisateur obligatoire
163
	* uid[1] : ordres de l'observation à supprimer
145
	* uid[1] : ordres de l'observation à supprimer
164
	*/ 
146
	*/
165
	function deleteElement($uid){
-
 
166
 
147
	public function deleteElement($uid){
167
		// Controle detournement utilisateur
148
		// Controle detournement utilisateur
Line 168... Line 149...
168
		$this->controleUtilisateur($uid[0]);
149
		$this->controleUtilisateur($uid[0]);
169
		
150
 
Line 182... Line 163...
182
		$champs_supp = $gestion_champs_etendus->vider($id_obs);
163
		$champs_supp = $gestion_champs_etendus->vider($id_obs);
Line 183... Line 164...
183
		
164
 
184
		if ($suppression_observation) {
165
		if ($suppression_observation) {
185
			echo "OK";	
166
			echo "OK";
186
		}
-
 
187
		
167
		}
188
    	exit() ;
168
		exit();
Line 189... Line -...
189
	}
-
 
190
	
169
	}
191
	
170
 
192
	function doitGenererCleChampEtendu($champ_etendu) {
171
	private function doitGenererCleChampEtendu($champ_etendu) {
193
		return !isset($champ_etendu['cle']) ||
172
		return !isset($champ_etendu['cle']) ||
194
				trim($champ_etendu['cle'] == "" ||
173
			trim($champ_etendu['cle'] == "" ||
195
				strpos($champ_etendu['cle'],'tempid_') !== false);
174
			strpos($champ_etendu['cle'],'tempid_') !== false);
196
	}
-
 
197
}
-
 
198
/* +--Fin du code ---------------------------------------------------------------------------------------+
-
 
199
* $Log$
-
 
200
* Revision 1.11  2008-11-13 11:29:12  ddelon
-
 
201
* Reecriture gwt-ext
-
 
202
*
-
 
203
* Revision 1.10  2008-01-30 08:57:28  ddelon
-
 
204
* fin mise en place mygwt
-
 
205
*
-
 
206
* Revision 1.9  2007-05-22 12:54:09  ddelon
-
 
207
* Securisation acces utilisateur
-
 
208
*
-
 
209
*/
175
	}