Subversion Repositories Applications.bazar

Rev

Rev 139 | Rev 149 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 139 Rev 143
1
<?php
1
<?php
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */ 
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */ 
3
// +------------------------------------------------------------------------------------------------------+
3
// +------------------------------------------------------------------------------------------------------+
4
// | PHP version 4.1                                                                                      |
4
// | PHP version 4.1                                                                                      |
5
// +------------------------------------------------------------------------------------------------------+
5
// +------------------------------------------------------------------------------------------------------+
6
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
6
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
7
// +------------------------------------------------------------------------------------------------------+
7
// +------------------------------------------------------------------------------------------------------+
8
// | This library is free software; you can redistribute it and/or                                        |
8
// | This library is free software; you can redistribute it and/or                                        |
9
// | modify it under the terms of the GNU Lesser General Public                                           |
9
// | modify it under the terms of the GNU Lesser General Public                                           |
10
// | License as published by the Free Software Foundation; either                                         |
10
// | License as published by the Free Software Foundation; either                                         |
11
// | version 2.1 of the License, or (at your option) any later version.                                   |
11
// | version 2.1 of the License, or (at your option) any later version.                                   |
12
// |                                                                                                      |
12
// |                                                                                                      |
13
// | This library is distributed in the hope that it will be useful,                                      |
13
// | This library is distributed in the hope that it will be useful,                                      |
14
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
14
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
15
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
15
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
16
// | Lesser General Public License for more details.                                                      |
16
// | Lesser General Public License for more details.                                                      |
17
// |                                                                                                      |
17
// |                                                                                                      |
18
// | You should have received a copy of the GNU Lesser General Public                                     |
18
// | You should have received a copy of the GNU Lesser General Public                                     |
19
// | License along with this library; if not, write to the Free Software                                  |
19
// | License along with this library; if not, write to the Free Software                                  |
20
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
20
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
21
// +------------------------------------------------------------------------------------------------------+
21
// +------------------------------------------------------------------------------------------------------+
22
// CVS : $Id: bazar.fonct.rss.php,v 1.56 2006-07-18 14:13:35 alexandre_tb Exp $
22
// CVS : $Id: bazar.fonct.rss.php,v 1.57 2006-07-25 13:22:27 alexandre_tb Exp $
23
/**
23
/**
24
* 
24
* 
25
*@package bazar
25
*@package bazar
26
//Auteur original :
26
//Auteur original :
27
*@author        Alexandre GRANIER <alexandre@tela-botanica.org>
27
*@author        Alexandre GRANIER <alexandre@tela-botanica.org>
28
*@author        Florian Schmitt <florian@ecole-et-nature.org>
28
*@author        Florian Schmitt <florian@ecole-et-nature.org>
29
//Autres auteurs :
29
//Autres auteurs :
30
*@copyright     Tela-Botanica 2000-2006
30
*@copyright     Tela-Botanica 2000-2006
31
*@version       $Revision: 1.56 $
31
*@version       $Revision: 1.57 $
32
// +------------------------------------------------------------------------------------------------------+
32
// +------------------------------------------------------------------------------------------------------+
33
*/
33
*/
34
 
34
 
35
// +------------------------------------------------------------------------------------------------------+
35
// +------------------------------------------------------------------------------------------------------+
36
// |                                            ENTETE du PROGRAMME                                       |
36
// |                                            ENTETE du PROGRAMME                                       |
37
// +------------------------------------------------------------------------------------------------------+
37
// +------------------------------------------------------------------------------------------------------+
38
 
38
 
39
require_once BAZ_CHEMIN_APPLI.'bibliotheque/bazar.class.php';
39
require_once BAZ_CHEMIN_APPLI.'bibliotheque/bazar.class.php';
40
require_once BAZ_CHEMIN_APPLI.'bibliotheque/bazar.fonct.php';
40
require_once BAZ_CHEMIN_APPLI.'bibliotheque/bazar.fonct.php';
41
 
41
 
42
 
42
 
43
/** baz_valeur_template() - Renvoi des valeurs inscrite dans le fichier de template
43
/** baz_valeur_template() - Renvoi des valeurs inscrite dans le fichier de template
44
*
44
*
45
* @param   string valeur du template de bazar_nature
45
* @param   string valeur du template de bazar_nature
46
*
46
*
47
* @return   mixed  tableau contenant les champs du fichier template
47
* @return   mixed  tableau contenant les champs du fichier template
48
*/
48
*/
49
function baz_valeurs_template($valeur_template) {
49
function baz_valeurs_template($valeur_template) {
50
	//Parcours du fichier de templates, pour mettre les champs spécifiques
50
	//Parcours du fichier de templates, pour mettre les champs spécifiques
51
	$tableau= array();
51
	$tableau= array();
52
	$nblignes=0;
52
	$nblignes=0;
53
	$chaine = explode ("\n", $valeur_template);
53
	$chaine = explode ("\n", $valeur_template);
54
	array_pop($chaine);
54
	array_pop($chaine);
55
	foreach ($chaine as $ligne)  {
55
	foreach ($chaine as $ligne)  {
56
		$souschaine = explode ("***", $ligne) ;
56
		$souschaine = explode ("***", $ligne) ;
57
		$tableau[$nblignes]['type'] = trim($souschaine[0]) ;
57
		$tableau[$nblignes]['type'] = trim($souschaine[0]) ;
58
		if (isset($souschaine[1])) {$tableau[$nblignes]['nom_bdd'] = trim($souschaine[1]);}
58
		if (isset($souschaine[1])) {$tableau[$nblignes]['nom_bdd'] = trim($souschaine[1]);}
59
		else {$tableau[$nblignes]['nom_bdd'] ='';}
59
		else {$tableau[$nblignes]['nom_bdd'] ='';}
60
		if (isset($souschaine[2])) $tableau[$nblignes]['label'] = trim($souschaine[2]);
60
		if (isset($souschaine[2])) $tableau[$nblignes]['label'] = trim($souschaine[2]);
61
		else {$tableau[$nblignes]['label'] ='';}
61
		else {$tableau[$nblignes]['label'] ='';}
62
		if (isset($souschaine[3])) $tableau[$nblignes]['limite1'] = trim($souschaine[3]);
62
		if (isset($souschaine[3])) $tableau[$nblignes]['limite1'] = trim($souschaine[3]);
63
		else {$tableau[$nblignes]['limite1'] ='';}
63
		else {$tableau[$nblignes]['limite1'] ='';}
64
		if (isset($souschaine[4])) $tableau[$nblignes]['limite2'] = trim($souschaine[4]);
64
		if (isset($souschaine[4])) $tableau[$nblignes]['limite2'] = trim($souschaine[4]);
65
		else {$tableau[$nblignes]['limite2'] ='';}
65
		else {$tableau[$nblignes]['limite2'] ='';}
66
		if (isset($souschaine[5])) $tableau[$nblignes]['defaut'] = trim($souschaine[5]);
66
		if (isset($souschaine[5])) $tableau[$nblignes]['defaut'] = trim($souschaine[5]);
67
		else {$tableau[$nblignes]['defaut'] ='';}
67
		else {$tableau[$nblignes]['defaut'] ='';}
68
		if (isset($souschaine[6])) $tableau[$nblignes]['table_source'] = trim($souschaine[6]);
68
		if (isset($souschaine[6])) $tableau[$nblignes]['table_source'] = trim($souschaine[6]);
69
		else {$tableau[$nblignes]['table_source'] ='';}
69
		else {$tableau[$nblignes]['table_source'] ='';}
70
		if (isset($souschaine[7])) $tableau[$nblignes]['id_source'] = trim($souschaine[7]);
70
		if (isset($souschaine[7])) $tableau[$nblignes]['id_source'] = trim($souschaine[7]);
71
		else {$tableau[$nblignes]['id_source'] ='';}
71
		else {$tableau[$nblignes]['id_source'] ='';}
72
		if (isset($souschaine[8])) $tableau[$nblignes]['obligatoire'] = trim($souschaine[8]);
72
		if (isset($souschaine[8])) $tableau[$nblignes]['obligatoire'] = trim($souschaine[8]);
73
		else {$tableau[$nblignes]['obligatoire'] ='';}
73
		else {$tableau[$nblignes]['obligatoire'] ='';}
74
		if (isset($souschaine[9])) $tableau[$nblignes]['recherche'] = trim($souschaine[9]);
74
		if (isset($souschaine[9])) $tableau[$nblignes]['recherche'] = trim($souschaine[9]);
75
		else {$tableau[$nblignes]['recherche'] ='';}
75
		else {$tableau[$nblignes]['recherche'] ='';}
76
		
76
		
77
		
77
		
78
		// traitement des cases à cocher, dans ce cas la, on a une table de jointure entre la table
78
		// traitement des cases à cocher, dans ce cas la, on a une table de jointure entre la table
79
		// de liste et la table bazar_fiche (elle porte un nom du genre bazar_ont_***)
79
		// de liste et la table bazar_fiche (elle porte un nom du genre bazar_ont_***)
80
		// dans le template, à la place d'un nom de champs dans 'nom_bdd', on a un nom de table
80
		// dans le template, à la place d'un nom de champs dans 'nom_bdd', on a un nom de table
81
		// et 2 noms de champs séparés par un virgule ex : bazar_ont_theme,bot_id_theme,bot_id_fiche
81
		// et 2 noms de champs séparés par un virgule ex : bazar_ont_theme,bot_id_theme,bot_id_fiche
82
		
82
		
83
		if (isset($tableau[$nblignes]['nom_bdd']) && preg_match('/,/', $tableau[$nblignes]['nom_bdd'])) {
83
		if (isset($tableau[$nblignes]['nom_bdd']) && preg_match('/,/', $tableau[$nblignes]['nom_bdd'])) {
84
			$tableau_info_jointe = explode (',', $tableau[$nblignes]['nom_bdd']) ;
84
			$tableau_info_jointe = explode (',', $tableau[$nblignes]['nom_bdd']) ;
85
			$tableau[$nblignes]['table_jointe'] = $tableau_info_jointe[0] ;
85
			$tableau[$nblignes]['table_jointe'] = $tableau_info_jointe[0] ;
86
			$tableau[$nblignes]['champs_id_fiche'] = $tableau_info_jointe[1] ;
86
			$tableau[$nblignes]['champs_id_fiche'] = $tableau_info_jointe[1] ;
87
			$tableau[$nblignes]['champs_id_table_jointe'] = $tableau_info_jointe[2] ;		
87
			$tableau[$nblignes]['champs_id_table_jointe'] = $tableau_info_jointe[2] ;		
88
		}
88
		}
89
		$nblignes++;
89
		$nblignes++;
90
	}
90
	}
91
	return $tableau;
91
	return $tableau;
92
}
92
}
93
 
93
 
94
/**  baz_voir_fiches() - Permet de visualiser en detail une liste de fiche  au format XHTML
94
/**  baz_voir_fiches() - Permet de visualiser en detail une liste de fiche  au format XHTML
95
*
95
*
96
* @global boolean Rajoute des informations internes à l'application (date de modification, lien vers la page de départ de l'appli)
96
* @global boolean Rajoute des informations internes à l'application (date de modification, lien vers la page de départ de l'appli)
97
* @global integer Tableau d(Identifiant des fiches à afficher
97
* @global integer Tableau d(Identifiant des fiches à afficher
98
*
98
*
99
* @return   string  HTML
99
* @return   string  HTML
100
*/
100
*/
101
function baz_voir_fiches($danslappli, $idfiches=array()) {
101
function baz_voir_fiches($danslappli, $idfiches=array()) {
102
	$res='';
102
	$res='';
103
	foreach($idfiches as $idfiche) {
103
	foreach($idfiches as $idfiche) {
104
			$res.=baz_voir_fiche($danslappli, $idfiche);
104
			$res.=baz_voir_fiche($danslappli, $idfiche);
105
	}
105
	}
106
	return $res;
106
	return $res;
107
}
107
}
108
 
108
 
109
 
109
 
110
/**  baz_voir_fiche() - Permet de visualiser en detail une fiche  au format XHTML
110
/**  baz_voir_fiche() - Permet de visualiser en detail une fiche  au format XHTML
111
*
111
*
112
* @global boolean Rajoute des informations internes a l'application (date de modification, lien vers la page de départ de l'appli) si a 1
112
* @global boolean Rajoute des informations internes a l'application (date de modification, lien vers la page de départ de l'appli) si a 1
113
* @global integer Identifiant de la fiche a afficher
113
* @global integer Identifiant de la fiche a afficher
114
*
114
*
115
* @return   string  HTML
115
* @return   string  HTML
116
*/
116
*/
117
function baz_voir_fiche($danslappli, $idfiche='') {
117
function baz_voir_fiche($danslappli, $idfiche='') {
118
	$res='';
118
	$res='';
119
	if (isset($_GET['id_fiche'])) $GLOBALS['_BAZAR_']['id_fiche']=$_GET['id_fiche'];
119
	if (isset($_GET['id_fiche'])) $GLOBALS['_BAZAR_']['id_fiche']=$_GET['id_fiche'];
120
	if ($idfiche!='') $GLOBALS['_BAZAR_']['id_fiche']=$idfiche;	
120
	if ($idfiche!='') $GLOBALS['_BAZAR_']['id_fiche']=$idfiche;	
121
	$url= $GLOBALS['_BAZAR_']['url'];
121
	$url= $GLOBALS['_BAZAR_']['url'];
122
	$url->addQueryString('action', BAZ_VOIR_FICHE);
122
	$url->addQueryString('action', BAZ_VOIR_FICHE);
123
	$url->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
123
	$url->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
124
	$url = preg_replace ('/&amp;/', '&', $url->getURL()) ;
124
	$url = preg_replace ('/&amp;/', '&', $url->getURL()) ;
125
	
125
	
126
	//cas ou la fiche a été validee
126
	//cas ou la fiche a été validee
127
	if (isset($_GET['publiee'])) {
127
	if (isset($_GET['publiee'])) {
128
		publier_fiche($_GET['publiee']);			
128
		publier_fiche($_GET['publiee']);			
129
	}
129
	}
130
	
130
	
131
	//cas on une structure s'approprie une ressource
131
	//cas on une structure s'approprie une ressource
132
	if (isset($_GET['appropriation'])) {
132
	if (isset($_GET['appropriation'])) {
133
		if ($_GET['appropriation']==1) {
133
		if ($_GET['appropriation']==1) {
134
			$requete = 'INSERT INTO bazar_appropriation VALUES ('.$GLOBALS['_BAZAR_']['id_fiche'].', '.$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID).')';
134
			$requete = 'INSERT INTO bazar_appropriation VALUES ('.$GLOBALS['_BAZAR_']['id_fiche'].', '.$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID).')';
135
			$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
135
			$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
136
		}
136
		}
137
		elseif ($_GET['appropriation']==0) {
137
		elseif ($_GET['appropriation']==0) {
138
			$requete = 'DELETE FROM bazar_appropriation WHERE  ba_ce_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'].' AND ba_ce_id_structure='.$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID);
138
			$requete = 'DELETE FROM bazar_appropriation WHERE  ba_ce_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'].' AND ba_ce_id_structure='.$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID);
139
			$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
139
			$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
140
		}
140
		}
141
	}
141
	}
142
		
142
		
143
	//cas ou un commentaire a été entre
143
	//cas ou un commentaire a été entre
144
	if (isset($_POST['Nom'])) {
144
	if (isset($_POST['Nom'])) {
145
		$requete = 'INSERT INTO bazar_commentaires VALUES ('.
145
		$requete = 'INSERT INTO bazar_commentaires VALUES ('.
146
					baz_nextid('bazar_commentaires', 'bc_id_commentaire', $GLOBALS['_BAZAR_']['db']).
146
					baz_nextid('bazar_commentaires', 'bc_id_commentaire', $GLOBALS['_BAZAR_']['db']).
147
					', '.$GLOBALS['_BAZAR_']['id_fiche'].', "'.$_POST['Nom'].'", "'.$_POST['Commentaire'].
147
					', '.$GLOBALS['_BAZAR_']['id_fiche'].', "'.$_POST['Nom'].'", "'.$_POST['Commentaire'].
148
					'", NOW() )';
148
					'", NOW() )';
149
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
149
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
150
	}
150
	}
151
	//cas ou un commentaire va etre supprime
151
	//cas ou un commentaire va etre supprime
152
	elseif (isset($_GET['id_commentaire'])) {
152
	elseif (isset($_GET['id_commentaire'])) {
153
		$requete = 'DELETE FROM bazar_commentaires WHERE bc_id_commentaire='.$_GET['id_commentaire'].' LIMIT 1';
153
		$requete = 'DELETE FROM bazar_commentaires WHERE bc_id_commentaire='.$_GET['id_commentaire'].' LIMIT 1';
154
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
154
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
155
	}
155
	}
