Subversion Repositories Applications.bazar

Rev

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

Rev 118 Rev 122
1
<?php
1
<?php
2
 
2
 
3
require_once BAZ_CHEMIN_APPLI.'bibliotheque/bazar.class.php';
3
require_once BAZ_CHEMIN_APPLI.'bibliotheque/bazar.class.php';
4
require_once BAZ_CHEMIN_APPLI.'bibliotheque/bazar.fonct.php';
4
require_once BAZ_CHEMIN_APPLI.'bibliotheque/bazar.fonct.php';
5
 
5
 
6
/** baz_valeur_template() - Renvoi des valeurs inscrite dans le fichier de template
6
/** baz_valeur_template() - Renvoi des valeurs inscrite dans le fichier de template
7
*
7
*
8
* @param   string valeur du template de bazar_nature
8
* @param   string valeur du template de bazar_nature
9
*
9
*
10
* @return   mixed  tableau contenant les champs du fichier template
10
* @return   mixed  tableau contenant les champs du fichier template
11
*/
11
*/
12
function baz_valeurs_template($valeur_template) {
12
function baz_valeurs_template($valeur_template) {
13
	//Parcours du fichier de templates, pour mettre les champs spécifiques
13
	//Parcours du fichier de templates, pour mettre les champs spécifiques
14
	$nblignes=0;
14
	$nblignes=0;
15
	$chaine = explode ("\n", $valeur_template);
15
	$chaine = explode ("\n", $valeur_template);
16
	array_pop($chaine);
16
	array_pop($chaine);
17
	foreach ($chaine as $ligne)  {
17
	foreach ($chaine as $ligne)  {
18
		$souschaine = explode ("***", $ligne) ;
18
		$souschaine = explode ("***", $ligne) ;
19
		$tableau[$nblignes]['type'] = trim($souschaine[0]) ;
19
		$tableau[$nblignes]['type'] = trim($souschaine[0]) ;
20
		if (isset($souschaine[1])) {$tableau[$nblignes]['nom_bdd'] = trim($souschaine[1]);}
20
		if (isset($souschaine[1])) {$tableau[$nblignes]['nom_bdd'] = trim($souschaine[1]);}
21
		else {$tableau[$nblignes]['nom_bdd'] ='';}
21
		else {$tableau[$nblignes]['nom_bdd'] ='';}
22
		if (isset($souschaine[2])) $tableau[$nblignes]['label'] = trim($souschaine[2]);
22
		if (isset($souschaine[2])) $tableau[$nblignes]['label'] = trim($souschaine[2]);
23
		else {$tableau[$nblignes]['label'] ='';}
23
		else {$tableau[$nblignes]['label'] ='';}
24
		if (isset($souschaine[3])) $tableau[$nblignes]['limite1'] = trim($souschaine[3]);
24
		if (isset($souschaine[3])) $tableau[$nblignes]['limite1'] = trim($souschaine[3]);
25
		else {$tableau[$nblignes]['limite1'] ='';}
25
		else {$tableau[$nblignes]['limite1'] ='';}
26
		if (isset($souschaine[4])) $tableau[$nblignes]['limite2'] = trim($souschaine[4]);
26
		if (isset($souschaine[4])) $tableau[$nblignes]['limite2'] = trim($souschaine[4]);
27
		else {$tableau[$nblignes]['limite2'] ='';}
27
		else {$tableau[$nblignes]['limite2'] ='';}
28
		if (isset($souschaine[5])) $tableau[$nblignes]['defaut'] = trim($souschaine[5]);
28
		if (isset($souschaine[5])) $tableau[$nblignes]['defaut'] = trim($souschaine[5]);
29
		else {$tableau[$nblignes]['defaut'] ='';}
29
		else {$tableau[$nblignes]['defaut'] ='';}
30
		if (isset($souschaine[6])) $tableau[$nblignes]['table_source'] = trim($souschaine[6]);
30
		if (isset($souschaine[6])) $tableau[$nblignes]['table_source'] = trim($souschaine[6]);
31
		else {$tableau[$nblignes]['table_source'] ='';}
31
		else {$tableau[$nblignes]['table_source'] ='';}
32
		if (isset($souschaine[7])) $tableau[$nblignes]['id_source'] = trim($souschaine[7]);
32
		if (isset($souschaine[7])) $tableau[$nblignes]['id_source'] = trim($souschaine[7]);
33
		else {$tableau[$nblignes]['id_source'] ='';}
33
		else {$tableau[$nblignes]['id_source'] ='';}
34
		if (isset($souschaine[8])) $tableau[$nblignes]['obligatoire'] = trim($souschaine[8]);
34
		if (isset($souschaine[8])) $tableau[$nblignes]['obligatoire'] = trim($souschaine[8]);
35
		else {$tableau[$nblignes]['obligatoire'] ='';}
35
		else {$tableau[$nblignes]['obligatoire'] ='';}
36
		if (isset($souschaine[9])) $tableau[$nblignes]['recherche'] = trim($souschaine[9]);
36
		if (isset($souschaine[9])) $tableau[$nblignes]['recherche'] = trim($souschaine[9]);
37
		else {$tableau[$nblignes]['recherche'] ='';}
37
		else {$tableau[$nblignes]['recherche'] ='';}
38
		
38
		
39
		
39
		
40
		// traitement des cases à cocher, dans ce cas la, on a une table de jointure entre la table
40
		// traitement des cases à cocher, dans ce cas la, on a une table de jointure entre la table
41
		// de liste et la table bazar_fiche (elle porte un nom du genre bazar_ont_***)
41
		// de liste et la table bazar_fiche (elle porte un nom du genre bazar_ont_***)
42
		// dans le template, à la place d'un nom de champs dans 'nom_bdd', on a un nom de table
42
		// dans le template, à la place d'un nom de champs dans 'nom_bdd', on a un nom de table
43
		// et 2 noms de champs séparés par un virgule ex : bazar_ont_theme,bot_id_theme,bot_id_fiche
43
		// et 2 noms de champs séparés par un virgule ex : bazar_ont_theme,bot_id_theme,bot_id_fiche
44
		
44
		
45
		if (isset($tableau[$nblignes]['nom_bdd']) && preg_match('/,/', $tableau[$nblignes]['nom_bdd'])) {
45
		if (isset($tableau[$nblignes]['nom_bdd']) && preg_match('/,/', $tableau[$nblignes]['nom_bdd'])) {
46
			$tableau_info_jointe = explode (',', $tableau[$nblignes]['nom_bdd']) ;
46
			$tableau_info_jointe = explode (',', $tableau[$nblignes]['nom_bdd']) ;
47
			$tableau[$nblignes]['table_jointe'] = $tableau_info_jointe[0] ;
47
			$tableau[$nblignes]['table_jointe'] = $tableau_info_jointe[0] ;
48
			$tableau[$nblignes]['champs_id_fiche'] = $tableau_info_jointe[1] ;
48
			$tableau[$nblignes]['champs_id_fiche'] = $tableau_info_jointe[1] ;
49
			$tableau[$nblignes]['champs_id_table_jointe'] = $tableau_info_jointe[2] ;		
49
			$tableau[$nblignes]['champs_id_table_jointe'] = $tableau_info_jointe[2] ;		
50
		}
50
		}
51
		$nblignes++;
51
		$nblignes++;
52
	}
52
	}
53
	return $tableau;
53
	return $tableau;
54
}
54
}
55
 
55
 
56
/**  baz_voir_fiches() - Permet de visualiser en detail une liste de fiche  au format XHTML
56
/**  baz_voir_fiches() - Permet de visualiser en detail une liste de fiche  au format XHTML
57
*
57
*
58
* @global boolean Rajoute des informations internes à l'application (date de modification, lien vers la page de départ de l'appli)
58
* @global boolean Rajoute des informations internes à l'application (date de modification, lien vers la page de départ de l'appli)
59
* @global integer Tableau d(Identifiant des fiches à afficher
59
* @global integer Tableau d(Identifiant des fiches à afficher
60
*
60
*
61
* @return   string  HTML
61
* @return   string  HTML
62
*/
62
*/
63
function baz_voir_fiches($danslappli, $idfiches=array()) {
63
function baz_voir_fiches($danslappli, $idfiches=array()) {
64
	$res='';
64
	$res='';
65
	foreach($idfiches as $idfiche) {
65
	foreach($idfiches as $idfiche) {
66
			$res.=baz_voir_fiche($danslappli, $idfiche);
66
			$res.=baz_voir_fiche($danslappli, $idfiche);
67
	}
67
	}
68
	return $res;
68
	return $res;
69
}
69
}
70
 
70
 
71
 
71
 
72
/**  baz_voir_fiche() - Permet de visualiser en detail une fiche  au format XHTML
72
/**  baz_voir_fiche() - Permet de visualiser en detail une fiche  au format XHTML
73
*
73
*
74
* @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
74
* @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
75
* @global integer Identifiant de la fiche a afficher
75
* @global integer Identifiant de la fiche a afficher
76
*
76
*
77
* @return   string  HTML
77
* @return   string  HTML
78
*/
78
*/
79
function baz_voir_fiche($danslappli, $idfiche='') {
79
function baz_voir_fiche($danslappli, $idfiche='') {
80
	$res='';
80
	$res='';
81
	if (isset($_GET['id_fiche'])) $GLOBALS['_BAZAR_']['id_fiche']=$_GET['id_fiche'];
81
	if (isset($_GET['id_fiche'])) $GLOBALS['_BAZAR_']['id_fiche']=$_GET['id_fiche'];
82
	if ($idfiche!='') $GLOBALS['_BAZAR_']['id_fiche']=$idfiche;	
82
	if ($idfiche!='') $GLOBALS['_BAZAR_']['id_fiche']=$idfiche;	
83
	$url= $GLOBALS['_BAZAR_']['url'];
83
	$url= $GLOBALS['_BAZAR_']['url'];
84
	$url->addQueryString('action', BAZ_VOIR_FICHE);
84
	$url->addQueryString('action', BAZ_VOIR_FICHE);
85
	$url->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
85
	$url->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
86
	$url = preg_replace ('/&amp;/', '&', $url->getURL()) ;
86
	$url = preg_replace ('/&amp;/', '&', $url->getURL()) ;
87
	
87
	
88
	//cas ou la fiche a été validee
88
	//cas ou la fiche a été validee
89
	if (isset($_GET['publiee'])) {
89
	if (isset($_GET['publiee'])) {
90
		publier_fiche($_GET['publiee']);			
90
		publier_fiche($_GET['publiee']);			
91
	}
91
	}
92
	
92
	
93
	//cas on une structure s'approprie une ressource
93
	//cas on une structure s'approprie une ressource
94
	if (isset($_GET['appropriation'])) {
94
	if (isset($_GET['appropriation'])) {
95
		if ($_GET['appropriation']==1) {
95
		if ($_GET['appropriation']==1) {
96
			$requete = 'INSERT INTO bazar_appropriation VALUES ('.$GLOBALS['_BAZAR_']['id_fiche'].', '.$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID).')';
96
			$requete = 'INSERT INTO bazar_appropriation VALUES ('.$GLOBALS['_BAZAR_']['id_fiche'].', '.$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID).')';
97
			$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
97
			$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
98
		}
98
		}
99
		elseif ($_GET['appropriation']==0) {
99
		elseif ($_GET['appropriation']==0) {
100
			$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);
100
			$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);
101
			$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
101
			$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
102
		}
102
		}
103
	}
103
	}
104
		
104
		
105
	//cas ou un commentaire a été entre
105
	//cas ou un commentaire a été entre
106
	if (isset($_POST['Nom'])) {
106
	if (isset($_POST['Nom'])) {
107
		$requete = 'INSERT INTO bazar_commentaires VALUES ('.
107
		$requete = 'INSERT INTO bazar_commentaires VALUES ('.
108
					baz_nextid('bazar_commentaires', 'bc_id_commentaire', $GLOBALS['_BAZAR_']['db']).
108
					baz_nextid('bazar_commentaires', 'bc_id_commentaire', $GLOBALS['_BAZAR_']['db']).
109
					', '.$GLOBALS['_BAZAR_']['id_fiche'].', "'.$_POST['Nom'].'", "'.$_POST['Commentaire'].
109
					', '.$GLOBALS['_BAZAR_']['id_fiche'].', "'.$_POST['Nom'].'", "'.$_POST['Commentaire'].
110
					'", NOW() )';
110
					'", NOW() )';
111
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
111
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
112
	}
112
	}
113
	//cas ou un commentaire va etre supprime
113
	//cas ou un commentaire va etre supprime
