Subversion Repositories Applications.bazar

Rev

Rev 468 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
468 mathias 1
Index: bibliotheque/bazar.fonct.rss.php
2
===================================================================
3
--- bibliotheque/bazar.fonct.rss.php	(révision 464)
4
+++ bibliotheque/bazar.fonct.rss.php	(révision 465)
5
@@ -392,7 +392,7 @@
6
 			$res .= '<br />'."\n".'<div class="BAZ_cadre_fiche BAZ_cadre_fiche_'.$GLOBALS['_BAZAR_']['class'].'">'."\n";
7
 			$res .= '<h2 class="BAZ_titre BAZ_titre_'.$GLOBALS['_BAZAR_']['class'].'">'.BAZ_LES_STRUCTURES_POSSEDANT_UNE_RESSOURCE.'</h2>'."\n";
8
 			$requete = 'SELECT '.BAZ_CHAMPS_ID.', '.BAZ_CHAMPS_NOM.' FROM bazar_appropriation,'.BAZ_ANNUAIRE.' WHERE ba_ce_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'].' AND ba_ce_id_structure='.BAZ_CHAMPS_ID.' ORDER BY '.BAZ_CHAMPS_NOM.' ASC';
9
-			$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
10
+			$resultat = $GLOBALS['_BAZAR_']['db']->query($requete . ' -- ' . __FILE__ . ':' . __LINE__) ;
11
 			if (DB::isError ($resultat)) {
12
 				return $resultat->getMessage().'<br />'.$resultat->getDebugInfo();
13
 			}
