Subversion Repositories Applications.bazar

Rev

Rev 221 | Rev 272 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5 florian 1
<?php
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */
3
// +------------------------------------------------------------------------------------------------------+
4
// | PHP version 4.1                                                                                      |
5
// +------------------------------------------------------------------------------------------------------+
6
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
7
// +------------------------------------------------------------------------------------------------------+
8
// | This library is free software; you can redistribute it and/or                                        |
9
// | modify it under the terms of the GNU Lesser General Public                                           |
10
// | License as published by the Free Software Foundation; either                                         |
11
// | version 2.1 of the License, or (at your option) any later version.                                   |
12
// |                                                                                                      |
13
// | This library is distributed in the hope that it will be useful,                                      |
14
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
15
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
16
// | Lesser General Public License for more details.                                                      |
17
// |                                                                                                      |
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                                  |
20
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
21
// +------------------------------------------------------------------------------------------------------+
225 neiluj 22
// CVS : $Id: bazar.php,v 1.40 2007-04-11 08:30:12 neiluj Exp $
5 florian 23
/**
24
*
25
*@package bazar
26
//Auteur original :
27
*@author        Alexandre GRANIER <alexandre@tela-botanica.org>
28
*@author        Florian Schmitt <florian@ecole-et-nature.org>
29
//Autres auteurs :
30
*@copyright     Tela-Botanica 2000-2004
225 neiluj 31
*@version       $Revision: 1.40 $ $Date: 2007-04-11 08:30:12 $
5 florian 32
// +------------------------------------------------------------------------------------------------------+
33
*/
34
 
35
// +------------------------------------------------------------------------------------------------------+
36
// |                                            ENTETE du PROGRAMME                                       |
37
// +------------------------------------------------------------------------------------------------------+
38
 
39
error_reporting(E_ALL);
118 florian 40
require_once PAP_CHEMIN_API_PEAR.'DB.php' ;
41
require_once PAP_CHEMIN_API_PEAR.'Auth.php' ;
54 florian 42
require_once 'configuration/baz_config.inc.php'; //fichier de configuration de Bazar
92 alexandre_ 43
require_once 'bibliotheque/bazar.class.php';
54 florian 44
require_once 'bibliotheque/bazar.fonct.php'; //fichier des fonctions de Bazar
5 florian 45
 
46
if (defined('PAP_VERSION')) { //si on est dans Papyrus
47
	GEN_stockerStyleExterne( 'bazar_interne', 'client/bazar/bazar.interne.css');
48
}
49
 
68 florian 50
//**********************************************************************************************************
225 neiluj 51
//initialisation des paramêtres papyrus
68 florian 52
//**********************************************************************************************************
225 neiluj 53
//si un parametre est précisé dans le gestionnaire de menus papyrus, on le prends en compte
154 florian 54
 
225 neiluj 55
//parametre action pour lancer directement l'action indiquée
64 florian 56
if (!isset($_GET['action'])and(isset($GLOBALS['_GEN_commun']['info_application']->action))) {
57
	$_GET['action']=$GLOBALS['_GEN_commun']['info_application']->action;
58
}
154 florian 59
 
225 neiluj 60
//parametre voir_menu pour afficher le menu ou pas (par défaut, il l'affiche)
64 florian 61
if ((isset($GLOBALS['_GEN_commun']['info_application']->voir_menu))and($GLOBALS['_GEN_commun']['info_application']->voir_menu==0)) {
62
	$GLOBALS['_BAZAR_']['affiche_menu']=0;
63
}
64
else $GLOBALS['_BAZAR_']['affiche_menu']=1;
154 florian 65
 
225 neiluj 66
//parametre categorie_nature pour préciser quels types de fiches sont montrees (par défaut, il affiche les id_menu=0)
64 florian 67
if (isset($GLOBALS['_GEN_commun']['info_application']->categorie_nature)) {
68
	$GLOBALS['_BAZAR_']['categorie_nature']=$GLOBALS['_GEN_commun']['info_application']->categorie_nature;
69
}
126 florian 70
elseif (isset($_REQUEST['categorie_nature'])) {
71
	$GLOBALS['_BAZAR_']['categorie_nature']=$_REQUEST['categorie_nature'];
72
}
64 florian 73
else $GLOBALS['_BAZAR_']['categorie_nature']=0;
154 florian 74
 