156
	else {
156
	else {
157
		if (isset($_GET['action'])) {
157
		if (isset($_GET['action'])) {
158
			if ($_GET['action']==BAZ_VOIR_FICHE) {
158
			if ($_GET['action']==BAZ_VOIR_FICHE) {
159
				//sinon on met a jour le nb de visites pour la fiche, puisque c'est une simple consultation
159
				//sinon on met a jour le nb de visites pour la fiche, puisque c'est une simple consultation
160
				$requete = 'UPDATE bazar_fiche SET bf_nb_consultations=bf_nb_consultations+1 WHERE bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
160
				$requete = 'UPDATE bazar_fiche SET bf_nb_consultations=bf_nb_consultations+1 WHERE bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
161
				$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
161
				$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
162
			}
162
			}
163
		}
163
		}
164
	}
164
	}
-
 
165
	$requete = 'SELECT * FROM bazar_fiche WHERE bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
-
 
166
	
-
 
167
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
-
 
168
	(DB::isError($resultat)) ? die(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete))
-
 
169
	    : '';
-
 
170
	
-
 
171
	$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC) ;
-
 
172
	if (!isset($GLOBALS['_BAZAR_']['typeannonce'])) $GLOBALS['_BAZAR_']['typeannonce'] = $ligne['bf_ce_nature'];
165
	
173
	
166
	//on verifie si l'utilisateur est administrateur
174
	//on verifie si l'utilisateur est administrateur
167
	$est_admin=0;
175
	$est_admin=0;
-
 
176
	$requete='SELECT bn_id_nature, bn_template, bn_commentaire FROM bazar_nature WHERE bn_id_nature="'.$GLOBALS['_BAZAR_']['typeannonce'].'"';
-
 
177
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
-
 
178
	if (DB::isError($resultat)) {
-
 
179
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
-
 
180
	}
-
 
181
	$result = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
-
 
182
	$id_nature = $result['bn_id_nature'];
-
 
183
	if (!isset($GLOBALS['_BAZAR_']['template'])) $GLOBALS['_BAZAR_']['template'] = $result['bn_template'];
-
 
184
	if (!isset($GLOBALS['_BAZAR_']['commentaire'])) $GLOBALS['_BAZAR_']['commentaire'] = $result['bn_commentaire'];
168
	if ($GLOBALS['AUTH']->getAuth()) {
185
	if ($GLOBALS['AUTH']->getAuth()) {
169
		$requete='SELECT bn_id_nature FROM bazar_nature WHERE bn_label_nature="'.$GLOBALS['_BAZAR_']['typeannonce'].'"';
-
 
170
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
-
 
171
		if (DB::isError($resultat)) {
-
 
172
			die ($resultat->getMessage().$resultat->getDebugInfo()) ;
-
 
173
		}
-
 
174
		$result = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
-
 
175
		$id_nature = $result['bn_id_nature'];
-
 
176
		if ((niveau_droit($result['bn_id_nature'],$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID))=='administrateur')
186
		if ((niveau_droit($result['bn_id_nature'],$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID))=='administrateur')
177
		     or(niveau_droit('0',$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID))=='superadministrateur'))
187
		     or(niveau_droit('0',$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID))=='superadministrateur'))
178
		{
188
		{
179
		        $est_admin=1;
189
		        $est_admin=1;
180
		}
190
		}
181
	}
191
	}
182
	//affiche le titre sous forme d'image
192
	//affiche le titre sous forme d'image
183
	if (isset ($GLOBALS['_BAZAR_']['image_titre']) && $GLOBALS['_BAZAR_']['image_titre']!='') {
193
	if (isset ($GLOBALS['_BAZAR_']['image_titre']) && $GLOBALS['_BAZAR_']['image_titre']!='') {
184
		$res .= '<img id="BAZ_img_titre" src="client/bazar/images/'.$GLOBALS['_BAZAR_']['image_titre'].'" alt="'.$GLOBALS['_BAZAR_']['typeannonce'].'" />'.'<br />'."\n";
194
		$res .= '<img id="BAZ_img_titre" src="client/bazar/images/'.$GLOBALS['_BAZAR_']['image_titre'].'" alt="'.$GLOBALS['_BAZAR_']['typeannonce'].'" />'.'<br />'."\n";
185
	}
195
	}
186
	//affiche le texte sinon
196
	//affiche le texte sinon
187
	else {
197
	else {
188
		$res .= '<h2 class="BAZ_titre">'.$GLOBALS['_BAZAR_']['typeannonce'].'</h2>'."\n";
198
		//$res .= '<h2 class="BAZ_titre">'.$GLOBALS['_BAZAR_']['typeannonce'].'</h2>'."\n";
189
	}
199
	}
190
	$res .= '<div class="BAZ_cadre_fiche">'."\n";
200
	$res .= '<div class="BAZ_cadre_fiche">'."\n";
191
	$requete = 'SELECT * FROM bazar_fiche WHERE bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
-
 
192
	
-
 
193
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
-
 
194
	(DB::isError($resultat)) ? die(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete))
-
 
195
	    : '';
-
 
196
 
-
 
197
	$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC) ;
201
	
198
	$GLOBALS['_BAZAR_']['annonceur'] = $ligne['bf_ce_utilisateur'] ;
202
	$GLOBALS['_BAZAR_']['annonceur'] = $ligne['bf_ce_utilisateur'] ;
199
	//si le template existe, on genere le template
203
	//si le template existe, on genere le template
200
	if ((file_exists(BAZ_CHEMIN_APPLI.'templates/'.$GLOBALS['_BAZAR_']['typeannonce'].'-fiche.php'))) {
204
	if ((file_exists(BAZ_CHEMIN_APPLI.'templates/'.$GLOBALS['_BAZAR_']['typeannonce'].'-fiche.php'))) {
201
		include_once(BAZ_CHEMIN_APPLI.'templates/'.$GLOBALS['_BAZAR_']['typeannonce'].'-fiche.php');
205
		include_once(BAZ_CHEMIN_APPLI.'templates/'.$GLOBALS['_BAZAR_']['typeannonce'].'-fiche.php');
202
		$res .=genere_fiche($ligne);
206
		$res .=genere_fiche($ligne);
203
	}
207
	}
204
	//on affiche ligne par ligne sinon
208
	//on affiche ligne par ligne sinon
205
	else {
209
	else {
206
		//cas d'une image personalisée
210
		//cas d'une image personalisée
207
		if (isset($ligne['bf_url_image'])) {
211
		if (isset($ligne['bf_url_image'])) {
208
			$res .= '<div id="fiche_image">'."\n";
212
			$res .= '<div id="fiche_image">'."\n";
209
			$res .= '<img src="client/bazar/upload/'.$ligne['bf_url_image'].'" border=0 alt="'.BAZ_TEXTE_IMG_ALTERNATIF.'" width="130" height="130"  />'."\n";
213
			$res .= '<img src="client/bazar/upload/'.$ligne['bf_url_image'].'" border=0 alt="'.BAZ_TEXTE_IMG_ALTERNATIF.'" width="130" height="130"  />'."\n";
210
			$res .= '</div>'."\n";
214
			$res .= '</div>'."\n";
211
		}
215
		}
212
		//cas d'une image par défaut
216
		//cas d'une image par défaut
213
		elseif (isset ($GLOBALS['_BAZAR_']['image_logo']) && $GLOBALS['_BAZAR_']['image_logo']!='') {
217
		elseif (isset ($GLOBALS['_BAZAR_']['image_logo']) && $GLOBALS['_BAZAR_']['image_logo']!='') {
214
			$res .= '<div id="fiche_image">'."\n";
218
			$res .= '<div id="fiche_image">'."\n";
215
			$res .= '<img src="client/bazar/images/'.$GLOBALS['_BAZAR_']['image_logo'].'" border=0 alt="'.BAZ_TEXTE_IMG_ALTERNATIF.'" width="130" height="130" />'."\n";
219
			$res .= '<img src="client/bazar/images/'.$GLOBALS['_BAZAR_']['image_logo'].'" border=0 alt="'.BAZ_TEXTE_IMG_ALTERNATIF.'" width="130" height="130" />'."\n";
216
			$res .= '</div>'."\n";
220
			$res .= '</div>'."\n";
217
		}
221
		}
218
		$res .= '<h1 id="fiche_titre">'.$ligne['bf_titre'].'</h1>'."\n";
222
		$res .= '<h1 id="fiche_titre">'.$ligne['bf_titre'].'</h1>'."\n";
219
		$res .= '<div id="BAZ_description">'.nl2br($ligne['bf_description']).'</div>'."\n";
223
		$res .= '<div id="BAZ_description">'.nl2br($ligne['bf_description']).'</div>'."\n";
220
		$tableau=baz_valeurs_template($GLOBALS['_BAZAR_']['template']);
224
		$tableau=baz_valeurs_template($GLOBALS['_BAZAR_']['template']);
221
		for ($i=0; $i<count($tableau); $i++) {
225
		for ($i=0; $i<count($tableau); $i++) {
222
			if (isset($ligne[$tableau[$i]['nom_bdd']]) && ( $tableau[$i]['type']=='texte' || $tableau[$i]['type']=='textelong' ) ) {
226
			if (isset($ligne[$tableau[$i]['nom_bdd']]) && ( $tableau[$i]['type']=='texte' || $tableau[$i]['type']=='textelong' ) ) {
223
				$val=$tableau[$i]['nom_bdd'];
227
				$val=$tableau[$i]['nom_bdd'];
224
				if (!in_array($val, array ('bf_titre', 'bf_description'))) {
228
				if (!in_array($val, array ('bf_titre', 'bf_description'))) {
225
					if ($ligne[$val] != '' and $ligne[$val] != BAZ_CHOISIR and $ligne[$val] != BAZ_NON_PRECISE) {
229
					if ($ligne[$val] != '' and $ligne[$val] != BAZ_CHOISIR and $ligne[$val] != BAZ_NON_PRECISE) {
226
						$res .= '<span class="rubrique">'.$tableau[$i]['label'].':</span>'."\n";
230
						$res .= '<span class="rubrique">'.$tableau[$i]['label'].':</span>'."\n";
227
						$res .= '<span class="description"> '.nl2br($ligne[$val]).'</span>'."\n".'<br />'."\n";
231
						$res .= '<span class="description"> '.nl2br($ligne[$val]).'</span>'."\n".'<br />'."\n";
228
					}
232
					}
229
				}
233
				}
230
			}
234
			}
231
			elseif ( $tableau[$i]['type']=='liste' || $tableau[$i]['type']=='checkbox' ) {
235
			elseif ( $tableau[$i]['type']=='liste' || $tableau[$i]['type']=='checkbox' ) {
232
				//pour les champs renseignes par une liste, on va chercher le label de la liste, plutot que l'id				
236
				//pour les champs renseignes par une liste, on va chercher le label de la liste, plutot que l'id				
233
				$requete = 'SELECT blv_label FROM bazar_fiche_valeur_liste, bazar_liste_valeurs WHERE bfvl_ce_fiche='.$GLOBALS['_BAZAR_']['id_fiche'].
237
				$requete = 'SELECT blv_label FROM bazar_fiche_valeur_liste, bazar_liste_valeurs WHERE bfvl_ce_fiche='.$GLOBALS['_BAZAR_']['id_fiche'].
234
				' AND  bfvl_ce_liste='.$tableau[$i]['nom_bdd'].' AND bfvl_valeur=blv_valeur AND blv_ce_liste='.$tableau[$i]['nom_bdd'].' AND blv_ce_i18n="'.$GLOBALS['_BAZAR_']['langue'].'"';
238
				' AND  bfvl_ce_liste='.$tableau[$i]['nom_bdd'].' AND bfvl_valeur=blv_valeur AND blv_ce_liste='.$tableau[$i]['nom_bdd'].' AND blv_ce_i18n="'.$GLOBALS['_BAZAR_']['langue'].'"';
235
				$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
239
				$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
236
				if (DB::isError ($resultat)) {
240
				if (DB::isError ($resultat)) {
237
					die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
241
					die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
238
				}
242
				}
239
				$val='';$nb=0;
243
				$val='';$nb=0;
240
				while ($tab = $resultat->fetchRow()) {
244
				while ($tab = $resultat->fetchRow()) {
241
					if ($nb>0) $val .= ', ';
245
					if ($nb>0) $val .= ', ';
242
					$val .= $tab[0];
246
					$val .= $tab[0];
243
					$nb++;
247
					$nb++;
244
				}				
248
				}				
245
				if ($val != '' and $val != BAZ_CHOISIR and $val != BAZ_NON_PRECISE) {
249
				if ($val != '' and $val != BAZ_CHOISIR and $val != BAZ_NON_PRECISE) {
246
					$res .= '<span class="rubrique">'.$tableau[$i]['label'].':</span>'."\n";
250
					$res .= '<span class="rubrique">'.$tableau[$i]['label'].':</span>'."\n";
247
					$res .= '<span class="description"> '.$val.'</span>'."\n".'<br />'."\n";
251
					$res .= '<span class="description"> '.$val.'</span>'."\n".'<br />'."\n";
248
				}
252
				}
249
			}
253
			}
250
			elseif ( $tableau[$i]['type']=='listedatedeb' || $tableau[$i]['type']=='listedatefin' ) {
254
			elseif ( $tableau[$i]['type']=='listedatedeb' || $tableau[$i]['type']=='listedatefin' ) {
251
				$val=$tableau[$i]['nom_bdd'];
255
				$val=$tableau[$i]['nom_bdd'];
252
				if (!in_array($val, array ('bf_date_debut_validite_fiche', 'bf_date_fin_validite_fiche'))) {
256
				if (!in_array($val, array ('bf_date_debut_validite_fiche', 'bf_date_fin_validite_fiche'))) {
253
					if ($ligne[$val] != '') {
257
					if ($ligne[$val] != '') {
254
						$res .= '<span class="rubrique">'.$tableau[$i]['label'].':</span>'."\n";
258
						$res .= '<span class="rubrique">'.$tableau[$i]['label'].':</span>'."\n";
255
						$res .= '<span class="description"> '.strftime('%d.%m.%Y',strtotime($ligne[$val])).'</span>'."\n".'<br />'."\n";
259
						$res .= '<span class="description"> '.strftime('%d.%m.%Y',strtotime($ligne[$val])).'</span>'."\n".'<br />'."\n";
256
					}
260
					}
257
				}		
261
				}		
258
			}
262
			}
259
		}
263
		}
260
	//afficher les liens pour l'annonce
264
	//afficher les liens pour l'annonce
261
	$requete = 'SELECT  bu_url, bu_descriptif_url FROM bazar_url WHERE bu_ce_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
265
	$requete = 'SELECT  bu_url, bu_descriptif_url FROM bazar_url WHERE bu_ce_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
262
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
266
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
263
	if (DB::isError($resultat)) {
267
	if (DB::isError($resultat)) {
264
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
268
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
265
	}
269
	}
266
	if ($resultat->numRows()>0) {
270
	if ($resultat->numRows()>0) {
267
		$res .= '<span class="rubrique">'.BAZ_LIEN_INTERNET.':</span>'."\n";
271
		$res .= '<span class="rubrique">'.BAZ_LIEN_INTERNET.':</span>'."\n";
268
		$res .= '<span class="description">'."\n";
272
		$res .= '<span class="description">'."\n";
269
		$res .= '<ul>'."\n";
273
		$res .= '<ul>'."\n";
270
		while ($ligne1 = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
274
		while ($ligne1 = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
271
			$res .= '<li><a href="'.$ligne1['bu_url'].'" target="_blank">'.$ligne1['bu_descriptif_url'].'</a></li>'."\n";
275
			$res .= '<li><a href="'.$ligne1['bu_url'].'" target="_blank">'.$ligne1['bu_descriptif_url'].'</a></li>'."\n";
272
		}
276
		}
273
		$res .= '</ul></span>'."\n";
277
		$res .= '</ul></span>'."\n";
274
	}
278
	}
275
	
279
	
276
	//afficher les fichiers pour l'annonce
280
	//afficher les fichiers pour l'annonce
277
	$requete = 'SELECT  bfj_description, bfj_fichier FROM bazar_fichier_joint WHERE bfj_ce_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
281
	$requete = 'SELECT  bfj_description, bfj_fichier FROM bazar_fichier_joint WHERE bfj_ce_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
278
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
282
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
279
	if (DB::isError($resultat)) {
283
	if (DB::isError($resultat)) {
280
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
284
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
281
	}
285
	}
282
	if ($resultat->numRows()>0) {
286
	if ($resultat->numRows()>0) {
283
		$res .= '<span class="rubrique">'.BAZ_LISTE_FICHIERS_JOINTS.':</span>'."\n";
287
		$res .= '<span class="rubrique">'.BAZ_LISTE_FICHIERS_JOINTS.':</span>'."\n";
284
		$res .= '<span class="description">'."\n";
288
		$res .= '<span class="description">'."\n";
285
		$res .= '<ul>'."\n";
289
		$res .= '<ul>'."\n";
286
		while ($ligne2 = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
290
		while ($ligne2 = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
287
			$res .= '<li><a href="client/bazar/upload/'.$ligne2['bfj_fichier'].'">'.$ligne2['bfj_description'].'</a></li>'."\n";
291
			$res .= '<li><a href="client/bazar/upload/'.$ligne2['bfj_fichier'].'">'.$ligne2['bfj_description'].'</a></li>'."\n";
288
		}
292
		}
289
		$res .= '</ul></span>'."\n";
293
		$res .= '</ul></span>'."\n";
290
	}
294
	}
291
	$res .= '<div class="bulle_haut">&nbsp;</div>'."\n";
295
	$res .= '<div class="bulle_haut">&nbsp;</div>'."\n";
292
	$res .= '<div class="bulle_corps">'."\n";
296
	$res .= '<div class="bulle_corps">'."\n";
293
	
297
	
294
	//affichage du redacteur de la fiche
298
	//affichage du redacteur de la fiche
295
	$requete = 'SELECT '.BAZ_CHAMPS_NOM.', '.BAZ_CHAMPS_PRENOM.', '.BAZ_CHAMPS_EMAIL.
299
	$requete = 'SELECT '.BAZ_CHAMPS_NOM.', '.BAZ_CHAMPS_PRENOM.', '.BAZ_CHAMPS_EMAIL.
296
					' FROM '.BAZ_ANNUAIRE.' WHERE '.BAZ_CHAMPS_ID.'='.$ligne['bf_ce_utilisateur'];
300
					' FROM '.BAZ_ANNUAIRE.' WHERE '.BAZ_CHAMPS_ID.'='.$ligne['bf_ce_utilisateur'];
297
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
301
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
298
	if (DB::isError($resultat)) {
302
	if (DB::isError($resultat)) {
299
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
303
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
300
	}
304
	}
301
	while ($redacteur = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
305
	while ($redacteur = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
302
		$res .= BAZ_FICHE_ECRITE.'<a href="mailto:'.$redacteur[BAZ_CHAMPS_EMAIL].'">'.$redacteur[BAZ_CHAMPS_PRENOM].' '.$redacteur[BAZ_CHAMPS_NOM].'</a><br />'."\n";
306
		$res .= BAZ_FICHE_ECRITE.'<a href="mailto:'.$redacteur[BAZ_CHAMPS_EMAIL].'">'.$redacteur[BAZ_CHAMPS_PRENOM].' '.$redacteur[BAZ_CHAMPS_NOM].'</a><br />'."\n";
303
	}
307
	}
304
	$res .= BAZ_NB_VUS.'<strong>'.$ligne['bf_nb_consultations'].'</strong>'.BAZ_FOIS.'<br />'."\n";
308
	$res .= BAZ_NB_VUS.'<strong>'.$ligne['bf_nb_consultations'].'</strong>'.BAZ_FOIS.'<br />'."\n";
305
	$res .= '</div>'."\n";
309
	$res .= '</div>'."\n";
306
	$res .= '<div class="bulle_bas">&nbsp;</div>'."\n";
310
	$res .= '<div class="bulle_bas">&nbsp;</div>'."\n";
307
	$res .= '<div id="BAZ_bas_page">';
311
	$res .= '<div id="BAZ_bas_page">';
308
	}
312
	}
