Subversion Repositories eFlore/Applications.cel

Rev

Rev 738 | Rev 923 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 738 Rev 922
Line 1... Line 1...
1
<?php
1
<?php
-
 
2
// ATTENTION ! Classe compatible uniquement avec nouveau format de bdd du cel //
-
 
3
/**
-
 
4
* PHP Version 5
-
 
5
*
-
 
6
* @category  PHP
-
 
7
* @package   papyrus_bp
-
 
8
* @author    David Delon <david@tela-botanica.org>
-
 
9
* @author    Aurelien Peronnet <aurelien@tela-botanica.org>
-
 
10
* @copyright 2010 Tela-Botanica
-
 
11
* @license   http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
-
 
12
* @version   SVN: <svn_id>
-
 
13
* @link      /doc/jrest/
-
 
14
*/
Line -... Line 15...
-
 
15
 
-
 
16
/**
-
 
17
* CRUD observation
-
 
18
* 
-
 
19
* in=utf8
-
 
20
* out=utf8
-
 
21
*
-
 
22
**/ 
-
 
23
class Inventory extends Cel {
-
 
24
	
-
 
25
	// TODO;: faire un descriptif du service
Line 2... Line -...
2
 
-
 
3
 
-
 
4
// CRUD ligne d'inventaire :
-
 
5
// In get : utf8
-
 
6
// In post : utf8
-
 
7
// out : utf8
-
 
8
 
-
 
9
Class Inventory extends DBAccessor {
-
 
10
 
-
 
11
 
-
 
12
	var $config;
-
 
13
 
-
 
14
	function Inventory($config) {
-
 
15
 
26
	function getRessource(){
Line 16... Line -...
16
		$this->config=$config;
-
 
17
	}
27
 
Line 18... Line 28...
18
 
28
	}
19
 
29
 
20
	function getElement($uid){
30
	function getElement($uid){
21
 
-
 
22
		   // Controle detournement utilisateur
-
 
23
		    session_start();
-
 
24
		 	$this->controleUtilisateur($uid[0]);
-
 
25
 
-
 
26
			$value=array();
-
 
27
			$DB=$this->connectDB($this->config,'database_cel');
-
 
28
 
-
 
29
			if (isset($uid[1])) {
-
 
30
	           	$query="SELECT identifiant, ordre, nom_sel, num_nom_sel, nom_ret, num_nom_ret, num_taxon, famille, location, id_location, date_observation, lieudit, station, milieu, commentaire, coord_x, coord_y FROM cel_inventory WHERE identifiant='".$DB->escapeSimple($uid[0])."' AND ordre =".$uid[1]." ORDER BY ordre";
-
 
31
			}
-
 
32
			else {
-
 
33
				if (isset($uid[0])) {
-
 
34
		           	$query="SELECT identifiant, ordre, nom_sel, num_nom_sel, nom_ret, num_nom_ret, num_taxon, famille, location, id_location, date_observation, lieudit, station, milieu, commentaire, coord_x, coord_y FROM cel_inventory WHERE identifiant='".$DB->escapeSimple($uid[0])."' ORDER BY ordre";
-
 
35
				}
-
 
36
			}
-
 
37
 
-
 
38
		    $res =& $DB->query($query);
-
 
39
 
-
 
40
 
-
 
41
	        if (DB::isError($res)) {
-
 
42
	        	$this->logger("CEL_bugs","Erreur de listage des observations :".$res->getMessage()." ".$query);
-
 
43
        	}
-
 
44
	        while ($row =& $res->fetchrow(DB_FETCHMODE_ASSOC)) {
-
 
45
	        	if ($row['date_observation']!="0000-00-00 00:00:00") {
-
 
46
	                list($year,$month,$day)= split ('-',$row['date_observation']);
-
 
47
    	            list($day)= split (' ',$day);
-
 
48
	                $row['date_observation']=$day."/".$month."/".$year;
-
 
49
	        	}
-
 
50
 
-
 
51
		     	$value=array($row['nom_sel'],$row['num_nom_sel'],$row['nom_ret'],$row['num_nom_ret'],$row['num_taxon'],$row['famille'], $row['location'], $row['id_location'], $row['ordre'], $row['date_observation'],$row['lieudit'], $row['station'], $row['milieu'], $row['commentaire'], $row['coord_x'],$row['coord_y']);
-
 
52
    	    }
-
 
53
 
-
 
Line 54... Line 31...
54
			$output = json_encode($value);
31
 
Line -... Line 32...
-
 
32
	   	// Controle detournement utilisateur
-
 
33
	    session_start();
-
 
34
	 	$this->controleUtilisateur($uid[0]);
-
 
35
 
-
 
36
		$value=array();
-
 
37
 
-
 
38
		if(!isset($uid[0])) {
-
 
39
			return;
-
 
40
		}
-
 
41
		
-
 
42
		$parametres_recherche = array(array('ce_utilisateur',$uid[0]),array('ordre',$uid[1]));
-
 
43
		
-
 
44
		$chercheur_observations = new RechercheObservation($this->config);
-
 
45
    	$retour_recherche = $chercheur_observations->rechercherObservations($uid[0], $parametres_recherche, 0, 1);
-
 
46
    	
-
 
47
    	$observation = array();
-
 
48
    	if(is_array($retour_recherche) && count($retour_recherche) > 0) {
-
 
49
    		$observation = $retour_recherche[0];
-
 
50
    	}
Line -... Line 51...
-
 
51
    	
55
			
52
        $observation = $this->formaterObservationVersTableauSequentiel(&$observation);
-
 
53
		$output = json_encode($observation);
-
 
54
		
-
 
55
		header("Content-type: application/json");
-
 
56
		print($output);
-
 
57
 
-
 
58
		return true;
-
 
59
	}
-
 
60
	
Line -... Line 61...
-
 
61
	private function formaterObservationVersTableauSequentiel($observation) {
-
 
62
		
-
 
63
    	if ($observation['date_observation']!="0000-00-00 00:00:00") {
-
 
64
            list($year,$month,$day)= split ('-',$observation['date_observation']);
-
 
65
            list($day)= split (' ',$day);
-
 
66
            $observation['date_observation']=$day."/".$month."/".$year;
-
 
67
    	}
56
			header("Content-type: application/json");
68
 
57
			print($output);
-
 
58
 
69
     	$observation = array($observation['nom_sel'], $observation['nom_sel_nn'],
-
 
70
     				$observation['nom_ret'], $observation['nom_ret_nn'],
59
			return true;
71
     				$observation['nt'], $observation['famille'], $observation['zone_geo'],
Line 60... Line -...
60
 
-
 
61
 
72
     				$observation['ce_zone_geo'], $observation['ordre'],
Line 62... Line 73...
62
	}
73
     				$observation['date_observation'], $observation['lieudit'],
63
 
74
     				$observation['station'], $observation['milieu'],
64
	function getRessource(){
75
     				$observation['commentaire'], $observation['latitude'],
65
 
-
 
66
 
-
 
67
	}
-
 
68
 
-
 
69
 
-
 
70
	function updateElement($uid,$pairs) {
-
 
71
 
-
 
72
		 // Controle detournement utilisateur
-
 
73
			    session_start();
-
 
74
			 	$this->controleUtilisateur($uid[0]);
-
 
75
 
-
 
76
				if ($pairs['num_nom_sel']!='') {
-
 
77
 
-
 
78
 
-
 
79
 
-
 
80
				// Utilisation d'un nom faisant parti du referentiel : recherche du nom valide correspondant
-
 
81
					$complement=$this->rechercherInformationsComplementaires($pairs['num_nom_sel']);
-
 
82
 
-
 
83
 
-
 
84
			        $pairs['nom_ret']=$complement['Nom_Retenu'];
-
 
85
			        $pairs['num_nom_ret']=$complement['Num_Nom_Retenu'];
-
 
86
			        $pairs['num_taxon']=$complement['Num_Taxon'];
-
 
87
			        $pairs['famille']=$complement['Famille'];
-
 
88
 
-
 
89
				}
-
 
90
 
-
 
91
 
-
 
92
 
-
 
93
 
-
 
94
				$DB=$this->connectDB($this->config,'database_cel');
-
 
95
 
-
 
96
                // Nullifiage ...
-
 
97
 
-
 
98
				foreach($pairs as $k=>$v) {
-
 
99
					if (trim($v)=="") {
-
 
100
						$pairs[$k]="null";
-
 
101
					}
-
 
102
 
-
 
103
				}
-
 
104
 
-
 
105
				// Pour apparaitre le premier dans les tris ...
-
 
106
                if ($pairs['location']=="null") $pairs['location']="000null";
-
 
107
 
-
 
108
 
-
 
109
				// Pour apparaitre le premier dans les tris ...
-
 
110
                if ($pairs['lieudit']=="null") $pairs['lieudit']="000null";
-
 
111
 
-
 
112
 
-
 
113
				// Pour apparaitre le premier dans les tris ...
-
 
114
                if ($pairs['id_location']=="null") {
-
 
115
                	$pairs['id_location']="000null";
-
 
116
                } else {
-
 
117
                	// Pour empecher que des numéros de département de 1 à 9 soient saisis sans 0
-
 
118
                	if (strlen($pairs['id_location']) == 1) {
-
 
119
                		$pairs['id_location'] = '0'.$pairs['id_location'];
-
 
120
                	}
-
 
121
                }
-
 
122
 
-
 
123
                // Pour apparaitre le premier dans les tris ...
-
 
124
                if ($pairs['station']=="null") $pairs['station']="000null";
-
 
125
 
-
 
126
 
-
 
127
              	// Pour apparaitre le premier dans les tris ...
-
 
128
                if ($pairs['milieu']=="null") $pairs['milieu']="000null";
-
 
129
 
-
 
130
                // Pour supprimer les séparateurs de mots clés en trop
-
 
131
                if (isset($pairs['mot_cles'])) {
-
 
132
                	$pairs['mot_cles'] = str_replace(';;',';',$pairs['mot_cles']);
-
 
133
                }
-
 
134
 
-
 
135
                // TODO : decouper avec les /
-
 
136
 
-
 
137
                if ($pairs['date_observation']!="null") {
-
 
138
                	list($jour,$mois,$annee)=split("/",$pairs['date_observation']);
-
 
139
                	$pairs['date_observation']=$annee."-".$mois."-".$jour." 0:0:0";
-
 
140
                }
-
 
141
 
-
 
142
                if ($pairs['coord_x']=="null") {
-
 
143
					$pairs['coord_x'] = "000null";
-
 
144
                }
-
 
145
 
-
 
146
                if ($pairs['coord_y']=="null") {
-
 
147
					$pairs['coord_y'] = "000null";
-
 
148
                }
-
 
149
 
-
 
150
				$query="UPDATE cel_inventory SET nom_sel = '".$DB->escapeSimple($pairs['nom_sel'])."',".
-
 
151
				"num_nom_sel = '".$DB->escapeSimple($pairs['num_nom_sel'])."',".
-
 
152
				"nom_ret = '".$DB->escapeSimple($pairs['nom_ret'])."',".
-
 
153
				"num_nom_ret = '".$DB->escapeSimple($pairs['num_nom_ret'])."',".
-
 
154
				"num_taxon = '".$DB->escapeSimple($pairs['num_taxon'])."',".
-
 
155
				"famille = '".$DB->escapeSimple($pairs['famille'])."',".
-
 
156
				"location = '".$DB->escapeSimple($pairs['location'])."',".
-
 
157
				"id_location = '".$DB->escapeSimple($pairs['id_location'])."',".
-
 
158
				"date_observation = '".$DB->escapeSimple($pairs['date_observation'])."',".
-
 
159
				"lieudit = '".$DB->escapeSimple($pairs['lieudit'])."',".
-
 
160
				"station = '".$DB->escapeSimple($pairs['station'])."',".
-
 
161
				"milieu = '".$DB->escapeSimple($pairs['milieu'])."',".
-
 
162
				"commentaire = '".$DB->escapeSimple($pairs['commentaire'])."',".
-
 
163
				"date_modification = now() ,".
-
 
Line -... Line 76...
-
 
76
     				$observation['longitude']);
-
 
77
	    
-
 
78
	    return $observation;
-
 
79
	}
-
 
80
 
-
 
81
	function updateElement($uid,$pairs) {
-
 
82
 
-
 
83
		// Controle detournement utilisateur
-
 
84
	    session_start();
-
 
85
	 	$this->controleUtilisateur($uid[0]);
-
 
86
 
164
				"mots_cles = '".$DB->escapeSimple($pairs['mots_cles'])."',".
87
        if (!isset($uid[1])) {
Line 165... Line 88...
165
				"coord_x='".$DB->escapeSimple($pairs['coord_x'])."',".
88
			//TODO: envoyer un message d'erreur
Line 166... Line -...
166
				"coord_y='".$DB->escapeSimple($pairs['coord_y'])."' ".
-
 
167
				"WHERE ordre = '".$DB->escapeSimple($uid[1])."' AND identifiant='".$DB->escapeSimple($uid[0])."'";
-
 
168
 
-
 
169
		    	$res =& $DB->query($query);
-
 
170
                if (PEAR::isError($res)) {
-
 
171
                	$this->logger("CEL_bugs","Erreur de modification d'une observation :".$res->getMessage()." ".$query);
-
 
172
                }
-
 
173
                return	true;
-
 
174
 
-
 
175
	}
-
 
176
 
-
 
177
 
-
 
178
	function createElement($pairs){
-
 
179
 
-
 
180
 
-
 
181
			 // Controle detournement utilisateur
-
 
182
			    session_start();
-
 
183
			 	$this->controleUtilisateur($pairs['identifiant']);
-
 
184
			 	
-
 
185
			 					
-
 
186
				if (($pairs['num_nom_sel'] == '' || $pairs['num_nom_sel'] == 0) && $pairs['nom_sel'] != '') {
-
 
187
 
-
 
188
					// Utilisation d'un nom sans numéro nomenclatural, recherche d'une correspondance sur le nom
-
 
189
					$complement=$this->rechercherInformationsComplementairesSurNom($pairs['nom_sel']);
-
 
190
 
-
 
191
					// Si l'on a trouvé un résultat sur la recherche, il s'agit vraisemblablement d'un copié-collé
-
 
192
					// de nom de taxon qui n'a pas été validé par la selection
-
 
193
					if(count($complement) > 0) {
-
 
194
						$pairs['num_nom_sel'] = $complement[0][0];
-
 
195
					}
-
 
196
					
-
 
197
 
-
 
198
				}
-
 
199
 
-
 
200
				if ($pairs['num_nom_sel']!='') {
-
 
201
					
-
 
202
					// Utilisation d'un nom faisant parti du referentiel : recherche du nom valide correspondant
-
 
203
					$complement=$this->rechercherInformationsComplementaires($pairs['num_nom_sel']);
-
 
204
 
-
 
205
 
-
 
206
			        $pairs['nom_ret']=$complement['Nom_Retenu'];
-
 
207
			        $pairs['num_nom_ret']=$complement['Num_Nom_Retenu'];
-
 
208
			        $pairs['num_taxon']=$complement['Num_Taxon'];
-
 
209
			        $pairs['famille']=$complement['Famille'];
-
 
210
 
-
 
211
				}
-
 
212
 
-
 
213
				// Dernier numero d'ordre utilise :
-
 
214
 
-
 
215
                $DB=$this->connectDB($this->config,'database_cel');
-
 
216
	           	$query="SELECT max(ordre) AS ordre FROM cel_inventory WHERE identifiant='".$DB->escapeSimple($pairs['identifiant'])."' ";
-
 
217
 
-
 
218
			    $res =& $DB->query($query);
-
 
219
                if (DB::isError($res)) {
-
 
220
	    	        die($res->getMessage());
-
 
221
    	    	}
-
 
222
    	    	$row['ordre']=0;
-
 
223
	    	    while ($row =& $res->fetchrow(DB_FETCHMODE_ASSOC)) {
-
 
224
            	    $pairs['ordre']=$row['ordre']+1;
-
 
225
    	    	}
-
 
226
 
-
 
227
                // Nullifiage ...
-
 
228
 
-
 
229
				foreach($pairs as $k=>$v) {
-
 
230
					if (trim($v)=="") {
-
 
231
						$pairs[$k]="null";
-
 
232
					}
-
 
233
 
-
 
234
				}
-
 
235
 
-
 
236
				// Pour apparaitre le premier dans les tris ...
-
 
237
                if ($pairs['location']=="null") $pairs['location']="000null";
-
 
238
 
-
 
239
 
-
 
240
				// Pour apparaitre le premier dans les tris ...
-
 
241
                if ($pairs['lieudit']=="null") $pairs['lieudit']="000null";
-
 
242
 
-
 
243
 
-
 
244
				// Pour apparaitre le premier dans les tris ...
-
 
245
                if ($pairs['id_location']=="null") {
-
 
246
                	$pairs['id_location']="000null";
-
 
247
                } else {
-
 
248
                	// Pour empecher que des numéros de département de 1 à 9 soient saisis sans 0
-
 
249
                	if (strlen($pairs['id_location']) == 1) {
-
 
250
                		$pairs['id_location'] = '0'.$pairs['id_location'];
-
 
251
                	}
-
 
252
                }
-
 
253
 
-
 
254
				// Pour apparaitre le premier dans les tris ...
-
 
255
                if ($pairs['station']=="null") $pairs['station']="000null";
-
 
256
 
-
 
257
 
-
 
258
				// Pour apparaitre le premier dans les tris ...
-
 
259
                if ($pairs['milieu']=="null") $pairs['milieu']="000null";
-
 
260
 
-
 
261
 
-
 
262
                // TODO : decouper avec les /
-
 
263
 
-
 
264
                if ($pairs['date_observation']!="null") {
-
 
265
 
-
 
266
                	list($jour,$mois,$annee)=split("/",$pairs['date_observation']);
-
 
267
                	$pairs['date_observation']=$annee."-".$mois."-".$jour." 0:0:0";
-
 
268
 
-
 
269
                }
-
 
270
 
-
 
271
                if ($pairs['coord_x']=="null") {
-
 
272
					$pairs['coord_x'] = "000null";
-
 
273
                }
-
 
274
 
-
 
275
                if ($pairs['coord_y']=="null") {
-
 
276
					$pairs['coord_y'] = "000null";
-
 
277
                }
-
 
278
 
-
 
279
                $query  = "INSERT INTO cel_inventory (identifiant,ordre,nom_sel,num_nom_sel,nom_ret,num_nom_ret,num_taxon,famille,location,id_location,date_observation,lieudit,station, milieu, commentaire, date_creation,date_modification,coord_x,coord_y) " .
-
 
280
                " VALUES('".$DB->escapeSimple($pairs['identifiant'])."','".
-
 
281
                $DB->escapeSimple($pairs['ordre'])."','".
-
 
282
                $DB->escapeSimple($pairs['nom_sel'])."','".
-
 
283
                $DB->escapeSimple($pairs['num_nom_sel'])."','".
-
 
284
                $DB->escapeSimple($pairs['nom_ret'])."','".
-
 
285
                $DB->escapeSimple($pairs['num_nom_ret'])."','".
-
 
286
                $DB->escapeSimple($pairs['num_taxon'])."','".
-
 
287
                $DB->escapeSimple($pairs['famille'])."','".
-
 
288
                $DB->escapeSimple($pairs['location'])."','".
-
 
289
                $DB->escapeSimple($pairs['id_location'])."','".
-
 
290
                $DB->escapeSimple($pairs['date_observation'])."','".
-
 
291
                $DB->escapeSimple($pairs['lieudit'])."','".
-
 
292
                $DB->escapeSimple($pairs['station'])."','".
-
 
293
                $DB->escapeSimple($pairs['milieu'])."','".
-
 
294
                $DB->escapeSimple($pairs['commentaire'])."',".
-
 
295
                "now() , now(),'".
-
 
296
				$DB->escapeSimple($pairs['coord_x'])."','".
-
 
297
				$DB->escapeSimple($pairs['coord_y'])."')";
-
 
298
		    	$res =& $DB->query($query);
-
 
299
 
89
			return;	
300
                if (PEAR::isError($res)) {
90
		}
301
                	$this->logger("CEL_bugs","Erreur de creation d'une observation :".$res->getMessage()." ".$query);
91
		
302
                	return false;
92
		$uid[1] = rtrim($uid[1],',');
303
                	//die($res->getMessage());
-
 
304
                }
93
		
305
 
-
 
306
                return	true;
-
 
307
 
-
 
308
	}
-
 
309
 
-
 
310
 
-
 
311
	function deleteElement($uid){
-
 
312
 
-
 
313
	 // Controle detournement utilisateur
94
		$gestionnaire_observation = new GestionObservation($this->config);
314
	    session_start();
-
 
315
     $this->controleUtilisateur($uid[0]);
-
 
316
 
-
 
317
		$value=array();
-
 
318
		$DB=$this->connectDB($this->config,'database_cel');
-
 
319
 
-
 
Line 320... Line 95...
320
		if (isset($uid[1])) {
95
		$modification_observation = $gestionnaire_observation->modifierObservation($uid[0],$uid[1],$pairs);	
321
	           	$query="DELETE FROM cel_inventory WHERE identifiant='".$DB->escapeSimple($uid[0])."' AND ordre in (".$DB->escapeSimple($uid[1]) .")";
-
 
322
		}
-
 
323
 
96
       	 
Line -... Line 97...
-
 
97
        return true;
-
 
98
	}
-
 
99
 
-
 
100
 
-
 
101
	function createElement($pairs){
-
 
102
 
-
 
103
	 	// Controle detournement utilisateur
Line 324... Line -...
324
    	$res =& $DB->query($query);
-
 
325
 
-
 
326
        if (PEAR::isError($res)) {
-
 
327
        	$this->logger("CEL_bugs","Erreur de suppression d'une observation :".$res->getMessage()." ".$query);
-
 
328
        	return false;
-
 
329
        }
-
 
330
        else {
-
 
331
        	echo "OK" ;
-
 
332
        	exit() ;
-
 
333
        }
-
 
334
 
-
 
335
        return true;
-
 
336
 
-
 
337
 
-
 
338
	}
-
 
339
 
-
 
340
 
-
 
341
	function rechercherInformationsComplementaires($numNom) {
-
 
342
 
-
 
343
		$DB=$this->connectDB($this->config);
-
 
344
 
-
 
345
		$query = "SELECT DISTINCT en_nom_genre, en_epithete_espece, en_nom_supra_generique, en_epithete_infra_generique,".
104
	    session_start();
346
			     	       			"   auteur_bex.enaia_intitule_abrege AS abreviation_auteur_basio_ex ".
-
 
347
        	       			" , auteur_b.enaia_intitule_abrege AS abreviation_auteur_basio ".
-
 
348
        	       			" , auteur_mex.enaia_intitule_abrege AS abreviation_auteur_modif_ex ".
-
 
349
        	       			" , auteur_m.enaia_intitule_abrege AS abreviation_auteur_modif ".
-
 
350
			     " , en_epithete_espece, en_epithete_infra_specifique, enrg_abreviation_rang, b.esn_id_taxon, b.esn_id_nom" .
-
 
351
			     " FROM eflore_nom, eflore_nom_rang," .
-
 
352
			       			"  	  eflore_naturaliste_intitule_abreviation AS auteur_bex ".
-
 
353
        	       			"   , eflore_naturaliste_intitule_abreviation AS auteur_b ".
-
 
354
        	       			"   , eflore_naturaliste_intitule_abreviation AS auteur_mex ".
-
 
355
        	       			"   , eflore_naturaliste_intitule_abreviation AS auteur_m ".
-
 
356
			     " ,eflore_selection_nom a, eflore_selection_nom b".
-
 
357
			     " WHERE a.esn_id_nom= ".$numNom.
-
 
358
			     " AND a.esn_id_version_projet_taxon = 25 ".
-
 
359
			     " AND a.esn_id_taxon=b.esn_id_taxon ".
-
 
360
			     " AND b.esn_ce_statut=3 ".
-
 
361
			     " AND a.esn_id_version_projet_taxon=b.esn_id_version_projet_taxon" .
-
 
362
			     " AND en_ce_rang = enrg_id_rang" .
105
	 	$this->controleUtilisateur($pairs['ce_utilisateur']);
363
			     " AND en_id_nom = b.esn_id_nom" .
-
 
364
			     " AND en_ce_auteur_basio_ex = auteur_bex.enaia_id_intitule_naturaliste_abrege ".
-
 
365
       			 " AND en_ce_auteur_basio = auteur_b.enaia_id_intitule_naturaliste_abrege  ".
-
 
366
       			 " AND en_ce_auteur_modif_ex = auteur_mex.enaia_id_intitule_naturaliste_abrege ".
-
 
367
        	     " AND en_ce_auteur_modif = auteur_m.enaia_id_intitule_naturaliste_abrege ".
-
 
368
			     " AND a.esn_id_version_projet_taxon=en_id_version_projet_nom ";
-
 
369
 
-
 
370
 
-
 
371
	   $res =& $DB->query($query);
-
 
372
 
-
 
373
 
-
 
374
        if (DB::isError($res)) {
-
 
375
	        die($res->getMessage());
106
	 	
376
    	}
-
 
377
 
-
 
378
    		// Nom retenu, Num Nomen nom retenu, Num Taxon,
-
 
379
										// Famille
-
 
380
 
-
 
381
		$value=array('Nom_Retenu'=>"",'Num_Nom_Retenu'=>"0",'Num_Taxon'=>"0",'Famille'=>"");
-
 
382
 
-
 
383
	        while ($row =& $res->fetchrow(DB_FETCHMODE_ASSOC)) {
-
 
384
	        	$fam=$this->rechercherFamille($row['esn_id_taxon'],$DB);
-
 
385
        	while (($fam['en_ce_rang']!='fin') && ($fam['en_ce_rang'] !=120)) {
-
 
386
	        	$fam=$this->rechercherFamille($fam['etr_id_taxon_2'],$DB);
-
 
Line -... Line 107...
-
 
107
	 	$gestionnaire_observation = new GestionObservation($this->config);
387
        	}
108
	 	$gestionnaire_observation->ajouterObservation($pairs['ce_utilisateur'], $pairs);
-
 
109
 
-
 
110
        return true;
Line 388... Line 111...
388
        	if ($fam['en_ce_rang']==120) {
111
	}
Line 389... Line 112...
389
        		$famille=$fam['en_nom_supra_generique'];
112
 
-
 
113
	/**
Line 390... Line -...
390
        	}
-
 
391
        	else {
-
 
392
        		$famille="Famille inconnue";
-
 
393
        	}
-
 
394
        	$value=array('Nom_Retenu'=>$this->formaterNom($row),'Num_Nom_Retenu'=>$row['esn_id_nom'],'Num_Taxon'=>$row['esn_id_taxon'],'Famille'=>$famille);
-
 
395
 
-
 
396
 
-
 
397
	    }
-
 
398
 
-
 
399
	    return $value;
-
 
400
 
114
	* Supprime une observation
401
	}
-
 
402
	
-
 
403
	function rechercherInformationsComplementairesSurNom($nom_saisi) {
-
 
404
		
-
 
405
		$DB=$this->connectDB($this->config);
-
 
406
		
-
 
407
		$value = array();
115
	* 
408
		
116
	* uid[0] : utilisateur obligatoire
409
		if($nom_saisi != null && $nom_saisi != "") { 
-
 
410
		
-
 
411
			$query = 'SELECT * FROM eflore_nom_intitule '.
-
 
412
			'WHERE eni_id_categorie_format = 3 AND '.
-
 
413
			'eni_id_version_projet_nom = 25 AND '.
-
 
414
			'(eni_id_valeur_format = 3 OR eni_id_valeur_format = 4) AND '.
-
 
415
			'eni_intitule_nom LIKE "'.$nom_saisi.'%" '.
-
 
416
			'ORDER BY LENGTH(eni_intitule_nom)';
-
 
417
			
-
 
418
			$res =& $DB->query($query);
-
 
419
			    
-
 
420
			    
-
 
421
	        if (DB::isError($res)) {
-
 
422
    	        die($res->getMessage());
-
 
423
        	}
-
 
424
        	
-
 
425
	        while ($row =& $res->fetchrow(DB_FETCHMODE_ASSOC)) {
-
 
426
	        	$value[]=array($row['eni_id_nom'], $row['eni_intitule_nom']);
-
 
427
    	    
-
 
428
	        }
-
 
429
		}
-
 
430
	                
-
 
431
		return $value;
-
 
432
	}
-
 
433
 
-
 
434
 
-
 
435
function formaterNom($rawnom) {
-
 
436
 
-
 
437
 
-
 
438
                // Constitution du nom:
-
 
439
                $nom = '';
-
 
440
 
-
 
441
                if ($rawnom['en_nom_supra_generique'] != '') {
-
 
442
                    $nom .= $rawnom['en_nom_supra_generique'];
-
 
443
                } else if ($rawnom['en_epithete_infra_generique'] != '') {
-
 
444
                    $nom .= $rawnom['en_epithete_infra_generique'];
-
 
445
                } else {
-
 
446
                        if ($rawnom['en_nom_genre'] != '') {
-
 
447
                            $nom .=  $rawnom['en_nom_genre'];
-
 
448
                        }
-
 
449
                        if ($rawnom['en_epithete_espece']!= '') {
-
 
450
                            $nom .= ' '.$rawnom['en_epithete_espece'];
-
 
451
                        }
-
 
452
                        if ($rawnom['en_epithete_infra_specifique'] != '') {
-
 
453
                                if (!empty($rawnom['enrg_abreviation_rang'])) {
-
 
454
                                        $nom .= ' '.$rawnom['enrg_abreviation_rang'].'';
-
 
455
                                }
-
 
456
                                $nom .= ' '.$rawnom['en_epithete_infra_specifique'];
-
 
457
                        }
-
 
458
 
-
 
459
                }
-
 
460
 
-
 
461
                return $nom .$this->retournerAuteur($rawnom) ;
-
 
462
 
-
 
463
 }
-
 
464
 
-
 
465
 
117
	* uid[1] : ordres de l'observation à supprimer
466
function rechercherFamille($taxon,&$DB) {
-
 
467
 
-
 
468
	$row=array();
-
 
469
 
118
	*/ 
470
	$query="SELECT DISTINCT en_ce_rang, etr_id_taxon_2, en_id_nom, en_nom_supra_generique ".
-
 
471
	" FROM eflore_taxon_relation, eflore_selection_nom, eflore_nom ".
-
 
472
	" WHERE etr_id_taxon_1 = ".$taxon.
-
 
473
	" AND etr_id_version_projet_taxon_1 = 25 ".
-
 
474
	" AND etr_id_categorie_taxon = 3 ".
-
 
475
	" AND etr_id_valeur_taxon = 3 ".
-
 
476
	" AND esn_id_taxon =  etr_id_taxon_2 ".
-
 
477
	" AND esn_ce_statut = 3 ".
-
 
478
	" AND esn_id_version_projet_taxon = etr_id_version_projet_taxon_1 ".
-
 
479
	" AND en_id_nom = esn_id_nom ".
-
 
480
	" AND esn_id_version_projet_taxon=en_id_version_projet_nom  ";
-
 
481
	$res =& $DB->query($query);
-
 
482
 
-
 
483
	if (DB::isError($res)) {
-
 
484
         die($res->getMessage());
-
 
485
   	}
-
 
486
 
-
 
487
	if ($row =& $res->fetchrow(DB_FETCHMODE_ASSOC)) {
-
 
488
		return $row;
-
 
489
    }
-
 
490
    else {
-
 
491
    	$row['en_ce_rang']='fin';
-
 
492
    	return $row;
-
 
493
    }
-
 
494
 
-
 
495
}
-
 
496
 
-
 
497
 
-
 
498
 
-
 
499
function retournerAuteur($rawnom) {
-
 
500
		$auteurs = '';
-
 
501
		$auteur_basio = '';
-
 
502
		$auteur_modif = '';
-
 
503
		if (!empty($rawnom['abreviation_auteur_basio_ex']) && $rawnom['abreviation_auteur_basio_ex']!='-' )  {
-
 
504
		    $auteur_basio .= $rawnom['abreviation_auteur_basio_ex'];
-
 
505
		    if (!empty($rawnom['abreviation_auteur_basio']) && $rawnom['abreviation_auteur_basio']!='-') {
-
 
506
		        $auteur_basio .= ' ex '.$rawnom['abreviation_auteur_basio'];
-
 
507
		    }
119
	function deleteElement($uid){
508
		} else if (!empty($rawnom['abreviation_auteur_basio']) && $rawnom['abreviation_auteur_basio']!='-') {
-
 
509
		    $auteur_basio .= $rawnom['abreviation_auteur_basio'];
-
 
510
		}
-
 
511
 
120
 
512
		if (!empty($rawnom['abreviation_auteur_modif_ex']) && $rawnom['abreviation_auteur_modif_ex']!='-') {
-
 
513
		    $auteur_modif .= $rawnom['abreviation_auteur_modif_ex'];
121
		// Controle detournement utilisateur
514
		    if (!empty($rawnom['abreviation_auteur_modif']) && $rawnom['abreviation_auteur_modif']!='-') {
122
		session_start();
515
		        $auteur_modif .= ' ex '.$rawnom['abreviation_auteur_modif'];
123
		$this->controleUtilisateur($uid[0]);
516
		    }
124
		
517
		} else if (!empty($rawnom['abreviation_auteur_modif']) && $rawnom['abreviation_auteur_modif']!='-')  {
125
		if (!isset($uid[1])) {
Line 540... Line 148...
540
* fin mise en place mygwt
148
* fin mise en place mygwt
541
*
149
*
542
* Revision 1.9  2007-05-22 12:54:09  ddelon
150
* Revision 1.9  2007-05-22 12:54:09  ddelon
543
* Securisation acces utilisateur
151
* Securisation acces utilisateur
544
*
152
*
545
*
-
 
546
*
-
 
547
*/
153
*/
548
 
-
 
549
?>
154
?>
550
155