64 florian 75
//parametre id_nature pour afficher un certain type de fiche (par défaut, tous les types de fiches)
76
if (isset($GLOBALS['_GEN_commun']['info_application']->id_nature)) {
68 florian 77
	$GLOBALS['_BAZAR_']['id_typeannonce']=$GLOBALS['_GEN_commun']['info_application']->id_nature;
64 florian 78
}
68 florian 79
elseif (!isset($GLOBALS['_BAZAR_']['typeannonce'])) $GLOBALS['_BAZAR_']['typeannonce']='toutes';
64 florian 80
 
68 florian 81
//**********************************************************************************************************
82
//initialisation de la variable globale de bazar
83
//**********************************************************************************************************
84
$GLOBALS['id_user']=$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID);
85
 
86
//Recuperer les eventuelles variables passees en GET ou en POST
84 alexandre_ 87
if (isset($_REQUEST['id_fiche'])) {
88
	$GLOBALS['_BAZAR_']['id_fiche']=$_REQUEST['id_fiche'];
89
	// récupération du type d'annonce à partir de la fiche
90
	$requete = 'select bf_ce_nature from bazar_fiche where bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'] ;
91
	$resultat = $GLOBALS['_BAZAR_']['db']->query ($requete) ;
92
	if (DB::isError($resultat)) {
93
		echo $resultat->getMessage().'<br />'.$resultat->getInfoDebug();
94
	}
95
	$ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT) ;
96
	$GLOBALS['_BAZAR_']['id_typeannonce'] = $ligne->bf_ce_nature ;
97
	$resultat->free();
98
}
68 florian 99
if (isset($_REQUEST['typeannonce'])) {
100
	$GLOBALS['_BAZAR_']['id_typeannonce']=$_REQUEST['typeannonce'];
101
}
102
 
103
if ((isset($GLOBALS['_BAZAR_']['id_typeannonce']))and($GLOBALS['_BAZAR_']['id_typeannonce']!='toutes')) {
185 jp_milcent 104
	$requete = 'SELECT bn_label_nature, bn_condition, bn_template, bn_commentaire, bn_appropriation, bn_image_titre, bn_image_logo FROM bazar_nature WHERE bn_id_nature = '.$GLOBALS['_BAZAR_']['id_typeannonce'];
68 florian 105
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
106
	if (DB::isError($resultat)) {
107
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
108
	}
109
	$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
110
	$GLOBALS['_BAZAR_']['typeannonce']=$ligne['bn_label_nature'];
111
	$GLOBALS['_BAZAR_']['condition']=$ligne['bn_condition'];
112
    $GLOBALS['_BAZAR_']['template']=$ligne['bn_template'];
113
	$GLOBALS['_BAZAR_']['commentaire']=$ligne['bn_commentaire'];
114
	$GLOBALS['_BAZAR_']['appropriation']=$ligne['bn_appropriation'];
115
	$GLOBALS['_BAZAR_']['image_titre']=$ligne['bn_image_titre'];
87 alexandre_ 116
	$GLOBALS['_BAZAR_']['image_logo']=$ligne['bn_image_logo'];
68 florian 117
}
87 alexandre_ 118
if (!isset($GLOBALS['_BAZAR_']['id_typeannonce'])) $GLOBALS['_BAZAR_']['id_typeannonce'] = 'toutes' ;
5 florian 119
// +------------------------------------------------------------------------------------------------------+
120
// |                                           LISTE de FONCTIONS                                         |
121
// +------------------------------------------------------------------------------------------------------+
64 florian 122
if ($GLOBALS['_BAZAR_']['affiche_menu']) {
123
	//---------------le menu de l'appli-----------
124
	function afficherContenuNavigation () {
84 alexandre_ 125
		$res ='<ul id="BAZ_menu">'."\n";
154 florian 126
		//partie consultation d'annonces
64 florian 127
		$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_VOIR_TOUTES_ANNONCES);
154 florian 128
		$res .= '<li id="consulter"';
129
		if (!isset($_GET['action']) || (isset($_GET['action']) && ($_GET['action']==BAZ_VOIR_TOUTES_ANNONCES || $_GET['action']==BAZ_VOIR_FICHE))) $res .=' class="onglet_actif" ';
130
		$res .='><a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'">'.BAZ_CONSULTER.'</a>'."\n".'</li>'."\n";
205 jp_milcent 131
		$GLOBALS['_BAZAR_']['url']->removeQueryString('action');
5 florian 132
 
132 alexandre_ 133
		// Mes fiches
134
		$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_ACTION_VOIR_VOS_ANNONCES);
154 florian 135
		$res .= '<li id="consulter"';
136
		if (isset($_GET['action']) && $_GET['action']==BAZ_ACTION_VOIR_VOS_ANNONCES) $res .=' class="onglet_actif" ';