309
	
313
	
310
	//informations complementaires (id fiche, etat publication,... )
314
	//informations complementaires (id fiche, etat publication,... )
311
	if ($danslappli==1) {		
315
	if ($danslappli==1) {
312
		if ($ligne['bf_statut_fiche']==1 && $GLOBALS['_BAZAR_']['appropriation']!=1 ) {
316
		if ($ligne['bf_statut_fiche']==1 && $GLOBALS['_BAZAR_']['appropriation']!=1 ) {
313
			$res .= '<span class="rubrique">'.BAZ_PUBLIEE.':</span> '.BAZ_DU.' '.strftime('%d.%m.%Y',strtotime($ligne['bf_date_debut_validite_fiche'])).' '.BAZ_AU.' '.strftime('%d.%m.%Y',strtotime($ligne['bf_date_fin_validite_fiche'])).'<br />'."\n";
317
			$res .= '<span class="rubrique">'.BAZ_PUBLIEE.':</span> '.BAZ_DU.' '.strftime('%d.%m.%Y',strtotime($ligne['bf_date_debut_validite_fiche'])).' '.BAZ_AU.' '.strftime('%d.%m.%Y',strtotime($ligne['bf_date_fin_validite_fiche'])).'<br />'."\n";
314
		}
318
		}
315
		elseif ($GLOBALS['_BAZAR_']['appropriation']!=1 || $ligne['bf_statut_fiche']!=1) {
319
		elseif ($GLOBALS['_BAZAR_']['appropriation']!=1 || $ligne['bf_statut_fiche']!=1) {
316
			$res .= '<span class="rubrique">'.BAZ_PUBLIEE.':</span> '.BAZ_NON;							
320
			$res .= '<span class="rubrique">'.BAZ_PUBLIEE.':</span> '.BAZ_NON;							
317
			if ( $est_admin ) {
321
			if ( $est_admin ) {
318
				$res .= '&nbsp;&nbsp;&nbsp;<strong>'.BAZ_VALIDER_PUBLICATION.'&nbsp;:&nbsp;</strong>'."\n";
322
				$res .= '&nbsp;&nbsp;&nbsp;<strong>'.BAZ_VALIDER_PUBLICATION.'&nbsp;:&nbsp;</strong>'."\n";
319
				$lien_publie = &$GLOBALS['_BAZAR_']['url'];
323
				$lien_publie = &$GLOBALS['_BAZAR_']['url'];
320
				$lien_publie->addQueryString('action', BAZ_VOIR_FICHE);
324
				$lien_publie->addQueryString('action', BAZ_VOIR_FICHE);
321
				$lien_publie->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
325
				$lien_publie->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
322
				$lien_publie->addQueryString('typeannonce', $ligne['bf_ce_nature']);
326
				$lien_publie->addQueryString('typeannonce', $ligne['bf_ce_nature']);
323
				$lien_publie->addQueryString('publiee', 1);
327
				$lien_publie->addQueryString('publiee', 1);
324
				$res .= '<a href="'.$lien_publie->getURL().'">'.BAZ_OUI.'</a>&nbsp;/&nbsp;';
328
				$res .= '<a href="'.$lien_publie->getURL().'">'.BAZ_OUI.'</a>&nbsp;/&nbsp;';
325
				$lien_publie->removeQueryString('publiee');
329
				$lien_publie->removeQueryString('publiee');
326
				$lien_publie->addQueryString('publiee', 0);
330
				$lien_publie->addQueryString('publiee', 0);
327
				$res .='<a href="'.$lien_publie->getURL().'">'.BAZ_NON.'</a>'."\n";
331
				$res .='<a href="'.$lien_publie->getURL().'">'.BAZ_NON.'</a>'."\n";
328
				$lien_publie->removeQueryString('publiee');
332
				$lien_publie->removeQueryString('publiee');
329
			}
333
			}
330
			$res .= '<br />'."\n";
334
			$res .= '<br />'."\n";
331
		}
335
		}
332
		//affichage des infos pouvant interesser les admins
336
		//affichage des infos pouvant interesser les admins
333
		if ( $est_admin ) {
337
		if ( $est_admin ) {
334
			$res .= '<span class="rubrique" id="numero_fiche">'.BAZ_NUM_FICHE.':</span> '.$GLOBALS['_BAZAR_']['id_fiche'].'<br />'."\n";
338
			$res .= '<span class="rubrique" id="numero_fiche">'.BAZ_NUM_FICHE.':</span> '.$GLOBALS['_BAZAR_']['id_fiche'].'<br />'."\n";
335
			$res .= '<span class="rubrique" id="date_creation">'.BAZ_DATE_CREATION.' :</span> '.strftime('%d.%m.%Y &agrave; %H:%M',strtotime($ligne['bf_date_creation_fiche'])).'<br />'."\n";			
339
			$res .= '<span class="rubrique" id="date_creation">'.BAZ_DATE_CREATION.' :</span> '.strftime('%d.%m.%Y &agrave; %H:%M',strtotime($ligne['bf_date_creation_fiche'])).'<br />'."\n";			
336
		}		
340
		}		
337
		//affichage des infos et du lien pour la mise a jour de la fiche
341
		//affichage des infos et du lien pour la mise a jour de la fiche
338
		if ( $est_admin || $GLOBALS['_BAZAR_']['annonceur']==$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID) ) {			
342
		if ( $est_admin || $GLOBALS['_BAZAR_']['annonceur']==$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID) ) {			
339
			$res .= '<span class="rubrique" id="date_mise_a_jour">'.BAZ_DATE_MAJ.' :</span> '.strftime('%d.%m.%Y &agrave; %H:%M',strtotime($ligne['bf_date_maj_fiche']))."\n";
343
			$res .= '<span class="rubrique" id="date_mise_a_jour">'.BAZ_DATE_MAJ.' :</span> '.strftime('%d.%m.%Y &agrave; %H:%M',strtotime($ligne['bf_date_maj_fiche']))."\n";
340
			$lien_modifier=$GLOBALS['_BAZAR_']['url'];
344
			$lien_modifier=$GLOBALS['_BAZAR_']['url'];
341
			$lien_modifier->addQueryString('action', BAZ_ACTION_MODIFIER);
345
			$lien_modifier->addQueryString('action', BAZ_ACTION_MODIFIER);
342
			$lien_modifier->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
346
			$lien_modifier->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
343
			$lien_modifier->addQueryString('typeannonce', $ligne['bf_ce_nature']);
347
			$lien_modifier->addQueryString('typeannonce', $ligne['bf_ce_nature']);
344
			$res .= '&nbsp;&nbsp;&nbsp;<a href="'.$lien_modifier->getURL().'" id="modifier_fiche">'.BAZ_MODIFIER_LA_FICHE.'</a>'."\n";
348
			$res .= '&nbsp;&nbsp;&nbsp;<a href="'.$lien_modifier->getURL().'" id="modifier_fiche">'.BAZ_MODIFIER_LA_FICHE.'</a>'."\n";
345
		}
349
		}
346
	}
350
	}
347
	$res .= '</div>'."\n";
351
	$res .= '</div>'."\n";
348
	$res .= '</div>'."\n";
352
	$res .= '</div>'."\n";
349
	
353
	
350
	//on ajoute les appropriations, s'il le faut
354
	//on ajoute les appropriations, s'il le faut
351
	if (($danslappli==1)and($GLOBALS['_BAZAR_']['appropriation']==1)) {
355
	if (($danslappli==1)and($GLOBALS['_BAZAR_']['appropriation']==1)) {
352
		$res .= '<br />'."\n".'<div class="BAZ_cadre_fiche">'."\n";
356
		$res .= '<br />'."\n".'<div class="BAZ_cadre_fiche">'."\n";
353
		$res .= '<h3>'.BAZ_LES_STRUCTURES_POSSEDANT_UNE_RESSOURCE.'</h3>'."\n";		
357
		$res .= '<h3>'.BAZ_LES_STRUCTURES_POSSEDANT_UNE_RESSOURCE.'</h3>'."\n";		
354
		$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';
358
		$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';
355
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
359
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
356
		if (DB::isError ($resultat)) {
360
		if (DB::isError ($resultat)) {
357
			die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
361
			die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
358
		}
362
		}
359
		$possede_ressource=0;
363
		$possede_ressource=0;
360
		if ($resultat->numRows()>0) {
364
		if ($resultat->numRows()>0) {
361
			$res .= BAZ_IL_Y_A.$resultat->numRows().' ';
365
			$res .= BAZ_IL_Y_A.$resultat->numRows().' ';
362
			if ($resultat->numRows()==1) $res .= BAZ_STRUCTURE_POSSEDANT.'<br />'."\n";
366
			if ($resultat->numRows()==1) $res .= BAZ_STRUCTURE_POSSEDANT.'<br />'."\n";
363
			else $res .= BAZ_STRUCTURES_POSSEDANT.'<br />'."\n";
367
			else $res .= BAZ_STRUCTURES_POSSEDANT.'<br />'."\n";
364
			$res .= '<ul>'."\n";
368
			$res .= '<ul>'."\n";
365
			while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
369
			while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
366
				$res .= '<li><a href="'.BAZ_URL_ANNUAIRE.'&amp;voir_fiche='.$ligne[BAZ_CHAMPS_ID].'" onclick="javascript:window.open(this.href);return false;">'.$ligne[BAZ_CHAMPS_NOM].'</a></li>'."\n";
370
				$res .= '<li><a href="'.BAZ_URL_ANNUAIRE.'&amp;voir_fiche='.$ligne[BAZ_CHAMPS_ID].'" onclick="javascript:window.open(this.href);return false;">'.$ligne[BAZ_CHAMPS_NOM].'</a></li>'."\n";
367
				if ($GLOBALS['AUTH']->getAuth() && $GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID)==$ligne[BAZ_CHAMPS_ID]) $possede_ressource=1;
371
				if ($GLOBALS['AUTH']->getAuth() && $GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID)==$ligne[BAZ_CHAMPS_ID]) $possede_ressource=1;
368
			}
372
			}
369
			$res .= '</ul><br />'."\n";
373
			$res .= '</ul><br />'."\n";
370
		}
374
		}
371
		else $res .= BAZ_PAS_D_APPROPRIATION.'<br /><br />'."\n";
375
		else $res .= BAZ_PAS_D_APPROPRIATION.'<br /><br />'."\n";
372
		$res .='<p class="bulle_corps">'."\n";
376
		$res .='<p class="bulle_corps">'."\n";
373
		$lien_appropriation = $GLOBALS['_BAZAR_']['url'];
377
		$lien_appropriation = $GLOBALS['_BAZAR_']['url'];
374
		$lien_appropriation->addQueryString('action', BAZ_VOIR_FICHE);
378
		$lien_appropriation->addQueryString('action', BAZ_VOIR_FICHE);
375
		$lien_appropriation->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);			
379
		$lien_appropriation->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);			
376
		if ($possede_ressource) {
380
		if ($possede_ressource) {
377
			$lien_appropriation->addQueryString('appropriation', 0);
381
			$lien_appropriation->addQueryString('appropriation', 0);
378
			$res .= BAZ_POSSEDE_DEJA_RESSOURCE.'<br />'."\n".'<a href="'.$lien_appropriation->getURL().'">'.BAZ_CLIQUER_POUR_VOUS_ENLEVER.'</a>'."\n";
382
			$res .= BAZ_POSSEDE_DEJA_RESSOURCE.'<br />'."\n".'<a href="'.$lien_appropriation->getURL().'">'.BAZ_CLIQUER_POUR_VOUS_ENLEVER.'</a>'."\n";
379
			$lien_appropriation->removeQueryString('appropriation');
383
			$lien_appropriation->removeQueryString('appropriation');
380
		}
384
		}
381
		elseif ($GLOBALS['AUTH']->getAuth() && $GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_EST_STRUCTURE)) {
385
		elseif ($GLOBALS['AUTH']->getAuth() && $GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_EST_STRUCTURE)) {
382
			$lien_appropriation->addQueryString('appropriation', 1);
386
			$lien_appropriation->addQueryString('appropriation', 1);
383
			$res .= BAZ_SI_POSSEDE_RESSOURCE.'<br />'."\n".'<a href="'.$lien_appropriation->getURL().'">'.BAZ_CLIQUER_POUR_APPARAITRE.'</a>'."\n";
387
			$res .= BAZ_SI_POSSEDE_RESSOURCE.'<br />'."\n".'<a href="'.$lien_appropriation->getURL().'">'.BAZ_CLIQUER_POUR_APPARAITRE.'</a>'."\n";
384
			$lien_appropriation->removeQueryString('appropriation');
388
			$lien_appropriation->removeQueryString('appropriation');
385
		}
389
		}