114
	elseif (isset($_GET['id_commentaire'])) {
114
	elseif (isset($_GET['id_commentaire'])) {
115
		$requete = 'DELETE FROM bazar_commentaires WHERE bc_id_commentaire='.$_GET['id_commentaire'].' LIMIT 1';
115
		$requete = 'DELETE FROM bazar_commentaires WHERE bc_id_commentaire='.$_GET['id_commentaire'].' LIMIT 1';
116
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
116
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
117
	}
117
	}
118
	else {
118
	else {
119
		if (isset($_GET['action'])) {
119
		if (isset($_GET['action'])) {
120
			if ($_GET['action']==BAZ_VOIR_FICHE) {
120
			if ($_GET['action']==BAZ_VOIR_FICHE) {
121
				//sinon on met a jour le nb de visites pour la fiche, puisque c'est une simple consultation
121
				//sinon on met a jour le nb de visites pour la fiche, puisque c'est une simple consultation
122
				$requete = 'UPDATE bazar_fiche SET bf_nb_consultations=bf_nb_consultations+1 WHERE bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
122
				$requete = 'UPDATE bazar_fiche SET bf_nb_consultations=bf_nb_consultations+1 WHERE bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
123
				$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
123
				$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
124
			}
124
			}
125
		}
125
		}
126
	}
126
	}
127
	
127
	
128
	//on verifie si l'utilisateur est administrateur
128
	//on verifie si l'utilisateur est administrateur
129
	$est_admin=0;
129
	$est_admin=0;
130
	if ($GLOBALS['AUTH']->getAuth()) {
130
	if ($GLOBALS['AUTH']->getAuth()) {
131
		$requete='SELECT bn_id_nature FROM bazar_nature WHERE bn_label_nature="'.$GLOBALS['_BAZAR_']['typeannonce'].'"';
131
		$requete='SELECT bn_id_nature FROM bazar_nature WHERE bn_label_nature="'.$GLOBALS['_BAZAR_']['typeannonce'].'"';
132
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
132
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
133
		if (DB::isError($resultat)) {
133
		if (DB::isError($resultat)) {
134
			die ($resultat->getMessage().$resultat->getDebugInfo()) ;
134
			die ($resultat->getMessage().$resultat->getDebugInfo()) ;
135
		}
135
		}
136
		$result = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
136
		$result = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
137
		$id_nature = $result['bn_id_nature'];
137
		$id_nature = $result['bn_id_nature'];
138
		if ((niveau_droit($result['bn_id_nature'],$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID))=='administrateur')
138
		if ((niveau_droit($result['bn_id_nature'],$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID))=='administrateur')
139
		     or(niveau_droit('0',$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID))=='superadministrateur'))
139
		     or(niveau_droit('0',$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID))=='superadministrateur'))
140
		{
140
		{
141
		        $est_admin=1;
141
		        $est_admin=1;
142
		}
142
		}
143
	}
143
	}
144
	//affiche le titre sous forme d'image
144
	//affiche le titre sous forme d'image
145
	if (isset ($GLOBALS['_BAZAR_']['image_titre']) && $GLOBALS['_BAZAR_']['image_titre']!='') {
145
	if (isset ($GLOBALS['_BAZAR_']['image_titre']) && $GLOBALS['_BAZAR_']['image_titre']!='') {
146
		$res .= '<img id="BAZ_img_titre" src="client/bazar/images/'.$GLOBALS['_BAZAR_']['image_titre'].'" alt="'.$GLOBALS['_BAZAR_']['typeannonce'].'" />'.'<br />'."\n";
146
		$res .= '<img id="BAZ_img_titre" src="client/bazar/images/'.$GLOBALS['_BAZAR_']['image_titre'].'" alt="'.$GLOBALS['_BAZAR_']['typeannonce'].'" />'.'<br />'."\n";
147
	}
147
	}
148
	//affiche le texte sinon
148
	//affiche le texte sinon
149
	else {
149
	else {
150
		$res .= '<h2 class="BAZ_titre">'.$GLOBALS['_BAZAR_']['typeannonce'].'</h2>'."\n";
150
		$res .= '<h2 class="BAZ_titre">'.$GLOBALS['_BAZAR_']['typeannonce'].'</h2>'."\n";
151
	}
151
	}
152
	$res .= '<div class="BAZ_cadre_fiche">'."\n";
152
	$res .= '<div class="BAZ_cadre_fiche">'."\n";
153
	$requete = 'SELECT * FROM bazar_fiche WHERE bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
153
	$requete = 'SELECT * FROM bazar_fiche WHERE bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
154
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
154
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
155
	if (DB::isError ($resultat)) {
155
	if (DB::isError ($resultat)) {
156
		die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
156
		die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
157
	}
157
	}
158
	$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC) ;
158
	$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC) ;
159
	$GLOBALS['_BAZAR_']['annonceur'] = $ligne['bf_ce_utilisateur'] ;
159
	$GLOBALS['_BAZAR_']['annonceur'] = $ligne['bf_ce_utilisateur'] ;
160
	//si le template existe, on genere le template
160
	//si le template existe, on genere le template
161
	if ((file_exists(BAZ_CHEMIN_APPLI.'templates/'.$GLOBALS['_BAZAR_']['typeannonce'].'-fiche.php'))) {
161
	if ((file_exists(BAZ_CHEMIN_APPLI.'templates/'.$GLOBALS['_BAZAR_']['typeannonce'].'-fiche.php'))) {
162
		include_once(BAZ_CHEMIN_APPLI.'templates/'.$GLOBALS['_BAZAR_']['typeannonce'].'-fiche.php');
162
		include_once(BAZ_CHEMIN_APPLI.'templates/'.$GLOBALS['_BAZAR_']['typeannonce'].'-fiche.php');
163
		$res .=genere_fiche($ligne);
163
		$res .=genere_fiche($ligne);
164
	}
164
	}
165
	//on affiche ligne par ligne sinon
165
	//on affiche ligne par ligne sinon
166
	else {
166
	else {
167
		//cas d'une image personalisée
167
		//cas d'une image personalisée
168
		if (isset($ligne['bf_url_image'])) {
168
		if (isset($ligne['bf_url_image'])) {
169
			$res .= '<div id="fiche_image">'."\n";
169
			$res .= '<div id="fiche_image">'."\n";
170
			$res .= '<img src="client/bazar/upload/'.$ligne['bf_url_image'].'" border=0 alt="'.BAZ_TEXTE_IMG_ALTERNATIF.'" width="130" height="130"  />'."\n";
170
			$res .= '<img src="client/bazar/upload/'.$ligne['bf_url_image'].'" border=0 alt="'.BAZ_TEXTE_IMG_ALTERNATIF.'" width="130" height="130"  />'."\n";
171
			$res .= '</div>'."\n";
171
			$res .= '</div>'."\n";
172
		}
172
		}
173
		//cas d'une image par défaut
173
		//cas d'une image par défaut
174
		elseif (isset ($GLOBALS['_BAZAR_']['image_logo']) && $GLOBALS['_BAZAR_']['image_logo']!='') {
174
		elseif (isset ($GLOBALS['_BAZAR_']['image_logo']) && $GLOBALS['_BAZAR_']['image_logo']!='') {
175
			$res .= '<div id="fiche_image">'."\n";
175
			$res .= '<div id="fiche_image">'."\n";
176
			$res .= '<img src="client/bazar/images/'.$GLOBALS['_BAZAR_']['image_logo'].'" border=0 alt="'.BAZ_TEXTE_IMG_ALTERNATIF.'" width="130" height="130" />'."\n";
176
			$res .= '<img src="client/bazar/images/'.$GLOBALS['_BAZAR_']['image_logo'].'" border=0 alt="'.BAZ_TEXTE_IMG_ALTERNATIF.'" width="130" height="130" />'."\n";
177
			$res .= '</div>'."\n";
177
			$res .= '</div>'."\n";
178
		}
178
		}
179
		$res .= '<h1 id="fiche_titre">'.$ligne['bf_titre'].'</h1>'."\n";
179
		$res .= '<h1 id="fiche_titre">'.$ligne['bf_titre'].'</h1>'."\n";
180
		$res .= '<div id="BAZ_description">'.$ligne['bf_description'].'</div>'."\n";
180
		$res .= '<div id="BAZ_description">'.nl2br($ligne['bf_description']).'</div>'."\n";
181
		$tableau=baz_valeurs_template($GLOBALS['_BAZAR_']['template']);
181
		$tableau=baz_valeurs_template($GLOBALS['_BAZAR_']['template']);
182
		for ($i=0; $i<count($tableau); $i++) {
182
		for ($i=0; $i<count($tableau); $i++) {
183
			if (isset($ligne[$tableau[$i]['nom_bdd']]) && ( $tableau[$i]['type']=='texte' || $tableau[$i]['type']=='textelong' ) ) {
183
			if (isset($ligne[$tableau[$i]['nom_bdd']]) && ( $tableau[$i]['type']=='texte' || $tableau[$i]['type']=='textelong' ) ) {
184
				$val=$tableau[$i]['nom_bdd'];
184
				$val=$tableau[$i]['nom_bdd'];
185
				if (!in_array($val, array ('bf_titre', 'bf_description', 'bf_date_debut_validite_fiche',
185
				if (!in_array($val, array ('bf_titre', 'bf_description'))) {
186
								'bf_date_fin_validite_fiche'))) {
-
 
187
					if ($val != '' and $val != BAZ_CHOISIR and $val != BAZ_NON_PRECISE) {
186
					if ($ligne[$val] != '' and $ligne[$val] != BAZ_CHOISIR and $ligne[$val] != BAZ_NON_PRECISE) {
188
						$res .= '<span class="rubrique">'.$tableau[$i]['label'].':</span>'."\n";
187
						$res .= '<span class="rubrique">'.$tableau[$i]['label'].':</span>'."\n";
189
						$res .= '<span class="description"> '.$ligne[$val].'</span>'."\n".'<br />'."\n";
188
						$res .= '<span class="description"> '.nl2br($ligne[$val]).'</span>'."\n".'<br />'."\n";
190
					}
189
					}
191
				}
190
				}
192
			}
191
			}
193
			elseif ( $tableau[$i]['type']=='liste' || $tableau[$i]['type']=='checkbox' ) {
192
			elseif ( $tableau[$i]['type']=='liste' || $tableau[$i]['type']=='checkbox' ) {
194
				//pour les champs renseignes par une liste, on va chercher le label de la liste, plutot que l'id				
193
				//pour les champs renseignes par une liste, on va chercher le label de la liste, plutot que l'id				
195
				$requete = 'SELECT blv_label FROM bazar_fiche_valeur_liste, bazar_liste_valeurs WHERE bfvl_ce_fiche='.$GLOBALS['_BAZAR_']['id_fiche'].
194
				$requete = 'SELECT blv_label FROM bazar_fiche_valeur_liste, bazar_liste_valeurs WHERE bfvl_ce_fiche='.$GLOBALS['_BAZAR_']['id_fiche'].
196
				' 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'].'"';
195
				' 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'].'"';
197
				$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
196
				$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
198
				if (DB::isError ($resultat)) {
197
				if (DB::isError ($resultat)) {
199
					die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
198
					die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
200
				}
199
				}
201
				$val='';$nb=0;
200
				$val='';$nb=0;
202
				while ($tab = $resultat->fetchRow()) {
201
				while ($tab = $resultat->fetchRow()) {
203
					if ($nb>0) $val .= ', ';
202
					if ($nb>0) $val .= ', ';
204
					$val .= $tab[0];
203
					$val .= $tab[0];
205
					$nb++;
204
					$nb++;
206
				}				
205
				}				
-
 
206
				if ($val != '' and $val != BAZ_CHOISIR and $val != BAZ_NON_PRECISE) {
207
				$res .= '<span class="rubrique">'.$tableau[$i]['label'].':</span>'."\n";
207
					$res .= '<span class="rubrique">'.$tableau[$i]['label'].':</span>'."\n";
208
				$res .= '<span class="description"> '.$val.'</span>'."\n".'<br />'."\n";
208
					$res .= '<span class="description"> '.$val.'</span>'."\n".'<br />'."\n";
-
 
209
				}
-
 
210
			}
-
 
211
			elseif ( $tableau[$i]['type']=='listedatedeb' || $tableau[$i]['type']=='listedatefin' ) {
-
 
212
				$val=$tableau[$i]['nom_bdd'];
-
 
213
				if (!in_array($val, array ('bf_date_debut_validite_fiche', 'bf_date_fin_validite_fiche'))) {
-
 
214
					if ($ligne[$val] != '') {
-
 
215
						$res .= '<span class="rubrique">'.$tableau[$i]['label'].':</span>'."\n";
-
 
216
						$res .= '<span class="description"> '.strftime('%d.%m.%Y',strtotime($ligne[$val])).'</span>'."\n".'<br />'."\n";
-
 
217
					}
-
 
218
				}		
209
			}
219
			}
210
		}
220
		}
