Subversion Repositories eFlore/Applications.coel

Rev

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

Rev 1708 Rev 1709
Line 197... Line 197...
197
		if (!$this->etreAutorise($id_utilisateur)) {
197
		if (!$this->etreAutorise($id_utilisateur)) {
198
			$this->envoyer();
198
			$this->envoyer();
199
			return;
199
			return;
200
		}
200
		}
201
		try {
201
		try {
202
			$form_needs_refresh = self::callNominatim($params);
202
			$form_needs_refresh = self::callNominatim($params, $this->bdd);
Line 203... Line 203...
203
 
203
 
Line 204... Line 204...
204
			self::NULLifNotNum($params, self::$optional_bool_fields);
204
			self::NULLifNotNum($params, self::$optional_bool_fields);
205
 
205
 
Line 272... Line 272...
272
		if (!$this->etreAutorise($id_utilisateur)) {
272
		if (!$this->etreAutorise($id_utilisateur)) {
273
			$this->envoyer();
273
			$this->envoyer();
274
			return;
274
			return;
275
		}
275
		}
276
		try {
276
		try {
277
			$form_needs_refresh = self::callNominatim($params);
277
			$form_needs_refresh = self::callNominatim($params, $this->bdd);
Line 278... Line 278...
278
 
278
 
Line 279... Line 279...
279
			self::NULLifNotNum($params, self::$optional_bool_fields);
279
			self::NULLifNotNum($params, self::$optional_bool_fields);
280
 
280
 
Line 365... Line 365...
365
            'SELECT COUNT(cc_id_collection) AS nbre_collection FROM coel_collection ' .
365
            'SELECT COUNT(cc_id_collection) AS nbre_collection FROM coel_collection ' .
366
            ' WHERE cc_ce_structure = %d GROUP BY cc_ce_structure ',
366
            ' WHERE cc_ce_structure = %d GROUP BY cc_ce_structure ',
367
            $id_structure))->fetchColumn() != 0);
367
            $id_structure))->fetchColumn() != 0);
368
	}
368
	}
Line 369... Line 369...
369
 
369
 
370
	static function callNominatim(&$params) {
370
	static function callNominatim(&$params, $db = NULL) {
371
		if (
371
        // lon/lat déjà saisies ?
-
 
372
		if (@$params['cs_latitude'] && @$params['cs_longitude']) return FALSE;
-
 
373
 
372
            (! @$params['cs_latitude'] || ! @$params['cs_longitude']) &&
374
        // ni adresse, ni CP, ni ville ? rien n'est possible
-
 
375
        if (!@$params['cs_adresse_01'] && !@$params['cs_code_postal'] && !@$params['cs_ville']) return FALSE;
373
            (@$params['cs_adresse_01'] || @$params['cs_code_postal'] || @$params['cs_ville']) ) {
376
 
374
			$lonlat = array();
377
        $lonlat = array();
375
			if(Coel::coordGuess(Coel::addrReStruct($params), $lonlat)) {
378
        if(Coel::coordGuess(Coel::addrReStruct($params, $db), $lonlat)) {
376
				$params['cs_latitude'] = $lonlat['lat'];
379
            $params['cs_latitude'] = $lonlat['lat'];
377
				$params['cs_longitude'] = $lonlat['lon'];
380
            $params['cs_longitude'] = $lonlat['lon'];
378
				return TRUE;
381
            return TRUE;
379
			}
382
        }
-
 
383
 
-
 
384
        // second guess, sans code postal
-
 
385
        if(@$params['cs_code_postal']) {
-
 
386
            $params2 = $params;
-
 
387
            unset($params2['cs_code_postal']);
-
 
388
            if(Coel::coordGuess(Coel::addrReStruct($params2, $db), $lonlat)) {
-
 
389
                $params['cs_latitude'] = $lonlat['lat'];
-
 
390
                $params['cs_longitude'] = $lonlat['lon'];
-
 
391
                return TRUE;
-
 
392
            }
380
		}
393
        }
381
		return FALSE;
394
		return FALSE;
Line 382... Line 395...
382
	}
395
	}
383
	
396