137
		$res .= '><a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'">'.BAZ_VOIR_VOS_ANNONCES.'</a>'."\n".'</li>'."\n";
205 jp_milcent 138
		$GLOBALS['_BAZAR_']['url']->removeQueryString('action');
132 alexandre_ 139
 
64 florian 140
		//partie abonnement aux annonces
141
		$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_S_INSCRIRE);
154 florian 142
		$res .= '<li id="inscrire"';
143
		if (isset($_GET['action']) && $_GET['action']==BAZ_S_INSCRIRE) $res .=' class="onglet_actif" ';
144
		$res .= '><a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'">'.BAZ_S_ABONNER.'</a></li>'."\n" ;
64 florian 145
		$GLOBALS['_BAZAR_']['url']->removeQueryString('action');
146
 
147
		//partie saisie d'annonces
148
		$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_DEPOSER_ANNONCE);
154 florian 149
		$res .= '<li id="deposer"';
150
		if (isset($_GET['action']) && ($_GET['action']==BAZ_DEPOSER_ANNONCE || $_GET['action']==BAZ_ACTION_NOUVEAU_V || $_GET['action']==BAZ_ACTION_MODIFIER)) $res .=' class="onglet_actif" ';
151
		$res .='><a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'">'.BAZ_SAISIR.'</a>'."\n".'</li>'."\n";
64 florian 152
		$GLOBALS['_BAZAR_']['url']->removeQueryString('action');
153
 
154
		//choix des administrateurs
111 alexandre_ 155
		$utilisateur = new Administrateur_bazar($GLOBALS['AUTH']) ;
64 florian 156
		$est_admin=0;
157
		if ($GLOBALS['AUTH']->getAuth()) {
158
			$requete='SELECT bn_id_nature FROM bazar_nature';
159
			$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
160
			if (DB::isError($resultat)) {
161
				die ($resultat->getMessage().$resultat->getDebugInfo()) ;
162
			}
163
			while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
92 alexandre_ 164
				if ($utilisateur->isAdmin ($ligne['bn_id_nature'])) {
64 florian 165
					$est_admin=1;
166
			    }
167
			}
92 alexandre_ 168
			if ($est_admin || $utilisateur->isSuperAdmin()) {
64 florian 169
				//partie administrer
170
				$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_ANNONCES_A_VALIDER);
154 florian 171
				$res .= '<li id="administrer"';
172
				if (isset($_GET['action']) && $_GET['action']==BAZ_ANNONCES_A_VALIDER) $res .=' class="onglet_actif" ';
173
				$res .='><a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'">'.BAZ_ADMINISTRER.'</a></li>'."\n";
64 florian 174
				$GLOBALS['_BAZAR_']['url']->removeQueryString('action');
175
 
92 alexandre_ 176
				if ($utilisateur->isSuperAdmin()) {
64 florian 177
					$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_GERER_DROITS);
154 florian 178
					$res .= '<li id="gerer"';
179
					if (isset($_GET['action']) && $_GET['action']==BAZ_GERER_DROITS) $res .=' class="onglet_actif" ';
180
					$res .='><a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'">'.BAZ_GESTION_DES_DROITS.'</a></li>'."\n" ;
64 florian 181
					$GLOBALS['_BAZAR_']['url']->removeQueryString('action');
182
				}
183
			}
184
		}
185
		$res.= '</ul>'."\n";
186
	    return $res ;
187
	}
188
}
189
 