211
	//afficher les liens pour l'annonce
221
	//afficher les liens pour l'annonce
212
	$requete = 'SELECT  bu_url, bu_descriptif_url FROM bazar_url WHERE bu_ce_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
222
	$requete = 'SELECT  bu_url, bu_descriptif_url FROM bazar_url WHERE bu_ce_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
213
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
223
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
214
	if (DB::isError($resultat)) {
224
	if (DB::isError($resultat)) {
215
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
225
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
216
	}
226
	}
217
	if ($resultat->numRows()>0) {
227
	if ($resultat->numRows()>0) {
218
		$res .= '<span class="rubrique">'.BAZ_LIEN_INTERNET.':</span>'."\n";
228
		$res .= '<span class="rubrique">'.BAZ_LIEN_INTERNET.':</span>'."\n";
219
		$res .= '<span class="description">'."\n";
229
		$res .= '<span class="description">'."\n";
220
		$res .= '<ul>'."\n";
230
		$res .= '<ul>'."\n";
221
		while ($ligne1 = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
231
		while ($ligne1 = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
222
			$res .= '<li><a href="'.$ligne1['bu_url'].'" target="_blank">'.$ligne1['bu_descriptif_url'].'</a></li>'."\n";
232
			$res .= '<li><a href="'.$ligne1['bu_url'].'" target="_blank">'.$ligne1['bu_descriptif_url'].'</a></li>'."\n";
223
		}
233
		}
224
		$res .= '</ul></span>'."\n";
234
		$res .= '</ul></span>'."\n";
225
	}
235
	}
226
	
236
	
227
	//afficher les fichiers pour l'annonce
237
	//afficher les fichiers pour l'annonce
228
	$requete = 'SELECT  bfj_description, bfj_fichier FROM bazar_fichier_joint WHERE bfj_ce_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
238
	$requete = 'SELECT  bfj_description, bfj_fichier FROM bazar_fichier_joint WHERE bfj_ce_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
229
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
239
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
230
	if (DB::isError($resultat)) {
240
	if (DB::isError($resultat)) {
231
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
241
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
232
	}
242
	}
233
	if ($resultat->numRows()>0) {
243
	if ($resultat->numRows()>0) {
234
		$res .= '<span class="rubrique">'.BAZ_LISTE_FICHIERS_JOINTS.':</span>'."\n";
244
		$res .= '<span class="rubrique">'.BAZ_LISTE_FICHIERS_JOINTS.':</span>'."\n";
235
		$res .= '<span class="description">'."\n";
245
		$res .= '<span class="description">'."\n";
236
		$res .= '<ul>'."\n";
246
		$res .= '<ul>'."\n";
237
		while ($ligne2 = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
247
		while ($ligne2 = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
238
			$res .= '<li><a href="client/bazar/upload/'.$ligne2['bfj_fichier'].'">'.$ligne2['bfj_description'].'</a></li>'."\n";
248
			$res .= '<li><a href="client/bazar/upload/'.$ligne2['bfj_fichier'].'">'.$ligne2['bfj_description'].'</a></li>'."\n";
239
		}
249
		}
240
		$res .= '</ul></span>'."\n";
250
		$res .= '</ul></span>'."\n";
241
	}
251
	}
242
	$res .= '<div class="bulle_haut">&nbsp;</div>'."\n";
252
	$res .= '<div class="bulle_haut">&nbsp;</div>'."\n";
243
	$res .= '<div class="bulle_corps">'."\n";
253
	$res .= '<div class="bulle_corps">'."\n";
244
	
254
	
245
	//affichage du redacteur de la fiche
255
	//affichage du redacteur de la fiche
246
	$requete = 'SELECT '.BAZ_CHAMPS_NOM.', '.BAZ_CHAMPS_PRENOM.', '.BAZ_CHAMPS_EMAIL.
256
	$requete = 'SELECT '.BAZ_CHAMPS_NOM.', '.BAZ_CHAMPS_PRENOM.', '.BAZ_CHAMPS_EMAIL.
247
					' FROM '.BAZ_ANNUAIRE.' WHERE '.BAZ_CHAMPS_ID.'='.$ligne['bf_ce_utilisateur'];
257
					' FROM '.BAZ_ANNUAIRE.' WHERE '.BAZ_CHAMPS_ID.'='.$ligne['bf_ce_utilisateur'];
248
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
258
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
249
	if (DB::isError($resultat)) {
259
	if (DB::isError($resultat)) {
250
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
260
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
251
	}
261
	}
252
	while ($redacteur = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
262
	while ($redacteur = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
253
		$res .= BAZ_FICHE_ECRITE.'<a href="mailto:'.$redacteur[BAZ_CHAMPS_EMAIL].'">'.$redacteur[BAZ_CHAMPS_PRENOM].' '.$redacteur[BAZ_CHAMPS_NOM].'</a><br />'."\n";
263
		$res .= BAZ_FICHE_ECRITE.'<a href="mailto:'.$redacteur[BAZ_CHAMPS_EMAIL].'">'.$redacteur[BAZ_CHAMPS_PRENOM].' '.$redacteur[BAZ_CHAMPS_NOM].'</a><br />'."\n";
254
	}
264
	}
255
	$res .= BAZ_NB_VUS.'<strong>'.$ligne['bf_nb_consultations'].'</strong>'.BAZ_FOIS.'<br />'."\n";
265
	$res .= BAZ_NB_VUS.'<strong>'.$ligne['bf_nb_consultations'].'</strong>'.BAZ_FOIS.'<br />'."\n";
256
	$res .= '</div>'."\n";
266
	$res .= '</div>'."\n";
257
	$res .= '<div class="bulle_bas">&nbsp;</div>'."\n";
267
	$res .= '<div class="bulle_bas">&nbsp;</div>'."\n";
258
	$res .= '<div id="BAZ_bas_page">';
268
	$res .= '<div id="BAZ_bas_page">';
259
	}
269
	}
260
	
270
	
261
	//informations complementaires (id fiche, etat publication,... )
271
	//informations complementaires (id fiche, etat publication,... )
262
	if ($danslappli==1) {		
272
	if ($danslappli==1) {		
263
		if ($ligne['bf_statut_fiche']==1 && $GLOBALS['_BAZAR_']['appropriation']!=1 ) {
273
		if ($ligne['bf_statut_fiche']==1 && $GLOBALS['_BAZAR_']['appropriation']!=1 ) {
264
			$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";
274
			$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";
265
		}
275
		}
266
		elseif ($GLOBALS['_BAZAR_']['appropriation']!=1 || $ligne['bf_statut_fiche']!=1) {
276
		elseif ($GLOBALS['_BAZAR_']['appropriation']!=1 || $ligne['bf_statut_fiche']!=1) {
267
			$res .= '<span class="rubrique">'.BAZ_PUBLIEE.':</span> '.BAZ_NON;							
277
			$res .= '<span class="rubrique">'.BAZ_PUBLIEE.':</span> '.BAZ_NON;							
268
			if ( $est_admin ) {
278
			if ( $est_admin ) {
269
				$res .= '&nbsp;&nbsp;&nbsp;<strong>'.BAZ_VALIDER_PUBLICATION.'&nbsp;:&nbsp;</strong>'."\n";
279
				$res .= '&nbsp;&nbsp;&nbsp;<strong>'.BAZ_VALIDER_PUBLICATION.'&nbsp;:&nbsp;</strong>'."\n";
270
				$lien_publie = &$GLOBALS['_BAZAR_']['url'];
280
				$lien_publie = &$GLOBALS['_BAZAR_']['url'];
271
				$lien_publie->addQueryString('action', BAZ_VOIR_FICHE);
281
				$lien_publie->addQueryString('action', BAZ_VOIR_FICHE);
272
				$lien_publie->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
282
				$lien_publie->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
273
				$lien_publie->addQueryString('typeannonce', $ligne['bf_ce_nature']);
283
				$lien_publie->addQueryString('typeannonce', $ligne['bf_ce_nature']);
274
				$lien_publie->addQueryString('publiee', 1);
284
				$lien_publie->addQueryString('publiee', 1);
275
				$res .= '<a href="'.$lien_publie->getURL().'">'.BAZ_OUI.'</a>&nbsp;/&nbsp;';
285
				$res .= '<a href="'.$lien_publie->getURL().'">'.BAZ_OUI.'</a>&nbsp;/&nbsp;';
276
				$lien_publie->removeQueryString('publiee');
286
				$lien_publie->removeQueryString('publiee');
277
				$lien_publie->addQueryString('publiee', 0);
287
				$lien_publie->addQueryString('publiee', 0);
278
				$res .='<a href="'.$lien_publie->getURL().'">'.BAZ_NON.'</a>'."\n";
288
				$res .='<a href="'.$lien_publie->getURL().'">'.BAZ_NON.'</a>'."\n";
279
				$lien_publie->removeQueryString('publiee');
289
				$lien_publie->removeQueryString('publiee');
280
			}
290
			}
281
			$res .= '<br />'."\n";
291
			$res .= '<br />'."\n";
282
		}
292
		}
283
		//affichage des infos pouvant interesser les admins
293
		//affichage des infos pouvant interesser les admins
284
		if ( $est_admin ) {
294
		if ( $est_admin ) {
285
			$res .= '<span class="rubrique">'.BAZ_NUM_FICHE.':</span> '.$GLOBALS['_BAZAR_']['id_fiche'].'<br />'."\n";
295
			$res .= '<span class="rubrique">'.BAZ_NUM_FICHE.':</span> '.$GLOBALS['_BAZAR_']['id_fiche'].'<br />'."\n";
286
			$res .= '<span class="rubrique">'.BAZ_DATE_CREATION.' :</span> '.strftime('%d.%m.%Y &agrave; %H:%M',strtotime($ligne['bf_date_creation_fiche'])).'<br />'."\n";			
296
			$res .= '<span class="rubrique">'.BAZ_DATE_CREATION.' :</span> '.strftime('%d.%m.%Y &agrave; %H:%M',strtotime($ligne['bf_date_creation_fiche'])).'<br />'."\n";			
287
		}		
297
		}		
288
		//affichage des infos et du lien pour la mise a jour de la fiche
298
		//affichage des infos et du lien pour la mise a jour de la fiche
289
		if ( $est_admin || $GLOBALS['_BAZAR_']['annonceur']==$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID) ) {			
299
		if ( $est_admin || $GLOBALS['_BAZAR_']['annonceur']==$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID) ) {			
290
			$res .= '<span class="rubrique">'.BAZ_DATE_MAJ.' :</span> '.strftime('%d.%m.%Y &agrave; %H:%M',strtotime($ligne['bf_date_maj_fiche']))."\n";
300
			$res .= '<span class="rubrique">'.BAZ_DATE_MAJ.' :</span> '.strftime('%d.%m.%Y &agrave; %H:%M',strtotime($ligne['bf_date_maj_fiche']))."\n";
291
			$lien_modifier=$GLOBALS['_BAZAR_']['url'];
301
			$lien_modifier=$GLOBALS['_BAZAR_']['url'];
292
			$lien_modifier->addQueryString('action', BAZ_ACTION_MODIFIER);
302
			$lien_modifier->addQueryString('action', BAZ_ACTION_MODIFIER);
293
			$lien_modifier->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
303
			$lien_modifier->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
294
			$lien_modifier->addQueryString('typeannonce', $ligne['bf_ce_nature']);
304
			$lien_modifier->addQueryString('typeannonce', $ligne['bf_ce_nature']);
295
			$res .= '&nbsp;&nbsp;&nbsp;<a href="'.$lien_modifier->getURL().'">'.BAZ_MODIFIER_LA_FICHE.'</a>'."\n";
305
			$res .= '&nbsp;&nbsp;&nbsp;<a href="'.$lien_modifier->getURL().'">'.BAZ_MODIFIER_LA_FICHE.'</a>'."\n";
296
		}
306
		}
297
	}
307
	}
298
	$res .= '</div>'."\n";
308
	$res .= '</div>'."\n";
299
	$res .= '</div>'."\n";
309
	$res .= '</div>'."\n";
300
	
310
	
301
	//on ajoute les appropriations, s'il le faut
311
	//on ajoute les appropriations, s'il le faut