386
		elseif ($GLOBALS['AUTH']->getAuth() && !$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_EST_STRUCTURE)) {
390
		elseif ($GLOBALS['AUTH']->getAuth() && !$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_EST_STRUCTURE)) {
387
			$res .= BAZ_IL_FAUT_ETRE_STRUCTURE."\n";
391
			$res .= BAZ_IL_FAUT_ETRE_STRUCTURE."\n";
388
		}
392
		}
389
		elseif (!$GLOBALS['AUTH']->getAuth()) {
393
		elseif (!$GLOBALS['AUTH']->getAuth()) {
390
			$res .= BAZ_IL_FAUT_ETRE_IDENTIFIE_STRUCTURE."\n";
394
			$res .= BAZ_IL_FAUT_ETRE_IDENTIFIE_STRUCTURE."\n";
391
		}
395
		}
392
		$res .='</p>'."\n";
396
		$res .='</p>'."\n";
393
		$res .= '</div>'."\n";
397
		$res .= '</div>'."\n";
394
	}
398
	}
395
	
399
	
396
	//on ajoute les commentaires, s'il le faut
400
	//on ajoute les commentaires, s'il le faut
397
	if (($danslappli==1)and($GLOBALS['_BAZAR_']['commentaire']==1)) {
401
	if (($danslappli==1)and($GLOBALS['_BAZAR_']['commentaire']==1)) {
398
		$res .= '<br />'."\n".'<div class="BAZ_cadre_fiche">'."\n";
402
		$res .= '<br />'."\n".'<div class="BAZ_cadre_fiche">'."\n";
399
		$res .= '<h3>'.BAZ_LES_COMMENTAIRES.'</h3>'."\n";
403
		$res .= '<h3>'.BAZ_LES_COMMENTAIRES.'</h3>'."\n";
400
		$requete = 'SELECT * FROM bazar_commentaires WHERE bc_ce_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'].' ORDER BY bc_date ASC';
404
		$requete = 'SELECT * FROM bazar_commentaires WHERE bc_ce_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'].' ORDER BY bc_date ASC';
401
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
405
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
402
		if (DB::isError ($resultat)) {
406
		if (DB::isError ($resultat)) {
403
			die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
407
			die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
404
		}
408
		}
405
		if ($resultat->numRows()>0) {
409
		if ($resultat->numRows()>0) {
406
			$res .= BAZ_IL_Y_A.$resultat->numRows().' ';
410
			$res .= BAZ_IL_Y_A.$resultat->numRows().' ';
407
			if ($resultat->numRows()==1) $res .= BAZ_COMMENTAIRE.'<br />'."\n";
411
			if ($resultat->numRows()==1) $res .= BAZ_COMMENTAIRE.'<br />'."\n";
408
			else $res .= BAZ_COMMENTAIRES.'<br />'."\n";
412
			else $res .= BAZ_COMMENTAIRES.'<br />'."\n";
409
			while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
413
			while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
410
				$res .= '<div class="bulle_haut">&nbsp;</div>'."\n";
414
				$res .= '<div class="bulle_haut">&nbsp;</div>'."\n";
411
				$res .= '<div class="bulle_corps">'."\n";
415
				$res .= '<div class="bulle_corps">'."\n";
412
				//affichage du commentaire
416
				//affichage du commentaire
413
				$res .= $ligne['bc_commentaire'].'<br />'."\n";
417
				$res .= $ligne['bc_commentaire'].'<br />'."\n";
414
				$res .= '</div>'."\n";
418
				$res .= '</div>'."\n";
415
				$res .= '<div class="bulle_bas">'."\n";
419
				$res .= '<div class="bulle_bas">'."\n";
416
				$res .= '<div style="font-size:9px;margin-left:10px;">'.BAZ_PAR.' : <strong>'.$ligne['bc_nom'].'</strong>'.BAZ_ECRIT_LE.$ligne['bc_date'].'</div>'."\n";
420
				$res .= '<div style="font-size:9px;margin-left:10px;">'.BAZ_PAR.' : <strong>'.$ligne['bc_nom'].'</strong>'.BAZ_ECRIT_LE.$ligne['bc_date'].'</div>'."\n";
417
				//pour les identifies seulement, administrateurs de la rubrique ou superadmins
421
				//pour les identifies seulement, administrateurs de la rubrique ou superadmins
418
				if ($est_admin==1) {
422
				if ($est_admin==1) {
419
					$url_comment= $GLOBALS['_BAZAR_']['url'];
423
					$url_comment= $GLOBALS['_BAZAR_']['url'];
420
					$url_comment->addQueryString('action', BAZ_VOIR_FICHE);
424
					$url_comment->addQueryString('action', BAZ_VOIR_FICHE);
421
					$url_comment->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
425
					$url_comment->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
422
					$url_comment->addQueryString('id_commentaire', $ligne['bc_id_commentaire']);
426
					$url_comment->addQueryString('id_commentaire', $ligne['bc_id_commentaire']);
423
					$res .= '<a href="'.$url_comment->getURL().'" style="font-size:9px;float:right;">'.BAZ_SUPPRIMER.'</a>'."\n";
427
					$res .= '<a href="'.$url_comment->getURL().'" style="font-size:9px;float:right;">'.BAZ_SUPPRIMER.'</a>'."\n";
424
				}
428
				}
425
				$res .= '</div>'."\n";
429
				$res .= '</div>'."\n";
426
			}
430
			}
427
		}
431
		}
428
		else $res .= BAZ_PAS_DE_COMMENTAIRES.'<br /><br />'."\n";
432
		else $res .= BAZ_PAS_DE_COMMENTAIRES.'<br /><br />'."\n";
429
		
433
		
430
		//formulaire des commentaires
434
		//formulaire des commentaires
431
		$form_commentaire = new HTML_QuickForm('bazar_commentaire', 'post', $url);
435
		$form_commentaire = new HTML_QuickForm('bazar_commentaire', 'post', $url);
432
		$squelette =& $form_commentaire->defaultRenderer();
436
		$squelette =& $form_commentaire->defaultRenderer();
433
		$squelette->setFormTemplate("\n".'<form {attributes}>'."\n".'{content}'."\n".'</form>'."\n");
437
		$squelette->setFormTemplate("\n".'<form {attributes}>'."\n".'{content}'."\n".'</form>'."\n");
434
		$squelette->setElementTemplate( '<label style="width:200px;">{label}'.
438
		$squelette->setElementTemplate( '<label style="width:200px;">{label}'.
435
										'<!-- BEGIN required --><span class="symbole_obligatoire">&nbsp;*</span><!-- END required -->'."\n".
439
										'<!-- BEGIN required --><span class="symbole_obligatoire">&nbsp;*</span><!-- END required -->'."\n".
436
									    '</label><br />'."\n".'{element}<br />'."\n");
440
									    '</label><br />'."\n".'{element}<br />'."\n");
437
		$squelette->setRequiredNoteTemplate("\n".'<span class="symbole_obligatoire"> *{requiredNote}</span>'."\n");
441
		$squelette->setRequiredNoteTemplate("\n".'<span class="symbole_obligatoire"> *{requiredNote}</span>'."\n");
438
		$option=array('style'=>'width:300px;border:1px solid #000;', 'maxlength'=>100);
442
		$option=array('style'=>'width:300px;border:1px solid #000;', 'maxlength'=>100);
439
		$form_commentaire->addElement('text', 'Nom', BAZ_ENTREZ_VOTRE_NOM, $option);
443
		$form_commentaire->addElement('text', 'Nom', BAZ_ENTREZ_VOTRE_NOM, $option);
440
		$option=array('style'=>'width:95%;height:100px;white-space: pre;padding:3px;border:1px solid #000;');
444
		$option=array('style'=>'width:95%;height:100px;white-space: pre;padding:3px;border:1px solid #000;');
441
		require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm/textarea.php';
445
		require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm/textarea.php';
442
		$formtexte= new HTML_QuickForm_textarea('Commentaire', BAZ_ENTREZ_VOTRE_COMMENTAIRE, $option);
446
		$formtexte= new HTML_QuickForm_textarea('Commentaire', BAZ_ENTREZ_VOTRE_COMMENTAIRE, $option);
443
		$form_commentaire->addElement($formtexte) ;
447
		$form_commentaire->addElement($formtexte) ;
444
		$option=array('style'=>'border:1px solid #000;');
448
		$option=array('style'=>'border:1px solid #000;');
445
		$form_commentaire->addElement('submit', 'Envoyer', BAZ_ENVOYER, $option);
449
		$form_commentaire->addElement('submit', 'Envoyer', BAZ_ENVOYER, $option);
446
		$form_commentaire->addRule('Nom', BAZ_NOM_REQUIS, 'required', '', 'client') ;
450
		$form_commentaire->addRule('Nom', BAZ_NOM_REQUIS, 'required', '', 'client') ;
447
		$form_commentaire->addRule('Commentaire', BAZ_COMMENTAIRE_REQUIS, 'required', '', 'client') ;
451
		$form_commentaire->addRule('Commentaire', BAZ_COMMENTAIRE_REQUIS, 'required', '', 'client') ;
448
		$form_commentaire->setRequiredNote(BAZ_CHAMPS_REQUIS) ;
452
		$form_commentaire->setRequiredNote(BAZ_CHAMPS_REQUIS) ;
449
		$res .= $form_commentaire->toHTML();
453
		$res .= $form_commentaire->toHTML();
450
		$res .= '</div>'."\n";
454
		$res .= '</div>'."\n";
451
	}
455
	}
452
	
456
	
453
	return $res ;
457
	return $res ;
454
}
458
}
455
 
459
 
456
 
460
 
457
/** RSSversHTML () transforme un flux RSS (en XML) en page HTML
461
/** RSSversHTML () transforme un flux RSS (en XML) en page HTML
458
*
462
*
459
*   On passe en paramètre le contenu du flux RSS, on affiche ou non la description,
463
*   On passe en paramètre le contenu du flux RSS, on affiche ou non la description,
460
*   et on choisit de format de la date à l'affichage. On a en sortie du code HTML à afficher 
464
*   et on choisit de format de la date à l'affichage. On a en sortie du code HTML à afficher 
461
*
465
*
462
*   @param  string   le contenu du flux RSS
466
*   @param  string   le contenu du flux RSS
463
*   @param  boolean  afficher ou non la description
467
*   @param  boolean  afficher ou non la description
464
*   @param  string  choisir le format de date: jmah (12/02/2004 12h34) jmh (12/02 12h34) jma (12/02/2004) jm (12/02) ou rien
468
*   @param  string  choisir le format de date: jmah (12/02/2004 12h34) jmh (12/02 12h34) jma (12/02/2004) jm (12/02) ou rien
465
*
469
*
466
*   @return  string    le code HTML
470
*   @return  string    le code HTML
467
*/
471
*/
468
function RSSversHTML($rss, $voirdesc, $formatdate, $affichenb) {
472
function RSSversHTML($rss, $voirdesc, $formatdate, $affichenb) {
469
	if ($rss!='') {
473
	if ($rss!='') {
470
		$rawitems='';$title='';$url='';$cat='';$date='';
474
		$rawitems='';$title='';$url='';$cat='';$date='';
471
		$res='';
475
		$res='';
472
		if( eregi('<item>(.*)</item>', $rss, $rawitems ) ) {
476
		if( eregi('<item>(.*)</item>', $rss, $rawitems ) ) {
473
			$items = explode('<item>', $rawitems[0]);
477
			$items = explode('<item>', $rawitems[0]);
474
			$res.='<ul id="BAZ_liste_fiche">'."\n";
478
			$res.='<ul id="BAZ_liste_fiche">'."\n";
475
			for( $i = 0; $i < count($items)-1; $i++ ) {
479
			for( $i = 0; $i < count($items)-1; $i++ ) {
476
				eregi('<title>(.*)</title>',$items[$i+1], $title );
480
				eregi('<title>(.*)</title>',$items[$i+1], $title );
477
				eregi('<link>(.*)</link>',$items[$i+1], $url );
481
				eregi('<link>(.*)</link>',$items[$i+1], $url );
478
				eregi('<description>(.*)</description>',$items[$i+1], $cat);
482
				eregi('<description>(.*)</description>',$items[$i+1], $cat);
479
				eregi('<pubDate>(.*)</pubDate>',$items[$i+1], $date);
483
				eregi('<pubDate>(.*)</pubDate>',$items[$i+1], $date);
480
				$res.='<li>';
484
				$res.='<li>';
481
				if ($formatdate=='jm') {$res.=strftime('%d.%m',strtotime($date[1])).': ';}
485
				if ($formatdate=='jm') {$res.=strftime('%d.%m',strtotime($date[1])).': ';}
482
				if ($formatdate=='jma') {$res.=strftime('%d.%m.%Y',strtotime($date[1])).': ';}
486
				if ($formatdate=='jma') {$res.=strftime('%d.%m.%Y',strtotime($date[1])).': ';}
483
				if ($formatdate=='jmh') {$res.=strftime('%d.%m %H:%M',strtotime($date[1])).': ';}
487
				if ($formatdate=='jmh') {$res.=strftime('%d.%m %H:%M',strtotime($date[1])).': ';}
484
				if ($formatdate=='jmah') {$res.=strftime('%d.%m.%Y %H:%M',strtotime($date[1])).': ';}
488
				if ($formatdate=='jmah') {$res.=strftime('%d.%m.%Y %H:%M',strtotime($date[1])).': ';}
485
				$res.='<a href="'.preg_replace ('/&amp;/', '&', $url[1]).'">'.$title[1].'</a>';
489
				$res.='<a href="'.preg_replace ('/&amp;/', '&', $url[1]).'">'.$title[1].'</a>';
486
				if ($voirdesc) {$res.=$cat[1];}
490
				if ($voirdesc) {$res.=$cat[1];}
487
				// Ajout du bouton supprimer pour les superadministrateur
491
				// Ajout du bouton supprimer pour les superadministrateur
488
				if (($GLOBALS['AUTH']->getAuth() && niveau_droit(0,$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID))=='superadministrateur')and($url[1]!='#')) {
492
				if (($GLOBALS['AUTH']->getAuth() && niveau_droit(0,$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID))=='superadministrateur')and($url[1]!='#')) {
489
					$mon_url = preg_replace ('/&amp;/', '&', $url[1]) ; 
493
					$mon_url = preg_replace ('/&amp;/', '&', $url[1]) ; 
490
					$url_suppr = new Net_URL(preg_replace ('/&amp;/', '&', $mon_url)) ;
494
					$url_suppr = new Net_URL(preg_replace ('/&amp;/', '&', $mon_url)) ;
491
					$url_suppr->addQueryString('action', BAZ_ACTION_SUPPRESSION) ;
495
					$url_suppr->addQueryString('action', BAZ_ACTION_SUPPRESSION) ;
492
		        	$res .= ' ( <a href="'.$url_suppr->getURL().
496
		        	$res .= ' ( <a href="'.$url_suppr->getURL().
493
							'" onclick="javascript:return confirm(\''.BAZ_SUPPRIMER.' ?\');">'.
497
							'" onclick="javascript:return confirm(\''.BAZ_SUPPRIMER.' ?\');">'.
494
							BAZ_SUPPRIMER.'</a> )'."\n" ;
498
							BAZ_SUPPRIMER.'</a> )'."\n" ;
495
					}
499
					}
496
				$res.='</li>'."\n";
500
				$res.='</li>'."\n";
497
			}
501
			}
498
			$res.='</ul>'."\n";
502
			$res.='</ul>'."\n";
499
			if ($affichenb==1) {
503
			if ($affichenb==1) {
500
				//une annonce trouvee, on accorde au singulier
504
				//une annonce trouvee, on accorde au singulier
501
				if (((count($items)-1)==1)and($title!=BAZ_PAS_D_ANNONCES)) {
505
				if (((count($items)-1)==1)and($title!=BAZ_PAS_D_ANNONCES)) {
502
					$res = '<br /><h4>'.BAZ_IL_Y_A.' 1 '.BAZ_FICHE_CORRESPONDANTE.'</h4><br />'."\n".$res;
506
					$res = '<br /><h4>'.BAZ_IL_Y_A.' 1 '.BAZ_FICHE_CORRESPONDANTE.'</h4><br />'."\n".$res;
503
				}
507
				}
504
				//plusieures annonces trouvees, on accorde au pluriel
508
				//plusieures annonces trouvees, on accorde au pluriel
505
				else {
509
				else {
506
					$res = '<br /><h4>'.BAZ_IL_Y_A.(count($items)-1).' '.BAZ_FICHES_CORRESPONDANTES.'</h4><br />'."\n".$res;
510
					$res = '<br /><h4>'.BAZ_IL_Y_A.(count($items)-1).' '.BAZ_FICHES_CORRESPONDANTES.'</h4><br />'."\n".$res;
507
				}
511
				}
508
			}
512
			}
509
			//cas des fiches pas trouvées
513
			//cas des fiches pas trouvées
510
			if (((count($items)-1)==1)and($title[1]==BAZ_PAS_D_ANNONCES)) {
514
			if (((count($items)-1)==1)and($title[1]==BAZ_PAS_D_ANNONCES)) {
511
				$res = '<br /><h4>'.BAZ_PAS_D_ANNONCES.'</h4><br />'."\n";
515
				$res = '<br /><h4>'.BAZ_PAS_D_ANNONCES.'</h4><br />'."\n";
512
			}  
516
			}  
513
		}
517
		}
514
	}
518
	}
