Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 1353 Rev 1354
Line 142... Line 142...
142
										$img_a_taguer_ids[] = $idImg;
142
										$img_a_taguer_ids[] = $idImg;
143
									}
143
									}
144
								}
144
								}
145
							}
145
							}
146
						}
146
						}
-
 
147
						
-
 
148
						$obs_a_taguer_ids = $this->obtenirIdsObsPourTableauOrdres($this->utilisateur_id, $obs_a_taguer_ordres);
147
						$this->taguerObs($obs_a_taguer_ordres);
149
						$this->taguerObs($obs_a_taguer_ids);
148
						$this->taguerImg($img_a_taguer_ids);
150
						$this->taguerImg($img_a_taguer_ids);
149
					} else {
151
					} else {
150
						$this->messages[] = "Un nouveau numéro d'ordre d'observation n'a pu être généré.";
152
						$this->messages[] = "Un nouveau numéro d'ordre d'observation n'a pu être généré.";
151
					}
153
					}
152
				} else {
154
				} else {
Line 208... Line 210...
208
			$dateMysql = implode('-', array_reverse($morceauxDate));
210
			$dateMysql = implode('-', array_reverse($morceauxDate));
209
		}
211
		}
210
		return $dateMysql;
212
		return $dateMysql;
211
	}
213
	}
Line 212... Line 214...
212
 
214
 
213
	private function taguerObs($obs_a_taguer_ordres) {
215
	private function taguerObs($obs_a_taguer_ids) {
214
		if (count($obs_a_taguer_ordres) > 0) {
216
		if (count($obs_a_taguer_ids) > 0) {
215
			foreach ($this->tagsObs as $hierarchieTag) {
217
			foreach ($this->tagsObs as $hierarchieTag) {
216
				$tagsALier = explode('>', $hierarchieTag);
218
				$tagsALier = explode('>', $hierarchieTag);
217
				$liaisonOk = $this->lierObsAMotsCles($obs_a_taguer_ordres, $tagsALier);
219
				$liaisonOk = $this->lierObsAMotsCles($obs_a_taguer_ids, $tagsALier);
218
				if ($liaisonOk === false) {
220
				if ($liaisonOk === false) {
219
					$e = "Toutes les observations n'ont pas pu être liées aux mots-clés : $hierarchieTag";
221
					$e = "Toutes les observations n'ont pas pu être liées aux mots-clés : $hierarchieTag";
220
					$this->messages[] = $e;
222
					$this->messages[] = $e;
221
				}
223
				}
222
			}
224
			}
223
		}
225
		}
Line 224... Line 226...
224
	}
226
	}
225
 
227
 
226
	private function lierObsAMotsCles($observations_ordres, $tags) {
228
	private function lierObsAMotsCles($observations_ids, $tags) {
227
		$idTagParent = self::OBS_RACINE_ID;
229
		$idTagParent = self::OBS_RACINE_ID;
228
		$listeIdsTags = array();
230
		$listeIdsTags = array();
229
		foreach ($tags as $tag) {
231
		foreach ($tags as $tag) {
230
			$tag = $this->nettoyerTag($tag);
232
			$tag = $this->nettoyerTag($tag);
231
			//if ($tag != '') {
233
			if ($tag != '') {
232
				$id_mot_cle = $this->ajouterMotCleObs($this->utilisateur_id, $tag, $idTagParent);
234
				$id_mot_cle = $this->ajouterMotCleObs($this->utilisateur_id, $tag, $idTagParent);
233
				/*if ($id_mot_cle !== false) {
235
				if ($id_mot_cle !== false) {
234
					$listeIdsTags[] = $id_mot_cle;
236
					$listeIdsTags[] = $id_mot_cle;
235
					$idTagParent = $id_mot_cle;
237
					$idTagParent = $id_mot_cle;
236
				}*/
238
				}
237
			//}
239
			}
238
		}
240
		}
239
		$liaison_ok = true;//$this->lierMotCleObs($this->utilisateur_id, $listeIdsTags, $observations_ordres);
241
		$liaison_ok = $this->lierMotCleObs($this->utilisateur_id, $listeIdsTags, $observations_ids);
Line 240... Line 242...
240
		return $liaison_ok;
242
		return $liaison_ok;
241
	}
243
	}
Line 257... Line 259...
257
	private function lierImgAMotsCles($images_ids, $tags) {
259
	private function lierImgAMotsCles($images_ids, $tags) {
258
		$idTagParent = self::IMG_RACINE_ID;
260
		$idTagParent = self::IMG_RACINE_ID;
259
		$listeIdsTags = array();
261
		$listeIdsTags = array();
260
		foreach ($tags as $tag) {
262
		foreach ($tags as $tag) {
261
			$tag = $this->nettoyerTag($tag);
263
			$tag = $this->nettoyerTag($tag);
262
			//if ($tag != '') {
264
			if ($tag != '') {
263
				$id_mot_cle = $this->ajouterMotCleImg($this->utilisateur_id, $tag, $idTagParent);
265
				$id_mot_cle = $this->ajouterMotCleImg($this->utilisateur_id, $tag, $idTagParent);
264
				/*if ($id_mot_cle !== false) {
266
				if ($id_mot_cle !== false) {
265
					$listeIdsTags[] = $id_mot_cle;
267
					$listeIdsTags[] = $id_mot_cle;
266
					$idTagParent = $id_mot_cle;
268
					$idTagParent = $id_mot_cle;
267
				}*/
269
				}
268
			//}
270
			}
269
		}
271
		}
270
		$liaison_ok = true;//$this->lierMotCleImg($this->utilisateur_id, $listeIdsTags, $images_ids);
272
		$liaison_ok = $this->lierMotCleImg($this->utilisateur_id, $listeIdsTags, $images_ids);
271
		return $liaison_ok;
273
		return $liaison_ok;
272
	}
274
	}
Line 273... Line 275...
273
 
275
 
274
	private function nettoyerTag($tag) {
276
	private function nettoyerTag($tag) {
Line 331... Line 333...
331
		$resultat = $this->executerRequete($requete);
333
		$resultat = $this->executerRequete($requete);
Line 332... Line 334...
332
		
334
		
333
		$id_obs = (count($resultat) > 0) ? $resultat[0]['id_observation'] : false;
335
		$id_obs = (count($resultat) > 0) ? $resultat[0]['id_observation'] : false;
334
		return $id_obs;
336
		return $id_obs;
-
 
337
	}
-
 
338
	
-
 
339
	private function obtenirIdsObsPourTableauOrdres($id_utilisateur, $ordres) {
-
 
340
		$id_utilisateur = $this->proteger($id_utilisateur);
-
 
341
		$ordres = array_map(array($this,'proteger'), $ordres);
-
 
342
		
-
 
343
		$requete = 'SELECT id_observation '.
-
 
344
							'FROM cel_obs '.
-
 
345
							"WHERE ce_utilisateur = $id_utilisateur ".
-
 
346
							" AND ordre IN (".implode(',',$ordres).") ";
-
 
347
		
-
 
348
		$resultat = $this->executerRequete($requete);
-
 
349
		$ids = array();
-
 
350
		foreach($resultat as $id) {
-
 
351
			$ids[] = $id['id_observation'];
-
 
352
		}
-
 
353
		return $ids;
Line 335... Line 354...
335
	}
354
	}
336
 
355
 
337
	public function nettoyerImagesUploades() {
356
	public function nettoyerImagesUploades() {
338
		$dossierStockage = $this->config['cel']['chemin_stockage_temp'].'/';
357
		$dossierStockage = $this->config['cel']['chemin_stockage_temp'].'/';