302
	if (($danslappli==1)and($GLOBALS['_BAZAR_']['appropriation']==1)) {
312
	if (($danslappli==1)and($GLOBALS['_BAZAR_']['appropriation']==1)) {
303
		$res .= '<br />'."\n".'<div class="BAZ_cadre_fiche">'."\n";
313
		$res .= '<br />'."\n".'<div class="BAZ_cadre_fiche">'."\n";
304
		$res .= '<h3>'.BAZ_LES_STRUCTURES_POSSEDANT_UNE_RESSOURCE.'</h3>'."\n";		
314
		$res .= '<h3>'.BAZ_LES_STRUCTURES_POSSEDANT_UNE_RESSOURCE.'</h3>'."\n";		
305
		$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';
315
		$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';
306
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
316
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
307
		if (DB::isError ($resultat)) {
317
		if (DB::isError ($resultat)) {
308
			die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
318
			die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
309
		}
319
		}
310
		$possede_ressource=0;
320
		$possede_ressource=0;
311
		if ($resultat->numRows()>0) {
321
		if ($resultat->numRows()>0) {
312
			$res .= BAZ_IL_Y_A.$resultat->numRows().' ';
322
			$res .= BAZ_IL_Y_A.$resultat->numRows().' ';
313
			if ($resultat->numRows()==1) $res .= BAZ_STRUCTURE_POSSEDANT.'<br />'."\n";
323
			if ($resultat->numRows()==1) $res .= BAZ_STRUCTURE_POSSEDANT.'<br />'."\n";
314
			else $res .= BAZ_STRUCTURES_POSSEDANT.'<br />'."\n";
324
			else $res .= BAZ_STRUCTURES_POSSEDANT.'<br />'."\n";
315
			$res .= '<ul>'."\n";
325
			$res .= '<ul>'."\n";
316
			while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
326
			while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
317
				$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";
327
				$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";
318
				if ($GLOBALS['AUTH']->getAuth() && $GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID)==$ligne[BAZ_CHAMPS_ID]) $possede_ressource=1;
328
				if ($GLOBALS['AUTH']->getAuth() && $GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID)==$ligne[BAZ_CHAMPS_ID]) $possede_ressource=1;
319
			}
329
			}
320
			$res .= '</ul><br />'."\n";
330
			$res .= '</ul><br />'."\n";
321
		}
331
		}
322
		else $res .= BAZ_PAS_D_APPROPRIATION.'<br /><br />'."\n";
332
		else $res .= BAZ_PAS_D_APPROPRIATION.'<br /><br />'."\n";
323
		$res .='<p class="bulle_corps">'."\n";
333
		$res .='<p class="bulle_corps">'."\n";
324
		$lien_appropriation = $GLOBALS['_BAZAR_']['url'];
334
		$lien_appropriation = $GLOBALS['_BAZAR_']['url'];
325
		$lien_appropriation->addQueryString('action', BAZ_VOIR_FICHE);
335
		$lien_appropriation->addQueryString('action', BAZ_VOIR_FICHE);
326
		$lien_appropriation->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);			
336
		$lien_appropriation->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);			
327
		if ($possede_ressource) {
337
		if ($possede_ressource) {
328
			$lien_appropriation->addQueryString('appropriation', 0);
338
			$lien_appropriation->addQueryString('appropriation', 0);
329
			$res .= BAZ_POSSEDE_DEJA_RESSOURCE.'<br />'."\n".'<a href="'.$lien_appropriation->getURL().'">'.BAZ_CLIQUER_POUR_VOUS_ENLEVER.'</a>'."\n";
339
			$res .= BAZ_POSSEDE_DEJA_RESSOURCE.'<br />'."\n".'<a href="'.$lien_appropriation->getURL().'">'.BAZ_CLIQUER_POUR_VOUS_ENLEVER.'</a>'."\n";
330
			$lien_appropriation->removeQueryString('appropriation');
340
			$lien_appropriation->removeQueryString('appropriation');
331
		}
341
		}
332
		elseif ($GLOBALS['AUTH']->getAuth() && $GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_EST_STRUCTURE)) {
342
		elseif ($GLOBALS['AUTH']->getAuth() && $GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_EST_STRUCTURE)) {
333
			$lien_appropriation->addQueryString('appropriation', 1);
343
			$lien_appropriation->addQueryString('appropriation', 1);
334
			$res .= BAZ_SI_POSSEDE_RESSOURCE.'<br />'."\n".'<a href="'.$lien_appropriation->getURL().'">'.BAZ_CLIQUER_POUR_APPARAITRE.'</a>'."\n";
344
			$res .= BAZ_SI_POSSEDE_RESSOURCE.'<br />'."\n".'<a href="'.$lien_appropriation->getURL().'">'.BAZ_CLIQUER_POUR_APPARAITRE.'</a>'."\n";
335
			$lien_appropriation->removeQueryString('appropriation');
345
			$lien_appropriation->removeQueryString('appropriation');
336
		}
346
		}
337
		elseif ($GLOBALS['AUTH']->getAuth() && !$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_EST_STRUCTURE)) {
347
		elseif ($GLOBALS['AUTH']->getAuth() && !$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_EST_STRUCTURE)) {
338
			$res .= BAZ_IL_FAUT_ETRE_STRUCTURE."\n";
348
			$res .= BAZ_IL_FAUT_ETRE_STRUCTURE."\n";
339
		}
349
		}
340
		elseif (!$GLOBALS['AUTH']->getAuth()) {
350
		elseif (!$GLOBALS['AUTH']->getAuth()) {
341
			$res .= BAZ_IL_FAUT_ETRE_IDENTIFIE_STRUCTURE."\n";
351
			$res .= BAZ_IL_FAUT_ETRE_IDENTIFIE_STRUCTURE."\n";
342
		}
352
		}
343
		$res .='</p>'."\n";
353
		$res .='</p>'."\n";
344
		$res .= '</div>'."\n";
354
		$res .= '</div>'."\n";
345
	}
355
	}
346
	
356
	
347
	//on ajoute les commentaires, s'il le faut
357
	//on ajoute les commentaires, s'il le faut
348
	if (($danslappli==1)and($GLOBALS['_BAZAR_']['commentaire']==1)) {
358
	if (($danslappli==1)and($GLOBALS['_BAZAR_']['commentaire']==1)) {
349
		$res .= '<br />'."\n".'<div class="BAZ_cadre_fiche">'."\n";
359
		$res .= '<br />'."\n".'<div class="BAZ_cadre_fiche">'."\n";
350
		$res .= '<h3>'.BAZ_LES_COMMENTAIRES.'</h3>'."\n";
360
		$res .= '<h3>'.BAZ_LES_COMMENTAIRES.'</h3>'."\n";
351
		$requete = 'SELECT * FROM bazar_commentaires WHERE bc_ce_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'].' ORDER BY bc_date ASC';
361
		$requete = 'SELECT * FROM bazar_commentaires WHERE bc_ce_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'].' ORDER BY bc_date ASC';
352
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
362
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
353
		if (DB::isError ($resultat)) {
363
		if (DB::isError ($resultat)) {
354
			die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
364
			die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
355
		}
365
		}
356
		if ($resultat->numRows()>0) {
366
		if ($resultat->numRows()>0) {
357
			$res .= BAZ_IL_Y_A.$resultat->numRows().' ';
367
			$res .= BAZ_IL_Y_A.$resultat->numRows().' ';
358
			if ($resultat->numRows()==1) $res .= BAZ_COMMENTAIRE.'<br />'."\n";
368
			if ($resultat->numRows()==1) $res .= BAZ_COMMENTAIRE.'<br />'."\n";
359
			else $res .= BAZ_COMMENTAIRES.'<br />'."\n";
369
			else $res .= BAZ_COMMENTAIRES.'<br />'."\n";
360
			while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
370
			while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
361
				$res .= '<div class="bulle_haut">&nbsp;</div>'."\n";
371
				$res .= '<div class="bulle_haut">&nbsp;</div>'."\n";
362
				$res .= '<div class="bulle_corps">'."\n";
372
				$res .= '<div class="bulle_corps">'."\n";
363
				//affichage du commentaire
373
				//affichage du commentaire
364
				$res .= $ligne['bc_commentaire'].'<br />'."\n";
374
				$res .= $ligne['bc_commentaire'].'<br />'."\n";
365
				$res .= '</div>'."\n";
375
				$res .= '</div>'."\n";
366
				$res .= '<div class="bulle_bas">'."\n";
376
				$res .= '<div class="bulle_bas">'."\n";
367
				$res .= '<div style="font-size:9px;margin-left:10px;">'.BAZ_PAR.' : <strong>'.$ligne['bc_nom'].'</strong>'.BAZ_ECRIT_LE.$ligne['bc_date'].'</div>'."\n";
377
				$res .= '<div style="font-size:9px;margin-left:10px;">'.BAZ_PAR.' : <strong>'.$ligne['bc_nom'].'</strong>'.BAZ_ECRIT_LE.$ligne['bc_date'].'</div>'."\n";
368
				//pour les identifies seulement, administrateurs de la rubrique ou superadmins
378
				//pour les identifies seulement, administrateurs de la rubrique ou superadmins
369
				if ($est_admin==1) {
379
				if ($est_admin==1) {
370
					$url_comment= $GLOBALS['_BAZAR_']['url'];
380
					$url_comment= $GLOBALS['_BAZAR_']['url'];
371
					$url_comment->addQueryString('action', BAZ_VOIR_FICHE);
381
					$url_comment->addQueryString('action', BAZ_VOIR_FICHE);
372
					$url_comment->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
382
					$url_comment->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
373
					$url_comment->addQueryString('id_commentaire', $ligne['bc_id_commentaire']);
383
					$url_comment->addQueryString('id_commentaire', $ligne['bc_id_commentaire']);
374
					$res .= '<a href="'.$url_comment->getURL().'" style="font-size:9px;float:right;">'.BAZ_SUPPRIMER.'</a>'."\n";
384
					$res .= '<a href="'.$url_comment->getURL().'" style="font-size:9px;float:right;">'.BAZ_SUPPRIMER.'</a>'."\n";
375
				}
385
				}
376
				$res .= '</div>'."\n";
386
				$res .= '</div>'."\n";
377
			}
387
			}
378
		}
388
		}
379
		else $res .= BAZ_PAS_DE_COMMENTAIRES.'<br /><br />'."\n";
389
		else $res .= BAZ_PAS_DE_COMMENTAIRES.'<br /><br />'."\n";
380
		
390
		
381
		//formulaire des commentaires
391
		//formulaire des commentaires
382
		$form_commentaire = new HTML_QuickForm('bazar_commentaire', 'post', $url);
392
		$form_commentaire = new HTML_QuickForm('bazar_commentaire', 'post', $url);
383
		$squelette =& $form_commentaire->defaultRenderer();
393
		$squelette =& $form_commentaire->defaultRenderer();
384
		$squelette->setFormTemplate("\n".'<form {attributes}>'."\n".'{content}'."\n".'</form>'."\n");
394
		$squelette->setFormTemplate("\n".'<form {attributes}>'."\n".'{content}'."\n".'</form>'."\n");
385
		$squelette->setElementTemplate( '<label style="width:200px;">{label}'.
395
		$squelette->setElementTemplate( '<label style="width:200px;">{label}'.
386
										'<!-- BEGIN required --><span class="symbole_obligatoire">&nbsp;*</span><!-- END required -->'."\n".
396
										'<!-- BEGIN required --><span class="symbole_obligatoire">&nbsp;*</span><!-- END required -->'."\n".
387
									    '</label><br />'."\n".'{element}<br />'."\n");
397
									    '</label><br />'."\n".'{element}<br />'."\n");
388
		$squelette->setRequiredNoteTemplate("\n".'<span class="symbole_obligatoire"> *{requiredNote}</span>'."\n");
398
		$squelette->setRequiredNoteTemplate("\n".'<span class="symbole_obligatoire"> *{requiredNote}</span>'."\n");
389
		$option=array('style'=>'width:300px;border:1px solid #000;', 'maxlength'=>100);
399
		$option=array('style'=>'width:300px;border:1px solid #000;', 'maxlength'=>100);
390
		$form_commentaire->addElement('text', 'Nom', BAZ_ENTREZ_VOTRE_NOM, $option);
400
		$form_commentaire->addElement('text', 'Nom', BAZ_ENTREZ_VOTRE_NOM, $option);
391
		$option=array('style'=>'width:95%;height:100px;white-space: pre;padding:3px;border:1px solid #000;');
401
		$option=array('style'=>'width:95%;height:100px;white-space: pre;padding:3px;border:1px solid #000;');
392
		require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm/textarea.php';
402
		require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm/textarea.php';
