New file |
0,0 → 1,92 |
<?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 demandes |
class 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 nom qui commmencent selon la valeur |
* |
*/ |
function getElement($uid){ |
|
// Controle detournement utilisateur |
session_start(); |
$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]; |
} |
|
} |
|
$output = json_encode($referentiel); |
print($output); |
} |
|
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) != ""); |
} |
} |
|
|
/* +--Fin du code ---------------------------------------------------------------------------------------+ |
* $Log$ |
* Revision 1.3 2008-01-30 08:57:28 ddelon |
* fin mise en place mygwt |
* |
* Revision 1.2 2007-05-22 12:54:09 ddelon |
* Securisation acces utilisateur |
* |
*/ |
?> |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |