Subversion Repositories Applications.bazar

Rev

Rev 84 | Rev 90 | 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
// +------------------------------------------------------------------------------------------------------+
87 alexandre_ 22
// CVS : $Id: bazar.php,v 1.25 2006-01-30 17:25:38 alexandre_tb 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
87 alexandre_ 31
*@version       $Revision: 1.25 $ $Date: 2006-01-30 17:25:38 $
5 florian 32
// +------------------------------------------------------------------------------------------------------+
33
*/
34
 
35
// +------------------------------------------------------------------------------------------------------+
36
// |                             LES CONSTANTES DES ACTIONS DE BAZAR                                      |
37
// +------------------------------------------------------------------------------------------------------+
38
 
39
define ('BAZ_VOIR_TOUTES_ANNONCES', 1) ;
40
define ('BAZ_DEPOSER_ANNONCE', 3) ;
41
define ('BAZ_ANNONCES_A_VALIDER', 4) ;
42
define ('BAZ_GERER_DROITS', 5) ;
43
define ('BAZ_ADMINISTRER_ANNONCES', 6) ;
44
define ('BAZ_MODIFIER_FICHE', 7) ;
30 ddelon 45
if (!defined('BAZ_VOIR_FICHE')) define ('BAZ_VOIR_FICHE', 8) ;
5 florian 46
define ('BAZ_SUPPRIMER_FICHE', 9) ;
47
define ('BAZ_ACTION_NOUVEAU', 10) ;
48
define ('BAZ_ACTION_NOUVEAU_V', 11) ;
49
define ('BAZ_ACTION_MODIFIER', 12) ;
50
define ('BAZ_ACTION_MODIFIER_V', 13) ;
51
define ('BAZ_ACTION_SUPPRESSION', 14) ;
52
define ('BAZ_ACTION_PUBLIER', 15) ;
53
define ('BAZ_ACTION_PAS_PUBLIER', 16) ;
54
define ('BAZ_S_INSCRIRE', 17);
55
define ('BAZ_VOIR_FLUX_RSS', 18);
56
 
57
 
58
// +------------------------------------------------------------------------------------------------------+
59
// |                                            ENTETE du PROGRAMME                                       |
60
// +------------------------------------------------------------------------------------------------------+
61
 
62
error_reporting(E_ALL);
57 florian 63
require_once 'DB.php' ;
64
require_once 'Auth.php' ;
54 florian 65
require_once 'configuration/baz_config.inc.php'; //fichier de configuration de Bazar
66
require_once 'bibliotheque/bazar.fonct.php'; //fichier des fonctions de Bazar
5 florian 67
 
68
if (defined('PAP_VERSION')) { //si on est dans Papyrus
69
	GEN_stockerStyleExterne( 'bazar_interne', 'client/bazar/bazar.interne.css');
70
}
71
 
68 florian 72
//**********************************************************************************************************
73
//initialisation des paramêtres papyrus
74
//**********************************************************************************************************
64 florian 75
//si un parametre est précisé dans le gestionnaire de menus papyrus, on le prends en compte
76
//parametre action pour lancer directement l'action indiquée
77
if (!isset($_GET['action'])and(isset($GLOBALS['_GEN_commun']['info_application']->action))) {
78
	$_GET['action']=$GLOBALS['_GEN_commun']['info_application']->action;
79
}
80
//parametre voir_menu pour afficher le menu ou pas (par défaut, il l'affiche)
81
if ((isset($GLOBALS['_GEN_commun']['info_application']->voir_menu))and($GLOBALS['_GEN_commun']['info_application']->voir_menu==0)) {
82
	$GLOBALS['_BAZAR_']['affiche_menu']=0;
83
}
84
else $GLOBALS['_BAZAR_']['affiche_menu']=1;
85
//parametre categorie_nature pour préciser quels types de fiches sont montrees (par défaut, il affiche les id_menu=0)
86
if (isset($GLOBALS['_GEN_commun']['info_application']->categorie_nature)) {
87
	$GLOBALS['_BAZAR_']['categorie_nature']=$GLOBALS['_GEN_commun']['info_application']->categorie_nature;
88
}
89
else $GLOBALS['_BAZAR_']['categorie_nature']=0;
90
//parametre id_nature pour afficher un certain type de fiche (par défaut, tous les types de fiches)
91
if (isset($GLOBALS['_GEN_commun']['info_application']->id_nature)) {
68 florian 92
	$GLOBALS['_BAZAR_']['id_typeannonce']=$GLOBALS['_GEN_commun']['info_application']->id_nature;
64 florian 93
}
68 florian 94
elseif (!isset($GLOBALS['_BAZAR_']['typeannonce'])) $GLOBALS['_BAZAR_']['typeannonce']='toutes';
64 florian 95
 
68 florian 96
//**********************************************************************************************************
97
//initialisation de la variable globale de bazar
98
//**********************************************************************************************************
99
$GLOBALS['id_user']=$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID);
100
 
101
//Recuperer les eventuelles variables passees en GET ou en POST
84 alexandre_ 102
if (isset($_REQUEST['id_fiche'])) {
103
	$GLOBALS['_BAZAR_']['id_fiche']=$_REQUEST['id_fiche'];
104
	// récupération du type d'annonce à partir de la fiche
105
	$requete = 'select bf_ce_nature from bazar_fiche where bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'] ;
106
	$resultat = $GLOBALS['_BAZAR_']['db']->query ($requete) ;
107
	if (DB::isError($resultat)) {
108
		echo $resultat->getMessage().'<br />'.$resultat->getInfoDebug();
109
	}
110
	$ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT) ;
111
	$GLOBALS['_BAZAR_']['id_typeannonce'] = $ligne->bf_ce_nature ;
112
	$resultat->free();
113
}
68 florian 114
if (isset($_REQUEST['typeannonce'])) {
115
	$GLOBALS['_BAZAR_']['id_typeannonce']=$_REQUEST['typeannonce'];
116
}
117
 
118
if ((isset($GLOBALS['_BAZAR_']['id_typeannonce']))and($GLOBALS['_BAZAR_']['id_typeannonce']!='toutes')) {
119
	$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'];
120
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
121
	if (DB::isError($resultat)) {
122
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
123
	}
124
	$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
125
	$GLOBALS['_BAZAR_']['typeannonce']=$ligne['bn_label_nature'];
126
	$GLOBALS['_BAZAR_']['condition']=$ligne['bn_condition'];
127
    $GLOBALS['_BAZAR_']['template']=$ligne['bn_template'];
128
	$GLOBALS['_BAZAR_']['commentaire']=$ligne['bn_commentaire'];
129
	$GLOBALS['_BAZAR_']['appropriation']=$ligne['bn_appropriation'];
130
	$GLOBALS['_BAZAR_']['image_titre']=$ligne['bn_image_titre'];
87 alexandre_ 131
	$GLOBALS['_BAZAR_']['image_logo']=$ligne['bn_image_logo'];
68 florian 132
}
87 alexandre_ 133
if (!isset($GLOBALS['_BAZAR_']['id_typeannonce'])) $GLOBALS['_BAZAR_']['id_typeannonce'] = 'toutes' ;
5 florian 134
// +------------------------------------------------------------------------------------------------------+
135
// |                                           LISTE de FONCTIONS                                         |
136
// +------------------------------------------------------------------------------------------------------+
64 florian 137
if ($GLOBALS['_BAZAR_']['affiche_menu']) {
138
	//---------------le menu de l'appli-----------
139
	function afficherContenuNavigation () {
84 alexandre_ 140
		$res ='<ul id="BAZ_menu">'."\n";
64 florian 141
		$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_VOIR_TOUTES_ANNONCES);
142
		$GLOBALS['_BAZAR_']['url']->addQueryString('nature', 'toutes');
143
		//partie consultation d'annonces
144
		$res .= '<li><a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'">'.BAZ_CONSULTER.'</a>'."\n".'</li>'."\n";
145
		$GLOBALS['_BAZAR_']['url']->removeQueryString('nature');
5 florian 146
 
64 florian 147
		//partie abonnement aux annonces
148
		$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_S_INSCRIRE);
149
		$res .= '<li><a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'">'.BAZ_S_ABONNER.'</a></li>'."\n" ;
150
		$GLOBALS['_BAZAR_']['url']->removeQueryString('action');
151
 
152
		//partie saisie d'annonces
153
		$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_DEPOSER_ANNONCE);
154
		$res .= '<li><a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'">'.BAZ_SAISIR.'</a>'."\n".'</li>'."\n";
155
		$GLOBALS['_BAZAR_']['url']->removeQueryString('action');
156
 
157
		//choix des administrateurs
158
		$est_admin=0;
159
		if ($GLOBALS['AUTH']->getAuth()) {
160
			$requete='SELECT bn_id_nature FROM bazar_nature';
161
			$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
162
			if (DB::isError($resultat)) {
163
				die ($resultat->getMessage().$resultat->getDebugInfo()) ;
164
			}
165
			while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
166
				if ((niveau_droit($ligne['bn_id_nature'],$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID)))=='administrateur') {
167
					$est_admin=1;
168
			    }
169
			}
170
			if (($est_admin)or(niveau_droit($id_nature_offre='0',$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID))=='superadministrateur')) {
171
				//partie administrer
172
				$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_ANNONCES_A_VALIDER);
173
				$res .= '<li><a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'">'.BAZ_ADMINISTRER.'</a></li>'."\n";
174
				$GLOBALS['_BAZAR_']['url']->removeQueryString('action');
175
 
176
				if (niveau_droit($id_nature_offre='0',$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID))=='superadministrateur') {
177
					$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_GERER_DROITS);
178
					$res .= '<li><a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'">'.BAZ_GESTION_DES_DROITS.'</a></li>'."\n" ;
179
					$GLOBALS['_BAZAR_']['url']->removeQueryString('action');
180
				}
181
			}
182
		}
183
		$res.= '</ul>'."\n";
184
	    return $res ;
185
	}
186
}
187
 
188
function afficherContenuCorps() {
5 florian 189
	$res = '';
7 florian 190
	$res.='<h1>'.$GLOBALS['_GEN_commun']['info_menu']->gm_titre.'</h1>'."\n";
45 florian 191
 
5 florian 192
	if (isset($_GET['action'])) {
68 florian 193
		if (($_GET['action']!=BAZ_ACTION_NOUVEAU_V)and($_GET['action']!=BAZ_ACTION_MODIFIER_V)) unset($_SESSION['formulaire_annonce_valide']);
5 florian 194
		switch ($_GET['action']) {
195
			case BAZ_VOIR_VOS_ANNONCES : $res .= mes_fiches(); break;
87 alexandre_ 196
			case BAZ_VOIR_TOUTES_ANNONCES : $res .= baz_liste($GLOBALS['_BAZAR_']['id_typeannonce']); break;
5 florian 197
			case BAZ_DEPOSER_ANNONCE : $res .= baz_formulaire(BAZ_DEPOSER_ANNONCE); break;
72 alexandre_ 198
			case BAZ_ANNONCES_A_VALIDER : $res .= fiches_a_valider().baz_liste(); break;
5 florian 199
			case BAZ_ADMINISTRER_ANNONCES : $res .= baz_administrer_annonces(); break;
200
			case BAZ_MODIFIER_FICHE : $res .= baz_formulaire(BAZ_ACTION_MODIFIER); break;
201
			case BAZ_SUPPRIMER_FICHE : $res .= baz_suppression().baz_liste('',$GLOBALS['id_user'],''); break;
202
			case BAZ_VOIR_FICHE : $res .= baz_voir_fiche(1); break;
203
			case BAZ_ACTION_NOUVEAU : $res .= baz_formulaire(BAZ_ACTION_NOUVEAU); break;
68 florian 204
			case BAZ_ACTION_NOUVEAU_V : $res .= baz_formulaire(BAZ_ACTION_NOUVEAU_V).baz_formulaire(BAZ_DEPOSER_ANNONCE); break;
5 florian 205
			case BAZ_ACTION_MODIFIER : $res .= baz_formulaire(BAZ_ACTION_MODIFIER); break;
68 florian 206
			case BAZ_ACTION_MODIFIER_V : $res .= baz_formulaire(BAZ_ACTION_MODIFIER_V).baz_formulaire(BAZ_DEPOSER_ANNONCE); break;
207
			case BAZ_ACTION_SUPPRESSION : $res .= baz_suppression().baz_formulaire(BAZ_DEPOSER_ANNONCE); break;
5 florian 208
			case BAZ_ACTION_PUBLIER : publier_fiche(1) ;$res .= fiches_a_valider(); break;
209
			case BAZ_ACTION_PAS_PUBLIER : publier_fiche(0) ;$res .= fiches_a_valider(); break;
68 florian 210
			case BAZ_GERER_DROITS : $res .= baz_gestion_droits(); break;
5 florian 211
			case BAZ_S_INSCRIRE : $res .= baz_s_inscrire(); break;
212
			case BAZ_VOIR_FLUX_RSS : header('Content-type: text/xml; charset=ISO-8859-1');include("bazarRSS.php");exit(0);break;
213
			default : $res .= accueil() ;
214
		}
215
	}
216
	else {
71 alexandre_ 217
		$res .= baz_liste();
5 florian 218
	}
219
	return $res ;
220
}
221
 
222
 
223
/* +--Fin du code ----------------------------------------------------------------------------------------+
224
*
10 ddelon 225
* $Log: not supported by cvs2svn $
87 alexandre_ 226
* Revision 1.24  2006/01/26 11:06:43  alexandre_tb
227
* ajout d'une requete pour recupere l'id_nature si un id_fiche est passé dans l'url
228
*
84 alexandre_ 229
* Revision 1.23  2006/01/17 10:07:36  alexandre_tb
230
* en cours
231
*
72 alexandre_ 232
* Revision 1.22  2006/01/16 15:11:28  alexandre_tb
233
* simplification code
234
*
71 alexandre_ 235
* Revision 1.21  2006/01/13 14:12:52  florian
236
* utilisation des temlates dans la table bazar_nature
237
*
68 florian 238
* Revision 1.20  2006/01/05 16:28:25  alexandre_tb
239
* prise en chage des checkbox, reste la mise à jour à gérer
240
*
67 alexandre_ 241
* Revision 1.19  2006/01/03 10:19:31  florian
242
* 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...
243
*
64 florian 244
* Revision 1.18  2005/12/02 10:57:03  florian
245
* MAJ pour paramétrage dans gestion de menus papyrus
246
*
59 florian 247
* Revision 1.17  2005/12/01 16:05:41  florian
248
* changement des chemins pour appli Pear
249
*
57 florian 250
* Revision 1.16  2005/12/01 15:31:30  florian
251
* correction bug modifs et saisies
252
*
56 florian 253
* Revision 1.15  2005/11/30 13:58:45  florian
254
* ajouts graphisme (logos, boutons), changement structure SQL bazar_fiche
255
*
55 florian 256
* Revision 1.14  2005/11/24 16:17:13  florian
257
* corrections bugs, ajout des cases à cocher
258
*
54 florian 259
* Revision 1.13  2005/11/14 16:04:54  florian
260
* maj bug affichage flux
261
*
51 florian 262
* Revision 1.12  2005/11/07 17:05:46  florian
263
* amélioration validation conditions de saisie, ajout des règles spécifiques de saisie des formulaires
264
*
45 florian 265
* Revision 1.11  2005/10/21 16:15:04  florian
266
* mise a jour appropriation
267
*
39 florian 268
* Revision 1.10  2005/10/12 17:20:33  ddelon
269
* Reorganisation calendrier + applette
270
*
30 ddelon 271
* Revision 1.9  2005/10/12 13:35:07  florian
272
* amélioration de l'interface de bazar, de manière a simplifier les consultations, et à harmoniser par rapport aux Ressources
273
*
22 florian 274
* Revision 1.8  2005/09/30 13:00:05  ddelon
275
* Fiche bazar generique
276
*
11 ddelon 277
* Revision 1.7  2005/09/30 12:34:44  ddelon
278
* petite modification pour integration bazar dans papyrus
279
*
10 ddelon 280
* Revision 1.6  2005/09/30 12:22:54  florian
281
* Ajouts commentaires pour fiche, modifications graphiques, maj SQL
282
*
7 florian 283
* Revision 1.4  2005/07/21 19:03:12  florian
284
* nouveautés bazar: templates fiches, correction de bugs, ...
285
*
5 florian 286
* Revision 1.2  2005/02/22 15:33:32  florian
287
* integration dans Papyrus
288
*
289
* Revision 1.1.1.1  2005/02/17 18:05:11  florian
290
* Import initial de Bazar
291
*
292
* Revision 1.1.1.1  2005/02/17 11:09:50  florian
293
* Import initial
294
*
295
* Revision 1.1.1.1  2005/02/16 18:06:35  florian
296
* import de la nouvelle version
297
*
298
* Revision 1.3  2004/07/05 15:10:14  florian
299
* changement interface de saisie
300
*
301
* Revision 1.2  2004/07/01 10:13:41  florian
302
* modif Florian
303
*
304
* Revision 1.1  2004/06/23 09:58:32  alex
305
* version initiale
306
*
307
* Revision 1.1  2004/06/18 09:00:07  alex
308
* version initiale
309
*
310
*
311
* +-- Fin du code ----------------------------------------------------------------------------------------+
312
*/
313
?>