393
		$formtexte= new HTML_QuickForm_textarea('Commentaire', BAZ_ENTREZ_VOTRE_COMMENTAIRE, $option);
403
		$formtexte= new HTML_QuickForm_textarea('Commentaire', BAZ_ENTREZ_VOTRE_COMMENTAIRE, $option);
394
		$form_commentaire->addElement($formtexte) ;
404
		$form_commentaire->addElement($formtexte) ;
395
		$option=array('style'=>'border:1px solid #000;');
405
		$option=array('style'=>'border:1px solid #000;');
396
		$form_commentaire->addElement('submit', 'Envoyer', BAZ_ENVOYER, $option);
406
		$form_commentaire->addElement('submit', 'Envoyer', BAZ_ENVOYER, $option);
397
		$form_commentaire->addRule('Nom', BAZ_NOM_REQUIS, 'required', '', 'client') ;
407
		$form_commentaire->addRule('Nom', BAZ_NOM_REQUIS, 'required', '', 'client') ;
398
		$form_commentaire->addRule('Commentaire', BAZ_COMMENTAIRE_REQUIS, 'required', '', 'client') ;
408
		$form_commentaire->addRule('Commentaire', BAZ_COMMENTAIRE_REQUIS, 'required', '', 'client') ;
399
		$form_commentaire->setRequiredNote(BAZ_CHAMPS_REQUIS) ;
409
		$form_commentaire->setRequiredNote(BAZ_CHAMPS_REQUIS) ;
400
		$res .= $form_commentaire->toHTML();
410
		$res .= $form_commentaire->toHTML();
401
		$res .= '</div>'."\n";
411
		$res .= '</div>'."\n";
402
	}
412
	}
403
	
413
	
404
	return $res ;
414
	return $res ;
405
}
415
}
406
 
416
 
407
 
417
 
408
/** RSSversHTML () transforme un flux RSS (en XML) en page HTML
418
/** RSSversHTML () transforme un flux RSS (en XML) en page HTML
409
*
419
*
410
*   On passe en paramètre le contenu du flux RSS, on affiche ou non la description,
420
*   On passe en paramètre le contenu du flux RSS, on affiche ou non la description,
411
*   et on choisit de format de la date à l'affichage. On a en sortie du code HTML à afficher 
421
*   et on choisit de format de la date à l'affichage. On a en sortie du code HTML à afficher 
412
*
422
*
413
*   @param  string   le contenu du flux RSS
423
*   @param  string   le contenu du flux RSS
414
*   @param  boolean  afficher ou non la description
424
*   @param  boolean  afficher ou non la description
415
*   @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
425
*   @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
416
*
426
*
417
*   @return  string    le code HTML
427
*   @return  string    le code HTML
418
*/
428
*/
419
function RSSversHTML($rss, $voirdesc, $formatdate, $affichenb) {
429
function RSSversHTML($rss, $voirdesc, $formatdate, $affichenb) {
420
	if ($rss!='') {
430
	if ($rss!='') {
421
		$rawitems='';$title='';$url='';$cat='';$date='';
431
		$rawitems='';$title='';$url='';$cat='';$date='';
422
		$res='';
432
		$res='';
423
		if( eregi('<item>(.*)</item>', $rss, $rawitems ) ) {
433
		if( eregi('<item>(.*)</item>', $rss, $rawitems ) ) {
424
			$items = explode('<item>', $rawitems[0]);
434
			$items = explode('<item>', $rawitems[0]);
425
			$res.='<ul id="BAZ_liste_fiche">'."\n";
435
			$res.='<ul id="BAZ_liste_fiche">'."\n";
426
			for( $i = 0; $i < count($items)-1; $i++ ) {
436
			for( $i = 0; $i < count($items)-1; $i++ ) {
427
				eregi('<title>(.*)</title>',$items[$i+1], $title );
437
				eregi('<title>(.*)</title>',$items[$i+1], $title );
428
				eregi('<link>(.*)</link>',$items[$i+1], $url );
438
				eregi('<link>(.*)</link>',$items[$i+1], $url );
429
				eregi('<description>(.*)</description>',$items[$i+1], $cat);
439
				eregi('<description>(.*)</description>',$items[$i+1], $cat);
430
				eregi('<pubDate>(.*)</pubDate>',$items[$i+1], $date);
440
				eregi('<pubDate>(.*)</pubDate>',$items[$i+1], $date);
431
				$res.='<li>';
441
				$res.='<li>';
432
				if ($formatdate=='jm') {$res.=strftime('%d.%m',strtotime($date[1])).': ';}
442
				if ($formatdate=='jm') {$res.=strftime('%d.%m',strtotime($date[1])).': ';}
433
				if ($formatdate=='jma') {$res.=strftime('%d.%m.%Y',strtotime($date[1])).': ';}
443
				if ($formatdate=='jma') {$res.=strftime('%d.%m.%Y',strtotime($date[1])).': ';}
434
				if ($formatdate=='jmh') {$res.=strftime('%d.%m %H:%M',strtotime($date[1])).': ';}
444
				if ($formatdate=='jmh') {$res.=strftime('%d.%m %H:%M',strtotime($date[1])).': ';}
435
				if ($formatdate=='jmah') {$res.=strftime('%d.%m.%Y %H:%M',strtotime($date[1])).': ';}
445
				if ($formatdate=='jmah') {$res.=strftime('%d.%m.%Y %H:%M',strtotime($date[1])).': ';}
436
				$res.='<a href="'.preg_replace ('/&amp;/', '&', $url[1]).'">'.$title[1].'</a>';
446
				$res.='<a href="'.preg_replace ('/&amp;/', '&', $url[1]).'">'.$title[1].'</a>';
437
				if ($voirdesc) {$res.=$cat[1];}
447
				if ($voirdesc) {$res.=$cat[1];}
438
				// Ajout du bouton supprimer pour les superadministrateur
448
				// Ajout du bouton supprimer pour les superadministrateur
439
				if (($GLOBALS['AUTH']->getAuth() && niveau_droit(0,$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID))=='superadministrateur')and($url[1]!='#')) {
449
				if (($GLOBALS['AUTH']->getAuth() && niveau_droit(0,$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID))=='superadministrateur')and($url[1]!='#')) {
440
					$mon_url = preg_replace ('/&amp;/', '&', $url[1]) ; 
450
					$mon_url = preg_replace ('/&amp;/', '&', $url[1]) ; 
441
					$url_suppr = new Net_URL(preg_replace ('/&amp;/', '&', $mon_url)) ;
451
					$url_suppr = new Net_URL(preg_replace ('/&amp;/', '&', $mon_url)) ;
442
					$url_suppr->addQueryString('action', BAZ_ACTION_SUPPRESSION) ;
452
					$url_suppr->addQueryString('action', BAZ_ACTION_SUPPRESSION) ;
443
		        	$res .= ' ( <a href="'.$url_suppr->getURL().
453
		        	$res .= ' ( <a href="'.$url_suppr->getURL().
444
							'" onclick="javascript:return confirm(\''.BAZ_SUPPRIMER.' ?\');">'.
454
							'" onclick="javascript:return confirm(\''.BAZ_SUPPRIMER.' ?\');">'.
445
							BAZ_SUPPRIMER.'</a> )'."\n" ;
455
							BAZ_SUPPRIMER.'</a> )'."\n" ;
446
					}
456
					}
447
				$res.='</li>'."\n";
457
				$res.='</li>'."\n";
448
			}
458
			}
449
			$res.='</ul>'."\n";
459
			$res.='</ul>'."\n";
450
			if ($affichenb==1) {
460
			if ($affichenb==1) {
451
				//une annonce trouvee, on accorde au singulier
461
				//une annonce trouvee, on accorde au singulier
452
				if (((count($items)-1)==1)and($title!=BAZ_PAS_D_ANNONCES)) {
462
				if (((count($items)-1)==1)and($title!=BAZ_PAS_D_ANNONCES)) {
453
					$res = '<br /><h4>'.BAZ_IL_Y_A.' 1 '.BAZ_FICHE_CORRESPONDANTE.'</h4><br />'."\n".$res;
463
					$res = '<br /><h4>'.BAZ_IL_Y_A.' 1 '.BAZ_FICHE_CORRESPONDANTE.'</h4><br />'."\n".$res;
454
				}
464
				}
455
				//plusieures annonces trouvees, on accorde au pluriel
465
				//plusieures annonces trouvees, on accorde au pluriel
456
				else {
466
				else {
457
					$res = '<br /><h4>'.BAZ_IL_Y_A.(count($items)-1).' '.BAZ_FICHES_CORRESPONDANTES.'</h4><br />'."\n".$res;
467
					$res = '<br /><h4>'.BAZ_IL_Y_A.(count($items)-1).' '.BAZ_FICHES_CORRESPONDANTES.'</h4><br />'."\n".$res;
458
				}
468
				}
459
			}
469
			}
460
			//cas des fiches pas trouvées
470
			//cas des fiches pas trouvées
461
			if (((count($items)-1)==1)and($title[1]==BAZ_PAS_D_ANNONCES)) {
471
			if (((count($items)-1)==1)and($title[1]==BAZ_PAS_D_ANNONCES)) {
462
				$res = '<br /><h4>'.BAZ_PAS_D_ANNONCES.'</h4><br />'."\n";
472
				$res = '<br /><h4>'.BAZ_PAS_D_ANNONCES.'</h4><br />'."\n";
463
			}  
473
			}  
464
		}
474
		}
465
	}
475
	}
466
	else $res = BAZ_PAS_D_ANNONCES;
476
	else $res = BAZ_PAS_D_ANNONCES;
467
	return $res;
477
	return $res;
468
}
478
}
469
 
479
 
