Subversion Repositories Applications.bazar

Rev

Rev 68 | Rev 72 | 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
// +------------------------------------------------------------------------------------------------------+
71 alexandre_ 22
// CVS : $Id: bazar.php,v 1.22 2006-01-16 15:11:28 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
71 alexandre_ 31
*@version       $Revision: 1.22 $ $Date: 2006-01-16 15:11:28 $
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
102
if (isset($_REQUEST['id_fiche'])) $GLOBALS['_BAZAR_']['id_fiche']=$_REQUEST['id_fiche'];
103
if (isset($_REQUEST['typeannonce'])) {
104
	$GLOBALS['_BAZAR_']['id_typeannonce']=$_REQUEST['typeannonce'];
105
}
106
 
107
if ((isset($GLOBALS['_BAZAR_']['id_typeannonce']))and($GLOBALS['_BAZAR_']['id_typeannonce']!='toutes')) {
108
	$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'];
109
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
110
	if (DB::isError($resultat)) {
111
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
112
	}
113
	$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
114
	$GLOBALS['_BAZAR_']['typeannonce']=$ligne['bn_label_nature'];
115
	$GLOBALS['_BAZAR_']['condition']=$ligne['bn_condition'];
116
    $GLOBALS['_BAZAR_']['template']=$ligne['bn_template'];
117
	$GLOBALS['_BAZAR_']['commentaire']=$ligne['bn_commentaire'];
118
	$GLOBALS['_BAZAR_']['appropriation']=$ligne['bn_appropriation'];
119
	$GLOBALS['_BAZAR_']['nb_consultations']=$ligne['bf_nb_consultations'];
120
	$GLOBALS['_BAZAR_']['image_titre']=$ligne['bn_image_titre'];
121
	$GLOBALS['_BAZAR_']['image_logo']=$ligne['bn_image_logo'];
122
}
123
 
5 florian 124
// +------------------------------------------------------------------------------------------------------+
125
// |                                           LISTE de FONCTIONS                                         |
126
// +------------------------------------------------------------------------------------------------------+
64 florian 127
if ($GLOBALS['_BAZAR_']['affiche_menu']) {
128
	//---------------le menu de l'appli-----------
129
	function afficherContenuNavigation () {
67 alexandre_ 130
		$res ='<ul>'."\n";
64 florian 131
		$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_VOIR_TOUTES_ANNONCES);
132
		$GLOBALS['_BAZAR_']['url']->addQueryString('nature', 'toutes');
133
		//partie consultation d'annonces
134
		$res .= '<li><a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'">'.BAZ_CONSULTER.'</a>'."\n".'</li>'."\n";
135
		$GLOBALS['_BAZAR_']['url']->removeQueryString('nature');
5 florian 136
 
64 florian 137
		//partie abonnement aux annonces
138
		$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_S_INSCRIRE);
139
		$res .= '<li><a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'">'.BAZ_S_ABONNER.'</a></li>'."\n" ;
140
		$GLOBALS['_BAZAR_']['url']->removeQueryString('action');
141
 
142
		//partie saisie d'annonces
143
		$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_DEPOSER_ANNONCE);
144
		$res .= '<li><a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'">'.BAZ_SAISIR.'</a>'."\n".'</li>'."\n";
145
		$GLOBALS['_BAZAR_']['url']->removeQueryString('action');
146
 
147
		//choix des administrateurs
148
		$est_admin=0;
149
		if ($GLOBALS['AUTH']->getAuth()) {
150
			$requete='SELECT bn_id_nature FROM bazar_nature';
151
			$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
152
			if (DB::isError($resultat)) {
153
				die ($resultat->getMessage().$resultat->getDebugInfo()) ;
154
			}
155
			while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
156
				if ((niveau_droit($ligne['bn_id_nature'],$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID)))=='administrateur') {
157
					$est_admin=1;
158
			    }
159
			}