190
function afficherContenuCorps() {
5 florian 191
	$res = '';
145 alexandre_ 192
	$res.='<h1 id="titre_bazar">'.$GLOBALS['_GEN_commun']['info_menu']->gm_titre.'</h1>'."\n";
45 florian 193
 
5 florian 194
	if (isset($_GET['action'])) {
68 florian 195
		if (($_GET['action']!=BAZ_ACTION_NOUVEAU_V)and($_GET['action']!=BAZ_ACTION_MODIFIER_V)) unset($_SESSION['formulaire_annonce_valide']);
5 florian 196
		switch ($_GET['action']) {
133 alexandre_ 197
			case BAZ_ACTION_VOIR_VOS_ANNONCES : $res .= mes_fiches(); break;
87 alexandre_ 198
			case BAZ_VOIR_TOUTES_ANNONCES : $res .= baz_liste($GLOBALS['_BAZAR_']['id_typeannonce']); break;
5 florian 199
			case BAZ_DEPOSER_ANNONCE : $res .= baz_formulaire(BAZ_DEPOSER_ANNONCE); break;
154 florian 200
			case BAZ_ANNONCES_A_VALIDER : $res .= fiches_a_valider(); break;
5 florian 201
			case BAZ_ADMINISTRER_ANNONCES : $res .= baz_administrer_annonces(); break;
202
			case BAZ_MODIFIER_FICHE : $res .= baz_formulaire(BAZ_ACTION_MODIFIER); break;
203
			case BAZ_SUPPRIMER_FICHE : $res .= baz_suppression().baz_liste('',$GLOBALS['id_user'],''); break;
204
			case BAZ_VOIR_FICHE : $res .= baz_voir_fiche(1); break;
205
			case BAZ_ACTION_NOUVEAU : $res .= baz_formulaire(BAZ_ACTION_NOUVEAU); break;
90 alexandre_ 206
			case BAZ_ACTION_NOUVEAU_V : $res .= baz_formulaire(BAZ_ACTION_NOUVEAU_V).mes_fiches(); break;
5 florian 207
			case BAZ_ACTION_MODIFIER : $res .= baz_formulaire(BAZ_ACTION_MODIFIER); break;
225 neiluj 208
			case BAZ_ACTION_MODIFIER_V : $res .= baz_formulaire(BAZ_ACTION_MODIFIER_V).mes_fiches(); break;
209
			case BAZ_ACTION_SUPPRESSION : $res .= baz_suppression().mes_fiches(); break;
5 florian 210
			case BAZ_ACTION_PUBLIER : publier_fiche(1) ;$res .= fiches_a_valider(); break;
211
			case BAZ_ACTION_PAS_PUBLIER : publier_fiche(0) ;$res .= fiches_a_valider(); break;
68 florian 212
			case BAZ_GERER_DROITS : $res .= baz_gestion_droits(); break;
5 florian 213
			case BAZ_S_INSCRIRE : $res .= baz_s_inscrire(); break;
225 neiluj 214
			case BAZ_VOIR_FLUX_RSS : header('Content-type: text/xml; charset=ISO-8859-1');include("bazarRSS.php");exit(0);break;
118 florian 215
			default : $res .= baz_liste($GLOBALS['_BAZAR_']['id_typeannonce']) ;
5 florian 216
		}
217
	}
218
	else {
118 florian 219
		$res .= baz_liste($GLOBALS['_BAZAR_']['id_typeannonce']);
5 florian 220
	}
221
	return $res ;
222
}
223
 
224
 