470
/** gen_RSS() - generer un fichier de flux RSS par type d'annonce 
480
/** gen_RSS() - generer un fichier de flux RSS par type d'annonce 
471
*
481
*
472
* @param   string Le type de l'annonce (laisser vide pour tout type d'annonce)
482
* @param   string Le type de l'annonce (laisser vide pour tout type d'annonce)
473
* @param   integer Le nombre d'annonces a regrouper dans le fichier XML (laisser vide pour toutes)
483
* @param   integer Le nombre d'annonces a regrouper dans le fichier XML (laisser vide pour toutes)
474
* @param   integer L'identifiant de l'emetteur (laisser vide pour tous)
484
* @param   integer L'identifiant de l'emetteur (laisser vide pour tous)
475
* @param   integer L'etat de validation de l'annonce (laisser 1 pour les annonces validees, 0 pour les non-validees)
485
* @param   integer L'etat de validation de l'annonce (laisser 1 pour les annonces validees, 0 pour les non-validees)
476
* @param   string La requete SQL personnalisee
486
* @param   string La requete SQL personnalisee
477
*
487
*
478
* @return  string Le code du flux RSS
488
* @return  string Le code du flux RSS
479
*/
489
*/
480
function gen_RSS($typeannonce='', $nbitem='', $emetteur='', $valide=1, $requeteSQL='', $requeteSQLFrom = '') {
490
function gen_RSS($typeannonce='', $nbitem='', $emetteur='', $valide=1, $requeteSQL='', $requeteSQLFrom = '') {
481
	// generation de la requete MySQL personnalisee
491
	// generation de la requete MySQL personnalisee
482
	$req_where=0;
492
	$req_where=0;
483
	$requete = 'SELECT DISTINCT bf_id_fiche, bf_titre, bf_date_debut_validite_fiche '.
493
	$requete = 'SELECT DISTINCT bf_id_fiche, bf_titre, bf_date_debut_validite_fiche '.
484
				'FROM bazar_fiche, bazar_nature '.$requeteSQLFrom.' WHERE ';
494
				'FROM bazar_fiche, bazar_nature '.$requeteSQLFrom.' WHERE ';
485
	if ($valide!=2) {
495
	if ($valide!=2) {
486
		$requete .= 'bf_statut_fiche='.$valide;
496
		$requete .= 'bf_statut_fiche='.$valide;
487
		$req_where=1;
497
		$req_where=1;
488
	}
498
	}
489
	$nomflux=BAZ_DERNIERE_ACTU;
499
	$nomflux=BAZ_DERNIERE_ACTU;
490
	if (!is_array ($typeannonce) && $typeannonce!='' and $typeannonce!='toutes') {
500
	if (!is_array ($typeannonce) && $typeannonce!='' and $typeannonce!='toutes') {
491
		if ($req_where==1) {$requete .= ' AND ';}
501
		if ($req_where==1) {$requete .= ' AND ';}
492
		$requete .= 'bf_ce_nature='.$typeannonce;
502
		$requete .= 'bf_ce_nature='.$typeannonce;
493
		$req_where=1;
503
		$req_where=1;
494
		//le nom du flux devient le type d'annonce
504
		//le nom du flux devient le type d'annonce
495
		$nomflux = $typeannonce;
505
		$nomflux = $typeannonce;
496
	}
506
	}
497
	// Cas où il y plusieurs type d annonce demande
507
	// Cas où il y plusieurs type d annonce demande
498
	if (is_array ($typeannonce)) {
508
	if (is_array ($typeannonce)) {
499
		if ($req_where==1) {$requete .= ' AND ';}
509
		if ($req_where==1) {$requete .= ' AND ';}
500
		$requete .= 'bf_ce_nature IN (' ;
510
		$requete .= 'bf_ce_nature IN (' ;
501
		$chaine = '';
511
		$chaine = '';
502
		foreach ($typeannonce as $valeur) $chaine .= '"'.$valeur.'",' ;
512
		foreach ($typeannonce as $valeur) $chaine .= '"'.$valeur.'",' ;
503
		$requete .= substr ($chaine, 0, strlen ($chaine)-1) ; 
513
		$requete .= substr ($chaine, 0, strlen ($chaine)-1) ; 
504
		$requete .= ') ';
514
		$requete .= ') ';
505
	}
515
	}
506
	$utilisateur = new Administrateur_bazar ($GLOBALS['AUTH']) ;
516
	$utilisateur = new Administrateur_bazar ($GLOBALS['AUTH']) ;
507
	if ($valide!=0) {
517
	if ($valide!=0) {
508
		
518
		
509
		if ($utilisateur->isSuperAdmin()) {
519
		if ($utilisateur->isSuperAdmin()) {
510
			$req_where=1;
520
			$req_where=1;
511
		} else {
521
		} else {
512
			if ($req_where==1) {
522
			if ($req_where==1) {
513
				$requete .= ' AND ';
523
				$requete .= ' AND ';
514
			}
524
			}
515
			$requete .= '(bf_date_debut_validite_fiche<=NOW() or bf_date_debut_validite_fiche="0000-00-00")'.
525
			$requete .= '(bf_date_debut_validite_fiche<=NOW() or bf_date_debut_validite_fiche="0000-00-00")'.
516
						' AND (bf_date_fin_validite_fiche>=NOW() or bf_date_fin_validite_fiche="0000-00-00") AND bn_id_nature=bf_ce_nature';
526
						' AND (bf_date_fin_validite_fiche>=NOW() or bf_date_fin_validite_fiche="0000-00-00") AND bn_id_nature=bf_ce_nature';
517
		}
527
		}
518
	}
528
	}
519
	else $nomflux .= BAZ_A_MODERER;
529
	else $nomflux .= BAZ_A_MODERER;
520
	if ($emetteur!='' && $emetteur!='tous') {
530
	if ($emetteur!='' && $emetteur!='tous') {
521
		if ($req_where==1) {$requete .= ' AND ';}
531
		if ($req_where==1) {$requete .= ' AND ';}
522
		$requete .= 'bf_ce_utilisateur='.$emetteur;
532
		$requete .= 'bf_ce_utilisateur='.$emetteur;
523
		$req_where=1;
533
		$req_where=1;
524
		//requete pour afficher le nom de la structure
534
		//requete pour afficher le nom de la structure
525
		$requetenom = 'SELECT '.BAZ_CHAMPS_NOM.', '.BAZ_CHAMPS_PRENOM.' FROM '.
535
		$requetenom = 'SELECT '.BAZ_CHAMPS_NOM.', '.BAZ_CHAMPS_PRENOM.' FROM '.
526
						BAZ_ANNUAIRE.' WHERE '.BAZ_CHAMPS_ID.'='.$emetteur;
536
						BAZ_ANNUAIRE.' WHERE '.BAZ_CHAMPS_ID.'='.$emetteur;
527
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requetenom) ;
537
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requetenom) ;
528
		if (DB::isError($resultat)) {
538
		if (DB::isError($resultat)) {
529
			die ($resultat->getMessage().$resultat->getDebugInfo()) ;
539
			die ($resultat->getMessage().$resultat->getDebugInfo()) ;
530
		}
540
		}
531
		$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
541
		$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
532
		$nomflux .= ' ('.$ligne[BAZ_CHAMPS_NOM].' '.$ligne[BAZ_CHAMPS_PRENOM].')';
542
		$nomflux .= ' ('.$ligne[BAZ_CHAMPS_NOM].' '.$ligne[BAZ_CHAMPS_PRENOM].')';
533
	}
543
	}
534
	if ($requeteSQL!='') {
544
	if ($requeteSQL!='') {
535
		if ($req_where==1) {$requete .= ' AND ';}
545
		if ($req_where==1) {$requete .= ' AND ';}
536
		$requete .= '('.$requeteSQL.')';
546
		$requete .= '('.$requeteSQL.')';
537
		$req_where=1;
547
		$req_where=1;
538
	}
548
	}
539
	$requete .= ' ORDER BY  bf_date_debut_validite_fiche DESC, bf_date_fin_validite_fiche DESC, bf_date_maj_fiche DESC';
549
	$requete .= ' ORDER BY  bf_date_debut_validite_fiche DESC, bf_date_fin_validite_fiche DESC, bf_date_maj_fiche DESC';
540
	if ($nbitem!='') {$requete .= ' LIMIT 0,'.$nbitem;}
550
	if ($nbitem!='') {$requete .= ' LIMIT 0,'.$nbitem;}
541
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
551
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
542
	if (DB::isError($resultat)) {
552
	if (DB::isError($resultat)) {
543
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
553
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
544
	}
554
	}
545
	// En-tete du flux RSS version 2.0
555
	// En-tete du flux RSS version 2.0
546
	$xml = '<?xml version="1.0" encoding="ISO-8859-1"?>'."\n".'<rss version="2.0">'."\n";
556
	$xml = '<?xml version="1.0" encoding="ISO-8859-1"?>'."\n".'<rss version="2.0">'."\n";
547
	$xml .= '<channel>'."\n".'<title>'.$nomflux.'</title>'."\n".'<link>'.BAZ_RSS_ADRESSESITE.'</link>'."\n";
557
	$xml .= '<channel>'."\n".'<title>'.$nomflux.'</title>'."\n".'<link>'.BAZ_RSS_ADRESSESITE.'</link>'."\n";
548
	$xml .= '<description>'.BAZ_RSS_DESCRIPTIONSITE.'</description>'."\n".'<language>fr-FR</language>'."\n".
558
	$xml .= '<description>'.BAZ_RSS_DESCRIPTIONSITE.'</description>'."\n".'<language>fr-FR</language>'."\n".
549
	'<copyright>Copyright 2005 '.BAZ_RSS_NOMSITE.'</copyright>'."\n";
559
	'<copyright>Copyright 2005 '.BAZ_RSS_NOMSITE.'</copyright>'."\n";
550
	// Ajout de la date actuelle de publication (suivant la DTD RSS)
560
	// Ajout de la date actuelle de publication (suivant la DTD RSS)
551
	$xml .= '<lastBuildDate>'.strftime('%d %b %Y %H:%M:%S GMT').'</lastBuildDate>'."\n";
561
	$xml .= '<lastBuildDate>'.strftime('%d %b %Y %H:%M:%S GMT').'</lastBuildDate>'."\n";
552
	// En-tete suite et fin
562
	// En-tete suite et fin
553
	$xml .= '<docs>http://www.stervinou.com/projets/rss/</docs>'."\n".'<category>'.BAZ_RSS_CATEGORIE.'</category>'."\n".
563
	$xml .= '<docs>http://www.stervinou.com/projets/rss/</docs>'."\n".'<category>'.BAZ_RSS_CATEGORIE.'</category>'."\n".
554
	'<managingEditor>'.BAZ_RSS_MANAGINGEDITOR.'</managingEditor>'."\n".'<webMaster>'.BAZ_RSS_WEBMASTER.'</webMaster>'."\n";
564
	'<managingEditor>'.BAZ_RSS_MANAGINGEDITOR.'</managingEditor>'."\n".'<webMaster>'.BAZ_RSS_WEBMASTER.'</webMaster>'."\n";
555
	$xml .= '<ttl>60</ttl>'."\n".'<image>'."\n".'<title>'.BAZ_RSS_NOMSITE.'</title>'."\n".'<url>'.BAZ_RSS_LOGOSITE.'</url>'."\n".
565
	$xml .= '<ttl>60</ttl>'."\n".'<image>'."\n".'<title>'.BAZ_RSS_NOMSITE.'</title>'."\n".'<url>'.BAZ_RSS_LOGOSITE.'</url>'."\n".
556
	'<link>'.BAZ_RSS_ADRESSESITE.'</link>'."\n".'</image>'."\n";
566
	'<link>'.BAZ_RSS_ADRESSESITE.'</link>'."\n".'</image>'."\n";
557
	if ($resultat->numRows()>0) {
567
	if ($resultat->numRows()>0) {
558
		// Creation des items : titre + lien + description + date de publication
568
		// Creation des items : titre + lien + description + date de publication
559
		while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
569
		while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
560
			$xml .= '<item>'."\n";
570
			$xml .= '<item>'."\n";
561
			$xml .= '<title>'.$ligne['bf_titre'].'</title>'."\n";
571
			$xml .= '<title>'.$ligne['bf_titre'].'</title>'."\n";
562
			$lien=$GLOBALS['_BAZAR_']['url'];
572
			$lien=$GLOBALS['_BAZAR_']['url'];
563
			$lien->addQueryString('action', BAZ_VOIR_FICHE);
573
			$lien->addQueryString('action', BAZ_VOIR_FICHE);
564
			$lien->addQueryString('id_fiche', $ligne['bf_id_fiche']);
574
			$lien->addQueryString('id_fiche', $ligne['bf_id_fiche']);
565
			$xml .= '<link>'.str_replace ('&', '&amp;', $lien->getURL()).'</link>'."\n";
575
			$xml .= '<link>'.str_replace ('&', '&amp;', $lien->getURL()).'</link>'."\n";
566
			$xml .= '<description>'."\n".'<![CDATA[' ;
576
			$xml .= '<description>'."\n".'<![CDATA[' ;
567
			if ($_GET['action'] != BAZ_VOIR_TOUTES_ANNONCES) {
577
			if ($_GET['action'] != BAZ_VOIR_TOUTES_ANNONCES) {
568
				$xml .= baz_voir_fiche(0,$ligne['bf_id_fiche']) ;
578
				$xml .= baz_voir_fiche(0,$ligne['bf_id_fiche']) ;
569
			}
579
			}
570
			$xml .= ']]>'."\n".'</description>'."\n";
580
			$xml .= ']]>'."\n".'</description>'."\n";
571
			$xml .= '<pubDate>'.strftime('%d %b %Y %H:%M:%S GMT',strtotime($ligne['bf_date_debut_validite_fiche'])).'</pubDate>'."\n";
581
			$xml .= '<pubDate>'.strftime('%d %b %Y %H:%M:%S GMT',strtotime($ligne['bf_date_debut_validite_fiche'])).'</pubDate>'."\n";
572
			$xml .= '</item>'."\n";
582
			$xml .= '</item>'."\n";
573
		}
583
		}
574
	}
584
	}
575
	else {//pas d'annonces
585
	else {//pas d'annonces
576
		$xml .= '<item>'."\n";
586
		$xml .= '<item>'."\n";
577
		$xml .= '<title>'.BAZ_PAS_D_ANNONCES.'</title>'."\n";
587
		$xml .= '<title>'.BAZ_PAS_D_ANNONCES.'</title>'."\n";
578
		$xml .= '<link>#</link>'."\n";
588
		$xml .= '<link>#</link>'."\n";
579
		$xml .= '<description>'.BAZ_PAS_D_ANNONCES.'</description>'."\n";
589
		$xml .= '<description>'.BAZ_PAS_D_ANNONCES.'</description>'."\n";
580
		$xml .= '<pubDate>'.strftime('%d %b %Y %H:%M:%S GMT',strtotime('12/12/2004')).'</pubDate>'."\n";
590
		$xml .= '<pubDate>'.strftime('%d %b %Y %H:%M:%S GMT',strtotime('12/12/2004')).'</pubDate>'."\n";
581
		$xml .= '</item>'."\n";
591
		$xml .= '</item>'."\n";
582
	}
592
	}
583
	$xml .= '</channel>'."\n".'</rss>'."\n";
593
	$xml .= '</channel>'."\n".'</rss>'."\n";
584
	return $xml;
594
	return $xml;
585
}
595
}
586
 
596
 