160
			if (($est_admin)or(niveau_droit($id_nature_offre='0',$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID))=='superadministrateur')) {
161
				//partie administrer
162
				$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_ANNONCES_A_VALIDER);
163
				$res .= '<li><a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'">'.BAZ_ADMINISTRER.'</a></li>'."\n";
164
				$GLOBALS['_BAZAR_']['url']->removeQueryString('action');
165
 
166
				if (niveau_droit($id_nature_offre='0',$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID))=='superadministrateur') {
167
					$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_GERER_DROITS);
168
					$res .= '<li><a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'">'.BAZ_GESTION_DES_DROITS.'</a></li>'."\n" ;
169
					$GLOBALS['_BAZAR_']['url']->removeQueryString('action');
170
				}
171
			}
172
		}
173
		$res.= '</ul>'."\n";
174
	    return $res ;
175
	}
176
}
177
 
178
function afficherContenuCorps() {
5 florian 179
	$res = '';
7 florian 180
	$res.='<h1>'.$GLOBALS['_GEN_commun']['info_menu']->gm_titre.'</h1>'."\n";
45 florian 181
 
5 florian 182
	if (isset($_GET['action'])) {
68 florian 183
		if (($_GET['action']!=BAZ_ACTION_NOUVEAU_V)and($_GET['action']!=BAZ_ACTION_MODIFIER_V)) unset($_SESSION['formulaire_annonce_valide']);
5 florian 184
		switch ($_GET['action']) {
185
			case BAZ_VOIR_VOS_ANNONCES : $res .= mes_fiches(); break;
64 florian 186
			case BAZ_VOIR_TOUTES_ANNONCES : $res .= baz_liste($GLOBALS['_BAZAR_']['id_nature']); break;
5 florian 187
			case BAZ_DEPOSER_ANNONCE : $res .= baz_formulaire(BAZ_DEPOSER_ANNONCE); break;
188
			case BAZ_ANNONCES_A_VALIDER : $res .= fiches_a_valider(); break;
189
			case BAZ_ADMINISTRER_ANNONCES : $res .= baz_administrer_annonces(); break;
190
			case BAZ_MODIFIER_FICHE : $res .= baz_formulaire(BAZ_ACTION_MODIFIER); break;
191
			case BAZ_SUPPRIMER_FICHE : $res .= baz_suppression().baz_liste('',$GLOBALS['id_user'],''); break;
192
			case BAZ_VOIR_FICHE : $res .= baz_voir_fiche(1); break;
193
			case BAZ_ACTION_NOUVEAU : $res .= baz_formulaire(BAZ_ACTION_NOUVEAU); break;
68 florian 194
			case BAZ_ACTION_NOUVEAU_V : $res .= baz_formulaire(BAZ_ACTION_NOUVEAU_V).baz_formulaire(BAZ_DEPOSER_ANNONCE); break;
5 florian 195
			case BAZ_ACTION_MODIFIER : $res .= baz_formulaire(BAZ_ACTION_MODIFIER); break;
68 florian 196
			case BAZ_ACTION_MODIFIER_V : $res .= baz_formulaire(BAZ_ACTION_MODIFIER_V).baz_formulaire(BAZ_DEPOSER_ANNONCE); break;
197
			case BAZ_ACTION_SUPPRESSION : $res .= baz_suppression().baz_formulaire(BAZ_DEPOSER_ANNONCE); break;
5 florian 198
			case BAZ_ACTION_PUBLIER : publier_fiche(1) ;$res .= fiches_a_valider(); break;
199
			case BAZ_ACTION_PAS_PUBLIER : publier_fiche(0) ;$res .= fiches_a_valider(); break;
68 florian 200
			case BAZ_GERER_DROITS : $res .= baz_gestion_droits(); break;
5 florian 201
			case BAZ_S_INSCRIRE : $res .= baz_s_inscrire(); break;
202
			case BAZ_VOIR_FLUX_RSS : header('Content-type: text/xml; charset=ISO-8859-1');include("bazarRSS.php");exit(0);break;
203
			default : $res .= accueil() ;
204
		}
205
	}
206
	else {
71 alexandre_ 207
		$res .= baz_liste();
5 florian 208
	}
209
	return $res ;
210
}
211
 