515
	else $res = BAZ_PAS_D_ANNONCES;
519
	else $res = BAZ_PAS_D_ANNONCES;
516
	
520
	
517
	return $res;
521
	return $res;
518
}
522
}
519
 
523
 
520
/** gen_RSS() - generer un fichier de flux RSS par type d'annonce 
524
/** gen_RSS() - generer un fichier de flux RSS par type d'annonce 
521
*
525
*
522
* @param   string Le type de l'annonce (laisser vide pour tout type d'annonce)
526
* @param   string Le type de l'annonce (laisser vide pour tout type d'annonce)
523
* @param   integer Le nombre d'annonces a regrouper dans le fichier XML (laisser vide pour toutes)
527
* @param   integer Le nombre d'annonces a regrouper dans le fichier XML (laisser vide pour toutes)
524
* @param   integer L'identifiant de l'emetteur (laisser vide pour tous)
528
* @param   integer L'identifiant de l'emetteur (laisser vide pour tous)
525
* @param   integer L'etat de validation de l'annonce (laisser 1 pour les annonces validees, 0 pour les non-validees)
529
* @param   integer L'etat de validation de l'annonce (laisser 1 pour les annonces validees, 0 pour les non-validees)
526
* @param   string La requete SQL personnalisee
530
* @param   string La requete SQL personnalisee
527
* @param   integer La categorie des fiches bazar
531
* @param   integer La categorie des fiches bazar
528
*
532
*
529
* @return  string Le code du flux RSS
533
* @return  string Le code du flux RSS
530
*/
534
*/
531
function gen_RSS($typeannonce='', $nbitem='', $emetteur='', $valide=1, $requeteSQL='', $requeteSQLFrom = '', $requeteWhereListe = '', $categorie_nature='') {
535
function gen_RSS($typeannonce='', $nbitem='', $emetteur='', $valide=1, $requeteSQL='', $requeteSQLFrom = '', $requeteWhereListe = '', $categorie_nature='') {
532
	// generation de la requete MySQL personnalisee
536
	// generation de la requete MySQL personnalisee
533
	$req_where=0;
537
	$req_where=0;
534
	$requete = 'SELECT DISTINCT bf_id_fiche, bf_titre, bf_date_debut_validite_fiche, bf_description '.
538
	$requete = 'SELECT DISTINCT bf_id_fiche, bf_titre, bf_date_debut_validite_fiche, bf_description '.
535
				'FROM bazar_fiche, bazar_nature '.$requeteSQLFrom.' WHERE '.$requeteWhereListe;
539
				'FROM bazar_fiche, bazar_nature '.$requeteSQLFrom.' WHERE '.$requeteWhereListe;
536
	if ($valide!=2) {
540
	if ($valide!=2) {
537
		$requete .= 'bf_statut_fiche='.$valide;
541
		$requete .= 'bf_statut_fiche='.$valide;
538
		$req_where=1;
542
		$req_where=1;
539
	}
543
	}
540
	$nomflux=BAZ_DERNIERE_ACTU;
544
	$nomflux=BAZ_DERNIERE_ACTU;
541
	if (!is_array ($typeannonce) && $typeannonce!='' and $typeannonce!='toutes') {
545
	if (!is_array ($typeannonce) && $typeannonce!='' and $typeannonce!='toutes') {
542
		if ($req_where==1) {$requete .= ' AND ';}
546
		if ($req_where==1) {$requete .= ' AND ';}
543
		$requete .= 'bf_ce_nature='.$typeannonce;
547
		$requete .= 'bf_ce_nature='.$typeannonce;
544
		$req_where=1;
548
		$req_where=1;
545
		//le nom du flux devient le type d'annonce
549
		//le nom du flux devient le type d'annonce
546
		$nomflux = $typeannonce;
550
		$nomflux = $typeannonce;
547
	}
551
	}
548
	// Cas où il y plusieurs type d annonce demande
552
	// Cas où il y plusieurs type d annonce demande
549
	if (is_array ($typeannonce)) {
553
	if (is_array ($typeannonce)) {
550
		if ($req_where==1) {$requete .= ' AND ';}
554
		if ($req_where==1) {$requete .= ' AND ';}
551
		$requete .= 'bf_ce_nature IN (' ;
555
		$requete .= 'bf_ce_nature IN (' ;
552
		$chaine = '';
556
		$chaine = '';
553
		foreach ($typeannonce as $valeur) $chaine .= '"'.$valeur.'",' ;
557
		foreach ($typeannonce as $valeur) $chaine .= '"'.$valeur.'",' ;
554
		$requete .= substr ($chaine, 0, strlen ($chaine)-1) ; 
558
		$requete .= substr ($chaine, 0, strlen ($chaine)-1) ; 
555
		$requete .= ') ';
559
		$requete .= ') ';
556
	}
560
	}
557
	$utilisateur = new Administrateur_bazar ($GLOBALS['AUTH']) ;
561
	$utilisateur = new Administrateur_bazar ($GLOBALS['AUTH']) ;
558
	if ($valide!=0) {
562
	if ($valide!=0) {
559
		
563
		
560
		if ($utilisateur->isSuperAdmin()) {
564
		if ($utilisateur->isSuperAdmin()) {
561
			$req_where=1;
565
			$req_where=1;
562
		} else {
566
		} else {
563
			if ($req_where==1) {
567
			if ($req_where==1) {
564
				$requete .= ' AND ';
568
				$requete .= ' AND ';
565
			}
569
			}
566
			$requete .= '(bf_date_debut_validite_fiche<=NOW() or bf_date_debut_validite_fiche="0000-00-00")'.
570
			$requete .= '(bf_date_debut_validite_fiche<=NOW() or bf_date_debut_validite_fiche="0000-00-00")'.
567
						' AND (bf_date_fin_validite_fiche>=NOW() or bf_date_fin_validite_fiche="0000-00-00") AND bn_id_nature=bf_ce_nature';
571
						' AND (bf_date_fin_validite_fiche>=NOW() or bf_date_fin_validite_fiche="0000-00-00") AND bn_id_nature=bf_ce_nature';
568
		}
572
		}
569
	}
573
	}
570
	else $nomflux .= BAZ_A_MODERER;
574
	else $nomflux .= BAZ_A_MODERER;
571
	if ($emetteur!='' && $emetteur!='tous') {
575
	if ($emetteur!='' && $emetteur!='tous') {
572
		if ($req_where==1) {$requete .= ' AND ';}
576
		if ($req_where==1) {$requete .= ' AND ';}
573
		$requete .= 'bf_ce_utilisateur='.$emetteur;
577
		$requete .= 'bf_ce_utilisateur='.$emetteur;
574
		$req_where=1;
578
		$req_where=1;
575
		//requete pour afficher le nom de la structure
579
		//requete pour afficher le nom de la structure
576
		$requetenom = 'SELECT '.BAZ_CHAMPS_NOM.', '.BAZ_CHAMPS_PRENOM.' FROM '.
580
		$requetenom = 'SELECT '.BAZ_CHAMPS_NOM.', '.BAZ_CHAMPS_PRENOM.' FROM '.
577
						BAZ_ANNUAIRE.' WHERE '.BAZ_CHAMPS_ID.'='.$emetteur;
581
						BAZ_ANNUAIRE.' WHERE '.BAZ_CHAMPS_ID.'='.$emetteur;
578
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requetenom) ;
582
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requetenom) ;
579
		if (DB::isError($resultat)) {
583
		if (DB::isError($resultat)) {
580
			die ($resultat->getMessage().$resultat->getDebugInfo()) ;
584
			die ($resultat->getMessage().$resultat->getDebugInfo()) ;
581
		}
585
		}
582
		$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
586
		$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
583
		$nomflux .= ' ('.$ligne[BAZ_CHAMPS_NOM].' '.$ligne[BAZ_CHAMPS_PRENOM].')';
587
		$nomflux .= ' ('.$ligne[BAZ_CHAMPS_NOM].' '.$ligne[BAZ_CHAMPS_PRENOM].')';
584
	}
588
	}
585
	if ($requeteSQL!='') {
589
	if ($requeteSQL!='') {
586
		if ($req_where==1) {$requete .= ' AND ';}
590
		if ($req_where==1) {$requete .= ' AND ';}
587
		$requete .= '('.$requeteSQL.')';
591
		$requete .= '('.$requeteSQL.')';
588
		$req_where=1;
592
		$req_where=1;
589
	}
593
	}
590
	if ($categorie_nature!='') {
594
	if ($categorie_nature!='') {
591
		if ($req_where==1) {$requete .= ' AND ';}
595
		if ($req_where==1) {$requete .= ' AND ';}
592
		$requete .= 'bn_ce_id_menu='.$categorie_nature.' ';
596
		$requete .= 'bn_ce_id_menu='.$categorie_nature.' ';
593
		$req_where=1;
597
		$req_where=1;
594
	}
598
	}
595
	
599
	
596
	$requete .= ' ORDER BY  bf_date_debut_validite_fiche DESC, bf_date_fin_validite_fiche DESC, bf_date_maj_fiche DESC';
600
	$requete .= ' ORDER BY  bf_date_debut_validite_fiche DESC, bf_date_fin_validite_fiche DESC, bf_date_maj_fiche DESC';
597
	if ($nbitem!='') {$requete .= ' LIMIT 0,'.$nbitem;}
601
	if ($nbitem!='') {$requete .= ' LIMIT 0,'.$nbitem;}
598
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
602
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
599
	if (DB::isError($resultat)) {
603
	if (DB::isError($resultat)) {
600
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
604
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
601
	}
605
	}
602
	// En-tete du flux RSS version 2.0
606
	// En-tete du flux RSS version 2.0
603
	$xml = '<?xml version="1.0" encoding="ISO-8859-1"?>'."\n".'<rss version="2.0">'."\n";
607
	$xml = '<?xml version="1.0" encoding="ISO-8859-1"?>'."\n".'<rss version="2.0">'."\n";
604
	$xml .= '<channel>'."\n".'<title>'.$nomflux.'</title>'."\n".'<link>'.BAZ_RSS_ADRESSESITE.'</link>'."\n";
608
	$xml .= '<channel>'."\n".'<title>'.$nomflux.'</title>'."\n".'<link>'.BAZ_RSS_ADRESSESITE.'</link>'."\n";
605
	$xml .= '<description>'.BAZ_RSS_DESCRIPTIONSITE.'</description>'."\n".'<language>fr-FR</language>'."\n".
609
	$xml .= '<description>'.BAZ_RSS_DESCRIPTIONSITE.'</description>'."\n".'<language>fr-FR</language>'."\n".
606
	'<copyright>Copyright 2005 '.BAZ_RSS_NOMSITE.'</copyright>'."\n";
610
	'<copyright>Copyright 2005 '.BAZ_RSS_NOMSITE.'</copyright>'."\n";
607
	// Ajout de la date actuelle de publication (suivant la DTD RSS)
611
	// Ajout de la date actuelle de publication (suivant la DTD RSS)
608
	$xml .= '<lastBuildDate>'.strftime('%d %b %Y %H:%M:%S GMT').'</lastBuildDate>'."\n";
612
	$xml .= '<lastBuildDate>'.strftime('%d %b %Y %H:%M:%S GMT').'</lastBuildDate>'."\n";
609
	// En-tete suite et fin
613
	// En-tete suite et fin
610
	$xml .= '<docs>http://www.stervinou.com/projets/rss/</docs>'."\n".'<category>'.BAZ_RSS_CATEGORIE.'</category>'."\n".
614
	$xml .= '<docs>http://www.stervinou.com/projets/rss/</docs>'."\n".'<category>'.BAZ_RSS_CATEGORIE.'</category>'."\n".
611
	'<managingEditor>'.BAZ_RSS_MANAGINGEDITOR.'</managingEditor>'."\n".'<webMaster>'.BAZ_RSS_WEBMASTER.'</webMaster>'."\n";
615
	'<managingEditor>'.BAZ_RSS_MANAGINGEDITOR.'</managingEditor>'."\n".'<webMaster>'.BAZ_RSS_WEBMASTER.'</webMaster>'."\n";
612
	$xml .= '<ttl>60</ttl>'."\n".'<image>'."\n".'<title>'.BAZ_RSS_NOMSITE.'</title>'."\n".'<url>'.BAZ_RSS_LOGOSITE.'</url>'."\n".
616
	$xml .= '<ttl>60</ttl>'."\n".'<image>'."\n".'<title>'.BAZ_RSS_NOMSITE.'</title>'."\n".'<url>'.BAZ_RSS_LOGOSITE.'</url>'."\n".
613
	'<link>'.BAZ_RSS_ADRESSESITE.'</link>'."\n".'</image>'."\n";
617
	'<link>'.BAZ_RSS_ADRESSESITE.'</link>'."\n".'</image>'."\n";
614
	if ($resultat->numRows()>0) {
618
	if ($resultat->numRows()>0) {
615
		// Creation des items : titre + lien + description + date de publication
619
		// Creation des items : titre + lien + description + date de publication
616
		while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
620
		while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
617
			$xml .= '<item>'."\n";
621
			$xml .= '<item>'."\n";
618
			$xml .= '<title>'.$ligne['bf_titre'].'</title>'."\n";
622
			$xml .= '<title>'.$ligne['bf_titre'].'</title>'."\n";
619
			$lien=$GLOBALS['_BAZAR_']['url'];
623
			$lien=$GLOBALS['_BAZAR_']['url'];
620
			$lien->addQueryString('action', BAZ_VOIR_FICHE);
624
			$lien->addQueryString('action', BAZ_VOIR_FICHE);
621
			$lien->addQueryString('id_fiche', $ligne['bf_id_fiche']);
625
			$lien->addQueryString('id_fiche', $ligne['bf_id_fiche']);
622
			$xml .= '<link>'.str_replace ('&', '&amp;', $lien->getURL()).'</link>'."\n";
626
			$xml .= '<link>'.str_replace ('&', '&amp;', $lien->getURL()).'</link>'."\n";
623
			$xml .= '<description>'."\n".'<![CDATA[' ;
627
			$xml .= '<description>'."\n".'<![CDATA[' ;
624
			if ($_GET['action'] != BAZ_VOIR_TOUTES_ANNONCES) {
628
			if ($_GET['action'] != BAZ_VOIR_TOUTES_ANNONCES) {
625
				//$xml .= baz_voir_fiche(0,$ligne['bf_id_fiche']) ;
629
				//$xml .= baz_voir_fiche(0,$ligne['bf_id_fiche']) ;
626
				$xml .= $ligne['bf_description'] ;
630
				$xml .= $ligne['bf_description'] ;
627
			}
631
			}
628
			$xml .= ']]>'."\n".'</description>'."\n";
632
			$xml .= ']]>'."\n".'</description>'."\n";
629
			$xml .= '<pubDate>'.strftime('%d %b %Y %H:%M:%S GMT',strtotime($ligne['bf_date_debut_validite_fiche'])).'</pubDate>'."\n";
633
			$xml .= '<pubDate>'.strftime('%d %b %Y %H:%M:%S GMT',strtotime($ligne['bf_date_debut_validite_fiche'])).'</pubDate>'."\n";
630
			$xml .= '</item>'."\n";
634
			$xml .= '</item>'."\n";
631
		}
635
		}
632
	}
636
	}
