Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 1869 Rev 1872
Line 40... Line 40...
40
 
40
 
41
	public function getElement($uid) {
41
	public function getElement($uid) {
42
		// Controle detournement utilisateur
42
		// Controle detournement utilisateur
43
		$id_utilisateur = $uid[1] ;
43
		$id_utilisateur = $uid[1] ;
44
		$this->controleUtilisateur($uid[1]);
-
 
45
		
44
		$this->controleUtilisateur($uid[1]);
Line -... Line 45...
-
 
45
		$this->setChampsEtTablePourSuffixe($uid[0]);
-
 
46
		
-
 
47
		$this->envoyerJson(self::getMotsClefs($uid[1], $uid[0]));
-
 
48
		return TRUE; // compat: pourquoi renvoyer true si vide ?
-
 
49
	}
-
 
50
 
-
 
51
 
-
 
52
	static function getMotsClefs($uid, $type) {
46
		$this->setChampsEtTablePourSuffixe($uid[0]);
53
		if($type == 'obs') {
47
		
54
			return Cel::db()->requeter(sprintf(
48
		$requete = 	'SELECT mot_cle, id_mot_cle'.$this->suffixe_champ.', ce_mot_cle'.$this->suffixe_champ.'_parent '.
55
				'SELECT mot_cle, id_mot_cle_obs, ce_mot_cle_obs_parent'.
49
					'FROM cel_mots_cles'.$this->suffixe_table.' '.
56
				' FROM cel_mots_cles_obs'.
-
 
57
				' WHERE id_utilisateur = %s'.
-
 
58
				' ORDER BY niveau',
50
					'WHERE id_utilisateur = '.Cel::db()->proteger($id_utilisateur).' '.
59
				Cel::db()->proteger($uid)));
-
 
60
		}
51
					'ORDER BY niveau ';
61
 
-
 
62
		if($type == 'images') {
-
 
63
			return Cel::db()->requeter(sprintf(
-
 
64
				'SELECT mot_cle, id_mot_cle_image, ce_mot_cle_image_parent'.
-
 
65
				' FROM cel_mots_cles_images'.
-
 
66
				' WHERE id_utilisateur = %s'.
-
 
67
				' ORDER BY niveau',
-
 
68
				Cel::db()->proteger($uid)));
-
 
69
		}
-
 
70
		/* pour extraire un mot-clef en particulier (bien que getMotsClefId() soit plus adapté:
-
 
71
		array_walk($ret,
-
 
72
				   create_function('&$val, $k, $keyword',
-
 
73
								   'if($val["mot_cle"] != $keyword) $val = NULL;' .
-
 
74
								   'else $val = $val["id_mot_cle_obs"];'),
-
 
75
				   'XXX');
-
 
76
		$obsKeywordIdToDetach = array_filter($ret);
-
 
77
		$obsKeywordIdToDetach = array_pop($obsKeywordIdToDetach); */
-
 
78
 
-
 
79
		return array();
52
		
80
	}
53
		$resultats_mots_cles = Cel::db()->requeter($requete);
81
 
54
		
82
 
-
 
83
	static function getMotsClefId($uid, $type, $keyword) {
55
		if (is_array($resultats_mots_cles)) {
84
		if($type == 'obs') {
-
 
85
			$ret = Cel::db()->requeter(sprintf(
-
 
86
				'SELECT mot_cle, id_mot_cle_obs, ce_mot_cle_obs_parent'.
56
			$mots_cles = array();
87
				' FROM cel_mots_cles_obs'.
-
 
88
				' WHERE id_utilisateur = %s'.
-
 
89
				' AND mot_cle = %s'.
-
 
90
				' ORDER BY niveau',
57
			foreach($resultats_mots_cles as $mot_cle) {
91
				Cel::db()->proteger($uid),
58
				$mots_cles[] = $mot_cle;
92
				Cel::db()->proteger($keyword) ));
-
 
93
		}
-
 
94
 
-
 
95
		if($type == 'images') {
59
			}
96
			$ret = Cel::db()->requeter(sprintf(
-
 
97
				'SELECT mot_cle, id_mot_cle_image, ce_mot_cle_image_parent'.
60
						
98
				' FROM cel_mots_cles_images'.
-
 
99
				' WHERE id_utilisateur = %s'.
-
 
100
				' AND mot_cle = %s'.
-
 
101
				' ORDER BY niveau',
61
			$this->envoyerJson($mots_cles);
102
				Cel::db()->proteger($uid),
-
 
103
				Cel::db()->proteger($keyword) ));
62
			return true;
104
		}
Line 63... Line 105...
63
		}
105
		return @$ret[0]['id_mot_cle_obs'];
64
	}
106
	}
65
 
107