212
 
213
/* +--Fin du code ----------------------------------------------------------------------------------------+
214
*
10 ddelon 215
* $Log: not supported by cvs2svn $
71 alexandre_ 216
* Revision 1.21  2006/01/13 14:12:52  florian
217
* utilisation des temlates dans la table bazar_nature
218
*
68 florian 219
* Revision 1.20  2006/01/05 16:28:25  alexandre_tb
220
* prise en chage des checkbox, reste la mise à jour à gérer
221
*
67 alexandre_ 222
* Revision 1.19  2006/01/03 10:19:31  florian
223
* 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...
224
*
64 florian 225
* Revision 1.18  2005/12/02 10:57:03  florian
226
* MAJ pour paramétrage dans gestion de menus papyrus
227
*
59 florian 228
* Revision 1.17  2005/12/01 16:05:41  florian
229
* changement des chemins pour appli Pear
230
*
57 florian 231
* Revision 1.16  2005/12/01 15:31:30  florian
232
* correction bug modifs et saisies
233
*
56 florian 234
* Revision 1.15  2005/11/30 13:58:45  florian
235
* ajouts graphisme (logos, boutons), changement structure SQL bazar_fiche
236
*
55 florian 237
* Revision 1.14  2005/11/24 16:17:13  florian
238
* corrections bugs, ajout des cases à cocher
239
*
54 florian 240
* Revision 1.13  2005/11/14 16:04:54  florian
241
* maj bug affichage flux
242
*
51 florian 243
* Revision 1.12  2005/11/07 17:05:46  florian
244
* amélioration validation conditions de saisie, ajout des règles spécifiques de saisie des formulaires
245
*
45 florian 246
* Revision 1.11  2005/10/21 16:15:04  florian
247
* mise a jour appropriation
248
*
39 florian 249
* Revision 1.10  2005/10/12 17:20:33  ddelon
250
* Reorganisation calendrier + applette
251
*
30 ddelon 252
* Revision 1.9  2005/10/12 13:35:07  florian
253
* amélioration de l'interface de bazar, de manière a simplifier les consultations, et à harmoniser par rapport aux Ressources
254
*
22 florian 255
* Revision 1.8  2005/09/30 13:00:05  ddelon
256
* Fiche bazar generique
257
*
11 ddelon 258
* Revision 1.7  2005/09/30 12:34:44  ddelon
259
* petite modification pour integration bazar dans papyrus
260
*
10 ddelon 261
* Revision 1.6  2005/09/30 12:22:54  florian
262
* Ajouts commentaires pour fiche, modifications graphiques, maj SQL
263
*
7 florian 264
* Revision 1.4  2005/07/21 19:03:12  florian
265
* nouveautés bazar: templates fiches, correction de bugs, ...
266
*
5 florian 267
* Revision 1.2  2005/02/22 15:33:32  florian
268
* integration dans Papyrus
269
*
270
* Revision 1.1.1.1  2005/02/17 18:05:11  florian
271
* Import initial de Bazar
272
*
273
* Revision 1.1.1.1  2005/02/17 11:09:50  florian
274
* Import initial
275
*
276
* Revision 1.1.1.1  2005/02/16 18:06:35  florian
277
* import de la nouvelle version
278
*
279
* Revision 1.3  2004/07/05 15:10:14  florian
280
* changement interface de saisie
281
*
282
* Revision 1.2  2004/07/01 10:13:41  florian
283
* modif Florian
284
*
285
* Revision 1.1  2004/06/23 09:58:32  alex
286
* version initiale
287
*
288
* Revision 1.1  2004/06/18 09:00:07  alex
289
* version initiale
290
*
291
*
292
* +-- Fin du code ----------------------------------------------------------------------------------------+
293
*/
294
?>