633
	else {//pas d'annonces
637
	else {//pas d'annonces
634
		$xml .= '<item>'."\n";
638
		$xml .= '<item>'."\n";
635
		$xml .= '<title>'.BAZ_PAS_D_ANNONCES.'</title>'."\n";
639
		$xml .= '<title>'.BAZ_PAS_D_ANNONCES.'</title>'."\n";
636
		$xml .= '<link>#</link>'."\n";
640
		$xml .= '<link>#</link>'."\n";
637
		$xml .= '<description>'.BAZ_PAS_D_ANNONCES.'</description>'."\n";
641
		$xml .= '<description>'.BAZ_PAS_D_ANNONCES.'</description>'."\n";
638
		$xml .= '<pubDate>'.strftime('%d %b %Y %H:%M:%S GMT',strtotime('12/12/2004')).'</pubDate>'."\n";
642
		$xml .= '<pubDate>'.strftime('%d %b %Y %H:%M:%S GMT',strtotime('12/12/2004')).'</pubDate>'."\n";
639
		$xml .= '</item>'."\n";
643
		$xml .= '</item>'."\n";
640
	}
644
	}
641
	$xml .= '</channel>'."\n".'</rss>'."\n";
645
	$xml .= '</channel>'."\n".'</rss>'."\n";
642
	return $xml;
646
	return $xml;
643
}
647
}
644
 
648
 
645
 
649
 
646
/** baz_liste() Formate la liste de toutes les annonces actuelles
650
/** baz_liste() Formate la liste de toutes les annonces actuelles
647
*
651
*
648
*   @return  string    le code HTML a afficher
652
*   @return  string    le code HTML a afficher
649
*/
653
*/
650
function baz_liste($typeannonce='toutes') {
654
function baz_liste($typeannonce='toutes') {
651
	//creation du lien pour le formulaire de recherche
655
	//creation du lien pour le formulaire de recherche
652
	$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_VOIR_TOUTES_ANNONCES);
656
	$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_VOIR_TOUTES_ANNONCES);
653
	if (isset($_REQUEST['recherche_avancee'])) $GLOBALS['_BAZAR_']['url']->addQueryString ('recherche_avancee', $_REQUEST['recherche_avancee']);
657
	if (isset($_REQUEST['recherche_avancee'])) $GLOBALS['_BAZAR_']['url']->addQueryString ('recherche_avancee', $_REQUEST['recherche_avancee']);
654
	$lien_formulaire = preg_replace ('/&amp;/', '&', $GLOBALS['_BAZAR_']['url']->getURL()) ;
658
	$lien_formulaire = preg_replace ('/&amp;/', '&', $GLOBALS['_BAZAR_']['url']->getURL()) ;
655
	$formtemplate = new HTML_QuickForm('formulaire', 'post', $lien_formulaire) ;
659
	$formtemplate = new HTML_QuickForm('formulaire', 'post', $lien_formulaire) ;
656
	$squelette =& $formtemplate->defaultRenderer();
660
	$squelette =& $formtemplate->defaultRenderer();
657
   	$squelette->setFormTemplate("\n".'<form {attributes}>'."\n".'<table style="border:0;width:100%;">'."\n".'{content}'."\n".'</table>'."\n".'</form>'."\n");
661
   	$squelette->setFormTemplate("\n".'<form {attributes}>'."\n".'<table style="border:0;width:100%;">'."\n".'{content}'."\n".'</table>'."\n".'</form>'."\n");
658
    $squelette->setElementTemplate( '<tr>'."\n".'<td style="font-size:12px;width:120px;text-align:right;">'."\n".'{label}'.
662
    $squelette->setElementTemplate( '<tr>'."\n".'<td style="font-size:12px;width:120px;text-align:right;">'."\n".'{label}'.
659
    		                        '<!-- BEGIN required --><span class="symbole_obligatoire">&nbsp;*</span><!-- END required -->'."\n".
663
    		                        '<!-- BEGIN required --><span class="symbole_obligatoire">&nbsp;*</span><!-- END required -->'."\n".
660
    								' :</td>'."\n".'<td style="text-align:left;padding:5px;"> '."\n".'{element}'."\n".
664
    								' :</td>'."\n".'<td style="text-align:left;padding:5px;"> '."\n".'{element}'."\n".
661
                                    '<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n".
665
                                    '<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n".
662
                                    '</td>'."\n".'</tr>'."\n");
666
                                    '</td>'."\n".'</tr>'."\n");
663
 	$squelette->setElementTemplate( '<tr>'."\n".'<td colspan="2" class="liste_a_cocher"><strong>{label}&nbsp;{element}</strong>'."\n".
667
 	$squelette->setElementTemplate( '<tr>'."\n".'<td colspan="2" class="liste_a_cocher"><strong>{label}&nbsp;{element}</strong>'."\n".
664
                                    '<!-- BEGIN required --><span class="symbole_obligatoire">&nbsp;*</span><!-- END required -->'."\n".'</td>'."\n".'</tr>'."\n", 'accept_condition');
668
                                    '<!-- BEGIN required --><span class="symbole_obligatoire">&nbsp;*</span><!-- END required -->'."\n".'</td>'."\n".'</tr>'."\n", 'accept_condition');
665
  	$squelette->setElementTemplate( '<tr><td colspan="2">{label}{element}</td></tr>'."\n", 'rechercher');
669
  	$squelette->setElementTemplate( '<tr><td colspan="2">{label}{element}</td></tr>'."\n", 'rechercher');
666
  	  	
670
  	  	
667
 	$squelette->setRequiredNoteTemplate("\n".'<tr>'."\n".'<td colspan="2" class="symbole_obligatoire">* {requiredNote}</td></tr>'."\n");
671
 	$squelette->setRequiredNoteTemplate("\n".'<tr>'."\n".'<td colspan="2" class="symbole_obligatoire">* {requiredNote}</td></tr>'."\n");
668
	//Traduction de champs requis
672
	//Traduction de champs requis
669
	$formtemplate->setRequiredNote(BAZ_CHAMPS_REQUIS) ;
673
	$formtemplate->setRequiredNote(BAZ_CHAMPS_REQUIS) ;
670
	$formtemplate->setJsWarnings(BAZ_ERREUR_SAISIE,BAZ_VEUILLEZ_CORRIGER);	
674
	$formtemplate->setJsWarnings(BAZ_ERREUR_SAISIE,BAZ_VEUILLEZ_CORRIGER);	
671
	
675
	
672
		
676
		
673
	//cas du formulaire de recherche proposant de chercher parmis tous les types d'annonces 
677
	//cas du formulaire de recherche proposant de chercher parmis tous les types d'annonces 
674
	//requete pour obtenir l'id et le label des types d'annonces
678
	//requete pour obtenir l'id et le label des types d'annonces
675
	$requete = 'SELECT bn_id_nature, bn_label_nature '.
679
	$requete = 'SELECT bn_id_nature, bn_label_nature '.
676
	           'FROM bazar_nature WHERE bn_ce_id_menu='.$GLOBALS['_BAZAR_']['categorie_nature'].' '.
680
	           'FROM bazar_nature WHERE bn_ce_id_menu='.$GLOBALS['_BAZAR_']['categorie_nature'].' '.
677
			   'ORDER BY bn_label_nature ASC';
681
			   'ORDER BY bn_label_nature ASC';
678
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
682
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
679
	if (DB::isError($resultat)) {
683
	if (DB::isError($resultat)) {
680
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
684
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
681
	}
685
	}
682
	//on récupère le nb de types de fiches, pour plus tard
686
	//on récupère le nb de types de fiches, pour plus tard
683
	$nb_type_de_fiches=$resultat->numRows();
687
	$nb_type_de_fiches=$resultat->numRows();
684
	$type_annonce_select['toutes']=BAZ_TOUS_TYPES_FICHES;
688
	$type_annonce_select['toutes']=BAZ_TOUS_TYPES_FICHES;
685
	while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
689
	while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
686
		$type_annonce_select[$ligne['bn_id_nature']] = $ligne['bn_label_nature'];
690
		$type_annonce_select[$ligne['bn_id_nature']] = $ligne['bn_label_nature'];
687
		$tableau_typeannonces[] = $ligne['bn_id_nature'] ;
691
		$tableau_typeannonces[] = $ligne['bn_id_nature'] ;
688
	}
692
	}
689
	if ($nb_type_de_fiches>1 && $GLOBALS['_BAZAR_']['typeannonce']=='toutes') {
693
	if ($nb_type_de_fiches>1 && $GLOBALS['_BAZAR_']['typeannonce']=='toutes') {
690
		$res= '<h2>'.BAZ_TOUTES_LES_ANNONCES.'</h2><br />'."\n";
694
		$res= '<h2>'.BAZ_TOUTES_LES_ANNONCES.'</h2><br />'."\n";
691
		$option=array('style'=>'border:1px solid #000;width: 200px;font:12px Myriad, Arial, sans-serif;',
695
		$option=array('style'=>'border:1px solid #000;width: 200px;font:12px Myriad, Arial, sans-serif;',
692
						'onchange' => 'javascript:this.form.submit();');
696
						'onchange' => 'javascript:this.form.submit();');
693
		$formtemplate->addElement ('select', 'nature', BAZ_TYPEANNONCE, $type_annonce_select, $option) ;
697
		$formtemplate->addElement ('select', 'nature', BAZ_TYPEANNONCE, $type_annonce_select, $option) ;
694
		if (isset($_REQUEST['nature'])) {
698
		if (isset($_REQUEST['nature'])) {
695
			$defauts=array('nature'=>$_REQUEST['nature']);
699
			$defauts=array('nature'=>$_REQUEST['nature']);
696
			$formtemplate->setDefaults($defauts);
700
			$formtemplate->setDefaults($defauts);
697
		}		
701
		}		
698
	}
702
	}
699
	//cas du type d'annonces prédéfini 
703
	//cas du type d'annonces prédéfini 
700
	else {
704
	else {
701
		$res = '<h2>'.BAZ_TOUTES_LES_ANNONCES_DE_TYPE.' '.$GLOBALS['_BAZAR_']['typeannonce'].'</h2>'."\n";
705
		$res = '<h2>'.BAZ_TOUTES_LES_ANNONCES_DE_TYPE.' '.$GLOBALS['_BAZAR_']['typeannonce'].'</h2>'."\n";
702
	}
706
	}
703
 
707
 
704
	//requete pour obtenir l'id, le nom et prenom de toutes les personnes ayant depose une fiche
708
	//requete pour obtenir l'id, le nom et prenom de toutes les personnes ayant depose une fiche
705
	// dans le but de construire l'élément de formulaire select avec les noms des émetteurs de fiche	
709
	// dans le but de construire l'élément de formulaire select avec les noms des émetteurs de fiche	
706
	if (BAZ_RECHERCHE_PAR_EMETTEUR) {
710
	if (BAZ_RECHERCHE_PAR_EMETTEUR) {
707
		$requete = 'SELECT '.BAZ_CHAMPS_ID.', '.BAZ_CHAMPS_NOM.', '.BAZ_CHAMPS_PRENOM.' '.
711
		$requete = 'SELECT '.BAZ_CHAMPS_ID.', '.BAZ_CHAMPS_NOM.', '.BAZ_CHAMPS_PRENOM.' '.
708
		           'FROM bazar_fiche,'.BAZ_ANNUAIRE.' WHERE ' ;
712
		           'FROM bazar_fiche,'.BAZ_ANNUAIRE.' WHERE ' ;
709
	
713
	
710
		$requete .= ' bf_date_debut_validite_fiche<=NOW() AND bf_date_fin_validite_fiche>=NOW() and';	
714
		$requete .= ' bf_date_debut_validite_fiche<=NOW() AND bf_date_fin_validite_fiche>=NOW() and';	
711
	
715
	
712
		$requete .= ' bf_ce_utilisateur='.BAZ_CHAMPS_ID.' ';
716
		$requete .= ' bf_ce_utilisateur='.BAZ_CHAMPS_ID.' ';
713
	    if (!isset($_REQUEST['nature'])) {
717
	    if (!isset($_REQUEST['nature'])) {
714
	    		if (isset($GLOBALS['_BAZAR_']['id_typeannonce'])) {
718
	    		if (isset($GLOBALS['_BAZAR_']['id_typeannonce'])) {
715
	    			$requete .= 'AND bf_ce_nature="'.$GLOBALS['_BAZAR_']['id_typeannonce'].'" ';
719
	    			$requete .= 'AND bf_ce_nature="'.$GLOBALS['_BAZAR_']['id_typeannonce'].'" ';
716
	    		} 
720
	    		} 
717
		}
721
		}
718
		else {
722
		else {
719
	    		if ($_REQUEST['nature']!='toutes') {
723
	    		if ($_REQUEST['nature']!='toutes') {
720
	    			$requete .= 'AND bf_ce_nature='.$_REQUEST['nature'].' ';
724
	    			$requete .= 'AND bf_ce_nature='.$_REQUEST['nature'].' ';
721
	    		}
725
	    		}
722
	    }
726
	    }
723
	    
727
	    
724
	    $requete .= 'ORDER BY '.BAZ_CHAMPS_NOM.' ASC';
728
	    $requete .= 'ORDER BY '.BAZ_CHAMPS_NOM.' ASC';
725
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
729
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
726
		if (DB::isError($resultat)) {
730
		if (DB::isError($resultat)) {
727
			die ($resultat->getMessage().$resultat->getDebugInfo()) ;
731
			die ($resultat->getMessage().$resultat->getDebugInfo()) ;
728
		}
732
		}
729
		$personnes_select['tous']=BAZ_TOUS_LES_EMETTEURS;
733
		$personnes_select['tous']=BAZ_TOUS_LES_EMETTEURS;
730
		while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
734
		while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
731
			$personnes_select[$ligne[BAZ_CHAMPS_ID]] = $ligne[BAZ_CHAMPS_NOM]." ".$ligne[BAZ_CHAMPS_PRENOM] ;
735
			$personnes_select[$ligne[BAZ_CHAMPS_ID]] = $ligne[BAZ_CHAMPS_NOM]." ".$ligne[BAZ_CHAMPS_PRENOM] ;
732
		}
736
		}
733
		$option=array('style'=>'border:1px solid #000;width: 200px;font:12px Myriad, Arial, sans-serif;');
737
		$option=array('style'=>'border:1px solid #000;width: 200px;font:12px Myriad, Arial, sans-serif;');
734
		$formtemplate->addElement ('select', 'personnes', BAZ_EMETTEUR, $personnes_select, $option) ;
738
		$formtemplate->addElement ('select', 'personnes', BAZ_EMETTEUR, $personnes_select, $option) ;
735
	} else {
739
	} else {
736
		$formtemplate->addElement ('hidden', 'personnes', 'tous') ;
740
		$formtemplate->addElement ('hidden', 'personnes', 'tous') ;
737
	}
741
	}
738
	
742
	
739
		//pour les super-administrateurs, on peut voir les annonces non validées
743
		//pour les super-administrateurs, on peut voir les annonces non validées
740
	//on verifie si l'utilisateur est administrateur
744
	//on verifie si l'utilisateur est administrateur
741
	$utilisateur = new Administrateur_bazar($GLOBALS['AUTH']) ;
745
	$utilisateur = new Administrateur_bazar($GLOBALS['AUTH']) ;
742
 
746
 
743
	if ($utilisateur->isSuperAdmin()) {
747
	if ($utilisateur->isSuperAdmin()) {
744
		$option=array('style'=>'border:1px solid #000;width: 200px;font:12px Myriad, Arial, sans-serif;');
748
		$option=array('style'=>'border:1px solid #000;width: 200px;font:12px Myriad, Arial, sans-serif;');
745
		$valide_select[0] = BAZ_FICHES_PAS_VALIDEES;
749
		$valide_select[0] = BAZ_FICHES_PAS_VALIDEES;
746
		$valide_select[1] = BAZ_FICHES_VALIDEES;
750
		$valide_select[1] = BAZ_FICHES_VALIDEES;
747
		$valide_select[2] = BAZ_LES_DEUX;
751
		$valide_select[2] = BAZ_LES_DEUX;
748
		$formtemplate->addElement ('select', 'valides', BAZ_VALIDE, $valide_select, $option) ; 
752
		$formtemplate->addElement ('select', 'valides', BAZ_VALIDE, $valide_select, $option) ; 
749
		$defauts=array('valides'=>1);
753
		$defauts=array('valides'=>1);
750
		$formtemplate->setDefaults($defauts);
754
		$formtemplate->setDefaults($defauts);
751
	}
755
	}
752
	
756
	
753
	//champs texte pour entrer les mots cles
757
	//champs texte pour entrer les mots cles
754
	$option=array('maxlength'=>60,'style'=>'border:1px solid #000;width:200px;font:12px Myriad, Arial, sans-serif;');
758
	$option=array('maxlength'=>60,'style'=>'border:1px solid #000;width:200px;font:12px Myriad, Arial, sans-serif;');
755
	$formtemplate->addElement('text', 'recherche_mots_cles', BAZ_MOT_CLE, $option) ;
759
	$formtemplate->addElement('text', 'recherche_mots_cles', BAZ_MOT_CLE, $option) ;
