Subversion Repositories eFlore/Applications.cel

Rev

Rev 1869 | Go to most recent revision | Show entire file | Regard 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) {
-
 
53
		if($type == 'obs') {
-
 
54
			return Cel::db()->requeter(sprintf(
-
 
55
				'SELECT mot_cle, id_mot_cle_obs, ce_mot_cle_obs_parent'.
-
 
56
				' FROM cel_mots_cles_obs'.
-
 
57
				' WHERE id_utilisateur = %s'.
-
 
58
				' ORDER BY niveau',
-
 
59
				Cel::db()->proteger($uid)));
-
 
60
		}
-
 
61
 
46
		$this->setChampsEtTablePourSuffixe($uid[0]);
62
		if($type == 'images') {
47
		
63
			return Cel::db()->requeter(sprintf(
48
		$requete = 	'SELECT mot_cle, id_mot_cle'.$this->suffixe_champ.', ce_mot_cle'.$this->suffixe_champ.'_parent '.
64
				'SELECT mot_cle, id_mot_cle_image, ce_mot_cle_image_parent'.
49
					'FROM cel_mots_cles'.$this->suffixe_table.' '.
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
 
Line 50... Line -...
50
					'WHERE id_utilisateur = '.Cel::db()->proteger($id_utilisateur).' '.
-
 
Line 51... Line 79...
51
					'ORDER BY niveau ';
79
		return array();
52
		
80
	}
-
 
81
 
53
		$resultats_mots_cles = Cel::db()->requeter($requete);
82
 
-
 
83
	static function getMotsClefId($uid, $type, $keyword) {
-
 
84
		if($type == 'obs') {
54
		
85
			$ret = Cel::db()->requeter(sprintf(
-
 
86
				'SELECT mot_cle, id_mot_cle_obs, ce_mot_cle_obs_parent'.
-
 
87
				' FROM cel_mots_cles_obs'.
-
 
88
				' WHERE id_utilisateur = %s'.
55
		if (is_array($resultats_mots_cles)) {
89
				' AND mot_cle = %s'.
Line -... Line 90...
-
 
90
				' ORDER BY niveau',
-
 
91
				Cel::db()->proteger($uid),
-
 
92
				Cel::db()->proteger($keyword) ));
56
			$mots_cles = array();
93
		}
-
 
94
 
57
			foreach($resultats_mots_cles as $mot_cle) {
95
		if($type == 'images') {
-
 
96
			$ret = Cel::db()->requeter(sprintf(
-
 
97
				'SELECT mot_cle, id_mot_cle_image, ce_mot_cle_image_parent'.
-
 
98
				' FROM cel_mots_cles_images'.
58
				$mots_cles[] = $mot_cle;
99
				' WHERE id_utilisateur = %s'.
-
 
100
				' AND mot_cle = %s'.
59
			}
101
				' ORDER BY niveau',
Line 60... Line 102...
60
						
102
				Cel::db()->proteger($uid),
61
			$this->envoyerJson($mots_cles);
103
				Cel::db()->proteger($keyword) ));
62
			return true;
104
		}