14
@@ -640,18 +640,17 @@
15
 function gen_RSS($typeannonce='', $nbitem='', $emetteur='', $valide=1, $requeteSQL='', $requeteSQLFrom = '', $requeteWhereListe = '', $categorie_nature='', $order = '') {
16
 	// generation de la requete MySQL personnalisee
17
 
18
-	$req_where=0;
19
 	$requete = 'SELECT DISTINCT bf_id_fiche, bf_titre, bf_date_debut_validite_fiche, bf_description,bf_date_debut_evenement, bn_label_nature, bf_date_creation_fiche, bf_ce_utilisateur '.
20
 				'FROM bazar_fiche, bazar_nature '.$requeteSQLFrom.' WHERE '.$requeteWhereListe;
21
+
22
+	$where_cond = array();
23
 	if ($valide!=2) {
24
-		$requete .= 'bf_statut_fiche='.$valide;
25
-		$req_where=1;
26
+		$where_cond[] = 'bf_statut_fiche='.$valide;
27
 	}
28
 	$nomflux=html_entity_decode(BAZ_DERNIERE_ACTU);
29
 	if (!is_array ($typeannonce) && $typeannonce!='' and $typeannonce!='toutes') {
30
-		if ($req_where==1) {$requete .= ' AND ';}
31
-		$requete .= 'bf_ce_nature='.$typeannonce.' and bf_ce_nature=bn_id_nature ';;
32
-		$req_where=1;
33
+		$where_cond[] = 'bf_ce_nature='.$typeannonce;
34
+		$where_cond[] = ' bf_ce_nature=bn_id_nature';
35
 		//le nom du flux devient le type d'annonce
36
 		$requete_nom_flux = 'select bn_label_nature from bazar_nature where bn_id_nature = '.$typeannonce;
37
 		$nomflux = $GLOBALS['_BAZAR_']['db']->getOne($requete_nom_flux) ;
38
@@ -659,38 +658,24 @@
39
 
40
 	// cas où on veut toutes les annonces
41
 	if ($typeannonce == 'toutes') {
42
-		if ($req_where==1) {$requete .= ' AND ';}
43
-		$requete .= 'bf_ce_nature IN (1,2,3,4' ;
44
-		$chaine = '';
45
-		$requete .= ') and bf_ce_nature=bn_id_nature ';
46
+		$where_cond[] = 'bf_ce_nature IN (1,2,3,4)';
47
+		$where_cond[] = 'bf_ce_nature=bn_id_nature';
48
 	}
49
 
50
 	// Cas ou il y plusieurs type d annonce demande
51
-	if (is_array ($typeannonce)) {
52
-		if ($req_where==1) {$requete .= ' AND ';}
53
-		$requete .= 'bf_ce_nature IN (' ;
54
-		$chaine = '';
55
-		foreach ($typeannonce as $valeur) $chaine .= '"'.$valeur.'",' ;
56
-		$requete .= substr ($chaine, 0, strlen ($chaine)-1) ;
57
-		$requete .= ') and bf_ce_nature=bn_id_nature ';
58
+	if (is_array($typeannonce) && ! empty($typeannonce)) {
59
+		$where_cond[] = 'bf_ce_nature IN (' . '"' . implode('","', $typeannonce) . '"' . ')';
60
+		$where_cond[] = 'bf_ce_nature=bn_id_nature';
61
 	}
62
-	$utilisateur = new Administrateur_bazar ($GLOBALS['AUTH']) ;
63
 
64
-	if ($utilisateur->isSuperAdmin()) {
65
-		$req_where=1;
66
-	} else {
67
-		if ($req_where==1) {
68
-			$requete .= ' AND ';
69
-		}
70
+	// useless ?
71
+	// $utilisateur = new Administrateur_bazar ($GLOBALS['AUTH']) ;
72
 
73
-	}
74
+	$where_cond[] = 'bf_date_debut_evenement >= NOW()';
75
+	$where_cond[] = 'bn_id_nature=bf_ce_nature';
76
 
77
-	$requete .= 'bf_date_debut_evenement >= NOW() AND bn_id_nature=bf_ce_nature';
78
-
79
 	if ($emetteur!='' && $emetteur!='tous') {
80
-		if ($req_where==1) {$requete .= ' AND ';}
81
-		$requete .= 'bf_ce_utilisateur='.$emetteur;
82
-		$req_where=1;
83
+		$where_cond[] = 'bf_ce_utilisateur='.$emetteur;
84
 		//requete pour afficher le nom de la structure
85
 		$requetenom = 'SELECT '.BAZ_CHAMPS_NOM.', '.BAZ_CHAMPS_PRENOM.' FROM '.
86
 						BAZ_ANNUAIRE.' WHERE '.BAZ_CHAMPS_ID.'='.$emetteur;
87
@@ -701,26 +686,25 @@
88
 		$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
89
 		$nomflux .= ' ('.$ligne[BAZ_CHAMPS_NOM].' '.$ligne[BAZ_CHAMPS_PRENOM].')';
90
 	}
91
-	if ($requeteSQL!='') {
92
-		if ($req_where==1) {$requete .= ' AND ';}
93
-		$requete .= '('.$requeteSQL.')';
94
-		$req_where=1;
95
+	if ($requeteSQL) {
96
+		$where_cond[] = $requeteSQL;
97
 	}
98
+
99
 	if ($categorie_nature!='') {
100
-		if ($req_where==1) {$requete .= ' AND ';}
101
-		$requete .= 'bn_ce_id_menu IN ('.$categorie_nature.') and bf_ce_nature=bn_id_nature ';
102
-		$req_where=1;
103
+		$where_cond[] = 'bn_ce_id_menu IN ('.$categorie_nature.')';
104
+		$where_cond[] = 'bf_ce_nature=bn_id_nature';
105
 	}
106
 
107
 	if (isset($_REQUEST['departement'])) {
108
-		  if ($req_where==1) {$requete .= ' AND ';}
109
-		  $requete .= ' bf_cp_lieu_evenement LIKE "'.$_REQUEST['departement'].'%" ';
110
+		$where_cond[] = 'bf_cp_lieu_evenement LIKE "'.$_REQUEST['departement'].'%"';
111
 	}
112
 
113
+
114
+	$requete .= implode(' AND ', $where_cond);
115
 	$requete .= ' ORDER BY bf_date_debut_evenement ASC ';
116
 
117
 	if ($nbitem!='') {$requete .= ' LIMIT 0,'.$nbitem;}
118
-	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
119
+	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete . ' -- ' . __FILE__ . ':' . __LINE__) ;
120
 
121
 	//mail('aurelien@tela-botanica.org','requete',$requete);
122