756
	$defauts=array('recherche_mots_cles'=>BAZ_MOT_CLE);
760
	$defauts=array('recherche_mots_cles'=>BAZ_MOT_CLE);
757
	$formtemplate->setDefaults($defauts);
761
	$formtemplate->setDefaults($defauts);
758
	
762
	
759
	//option cachee pour savoir si le formulaire a ete appele deja 
763
	//option cachee pour savoir si le formulaire a ete appele deja 
760
	$formtemplate->addElement('hidden', 'recherche_effectuee', 1) ;
764
	$formtemplate->addElement('hidden', 'recherche_effectuee', 1) ;
761
	
765
	
762
	// Ajout des options si un type de fiche a ete choisie
766
	// Ajout des options si un type de fiche a ete choisie
763
	if ( (isset($_REQUEST['nature']) && $_REQUEST['nature'] != 'toutes') || (isset($GLOBALS['_BAZAR_']['categorie_nature']) && $nb_type_de_fiches==1) ) {
767
	if ( (isset($_REQUEST['nature']) && $_REQUEST['nature'] != 'toutes') || (isset($GLOBALS['_BAZAR_']['categorie_nature']) && $nb_type_de_fiches==1) ) {
764
		if ( BAZ_MOTEUR_RECHERCHE_AVANCEE || ( isset($_REQUEST['recherche_avancee'])&&$_REQUEST['recherche_avancee']==1) ) { 
768
		if ( BAZ_MOTEUR_RECHERCHE_AVANCEE || ( isset($_REQUEST['recherche_avancee'])&&$_REQUEST['recherche_avancee']==1) ) { 
765
			if ($GLOBALS['_BAZAR_']['categorie_nature'] != '') {
769
			if ($GLOBALS['_BAZAR_']['categorie_nature'] != '') {
766
				$champs_requete = '' ;
770
				$champs_requete = '' ;
767
				if (!isset($_REQUEST['nature']) || $_REQUEST['nature'] == '') {
771
				if (!isset($_REQUEST['nature']) || $_REQUEST['nature'] == '') {
768
					$_REQUEST['nature'] = $tableau_typeannonces[0];
772
					$_REQUEST['nature'] = $tableau_typeannonces[0];
769
				}
773
				}
770
			}
774
			}
771
			// Récupération du template
775
			// Récupération du template
772
			$requete = 'SELECT bn_template FROM bazar_nature WHERE bn_id_nature="'.$_REQUEST['nature'].'"';
776
			$requete = 'SELECT bn_template FROM bazar_nature WHERE bn_id_nature="'.$_REQUEST['nature'].'"';
773
			$resultat = $GLOBALS['_BAZAR_']['db']->getOne($requete) ;
777
			$resultat = $GLOBALS['_BAZAR_']['db']->getOne($requete) ;
774
			if (DB::isError($resultat)) {
778
			if (DB::isError($resultat)) {
775
				die ($resultat->getMessage().$resultat->getDebugInfo()) ;
779
				die ($resultat->getMessage().$resultat->getDebugInfo()) ;
776
			}
780
			}
777
			
781
			
778
			if ($_REQUEST['recherche_avancee']==1) {
782
			if ($_REQUEST['recherche_avancee']==1) {
779
				foreach(array_merge($_POST, $_GET) as $cle => $valeur) $GLOBALS['_BAZAR_']['url']->addQueryString($cle, $valeur); 
783
				foreach(array_merge($_POST, $_GET) as $cle => $valeur) $GLOBALS['_BAZAR_']['url']->addQueryString($cle, $valeur); 
780
				$GLOBALS['_BAZAR_']['url']->addQueryString('recherche_avancee', '0');
784
				$GLOBALS['_BAZAR_']['url']->addQueryString('recherche_avancee', '0');
781
				$lien_recherche_de_base = '<a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'">'.BAZ_RECHERCHE_DE_BASE.'</a><br />';
785
				$lien_recherche_de_base = '<a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'">'.BAZ_RECHERCHE_DE_BASE.'</a><br />';
782
				//lien recherche de base
786
				//lien recherche de base
783
				labelhtml($formtemplate,'',$lien_recherche_de_base,'','','','','');		
787
				labelhtml($formtemplate,'',$lien_recherche_de_base,'','','','','');		
784
			}
788
			}
785
			
789
			
786
			$tableau = baz_valeurs_template($resultat) ;
790
			$tableau = baz_valeurs_template($resultat) ;
787
			for ($i=0; $i<count($tableau); $i++) {
791
			for ($i=0; $i<count($tableau); $i++) {
788
				if (($tableau[$i]['type'] == 'liste' || $tableau[$i]['type'] == 'checkbox') && $tableau[$i]['recherche'] == 1) {
792
				if (($tableau[$i]['type'] == 'liste' || $tableau[$i]['type'] == 'checkbox') && $tableau[$i]['recherche'] == 1) {
789
					$tableau[$i]['type']($formtemplate, $tableau[$i]['nom_bdd'], $tableau[$i]['label'], $tableau[$i]['limite1'],
793
					$tableau[$i]['type']($formtemplate, $tableau[$i]['nom_bdd'], $tableau[$i]['label'], $tableau[$i]['limite1'],
790
			                         $tableau[$i]['limite2'], $tableau[$i]['defaut'], $tableau[$i]['table_source'], $tableau[$i]['obligatoire'], 1) ;
794
			                         $tableau[$i]['limite2'], $tableau[$i]['defaut'], $tableau[$i]['table_source'], $tableau[$i]['obligatoire'], 1) ;
791
				}
795
				}
792
			}
796
			}
793
			
797
			
794
		}
798
		}
795
		else {
799
		else {
796
			foreach(array_merge($_POST, $_GET) as $cle => $valeur) $GLOBALS['_BAZAR_']['url']->addQueryString($cle, $valeur); 
800
			foreach(array_merge($_POST, $_GET) as $cle => $valeur) $GLOBALS['_BAZAR_']['url']->addQueryString($cle, $valeur); 
797
			$GLOBALS['_BAZAR_']['url']->addQueryString('recherche_avancee', '1');
801
			$GLOBALS['_BAZAR_']['url']->addQueryString('recherche_avancee', '1');
798
			$lien_recherche_avancee = '<a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'">'.BAZ_RECHERCHE_AVANCEE.'</a><br />';			
802
			$lien_recherche_avancee = '<a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'">'.BAZ_RECHERCHE_AVANCEE.'</a><br />';			
799
		}		 	
803
		}		 	
800
	}
804
	}
801
	
805
	
802
	//lien recherche avancee
806
	//lien recherche avancee
803
	if (isset($lien_recherche_avancee)) {
807
	if (isset($lien_recherche_avancee)) {
804
		labelhtml($formtemplate,'',$lien_recherche_avancee,'','','','','');
808
		labelhtml($formtemplate,'',$lien_recherche_avancee,'','','','','');
805
	}
809
	}
806
	
810
	
807
	//Bouton de validation du formulaire
811
	//Bouton de validation du formulaire
808
	$option=array('style'=>'border:1px solid #000;width:100px;font:12px Myriad, Arial, sans-serif;');
812
	$option=array('style'=>'border:1px solid #000;width:100px;font:12px Myriad, Arial, sans-serif;');
809
	//$bouton[] = &HTML_QuickForm::createElement('submit', 'rechercher', BAZ_RECHERCHER, $option);
813
	//$bouton[] = &HTML_QuickForm::createElement('submit', 'rechercher', BAZ_RECHERCHER, $option);
810
	//$formtemplate->addGroup($bouton, null, null, '');	
814
	//$formtemplate->addGroup($bouton, null, null, '');	
811
	$formtemplate->addElement('submit', 'rechercher', BAZ_RECHERCHER, $option);
815
	$formtemplate->addElement('submit', 'rechercher', BAZ_RECHERCHER, $option);
812
	
816
	
813
	//affichage du formulaire
817
	//affichage du formulaire
814
	$res.=$formtemplate->toHTML()."\n";
818
	$res.=$formtemplate->toHTML()."\n";
815
	
819
	
816
 
820
 
817
	// Ajout de la table bazar_fiche_liste_valeur dans le from de la requete
821
	// Ajout de la table bazar_fiche_liste_valeur dans le from de la requete
818
	$case_coche = false ;
822
	$case_coche = false ;
819
	$nb_jointures=0;
823
	$nb_jointures=0;
820
	$requeteFrom = '' ;
824
	$requeteFrom = '' ;
821
	$requeteWhere = '' ;
825
	$requeteWhere = '' ;
822
	$requeteWhereListe = '' ;
826
	$requeteWhereListe = '' ;
823
	
827
	
824
 	if ( isset($tableau) ) {
828
 	if ( isset($tableau) ) {
825
	 	for ($i = 0; $i < count ($tableau); $i++) {
829
	 	for ($i = 0; $i < count ($tableau); $i++) {
826
			if ($tableau[$i]['type'] == 'checkbox' || $tableau[$i]['type'] == 'liste') {
830
			if ($tableau[$i]['type'] == 'checkbox' || $tableau[$i]['type'] == 'liste') {
827
				$nb_jointures++;
831
				$nb_jointures++;
828
				$nom_liste = $tableau[$i]['type'].$tableau[$i]['nom_bdd'] ;			
832
				$nom_liste = $tableau[$i]['type'].$tableau[$i]['nom_bdd'] ;			
829
				if (isset($_REQUEST[$nom_liste]) && is_array($_REQUEST[$nom_liste])) {
833
				if (isset($_REQUEST[$nom_liste]) && is_array($_REQUEST[$nom_liste])) {
830
					$case_coche = true;
834
					$case_coche = true;
831
					$requeteWhereListe .= ' bfvl'.$nb_jointures.'.bfvl_ce_liste='.$tableau[$i]['nom_bdd'].' AND ' ; // Numéro de la liste
835
					$requeteWhereListe .= ' bfvl'.$nb_jointures.'.bfvl_ce_liste='.$tableau[$i]['nom_bdd'].' AND ' ; // Numéro de la liste
832
					$requeteWhereListe .= ' bfvl'.$nb_jointures.'.bfvl_valeur IN (' ;
836
					$requeteWhereListe .= ' bfvl'.$nb_jointures.'.bfvl_valeur IN (' ;
833
					$chaine = '';
837
					$chaine = '';
834
					//var_dump($_REQUEST[$nom_liste]);
838
					//var_dump($_REQUEST[$nom_liste]);
835
					foreach ($_REQUEST[$nom_liste] as $cle =>$valeur) {
839
					foreach ($_REQUEST[$nom_liste] as $cle =>$valeur) {
836
						if ($valeur == 1) {						
840
						if ($valeur == 1) {						
837
							$chaine .= '"'.$cle.'",' ;
841
							$chaine .= '"'.$cle.'",' ;
838
						}
842
						}
839
					}	
843
					}	
840
					$requeteWhereListe .= substr ($chaine, 0, strlen ($chaine)-1) ;
844
					$requeteWhereListe .= substr ($chaine, 0, strlen ($chaine)-1) ;
841
					$requeteWhereListe .= ') AND ';									
845
					$requeteWhereListe .= ') AND ';									
842
				} else {
846
				} else {
843
					if (isset ($_REQUEST[$nom_liste]) && $_REQUEST[$nom_liste]!=0) {
847
					if (isset ($_REQUEST[$nom_liste]) && $_REQUEST[$nom_liste]!=0) {
844
						$requeteWhereListe .= ' bfvl'.$nb_jointures.'.bfvl_ce_liste='.$tableau[$i]['nom_bdd'].' AND ' ; // Numéro de la liste
848
						$requeteWhereListe .= ' bfvl'.$nb_jointures.'.bfvl_ce_liste='.$tableau[$i]['nom_bdd'].' AND ' ; // Numéro de la liste
845
						$requeteWhereListe .= ' bfvl'.$nb_jointures.'.bfvl_valeur='.$_REQUEST[$nom_liste].' AND ';
849
						$requeteWhereListe .= ' bfvl'.$nb_jointures.'.bfvl_valeur='.$_REQUEST[$nom_liste].' AND ';
846
						$case_coche = true;
850
						$case_coche = true;
847
					}
851
					}
848
				}
852
				}
849
			}
853
			}
850
		}
854
		}
851
 	}
855
 	}
852
	if ($case_coche) {
856
	if ($case_coche) {
853
		for ($i = 0; $i < $nb_jointures ; $i++) {			
857
		for ($i = 0; $i < $nb_jointures ; $i++) {			
854
			$requeteFrom .= ', bazar_fiche_valeur_liste  as bfvl'.($i+1) ;
858
			$requeteFrom .= ', bazar_fiche_valeur_liste  as bfvl'.($i+1) ;
855
			$requeteWhere .= ' bfvl'.($i+1).'.bfvl_ce_fiche=bf_id_fiche AND ';
859
			$requeteWhere .= ' bfvl'.($i+1).'.bfvl_ce_fiche=bf_id_fiche AND ';
856
		}
860
		}
857
		 $requeteWhere .= $requeteWhereListe;
861
		 $requeteWhere .= $requeteWhereListe;
858
	}
862
	}
859
	if (isset($_REQUEST['nature']) && $_REQUEST['nature']!='' && $_REQUEST['nature']!='toutes') {
863
	if (isset($_REQUEST['nature']) && $_REQUEST['nature']!='' && $_REQUEST['nature']!='toutes') {
860
		$requeteWhere = 'bf_ce_nature="'.$_REQUEST['nature'].'" AND '.$requeteWhere;
864
		$requeteWhere = 'bf_ce_nature="'.$_REQUEST['nature'].'" AND '.$requeteWhere;
861
	}
865
	}
862
	
866
	
863
	//affichage des resultats de la recherche si le formulaire a ete envoye
867
	//affichage des resultats de la recherche si le formulaire a ete envoye
864
	$requeteSQL='';
868
	$requeteSQL='';
865
	if (isset($_REQUEST['recherche_effectuee'])) {
869
	if (isset($_REQUEST['recherche_effectuee'])) {
866
		//preparation de la requete pour trouver les mots cles
870
		//preparation de la requete pour trouver les mots cles
867
		if (($_REQUEST['recherche_mots_cles']!='')and($_REQUEST['recherche_mots_cles']!=BAZ_MOT_CLE)) {
871
		if (($_REQUEST['recherche_mots_cles']!='')and($_REQUEST['recherche_mots_cles']!=BAZ_MOT_CLE)) {
868
			//decoupage des mots cles
872
			//decoupage des mots cles
869
			$recherche = split(' ', $_REQUEST['recherche_mots_cles']) ;
873
			$recherche = split(' ', $_REQUEST['recherche_mots_cles']) ;
870
			$nbmots=count($recherche);
874
			$nbmots=count($recherche);
871
			$requeteSQL=''; 
875
			$requeteSQL=''; 
872
			for ($i=0; $i<$nbmots; $i++) {
876
			for ($i=0; $i<$nbmots; $i++) {
873
				if ($i>0) $requeteSQL.=' OR ';
877
				if ($i>0) $requeteSQL.=' OR ';
874
				$requeteSQL.='bf_titre LIKE "%'.$recherche[$i].'%" OR bf_description LIKE "%'.$recherche[$i].'%" ';
878
				$requeteSQL.='bf_titre LIKE "%'.$recherche[$i].'%" OR bf_description LIKE "%'.$recherche[$i].'%" ';
875
			}
879
			}
876
		}
880
		}
877
		if (!isset($_REQUEST['nature'])) {
881
		if (!isset($_REQUEST['nature'])) {
878
			if (!isset ($GLOBALS['_BAZAR_']['id_nature'])) $typedefiches = $tableau_typeannonces;
882
			if (!isset ($GLOBALS['_BAZAR_']['id_nature'])) $typedefiches = $tableau_typeannonces;
879
			else $typedefiches = $GLOBALS['_BAZAR_']['id_nature'] ; 
883
			else $typedefiches = $GLOBALS['_BAZAR_']['id_nature'] ; 
880
		} else {
884
		} else {
881
			$typedefiches = $_REQUEST['nature'] ;
885
			$typedefiches = $_REQUEST['nature'] ;
882
			if ($typedefiches == 'toutes') $typedefiches = $tableau_typeannonces ;
886
			if ($typedefiches == 'toutes') $typedefiches = $tableau_typeannonces ;
883
		}
887
		}
884
		if ($typeannonce!='toutes') $typedefiches=$typeannonce;
888
		if ($typeannonce!='toutes') $typedefiches=$typeannonce;
885
		if (isset($_REQUEST['valides'])) {$valides=$_REQUEST['valides'];}
889
		if (isset($_REQUEST['valides'])) {$valides=$_REQUEST['valides'];}
886
		else {$valides=1;}
890
		else {$valides=1;}
887
		//generation de la liste de flux a afficher
891
		//generation de la liste de flux a afficher
888
		if (!isset($_REQUEST['personne'])) $_REQUEST['personne']='tous';
892
		if (!isset($_REQUEST['personne'])) $_REQUEST['personne']='tous';
889
		$res .= baz_liste_pagine_HTML($typedefiches, '', $_REQUEST['personne'], $valides, $requeteSQL, $requeteFrom, $requeteWhere);		
893
		$res .= baz_liste_pagine_HTML($typedefiches, '', $_REQUEST['personne'], $valides, $requeteSQL, $requeteFrom, $requeteWhere);		
890
	}
894
	}
