Subversion Repositories eFlore/Applications.cel

Compare Revisions

Ignore whitespace Rev 1871 → Rev 1872

/trunk/jrest/services/InventoryKeyWordList.php
42,27 → 42,69
// Controle detournement utilisateur
$id_utilisateur = $uid[1] ;
$this->controleUtilisateur($uid[1]);
$this->setChampsEtTablePourSuffixe($uid[0]);
$requete = 'SELECT mot_cle, id_mot_cle'.$this->suffixe_champ.', ce_mot_cle'.$this->suffixe_champ.'_parent '.
'FROM cel_mots_cles'.$this->suffixe_table.' '.
'WHERE id_utilisateur = '.Cel::db()->proteger($id_utilisateur).' '.
'ORDER BY niveau ';
$resultats_mots_cles = Cel::db()->requeter($requete);
if (is_array($resultats_mots_cles)) {
$mots_cles = array();
foreach($resultats_mots_cles as $mot_cle) {
$mots_cles[] = $mot_cle;
}
$this->envoyerJson($mots_cles);
return true;
$this->envoyerJson(self::getMotsClefs($uid[1], $uid[0]));
return TRUE; // compat: pourquoi renvoyer true si vide ?
}
 
 
static function getMotsClefs($uid, $type) {
if($type == 'obs') {
return Cel::db()->requeter(sprintf(
'SELECT mot_cle, id_mot_cle_obs, ce_mot_cle_obs_parent'.
' FROM cel_mots_cles_obs'.
' WHERE id_utilisateur = %s'.
' ORDER BY niveau',
Cel::db()->proteger($uid)));
}
 
if($type == 'images') {
return Cel::db()->requeter(sprintf(
'SELECT mot_cle, id_mot_cle_image, ce_mot_cle_image_parent'.
' FROM cel_mots_cles_images'.
' WHERE id_utilisateur = %s'.
' ORDER BY niveau',
Cel::db()->proteger($uid)));
}
/* pour extraire un mot-clef en particulier (bien que getMotsClefId() soit plus adapté:
array_walk($ret,
create_function('&$val, $k, $keyword',
'if($val["mot_cle"] != $keyword) $val = NULL;' .
'else $val = $val["id_mot_cle_obs"];'),
'XXX');
$obsKeywordIdToDetach = array_filter($ret);
$obsKeywordIdToDetach = array_pop($obsKeywordIdToDetach); */
 
return array();
}
 
 
static function getMotsClefId($uid, $type, $keyword) {
if($type == 'obs') {
$ret = Cel::db()->requeter(sprintf(
'SELECT mot_cle, id_mot_cle_obs, ce_mot_cle_obs_parent'.
' FROM cel_mots_cles_obs'.
' WHERE id_utilisateur = %s'.
' AND mot_cle = %s'.
' ORDER BY niveau',
Cel::db()->proteger($uid),
Cel::db()->proteger($keyword) ));
}
 
if($type == 'images') {
$ret = Cel::db()->requeter(sprintf(
'SELECT mot_cle, id_mot_cle_image, ce_mot_cle_image_parent'.
' FROM cel_mots_cles_images'.
' WHERE id_utilisateur = %s'.
' AND mot_cle = %s'.
' ORDER BY niveau',
Cel::db()->proteger($uid),
Cel::db()->proteger($keyword) ));
}
return @$ret[0]['id_mot_cle_obs'];
}
 
public function updateElement($uid, $pairs) {
$id_utilisateur = $uid[1];
$this->controleUtilisateur($uid[1]);