587
 
597
 
588
/** baz_liste() Formate la liste de toutes les annonces actuelles
598
/** baz_liste() Formate la liste de toutes les annonces actuelles
589
*
599
*
590
*   @return  string    le code HTML a afficher
600
*   @return  string    le code HTML a afficher
591
*/
601
*/
592
function baz_liste($typeannonce='toutes') {
602
function baz_liste($typeannonce='toutes') {
593
	//creation du lien pour le formulaire de recherche
603
	//creation du lien pour le formulaire de recherche
594
	$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_VOIR_TOUTES_ANNONCES);
604
	$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_VOIR_TOUTES_ANNONCES);
595
	$lien_formulaire = preg_replace ('/&amp;/', '&', $GLOBALS['_BAZAR_']['url']->getURL()) ;
605
	$lien_formulaire = preg_replace ('/&amp;/', '&', $GLOBALS['_BAZAR_']['url']->getURL()) ;
596
	$formtemplate = new HTML_QuickForm('formulaire', 'post', $lien_formulaire) ;
606
	$formtemplate = new HTML_QuickForm('formulaire', 'post', $lien_formulaire) ;
597
	$squelette = &$formtemplate->defaultRenderer();
607
	$squelette = &$formtemplate->defaultRenderer();
598
	$squelette->setFormTemplate("\n".'<form{attributes}>'."\n".'<ul style="padding:0;margin:0;">'."\n".
608
	$squelette->setFormTemplate("\n".'<form{attributes}>'."\n".'<ul style="padding:0;margin:0;">'."\n".
599
								'{content}'."\n".'</ul>'."\n".'</form>'."\n");
609
								'{content}'."\n".'</ul>'."\n".'</form>'."\n");
600
	$squelette->setElementTemplate( '<li class="enligne">'."\n".'{element}'."\n".'</li>'."\n");
610
	$squelette->setElementTemplate( '<li class="enligne">'."\n".'{element}'."\n".'</li>'."\n");
601
		
611
		
602
	//cas du formulaire de recherche proposant de chercher parmis tous les types d'annonces 
612
	//cas du formulaire de recherche proposant de chercher parmis tous les types d'annonces 
603
	//requete pour obtenir l'id et le label des types d'annonces
613
	//requete pour obtenir l'id et le label des types d'annonces
604
	$requete = 'SELECT bn_id_nature, bn_label_nature '.
614
	$requete = 'SELECT bn_id_nature, bn_label_nature '.
605
	           'FROM bazar_nature WHERE bn_ce_id_menu='.$GLOBALS['_BAZAR_']['filtre'].' '.
615
	           'FROM bazar_nature WHERE bn_ce_id_menu='.$GLOBALS['_BAZAR_']['filtre'].' '.
606
			   'ORDER BY bn_label_nature ASC';
616
			   'ORDER BY bn_label_nature ASC';
607
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
617
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
608
	if (DB::isError($resultat)) {
618
	if (DB::isError($resultat)) {
609
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
619
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
610
	}
620
	}
611
	$type_annonce_select['toutes']=BAZ_TOUS_TYPES_FICHES;
621
	$type_annonce_select['toutes']=BAZ_TOUS_TYPES_FICHES;
612
	while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
622
	while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
613
		$type_annonce_select[$ligne['bn_id_nature']] = $ligne['bn_label_nature'];
623
		$type_annonce_select[$ligne['bn_id_nature']] = $ligne['bn_label_nature'];
614
		$tableau_typeannonces[] = $ligne['bn_id_nature'] ;
624
		$tableau_typeannonces[] = $ligne['bn_id_nature'] ;
615
	}
625
	}
616
	if ($GLOBALS['_BAZAR_']['typeannonce']=='toutes') {
626
	if ($GLOBALS['_BAZAR_']['typeannonce']=='toutes') {
617
		$res= '<h2>'.BAZ_TOUTES_LES_ANNONCES.'</h2><br />'."\n";
627
		$res= '<h2>'.BAZ_TOUTES_LES_ANNONCES.'</h2><br />'."\n";
618
		$option=array('style'=>'border:1px solid #000;width: 140px;font:12px Myriad, Arial, sans-serif;',
628
		$option=array('style'=>'border:1px solid #000;width: 140px;font:12px Myriad, Arial, sans-serif;',
619
						'onchange' => 'javascript:this.form.submit();');
629
						'onchange' => 'javascript:this.form.submit();');
620
		$formtemplate->addElement ('select', 'nature', BAZ_TYPEANNONCE, $type_annonce_select, $option) ;
630
		$formtemplate->addElement ('select', 'nature', BAZ_TYPEANNONCE, $type_annonce_select, $option) ;
621
	}
631
	}
622
	//cas du type d'annonces prédéfini 
632
	//cas du type d'annonces prédéfini 
623
	else {
633
	else {
624
		$res = '<h2>'.BAZ_TOUTES_LES_ANNONCES_DE_TYPE.' '.$GLOBALS['_BAZAR_']['typeannonce'].'</h2>'."\n";
634
		$res = '<h2>'.BAZ_TOUTES_LES_ANNONCES_DE_TYPE.' '.$GLOBALS['_BAZAR_']['typeannonce'].'</h2>'."\n";
625
	}
635
	}
626
 
636
 
627
	
637
	
628
	//requete pour obtenir l'id, le nom et prenom de toutes les personnes ayant depose une fiche
638
	//requete pour obtenir l'id, le nom et prenom de toutes les personnes ayant depose une fiche
629
	// dans le but de construire l'élément de formulaire select avec les noms des émetteurs de fiche
639
	// dans le but de construire l'élément de formulaire select avec les noms des émetteurs de fiche
630
	
640
	
631
	if (BAZ_RECHERCHE_PAR_EMETTEUR) {
641
	if (BAZ_RECHERCHE_PAR_EMETTEUR) {
632
		$requete = 'SELECT '.BAZ_CHAMPS_ID.', '.BAZ_CHAMPS_NOM.', '.BAZ_CHAMPS_PRENOM.' '.
642
		$requete = 'SELECT '.BAZ_CHAMPS_ID.', '.BAZ_CHAMPS_NOM.', '.BAZ_CHAMPS_PRENOM.' '.
633
		           'FROM bazar_fiche,'.BAZ_ANNUAIRE.' where' ;
643
		           'FROM bazar_fiche,'.BAZ_ANNUAIRE.' where' ;
634
	
644
	
635
		$requete .= ' bf_date_debut_validite_fiche<=NOW() AND bf_date_fin_validite_fiche>=NOW() and';	
645
		$requete .= ' bf_date_debut_validite_fiche<=NOW() AND bf_date_fin_validite_fiche>=NOW() and';	
636
	
646
	
637
		$requete .= ' bf_ce_utilisateur='.BAZ_CHAMPS_ID.' ';
647
		$requete .= ' bf_ce_utilisateur='.BAZ_CHAMPS_ID.' ';
638
	    if (!isset($_REQUEST['nature'])) {
648
	    if (!isset($_REQUEST['nature'])) {
639
	    	if (isset($GLOBALS['_BAZAR_']['id_typeannonce'])) {
649
	    	if (isset($GLOBALS['_BAZAR_']['id_typeannonce'])) {
640
	    		$requete .= 'AND bf_ce_nature="'.$GLOBALS['_BAZAR_']['id_typeannonce'].'" ';
650
	    		$requete .= 'AND bf_ce_nature="'.$GLOBALS['_BAZAR_']['id_typeannonce'].'" ';
641
	    	} 
651
	    	} 
642
	    }
652
	    }
643
	    else {
653
	    else {
644
	    	if ($_REQUEST['nature']!='toutes') {
654
	    	if ($_REQUEST['nature']!='toutes') {
645
	    		$requete .= 'AND bf_ce_nature='.$_REQUEST['nature'].' ';
655
	    		$requete .= 'AND bf_ce_nature='.$_REQUEST['nature'].' ';
646
	    	}
656
	    	}
647
	    }
657
	    }
648
	    
658
	    
649
	    $requete .= 'ORDER BY '.BAZ_CHAMPS_NOM.' ASC';
659
	    $requete .= 'ORDER BY '.BAZ_CHAMPS_NOM.' ASC';
650
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
660
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
651
		if (DB::isError($resultat)) {
661
		if (DB::isError($resultat)) {
652
			die ($resultat->getMessage().$resultat->getDebugInfo()) ;
662
			die ($resultat->getMessage().$resultat->getDebugInfo()) ;
653
		}
663
		}
654
		$personnes_select['tous']=BAZ_TOUS_LES_EMETTEURS;
664
		$personnes_select['tous']=BAZ_TOUS_LES_EMETTEURS;
655
		while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
665
		while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
656
			$personnes_select[$ligne[BAZ_CHAMPS_ID]] = $ligne[BAZ_CHAMPS_NOM]." ".$ligne[BAZ_CHAMPS_PRENOM] ;
666
			$personnes_select[$ligne[BAZ_CHAMPS_ID]] = $ligne[BAZ_CHAMPS_NOM]." ".$ligne[BAZ_CHAMPS_PRENOM] ;
657
		}
667
		}
658
		$option=array('style'=>'border:1px solid #000;width: 140px;font:12px Myriad, Arial, sans-serif;');
668
		$option=array('style'=>'border:1px solid #000;width: 140px;font:12px Myriad, Arial, sans-serif;');
659
		$formtemplate->addElement ('select', 'personnes', BAZ_EMETTEUR, $personnes_select, $option) ;
669
		$formtemplate->addElement ('select', 'personnes', BAZ_EMETTEUR, $personnes_select, $option) ;
660
	} else {
670
	} else {
661
		$formtemplate->addElement ('hidden', 'personnes', 'tous') ;
671
		$formtemplate->addElement ('hidden', 'personnes', 'tous') ;
662
	}
672
	}
663
	
673
	
664
		//pour les super-administrateurs, on peut voir les annonces non validées
674
		//pour les super-administrateurs, on peut voir les annonces non validées
665
	//on verifie si l'utilisateur est administrateur
675
	//on verifie si l'utilisateur est administrateur
666
	$utilisateur = new Administrateur_bazar($GLOBALS['AUTH']) ;
676
	$utilisateur = new Administrateur_bazar($GLOBALS['AUTH']) ;
667
 
677
 
668
	if ($utilisateur->isSuperAdmin()) {
678
	if ($utilisateur->isSuperAdmin()) {
669
		$option=array('style'=>'border:1px solid #000;width: 60px;font:12px Myriad, Arial, sans-serif;');
679
		$option=array('style'=>'border:1px solid #000;width: 60px;font:12px Myriad, Arial, sans-serif;');
670
		$valide_select[0] = BAZ_FICHES_PAS_VALIDEES;
680
		$valide_select[0] = BAZ_FICHES_PAS_VALIDEES;
671
		$valide_select[1] = BAZ_FICHES_VALIDEES;
681
		$valide_select[1] = BAZ_FICHES_VALIDEES;
672
		$valide_select[2] = BAZ_LES_DEUX;
682
		$valide_select[2] = BAZ_LES_DEUX;
673
		$formtemplate->addElement ('select', 'valides', BAZ_VALIDE, $valide_select, $option) ; 
683
		$formtemplate->addElement ('select', 'valides', BAZ_VALIDE, $valide_select, $option) ; 
674
		$defauts=array('valides'=>1);
684
		$defauts=array('valides'=>1);
675
		$formtemplate->setDefaults($defauts);
685
		$formtemplate->setDefaults($defauts);
676
	}
686
	}
677
	
687
	
678
	//champs texte pour entrer les mots cles
688
	//champs texte pour entrer les mots cles
679
	$option=array('maxlength'=>60,'style'=>'border:1px solid #000;width:100px;font:12px Myriad, Arial, sans-serif;');
689
	$option=array('maxlength'=>60,'style'=>'border:1px solid #000;width:100px;font:12px Myriad, Arial, sans-serif;');
680
	$formtemplate->addElement('text', 'recherche_mots_cles', BAZ_MOT_CLE, $option) ;
690
	$formtemplate->addElement('text', 'recherche_mots_cles', BAZ_MOT_CLE, $option) ;
681
	$defauts=array('recherche_mots_cles'=>BAZ_MOT_CLE);
691
	$defauts=array('recherche_mots_cles'=>BAZ_MOT_CLE);
682
	$formtemplate->setDefaults($defauts);
692
	$formtemplate->setDefaults($defauts);
683
	
693
	
684
	//option cachee pour savoir si le formulaire a ete appele deja 
694
	//option cachee pour savoir si le formulaire a ete appele deja 
685
	$formtemplate->addElement('hidden', 'recherche_effectuee', 1) ;
