Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 943 Rev 951
Line 51... Line 51...
51
	}
51
	}
Line 52... Line 52...
52
 
52
 
53
	//+----------------------------------------------------------------------------------------------------------------+
53
	//+----------------------------------------------------------------------------------------------------------------+
Line 54... Line 54...
54
	// GESTION de la BASE de DONNÉES
54
	// GESTION de la BASE de DONNÉES
55
 
55
 
56
	private function connecterPDO($config, $base = 'database') {
56
	protected function connecterPDO($config, $base = 'database_cel') {
57
        $cfg = $config[$base];
57
        $cfg = $config[$base];
58
        // ATTENTION : la connexin à la bdd peut échouer si l'host vaut localhost. Utiliser 127.0.0.1 à la place.
58
        // ATTENTION : la connexin à la bdd peut échouer si l'host vaut localhost. Utiliser 127.0.0.1 à la place.
59
		$dsn = $cfg['phptype'].':dbname='.$cfg['database'].';host='.$cfg['hostspec'];
59
		$dsn = $cfg['phptype'].':dbname='.$cfg['database'].';host='.$cfg['hostspec'];
Line 447... Line 447...
447
									 'WHERE id_utilisateur = '.$this->proteger($id_utilisateur);
447
									 'WHERE id_utilisateur = '.$this->proteger($id_utilisateur);
Line 448... Line 448...
448
									 
448
									 
Line 449... Line 449...
449
		$resultat_infos_utilisateur = $this->requeter($requete_infos_utilisateur);
449
		$resultat_infos_utilisateur = $this->requeter($requete_infos_utilisateur);
450
		
450
		
451
			if($resultat_infos_utilisateur && is_array($resultat_infos_utilisateur) && count($resultat_infos_utilisateur) > 0) {
451
			if($resultat_infos_utilisateur && is_array($resultat_infos_utilisateur) && count($resultat_infos_utilisateur) > 0) {
452
				$infos_utilisateur = $resultat_infos_utilisateur;
452
				$infos_utilisateur = $resultat_infos_utilisateur[0];
Line 453... Line 453...
453
			}
453
			}
454
		}
454
		}
Line 473... Line 473...
473
	}
473
	}
Line 474... Line 474...
474
 
474
 
475
	//+----------------------------------------------------------------------------------------------------------------+
475
	//+----------------------------------------------------------------------------------------------------------------+
Line -... Line 476...
-
 
476
	// GESTION DE MÉTHODES COMMUNES ENTRE LES SERVICES
-
 
477
	
-
 
478
	protected function denullifierTableauValeurCel($tableau) {
-
 
479
		
-
 
480
		// Denullifiage
-
 
481
		foreach($tableau as $k=>$v) {
-
 
482
			if (($v=="null") || ($v=="000null")) {
-
 
483
				$row[$k]="";
-
 
484
			}
-
 
485
			else {
-
 
486
				$row[$k]=utf8_decode($v);
-
 
487
			}
-
 
488
		}
-
 
489
		
-
 
490
		return $tableau;
476
	// GESTION DE MÉTHODES COMMUNES ENTRE LES SERVICES
491
	}
477
	
492
	
478
	protected function getUrlImage($id, $format = 'L') {
493
	protected function getUrlImage($id, $format = 'L') {
479
		$url_tpl = $this->config['settings']['celImgUrlTpl'];
494
		$url_tpl = $this->config['settings']['celImgUrlTpl'];
480
		$id = sprintf('%09s', $id).$format;
495
		$id = sprintf('%09s', $id).$format;
Line 490... Line 505...
490
	 */
505
	 */
491
	protected function creerAuteurs(Array $courriels) {
506
	protected function creerAuteurs(Array $courriels) {
492
		$auteurs = array();
507
		$auteurs = array();
493
		if ($identites = $this->recupererUtilisateursIdentite($courriels)) {
508
		if ($identites = $this->recupererUtilisateursIdentite($courriels)) {
494
			foreach ($identites as $courriel => $infos) {
509
			foreach ($identites as $courriel => $infos) {
495
				$auteurs[$courriel] = $info['identite'];
510
				$auteurs[$courriel] = $infos['intitule'];
496
			}
511
			}
497
		}
512
		}
498
		return $auteurs;
513
		return $auteurs;
499
	}
514
	}
Line 503... Line 518...
503
		$service = "utilisateur/identite-par-courriel/".implode(',', $courriels);
518
		$service = "utilisateur/identite-par-courriel/".implode(',', $courriels);
504
		$url = sprintf($this->config['settings']['baseURLServicesAnnuaireTpl'], $service);
519
		$url = sprintf($this->config['settings']['baseURLServicesAnnuaireTpl'], $service);
505
		$json = file_get_contents($url);
520
		$json = file_get_contents($url);
506
		$utilisateurs = json_decode($json);
521
		$utilisateurs = json_decode($json);
507
		foreach ($courriels as $courriel) {
522
		foreach ($courriels as $courriel) {
508
			$info = array('id' => null, 'identite' => '');
523
			$info = array('id' => null, 'intitule' => '');
509
			if (isset($utilisateurs->$courriel)) {
524
			if (isset($utilisateurs->$courriel)) {
510
				$info['intitule'] = $utilisateurs->$courriel->intitule;
525
				$info['intitule'] = $utilisateurs->$courriel->intitule;
511
				$info['id'] = $utilisateurs->$courriel->id;
526
				$info['id'] = $utilisateurs->$courriel->id;
512
			} else {
527
			} else {
513
				$info['intitule'] = $this->tronquerCourriel($courriel);
528
				$info['intitule'] = $this->tronquerCourriel($courriel);
Line 582... Line 597...
582
			$date_formatee = strftime($format, $timestamp);
597
			$date_formatee = strftime($format, $timestamp);
583
		}
598
		}
584
		return $date_formatee;
599
		return $date_formatee;
585
	}
600
	}
Line -... Line 601...
-
 
601
	
-
 
602
	protected function convertirCodeZoneGeoVersDepartement($code_zone_geo) {
-
 
603
		
-
 
604
		$code_departement = '';
-
 
605
		if($this->estUnCodeInseeDepartement($code_zone_geo)) {			
-
 
606
			$code_departement = substr(ltrim($code_zone_geo,'INSEE-C:'),0,2);
-
 
607
		}
-
 
608
		
-
 
609
		return $code_departement;
-
 
610
	}
-
 
611
	
-
 
612
	protected function estUnCodeInseeDepartement($code_a_tester) {
-
 
613
		return preg_match('/^INSEE-C:[0-9]{5}/',$code_a_tester);
-
 
614
	}
586
	
615
	
587
	protected function encoderMotCle($mot_cle) {
616
	protected function encoderMotCle($mot_cle) {
588
		return md5(mb_strtolower(trim($mot_cle)));
617
		return md5(mb_strtolower(trim($mot_cle)));
Line 589... Line 618...
589
	}
618
	}