225
/* +--Fin du code ----------------------------------------------------------------------------------------+
226
*
10 ddelon 227
* $Log: not supported by cvs2svn $
225 neiluj 228
* Revision 1.35.2.2  2007/03/07 16:53:17  jp_milcent
229
* Suppression du query string "action" et non pas "nature"
221 florian 230
*
185 jp_milcent 231
* Revision 1.35.2.1  2007/02/15 13:42:16  jp_milcent
232
* Utilisation de IN à la place du = dans les requêtes traitant les catégories de fiches.
233
* Permet d'utiliser la syntaxe 1,2,3 dans la configuration de categorie_nature.
234
*
235
* Revision 1.35  2006/10/05 08:53:50  florian
236
* amelioration moteur de recherche, correction de bugs
237
*
154 florian 238
* Revision 1.34  2006/09/04 15:25:12  alexandre_tb
239
* ajout d'un id dans la balise HTML du titre
240
*
145 alexandre_ 241
* Revision 1.33  2006/06/21 15:41:42  alexandre_tb
242
* rétablissement du menu mes fiches
243
*
133 alexandre_ 244
* Revision 1.32  2006/06/21 15:40:15  alexandre_tb
245
* rétablissement du menu mes fiches
246
*
132 alexandre_ 247
* Revision 1.31  2006/05/19 13:54:32  florian
248
* stabilisation du moteur de recherche, corrections bugs, lien recherche avancee
249
*
126 florian 250
* Revision 1.30  2006/04/28 12:46:14  florian
251
* integration des liens vers annuaire
252
*
118 florian 253
* Revision 1.29  2006/04/24 10:16:22  alexandre_tb
254
* ajout de la globale filtre.
255
* elle remplace (à terme) catégorie nature
256
*
117 alexandre_ 257
* Revision 1.28  2006/03/29 13:05:41  alexandre_tb
258
* utilisation de la classe Administrateur_bazar
259
*
111 alexandre_ 260
* Revision 1.27  2006/02/07 11:08:36  alexandre_tb
261
* utilisation de la classe Utilisateur_bazar pour la vérification des droits
262
*
92 alexandre_ 263
* Revision 1.26  2006/02/06 09:33:53  alexandre_tb
264
* modification de l'affichage lors de la saisie de fiche
265
*
90 alexandre_ 266
* Revision 1.25  2006/01/30 17:25:38  alexandre_tb
267
* correction de bugs
268
*
87 alexandre_ 269
* Revision 1.24  2006/01/26 11:06:43  alexandre_tb
270
* ajout d'une requete pour recupere l'id_nature si un id_fiche est passé dans l'url
271
*
84 alexandre_ 272
* Revision 1.23  2006/01/17 10:07:36  alexandre_tb
273
* en cours
274
*
72 alexandre_ 275
* Revision 1.22  2006/01/16 15:11:28  alexandre_tb
276
* simplification code
277
*
71 alexandre_ 278
* Revision 1.21  2006/01/13 14:12:52  florian
279
* utilisation des temlates dans la table bazar_nature
280
*
68 florian 281
* Revision 1.20  2006/01/05 16:28:25  alexandre_tb
282
* prise en chage des checkbox, reste la mise à jour à gérer
283
*
67 alexandre_ 284
* Revision 1.19  2006/01/03 10:19:31  florian
285
* Mise à jour pour accepter des parametres dans papyrus: faire apparaitre ou non le menu, afficher qu'un type de fiches, définir l'action par défaut...
286
*
64 florian 287
* Revision 1.18  2005/12/02 10:57:03  florian
288
* MAJ pour paramétrage dans gestion de menus papyrus
289
*
59 florian 290
* Revision 1.17  2005/12/01 16:05:41  florian
291
* changement des chemins pour appli Pear
292
*
57 florian 293
* Revision 1.16  2005/12/01 15:31:30  florian
294
* correction bug modifs et saisies
295
*
56 florian 296
* Revision 1.15  2005/11/30 13:58:45  florian
297
* ajouts graphisme (logos, boutons), changement structure SQL bazar_fiche
298
*
55 florian 299
* Revision 1.14  2005/11/24 16:17:13  florian
300
* corrections bugs, ajout des cases à cocher
301
*
54 florian 302
* Revision 1.13  2005/11/14 16:04:54  florian
303
* maj bug affichage flux
304
*
51 florian 305
* Revision 1.12  2005/11/07 17:05:46  florian
306
* amélioration validation conditions de saisie, ajout des règles spécifiques de saisie des formulaires
307
*
45 florian 308
* Revision 1.11  2005/10/21 16:15:04  florian
309
* mise a jour appropriation
310
*
39 florian 311
* Revision 1.10  2005/10/12 17:20:33  ddelon
312
* Reorganisation calendrier + applette
313
*
30 ddelon 314
* Revision 1.9  2005/10/12 13:35:07  florian
315
* amélioration de l'interface de bazar, de manière a simplifier les consultations, et à harmoniser par rapport aux Ressources
316
*
22 florian 317
* Revision 1.8  2005/09/30 13:00:05  ddelon
318
* Fiche bazar generique
319
*
11 ddelon 320
* Revision 1.7  2005/09/30 12:34:44  ddelon
321
* petite modification pour integration bazar dans papyrus
322
*
10 ddelon 323
* Revision 1.6  2005/09/30 12:22:54  florian
324
* Ajouts commentaires pour fiche, modifications graphiques, maj SQL
325
*
7 florian 326
* Revision 1.4  2005/07/21 19:03:12  florian
327
* nouveautés bazar: templates fiches, correction de bugs, ...
328
*
5 florian 329
* Revision 1.2  2005/02/22 15:33:32  florian
330
* integration dans Papyrus
331
*
332
* Revision 1.1.1.1  2005/02/17 18:05:11  florian
333
* Import initial de Bazar
334
*
335
* Revision 1.1.1.1  2005/02/17 11:09:50  florian
336
* Import initial
337
*
338
* Revision 1.1.1.1  2005/02/16 18:06:35  florian
339
* import de la nouvelle version
340
*
341
* Revision 1.3  2004/07/05 15:10:14  florian
342
* changement interface de saisie
343
*
344
* Revision 1.2  2004/07/01 10:13:41  florian
345
* modif Florian
346
*
347
* Revision 1.1  2004/06/23 09:58:32  alex
348
* version initiale
349
*
350
* Revision 1.1  2004/06/18 09:00:07  alex
351
* version initiale
352
*
353
*
354
* +-- Fin du code ----------------------------------------------------------------------------------------+
355
*/
356
?>