695
	$formtemplate->addElement('hidden', 'recherche_effectuee', 1) ;
686
//	
696
//	
687
//	// Ajout des options si un type de fiche a ete choisie
697
//	// Ajout des options si un type de fiche a ete choisie
688
//	if (isset($_POST['nature']) || isset($GLOBALS['_BAZAR_']['categorie_nature'])) {
698
//	if (isset($_POST['nature']) || isset($GLOBALS['_BAZAR_']['categorie_nature'])) {
689
//		if ($GLOBALS['_BAZAR_']['categorie_nature'] != '') {
699
//		if ($GLOBALS['_BAZAR_']['categorie_nature'] != '') {
690
//			$champs_requete = 'bn_ce_id_menu' ;
700
//			$champs_requete = 'bn_ce_id_menu' ;
691
//			$_POST['nature'] = $GLOBALS['_BAZAR_']['categorie_nature'];
701
//			$_POST['nature'] = $GLOBALS['_BAZAR_']['categorie_nature'];
692
//		} else {
702
//		} else {
693
//			$champs_requete = 'bn_id_nature' ;	
703
//			$champs_requete = 'bn_id_nature' ;	
694
//		}
704
//		}
695
//		// Récupération du template
705
//		// Récupération du template
696
//		$requete = 'select bn_template from bazar_nature where '.$champs_requete.'='.$_POST['nature'];
706
//		$requete = 'select bn_template from bazar_nature where '.$champs_requete.'='.$_POST['nature'];
697
//		$resultat = $GLOBALS['_BAZAR_']['db']->getOne($requete) ;
707
//		$resultat = $GLOBALS['_BAZAR_']['db']->getOne($requete) ;
698
//		if (DB::isError($resultat)) {
708
//		if (DB::isError($resultat)) {
699
//			die ($resultat->getMessage().$resultat->getDebugInfo()) ;
709
//			die ($resultat->getMessage().$resultat->getDebugInfo()) ;
700
//		}
710
//		}
701
//		
711
//		
702
//		$tableau = baz_valeurs_template($resultat) ;
712
//		$tableau = baz_valeurs_template($resultat) ;
703
//		
713
//		
704
//		for ($i=0; $i<count($tableau); $i++) {
714
//		for ($i=0; $i<count($tableau); $i++) {
705
//			if (($tableau[$i]['type'] == 'liste' || $tableau[$i]['type'] == 'checkbox') && $tableau[$i]['recherche'] == 1) {
715
//			if (($tableau[$i]['type'] == 'liste' || $tableau[$i]['type'] == 'checkbox') && $tableau[$i]['recherche'] == 1) {
706
//				if ($tableau[$i]['type'] == 'checkbox') {
716
//				if ($tableau[$i]['type'] == 'checkbox') {
707
//					$formtemplate->addElement ('html', '<br />'.$tableau[$i]['label'].'<br />') ;	
717
//					$formtemplate->addElement ('html', '<br />'.$tableau[$i]['label'].'<br />') ;	
708
//				}
718
//				}
709
//				$tableau[$i]['type']($formtemplate, $tableau[$i]['nom_bdd'], $tableau[$i]['label'], $tableau[$i]['limite1'],
719
//				$tableau[$i]['type']($formtemplate, $tableau[$i]['nom_bdd'], $tableau[$i]['label'], $tableau[$i]['limite1'],
710
//		                         $tableau[$i]['limite2'], $tableau[$i]['defaut'], $tableau[$i]['table_source'], $tableau[$i]['obligatoire']) ;
720
//		                         $tableau[$i]['limite2'], $tableau[$i]['defaut'], $tableau[$i]['table_source'], $tableau[$i]['obligatoire']) ;
711
//			}
721
//			}
712
//		 }	
722
//		 }	
713
//	}
723
//	}
714
	//Bouton de validation du formulaire
724
	//Bouton de validation du formulaire
715
	$option=array('style'=>'border:1px solid #000;width:80px;font:12px Myriad, Arial, sans-serif;');
725
	$option=array('style'=>'border:1px solid #000;width:80px;font:12px Myriad, Arial, sans-serif;');
716
	$bouton[] = &HTML_QuickForm::createElement('submit', 'rechercher', BAZ_RECHERCHER, $option);
726
	$bouton[] = &HTML_QuickForm::createElement('submit', 'rechercher', BAZ_RECHERCHER, $option);
717
	$formtemplate->addGroup($bouton, null, null, '');
727
	$formtemplate->addGroup($bouton, null, null, '');
718
	
728
	
719
	//affichage du formulaire
729
	//affichage du formulaire
720
	$res.=$formtemplate->toHTML()."\n";
730
	$res.=$formtemplate->toHTML()."\n";
721
	
731
	
722
	// Ajout de la table bazar_fiche_liste_valeur dans le from de la requete
732
	// Ajout de la table bazar_fiche_liste_valeur dans le from de la requete
723
	$case_coche = false ;
733
	$case_coche = false ;
724
	$requeteFrom = '' ;
734
	$requeteFrom = '' ;
725
	$requeteWhere = '' ;
735
	$requeteWhere = '' ;
726
	$requeteWhereListe = '' ;
736
	$requeteWhereListe = '' ;
727
	
737
	
728
// 	for ($i = 0; $i < count ($tableau); $i++) {
738
// 	for ($i = 0; $i < count ($tableau); $i++) {
729
//		if ($tableau[$i]['type'] == 'checkbox' || $tableau[$i]['type'] == 'liste') {
739
//		if ($tableau[$i]['type'] == 'checkbox' || $tableau[$i]['type'] == 'liste') {
730
//			$nom_liste = $tableau[$i]['type'].$tableau[$i]['nom_bdd'] ;
740
//			$nom_liste = $tableau[$i]['type'].$tableau[$i]['nom_bdd'] ;
731
//			
741
//			
732
//			if (is_array($_POST[$nom_liste])) {
742
//			if (is_array($_POST[$nom_liste])) {
733
//				foreach ($_POST[$nom_liste] as $cle =>$valeur) {
743
//				foreach ($_POST[$nom_liste] as $cle =>$valeur) {
734
//					if ($valeur == 1) {
744
//					if ($valeur == 1) {
735
//						$case_coche = true ;
745
//						$case_coche = true ;
736
//						$requeteWhereListe .= ' AND bfvl_ce_liste='.$tableau[$i]['nom_bdd'] ; // Numéro de la liste
746
//						$requeteWhereListe .= ' AND bfvl_ce_liste='.$tableau[$i]['nom_bdd'] ; // Numéro de la liste
737
//						
747
//						
738
//					}
748
//					}
739
//				}	
749
//				}	
740
//			}
750
//			}
741
//		}
751
//		}
742
//	}
752
//	}
743
//	if ($case_coche) {
753
//	if ($case_coche) {
744
//		$requeteFrom = ', bazar_fiche_valeur_liste ' ;
754
//		$requeteFrom = ', bazar_fiche_valeur_liste ' ;
745
//		$requeteWhereListe .= ' AND bfvl_valeur IN ()' ;
755
//		$requeteWhereListe .= ' AND bfvl_valeur IN ()' ;
746
//		$requeteWhere = ' bfvl_ce_fiche=bf_id_fiche'.$requeteWhereListe;
756
//		$requeteWhere = ' bfvl_ce_fiche=bf_id_fiche'.$requeteWhereListe;
747
//	}
757
//	}
748
//	
758
//	
749
	//affichage des resultats de la recherche si le formulaire a ete envoye
759
	//affichage des resultats de la recherche si le formulaire a ete envoye
750
	$requeteSQL='';
760
	$requeteSQL='';
751
	if (isset($_REQUEST['recherche_effectuee'])) {
761
	if (isset($_REQUEST['recherche_effectuee'])) {
752
		//preparation de la requete pour trouver les mots cles
762
		//preparation de la requete pour trouver les mots cles
753
		if (($_POST['recherche_mots_cles']!='')and($_POST['recherche_mots_cles']!=BAZ_MOT_CLE)) {
763
		if (($_POST['recherche_mots_cles']!='')and($_POST['recherche_mots_cles']!=BAZ_MOT_CLE)) {
754
			//decoupage des mots cles
764
			//decoupage des mots cles
755
			$recherche = split(' ', $_POST['recherche_mots_cles']) ;
765
			$recherche = split(' ', $_POST['recherche_mots_cles']) ;
756
			$nbmots=count($recherche);
766
			$nbmots=count($recherche);
757
			$requeteSQL=''; 
767
			$requeteSQL=''; 
758
			for ($i=0; $i<$nbmots; $i++) {
768
			for ($i=0; $i<$nbmots; $i++) {
759
				if ($i>0) $requeteSQL.=' OR ';
769
				if ($i>0) $requeteSQL.=' OR ';
760
				$requeteSQL.='bf_titre LIKE "%'.$recherche[$i].'%" OR bf_description LIKE "%'.$recherche[$i].'%" ';
770
				$requeteSQL.='bf_titre LIKE "%'.$recherche[$i].'%" OR bf_description LIKE "%'.$recherche[$i].'%" ';
761
			}
771
			}
762
		}
772
		}
763
		if (!isset($_REQUEST['nature'])) {
773
		if (!isset($_REQUEST['nature'])) {
764
			if (!isset ($GLOBALS['_BAZAR_']['id_nature'])) $typedefiches = $tableau_typeannonces;
774
			if (!isset ($GLOBALS['_BAZAR_']['id_nature'])) $typedefiches = $tableau_typeannonces;
765
			else $typedefiches = $GLOBALS['_BAZAR_']['id_nature'] ; 
775
			else $typedefiches = $GLOBALS['_BAZAR_']['id_nature'] ; 
766
		} else {
776
		} else {
767
			$typedefiches = $_REQUEST['nature'] ;
777
			$typedefiches = $_REQUEST['nature'] ;
768
			if ($typedefiches == 'toutes') $typedefiches = $tableau_typeannonces ;
778
			if ($typedefiches == 'toutes') $typedefiches = $tableau_typeannonces ;
769
		}
779
		}
770
		if ($typeannonce!='toutes') $typedefiches=$typeannonce;
780
		if ($typeannonce!='toutes') $typedefiches=$typeannonce;
771
		if (isset($_POST['valides'])) {$valides=$_POST['valides'];}
781
		if (isset($_POST['valides'])) {$valides=$_POST['valides'];}
772
		else {$valides=1;}
782
		else {$valides=1;}
773
		//generation de la liste de flux a afficher
783
		//generation de la liste de flux a afficher
774
		
784
		
775
		$res .= RSSversHTML(gen_RSS($typedefiches, '', $_POST['personnes'], $valides, $requeteSQL, $requeteFrom),
785
		$res .= RSSversHTML(gen_RSS($typedefiches, '', $_POST['personnes'], $valides, $requeteSQL, $requeteFrom),
776
							 0, BAZ_TYPE_AFFICHAGE_LISTE, 1) ;
786
							 0, BAZ_TYPE_AFFICHAGE_LISTE, 1) ;
777
	}
787
	}
778
	else {
788
	else {
779
		//on affiche toutes les annonces
789
		//on affiche toutes les annonces
780
		$res .= '<br /><p class="zone_info">'."\n".BAZ_ENTRER_VOS_CRITERES_DE_RECHERCHE.'</p>'."\n";
790
		$res .= '<br /><p class="zone_info">'."\n".BAZ_ENTRER_VOS_CRITERES_DE_RECHERCHE.'</p>'."\n";
781
		$GLOBALS['_BAZAR_']['url']->removeQueryString('action');
791
		$GLOBALS['_BAZAR_']['url']->removeQueryString('action');
782
		$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_VOIR_FLUX_RSS);
792
		$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_VOIR_FLUX_RSS);
783
		$GLOBALS['_BAZAR_']['url']->addQueryString('annonce', 'toutes');
793
		$GLOBALS['_BAZAR_']['url']->addQueryString('annonce', 'toutes');
784
		$res .= '{{Syndication titre="Les derni&egrave;res fiches enregistrées" url="'.$GLOBALS['_BAZAR_']['url']->getURL().'" nb=10 nouvellefenetre=0 formatdate="'.BAZ_TYPE_AFFICHAGE_LISTE.'"}}';
794
		$res .= '{{Syndication titre="Les derni&egrave;res fiches enregistrées" url="'.$GLOBALS['_BAZAR_']['url']->getURL().'" nb=10 nouvellefenetre=0 formatdate="'.BAZ_TYPE_AFFICHAGE_LISTE.'"}}';
785
	}
795
	}
786
	return $res;
796
	return $res;
787
}
797
}
788
?>
798
?>