891
	else {
895
	else {
892
		//on affiche toutes les annonces
896
		//on affiche toutes les annonces
893
		$res .= '<br /><p class="zone_info">'."\n".BAZ_ENTRER_VOS_CRITERES_DE_RECHERCHE.'</p>'."\n";
897
		$res .= '<br /><p class="zone_info">'."\n".BAZ_ENTRER_VOS_CRITERES_DE_RECHERCHE.'</p>'."\n";
894
		$GLOBALS['_BAZAR_']['url']->removeQueryString('action');
898
		$GLOBALS['_BAZAR_']['url']->removeQueryString('action');
895
		$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_VOIR_FLUX_RSS);
899
		$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_VOIR_FLUX_RSS);
896
		$GLOBALS['_BAZAR_']['url']->addQueryString('annonce', $typeannonce);
900
		$GLOBALS['_BAZAR_']['url']->addQueryString('annonce', $typeannonce);
897
		$GLOBALS['_BAZAR_']['url']->addQueryString('categorie_nature', $GLOBALS['_BAZAR_']['categorie_nature']);
901
		$GLOBALS['_BAZAR_']['url']->addQueryString('categorie_nature', $GLOBALS['_BAZAR_']['categorie_nature']);
898
		$res .= '{{Syndication titre="Les derni&egrave;res fiches enregistrées" url="'.preg_replace ('/&amp;/', '&', $GLOBALS['_BAZAR_']['url']->getURL()).
902
		$res .= '{{Syndication titre="Les derni&egrave;res fiches enregistrées" url="'.preg_replace ('/&amp;/', '&', $GLOBALS['_BAZAR_']['url']->getURL()).
899
                '" nb=10 nouvellefenetre=0 formatdate="'.BAZ_TYPE_AFFICHAGE_LISTE.'"}}';
903
                '" nb=10 nouvellefenetre=0 formatdate="'.BAZ_TYPE_AFFICHAGE_LISTE.'"}}';
900
	}
904
	}
901
	return $res;
905
	return $res;
902
}
906
}
903
 
907
 
904
/**
908
/**
905
 * Cette fonction renvoie du HTML
909
 * Cette fonction renvoie du HTML
906
 */
910
 */
907
function baz_liste_pagine_HTML($typeannonce, $nbitem, $emetteur, $valide, $requeteSQL = '', $requeteFrom = '', $requeteWhere = '') {	
911
function baz_liste_pagine_HTML($typeannonce, $nbitem, $emetteur, $valide, $requeteSQL = '', $requeteFrom = '', $requeteWhere = '') {	
908
	// generation de la requete MySQL personnalisee
912
	// generation de la requete MySQL personnalisee
909
	$req_where=0;
913
	$req_where=0;
910
	$requete = 'SELECT DISTINCT bf_id_fiche, bf_titre, bf_date_debut_validite_fiche '.
914
	$requete = 'SELECT DISTINCT bf_id_fiche, bf_titre, bf_date_debut_validite_fiche '.
911
				'FROM bazar_fiche, bazar_nature '.$requeteFrom.' WHERE '.$requeteWhere;
915
				'FROM bazar_fiche, bazar_nature '.$requeteFrom.' WHERE '.$requeteWhere;
912
	if ($valide!=2) {
916
	if ($valide!=2) {
913
		if ($req_where==1) {$requete .= ' AND ';}
917
		if ($req_where==1) {$requete .= ' AND ';}
914
		$req_where=1;
918
		$req_where=1;
915
		$requete .= 'bf_statut_fiche='.$valide;		
919
		$requete .= 'bf_statut_fiche='.$valide;		
916
	} else {
920
	} else {
917
		$requete .= '1 ' ;
921
		$requete .= '1 ' ;
918
	}
922
	}
-
 
923
	
919
	
924
	$utilisateur = new Administrateur_bazar ($GLOBALS['AUTH']) ;
920
	if ($valide!=0) {
-
 
921
		$utilisateur = new Administrateur_bazar ($GLOBALS['AUTH']) ;
925
	if ($valide!=0) {
922
		if ($utilisateur->isSuperAdmin()) {
926
		if ($utilisateur->isSuperAdmin()) {
923
			$req_where=1;
927
			$req_where=1;
924
		} else {
928
		} else {
925
			if ($req_where==1) {$requete .= ' AND ';}
929
			if ($req_where==1) {$requete .= ' AND ';}
926
			$requete .= '(bf_date_debut_validite_fiche<=NOW() or bf_date_debut_validite_fiche="0000-00-00")'.
930
			$requete .= '(bf_date_debut_validite_fiche<=NOW() or bf_date_debut_validite_fiche="0000-00-00")'.
927
						' AND (bf_date_fin_validite_fiche>=NOW() or bf_date_fin_validite_fiche="0000-00-00") AND bn_id_nature=bf_ce_nature';
931
						' AND (bf_date_fin_validite_fiche>=NOW() or bf_date_fin_validite_fiche="0000-00-00") AND bn_id_nature=bf_ce_nature';
928
			$req_where=1;
932
			$req_where=1;
929
		}
933
		}
930
	}
934
	}
931
	if ($emetteur!='' && $emetteur!='tous') {
935
	if ($emetteur!='' && $emetteur!='tous') {
932
		if ($req_where==1) {$requete .= ' AND ';}
936
		if ($req_where==1) {$requete .= ' AND ';}
933
		$requete .= 'bf_ce_utilisateur='.$emetteur;
937
		$requete .= 'bf_ce_utilisateur='.$emetteur;
934
		$req_where=1;
938
		$req_where=1;
935
		//requete pour afficher le nom de la structure
939
		//requete pour afficher le nom de la structure
936
		$requetenom = 'SELECT '.BAZ_CHAMPS_NOM.', '.BAZ_CHAMPS_PRENOM.' FROM '.
940
		$requetenom = 'SELECT '.BAZ_CHAMPS_NOM.', '.BAZ_CHAMPS_PRENOM.' FROM '.
937
						BAZ_ANNUAIRE.' WHERE '.BAZ_CHAMPS_ID.'='.$emetteur;
941
						BAZ_ANNUAIRE.' WHERE '.BAZ_CHAMPS_ID.'='.$emetteur;
938
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requetenom) ;
942
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requetenom) ;
939
		if (DB::isError($resultat)) {
943
		if (DB::isError($resultat)) {
940
			die ($resultat->getMessage().$resultat->getDebugInfo()) ;
944
			die ($resultat->getMessage().$resultat->getDebugInfo()) ;
941
		}
945
		}
942
		$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
946
		$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
943
		$nomflux .= ' ('.$ligne[BAZ_CHAMPS_NOM].' '.$ligne[BAZ_CHAMPS_PRENOM].')';
947
		$nomflux .= ' ('.$ligne[BAZ_CHAMPS_NOM].' '.$ligne[BAZ_CHAMPS_PRENOM].')';
944
	}
948
	}
945
	if ($requeteSQL!='') {
949
	if ($requeteSQL!='') {
946
		if ($req_where==1) {$requete .= ' AND ';}
950
		if ($req_where==1) {$requete .= ' AND ';}
947
		$requete .= '('.$requeteSQL.')';
951
		$requete .= '('.$requeteSQL.')';
948
		$req_where=1;
952
		$req_where=1;
949
	}
953
	}
950
	$requete .= ' ORDER BY  bf_date_debut_validite_fiche DESC, bf_date_fin_validite_fiche DESC, bf_date_maj_fiche DESC';
954
	$requete .= ' ORDER BY  bf_date_debut_validite_fiche DESC, bf_date_fin_validite_fiche DESC, bf_date_maj_fiche DESC';
951
	if ($nbitem!='') {$requete .= ' LIMIT 0,'.$nbitem;}
955
	if ($nbitem!='') {$requete .= ' LIMIT 0,'.$nbitem;}
952
	
956
	
953
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
957
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
954
	if (DB::isError($resultat)) {
958
	if (DB::isError($resultat)) {
955
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
959
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
956
	}
960
	}
957
	$res = '<br /><h4>'.BAZ_IL_Y_A.($resultat->numRows()).' '.BAZ_FICHES_CORRESPONDANTES.'</h4><br />'."\n";
961
	$res = '<br /><h4>'.BAZ_IL_Y_A.($resultat->numRows()).' '.BAZ_FICHES_CORRESPONDANTES.'</h4><br />'."\n";
958
	$res .= '<ul>' ;
962
	$res .= '<ul>' ;
959
	$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_VOIR_FICHE);
963
	$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_VOIR_FICHE);
960
	
964
	
961
	$donnees = array();
965
	$donnees = array();
962
	while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
966
	while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
963
		$GLOBALS['_BAZAR_']['url']->addQueryString('id_fiche', $ligne->bf_id_fiche) ;
967
		$GLOBALS['_BAZAR_']['url']->addQueryString('id_fiche', $ligne->bf_id_fiche) ;
964
		array_push ($donnees, array ($ligne->bf_id_fiche,$ligne->bf_titre));		
968
		array_push ($donnees, array ($ligne->bf_id_fiche,$ligne->bf_titre));		
965
	}
969
	}
966
	// Mise en place du Pager
970
	// Mise en place du Pager
967
	include_once PAP_CHEMIN_API_PEAR.'Pager/Pager.php';
971
	include_once PAP_CHEMIN_API_PEAR.'Pager/Pager.php';
968
	$params = array(
972
	$params = array(
969
    'mode'       => BAZ_MODE_DIVISION,
973
    'mode'       => BAZ_MODE_DIVISION,
970
    'perPage'    => BAZ_NOMBRE_RES_PAR_PAGE,
974
    'perPage'    => BAZ_NOMBRE_RES_PAR_PAGE,
971
    'delta'      => BAZ_DELTA,
975
    'delta'      => BAZ_DELTA,
972
    'httpMethod' => 'GET',
976
    'httpMethod' => 'GET',
973
    'extraVars' => array_merge($_POST, $_GET),
977
    'extraVars' => array_merge($_POST, $_GET),
974
    'altNext' => BAZ_SUIVANT,
978
    'altNext' => BAZ_SUIVANT,
975
    'altPrev' => BAZ_PRECEDENT,
979
    'altPrev' => BAZ_PRECEDENT,
976
    'nextImg' => BAZ_SUIVANT,
980
    'nextImg' => BAZ_SUIVANT,
977
    'prevImg' => BAZ_PRECEDENT,
981
    'prevImg' => BAZ_PRECEDENT,
978
    'itemData'   => $donnees
982
    'itemData'   => $donnees
979
	);
983
	);
980
	$pager = & Pager::factory($params);
984
	$pager = & Pager::factory($params);
981
	$data  = $pager->getPageData();
985
	$data  = $pager->getPageData();
982
	$links = $pager->getLinks();
986
	$links = $pager->getLinks();
983
    $res .= '<div class="bazar_numero">'.$pager->links.'</div>'."\n";
987
    $res .= '<div class="bazar_numero">'.$pager->links.'</div>'."\n";
984
	foreach ($data as $valeur) {
988
	foreach ($data as $valeur) {
985
		$GLOBALS['_BAZAR_']['url']->addQueryString('id_fiche', $valeur[0]) ;
989
		$GLOBALS['_BAZAR_']['url']->addQueryString('id_fiche', $valeur[0]) ;
986
		$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_VOIR_FICHE) ;
990
		$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_VOIR_FICHE) ;
987
		$res .= '<li><a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'">'.$valeur[1].'</a>'."\n" ;
991
		$res .= '<li><a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'">'.$valeur[1].'</a>'."\n" ;
988
		if ($utilisateur->isSuperAdmin()) {
992
		if ($utilisateur->isSuperAdmin()) {
989
			$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_ACTION_SUPPRESSION);
993
			$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_ACTION_SUPPRESSION);
990
			$res .= '<a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'" onclick="javascript:return confirm(\''.BAZ_SUPPRIMER.'\');">('.BAZ_SUPPRIMER.')</a>' ;
994
			$res .= '<a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'" onclick="javascript:return confirm(\''.BAZ_SUPPRIMER.'\');">('.BAZ_SUPPRIMER.')</a>' ;
991
			$GLOBALS['_BAZAR_']['url']->removeQueryString('action');
995
			$GLOBALS['_BAZAR_']['url']->removeQueryString('action');
992
		}
996
		}
993
		$res .= '</li>';
997
		$res .= '</li>';
994
	}
998
	}
995
	$res .= '</ul>';
999
	$res .= '</ul>';
996
	$res .= '<div class="bazar_numero">'.$pager->links.'</div>'."\n";
1000
	$res .= '<div class="bazar_numero">'.$pager->links.'</div>'."\n";
997
 
1001
 
998
	return $res ;
1002
	return $res ;
999
}
1003
}
1000
 
1004
 
1001
/* +--Fin du code ----------------------------------------------------------------------------------------+
1005
/* +--Fin du code ----------------------------------------------------------------------------------------+
1002
*
1006
*
1003
* $Log: not supported by cvs2svn $
1007
* $Log: not supported by cvs2svn $
-
 
1008
* Revision 1.56  2006/07/18 14:13:35  alexandre_tb
-
 
1009
* Ajout d identifiant HTML
-
 
1010
*
1004
* Revision 1.55  2006/07/04 14:29:18  alexandre_tb
1011
* Revision 1.55  2006/07/04 14:29:18  alexandre_tb
1005
* Ajout du bouton supprimer pour les administrateurs
1012
* Ajout du bouton supprimer pour les administrateurs
1006
*
1013
*
1007
* Revision 1.54  2006/07/03 09:51:21  alexandre_tb
1014
* Revision 1.54  2006/07/03 09:51:21  alexandre_tb
1008
* correction du bug recherche sur fiches validés et invalidés.
1015
* correction du bug recherche sur fiches validés et invalidés.
1009
*
1016
*
1010
* Revision 1.53  2006/06/29 10:29:51  florian
1017
* Revision 1.53  2006/06/29 10:29:51  florian
1011
* correction bug moteur de recherche
1018
* correction bug moteur de recherche
1012
*
1019
*
1013
* Revision 1.52  2006/06/02 09:29:07  florian
1020
* Revision 1.52  2006/06/02 09:29:07  florian
1014
* debut d'integration de wikini
1021
* debut d'integration de wikini
1015
*
1022
*
1016
* Revision 1.51  2006/05/23 15:41:27  alexandre_tb
1023
* Revision 1.51  2006/05/23 15:41:27  alexandre_tb
1017
* ajout de la numérotation des pages en haut et en bas ds résultats et ajout d'une div class=bazar_numero pour les entourer
1024
* ajout de la numérotation des pages en haut et en bas ds résultats et ajout d'une div class=bazar_numero pour les entourer
1018
*
1025
*
1019
* Revision 1.50  2006/05/22 09:55:12  alexandre_tb
1026
* Revision 1.50  2006/05/22 09:55:12  alexandre_tb
1020
* ajout de la variable recherche_avancee dans l'action du formulaire
1027
* ajout de la variable recherche_avancee dans l'action du formulaire
1021
*
1028
*
1022
* Revision 1.49  2006/05/19 13:54:11  florian
1029
* Revision 1.49  2006/05/19 13:54:11  florian
1023
* stabilisation du moteur de recherche, corrections bugs, lien recherche avancee
1030
* stabilisation du moteur de recherche, corrections bugs, lien recherche avancee
1024
*
1031
*
1025
* Revision 1.48  2006/05/17 09:50:13  alexandre_tb
1032
* Revision 1.48  2006/05/17 09:50:13  alexandre_tb
1026
* Ajout du moteur de recherche évolué et du découpage par page
1033
* Ajout du moteur de recherche évolué et du découpage par page
1027
*
1034
*
1028
* +-- Fin du code ----------------------------------------------------------------------------------------+
1035
* +-- Fin du code ----------------------------------------------------------------------------------------+
1029
*/
1036
*/
1030
?>
1037
?>