Rev 1014 | Rev 1765 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?php// ATTENTION ! Classe compatible uniquement avec nouveau format de bdd du cel //// in utf8// out utf8// Fournit un référentiel relatif à l'utilisateur sur l'un des champs demandesclass SelfRefList extends Cel {private $referentiels = array('station', 'lieudit', 'milieu');/*** Suivant le type de référentiel donné en paramètre, renvoie les liste de ses éléments** uid[0] : utilisateur obligatoire* uid[1] : referentiel demandé (obligatoire)* $_GET["start"] et $GET_["limit"] : selection intervalle* $_GET["recherche"] : cherche les noms qui commmencent selon la valeur**/function getElement($uid){// Controle detournement utilisateur$this->controleUtilisateur($uid[0]);if (!$this->paramObligatoiresSontPresents($uid)) {return;}if($_GET['recherche'] == '*') {$_GET['recherche'] = '%';}$referentiel_demande = $uid[1];$value=array();$requete_referentiel = "SELECT DISTINCT ".$referentiel_demande." " ."FROM cel_obs WHERE ce_utilisateur = '".$uid[0]."' ";if($this->filtreRechercheEstDemande()) {$requete_referentiel .= " AND ".$referentiel_demande." LIKE '".$_GET["recherche"]."%'";}if ($this->limiteEstDemandee()) {$requete_referentiel .= " ORDER BY '.$referentiel_demande.' LIMIT ".$_GET["start"].",".$_GET["limit"];}$referentiel_resultat = $this->executerRequete($requete_referentiel);$referentiel = array();foreach($referentiel_resultat as $cle => $valeur) {if($this->estUneValeurValide($valeur[$referentiel_demande])) {$referentiel[] = $valeur[$referentiel_demande];}}$this->envoyerJson($referentiel);return true;}function paramObligatoiresSontPresents($uid) {return (isset($uid[1]) && in_array($uid[1],$this->referentiels) && (isset($uid[0]) && $uid[0] != ""));}function filtreRechercheEstDemande() {return (isset($_GET["recherche"]) && trim($_GET["recherche"]) != "");}function limiteEstDemandee() {return isset($_GET["start"]) && is_numeric($_GET["start"]) && isset($_GET["limit"]) && is_numeric($_GET["limit"]);}function estUneValeurValide($chaine) {return ($chaine != null && $chaine != "000null" && trim($chaine) != "");}}?>