| Line 1... |
Line 1... |
| 1 |
<?php
|
1 |
<?php
|
| 2 |
/*vim: set expandtab tabstop=4 shiftwidth=4: */
|
2 |
/*vim: set expandtab tabstop=4 shiftwidth=4: */
|
| 3 |
// +------------------------------------------------------------------------------------------------------+
|
3 |
// +------------------------------------------------------------------------------------------------------+
|
| 4 |
// | PHP version 4.1 |
|
4 |
// | PHP version 4.1 |
|
| 5 |
// +------------------------------------------------------------------------------------------------------+
|
5 |
// +------------------------------------------------------------------------------------------------------+
|
| 6 |
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
|
6 |
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
|
| 7 |
// +------------------------------------------------------------------------------------------------------+
|
7 |
// +------------------------------------------------------------------------------------------------------+
|
| Line 19... |
Line 19... |
| 19 |
// | License along with this library; if not, write to the Free Software |
|
19 |
// | License along with this library; if not, write to the Free Software |
|
| 20 |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
20 |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
| 21 |
// +------------------------------------------------------------------------------------------------------+
|
21 |
// +------------------------------------------------------------------------------------------------------+
|
| 22 |
// CVS : $Id: bazar.class.php,v 1.11 2008-10-29 10:38:14 alexandre_tb Exp $
|
22 |
// CVS : $Id: bazar.class.php,v 1.11 2008-10-29 10:38:14 alexandre_tb Exp $
|
| 23 |
/**
|
23 |
/**
|
| 24 |
*
|
24 |
*
|
| 25 |
*@package bazar
|
25 |
*@package bazar
|
| 26 |
//Auteur original :
|
26 |
//Auteur original :
|
| 27 |
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
|
27 |
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
|
| 28 |
*@author Florian Schmitt <florian@ecole-et-nature.org>
|
28 |
*@author Florian Schmitt <florian@ecole-et-nature.org>
|
| 29 |
*@copyright Tela-Botanica 2000-2004
|
29 |
*@copyright Tela-Botanica 2000-2004
|
| Line 47... |
Line 47... |
| 47 |
include_once BAZ_CHEMIN_APPLI.'bibliotheque/bazarTemplate.class.php';
|
47 |
include_once BAZ_CHEMIN_APPLI.'bibliotheque/bazarTemplate.class.php';
|
| Line 48... |
Line 48... |
| 48 |
|
48 |
|
| Line 49... |
Line 49... |
| 49 |
class Administrateur_bazar {
|
49 |
class Administrateur_bazar {
|
| 50 |
|
50 |
|
| 51 |
var $_auth ;
|
51 |
var $_auth ;
|
| 52 |
|
52 |
|
| 53 |
/**
|
53 |
/**
|
| 54 |
* Identifiant de l'utilisateur
|
54 |
* Identifiant de l'utilisateur
|
| 55 |
*/
|
55 |
*/
|
| Line 56... |
Line 56... |
| 56 |
|
56 |
|
| 57 |
var $_id_utilisateur ;
|
57 |
var $_id_utilisateur ;
|
| 58 |
|
58 |
|
| 59 |
/**
|
59 |
/**
|
| 60 |
* Vaut true si l'utilisateur est un administrateur
|
60 |
* Vaut true si l'utilisateur est un administrateur
|
| 61 |
*/
|
61 |
*/
|
| 62 |
var $_isSuperAdmin ;
|
62 |
var $_isSuperAdmin ;
|
| 63 |
|
63 |
|
| 64 |
/** Constructeur
|
64 |
/** Constructeur
|
| 65 |
*
|
65 |
*
|
| 66 |
* @param object Un objet authentification
|
66 |
* @param object Un objet authentification
|
| 67 |
* @return void
|
67 |
* @return void
|
| 68 |
*
|
68 |
*
|
| 69 |
*/
|
69 |
*/
|
| 70 |
|
70 |
|
| 71 |
function Administrateur_bazar (&$AUTH) {
|
71 |
function Administrateur_bazar (&$AUTH) {
|
| 72 |
$this->_auth = $AUTH ;
|
72 |
$this->_auth = $AUTH ;
|
| 73 |
if ($AUTH->getAuth())$this->_id_utilisateur = $this->_auth->getAuthData(BAZ_CHAMPS_ID) ;
|
73 |
if ($AUTH->getAuth())$this->_id_utilisateur = $this->_auth->getAuthData(BAZ_CHAMPS_ID) ;
|
| 74 |
}
|
74 |
}
|
| 75 |
|
75 |
|
| 76 |
/** isSuperAdmin () - Renvoie true si l'utilisateur est un super administrateur
|
76 |
/** isSuperAdmin () - Renvoie true si l'utilisateur est un super administrateur
|
| 77 |
*
|
77 |
*
|
| 78 |
*/
|
78 |
*/
|
| 79 |
function isSuperAdmin() {
|
79 |
function isSuperAdmin() {
|
| 80 |
|
80 |
|
| 81 |
if(empty($this->_id_utilisateur))
|
81 |
if(empty($this->_id_utilisateur))
|
| 82 |
return FALSE;
|
82 |
return FALSE;
|
| 83 |
|
83 |
|
| 84 |
// On court-circuite si la question a déjà été posé pour ne pas refaire la requete
|
84 |
// On court-circuite si la question a déjà été posé pour ne pas refaire la requete
|
| 85 |
if (isset ($this->_isSuperAdmin)) return $this->_isSuperAdmin ;
|
85 |
if (isset ($this->_isSuperAdmin)) return $this->_isSuperAdmin ;
|
| 86 |
|
86 |
|
| 87 |
// On court-circuite si l'utilisateur n'est pas logué
|
87 |
// On court-circuite si l'utilisateur n'est pas logué
|
| 88 |
if (!$this->_auth->getAuth()) return false ;
|
88 |
if (!$this->_auth->getAuth()) return false ;
|
| 89 |
|
89 |
|
| 90 |
// Sinon on interroge la base
|
90 |
// Sinon on interroge la base
|
| Line 97... |
Line 97... |
| 97 |
return ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
|
97 |
return ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
|
| 98 |
}
|
98 |
}
|
| 99 |
if ($resultat->numRows() != 0) {
|
99 |
if ($resultat->numRows() != 0) {
|
| 100 |
$this->_isSuperAdmin = true ;
|
100 |
$this->_isSuperAdmin = true ;
|
| 101 |
} else {
|
101 |
} else {
|
| 102 |
$this->_isSuperAdmin = false ;
|
102 |
$this->_isSuperAdmin = false ;
|
| 103 |
}
|
103 |
}
|
| 104 |
return $this->_isSuperAdmin;
|
104 |
return $this->_isSuperAdmin;
|
| 105 |
}
|
105 |
}
|
| 106 |
|
106 |
|
| 107 |
/** isAdmin () - Renvoie true si l'utilisateur est administrateur du type de fiche spécifié
|
107 |
/** isAdmin () - Renvoie true si l'utilisateur est administrateur du type de fiche spécifié
|
| 108 |
*
|
108 |
*
|
| 109 |
* @param interger type_annonce Le type de l'annonce
|
109 |
* @param interger type_annonce Le type de l'annonce
|
| 110 |
*
|
110 |
*
|
| 111 |
*/
|
111 |
*/
|
| 112 |
|
112 |
|
| 113 |
function isAdmin($id_nature) {
|
113 |
function isAdmin($id_nature) {
|
| 114 |
// on court-circuite si l'utilisateur n'est pas logué
|
114 |
// on court-circuite si l'utilisateur n'est pas logué
|
| 115 |
if (!$this->_auth->getAuth()) return false ;
|
115 |
if (!$this->_auth->getAuth()) return false ;
|
| 116 |
|
116 |
|
| 117 |
return $this->_requeteDroit ($id_nature, 2) ;
|
117 |
return $this->_requeteDroit ($id_nature, 2) ;
|
| 118 |
}
|
118 |
}
|
| 119 |
|
119 |
|
| 120 |
/** isRedacteur() - Renvoie true si l'utilisateur est redacteur du type de fiche specifie
|
120 |
/** isRedacteur() - Renvoie true si l'utilisateur est redacteur du type de fiche specifie
|
| 121 |
*
|
121 |
*
|
| 122 |
*/
|
122 |
*/
|
| 123 |
|
123 |
|
| 124 |
function isRedacteur($id_nature) {
|
124 |
function isRedacteur($id_nature) {
|
| 125 |
if (isset($GLOBALS['droit_depot']) && $GLOBALS['droit_depot'] == 3) return true;
|
125 |
if (isset($GLOBALS['droit_depot']) && $GLOBALS['droit_depot'] == 3) return true;
|
| 126 |
return $this->_requeteDroit ($id_nature, 1) ;
|
126 |
return $this->_requeteDroit ($id_nature, 1) ;
|
| 127 |
}
|
127 |
}
|
| 128 |
|
128 |
|
| 129 |
/** _requeteDroit() - fait une requete sur la table bazar_droit
|
129 |
/** _requeteDroit() - fait une requete sur la table bazar_droit
|
| 130 |
*
|
130 |
*
|
| 131 |
*/
|
131 |
*/
|
| 132 |
|
132 |
|
| 133 |
function _requeteDroit ($id_nature, $niveau) {
|
133 |
function _requeteDroit ($id_nature, $niveau) {
|
| 134 |
|
134 |
|
| 135 |
if(empty($this->_id_utilisateur))
|
135 |
if(empty($this->_id_utilisateur))
|
| 136 |
return false;
|
136 |
return false;
|
| 137 |
|
137 |
|
| 138 |
$requete = 'SELECT bd_niveau_droit FROM bazar_droits WHERE bd_id_utilisateur='
|
138 |
$requete = 'SELECT bd_niveau_droit FROM bazar_droits WHERE bd_id_utilisateur='
|
| 139 |
.$this->_id_utilisateur.
|
139 |
.$this->_id_utilisateur.
|
| 140 |
' AND bd_id_nature_offre="'.$id_nature.'" and bd_niveau_droit='.$niveau;
|
140 |
' AND bd_id_nature_offre="'.$id_nature.'" and bd_niveau_droit='.$niveau;
|
| Line 141... |
Line 141... |
| 141 |
|
141 |
|
| Line 149... |
Line 149... |
| 149 |
return false ;
|
149 |
return false ;
|
| 150 |
}
|
150 |
}
|
| 151 |
}
|
151 |
}
|
| Line 152... |
Line 152... |
| 152 |
|
152 |
|
| 153 |
class Utilisateur_bazar extends Administrateur_bazar {
|
153 |
class Utilisateur_bazar extends Administrateur_bazar {
|
| 154 |
|
154 |
|
| 155 |
function Utilisateur_bazar($id_utilisateur) {
|
155 |
function Utilisateur_bazar($id_utilisateur) {
|
| 156 |
$this->_id_utilisateur = $id_utilisateur ;
|
156 |
$this->_id_utilisateur = $id_utilisateur ;
|
| 157 |
}
|
157 |
}
|
| 158 |
|
158 |
|
| 159 |
function isAdmin($id_nature) {
|
159 |
function isAdmin($id_nature) {
|
| 160 |
return $this->_requeteDroit ($id_nature, 2) ;
|
160 |
return $this->_requeteDroit ($id_nature, 2) ;
|
| 161 |
}
|
161 |
}
|
| 162 |
|
162 |
|
| 163 |
/** isSuperAdmin () - Renvoie true si l'utilisateur est un super administrateur
|
163 |
/** isSuperAdmin () - Renvoie true si l'utilisateur est un super administrateur
|
| 164 |
*
|
164 |
*
|
| 165 |
*/
|
165 |
*/
|
| 166 |
function isSuperAdmin() {
|
166 |
function isSuperAdmin() {
|
| 167 |
|
167 |
|
| 168 |
if(empty($this->_id_utilisateur))
|
168 |
if(empty($this->_id_utilisateur))
|
| 169 |
return false;
|
169 |
return false;
|
| 170 |
|
170 |
|
| 171 |
// On court-circuite si la question a déjà été posé pour ne pas refaire la requete
|
171 |
// On court-circuite si la question a déjà été posé pour ne pas refaire la requete
|
| 172 |
if (isset ($this->_isSuperAdmin)) return $this->_isSuperAdmin ;
|
172 |
if (isset ($this->_isSuperAdmin)) return $this->_isSuperAdmin ;
|
| 173 |
|
173 |
|
| 174 |
// Sinon on interroge la base
|
174 |
// Sinon on interroge la base
|
| 175 |
$requete = 'SELECT bd_niveau_droit FROM bazar_droits WHERE bd_id_utilisateur='.
|
175 |
$requete = 'SELECT bd_niveau_droit FROM bazar_droits WHERE bd_id_utilisateur='.
|
| 176 |
$this->_id_utilisateur.
|
176 |
$this->_id_utilisateur.
|
| Line 181... |
Line 181... |
| 181 |
return ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
|
181 |
return ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
|
| 182 |
}
|
182 |
}
|
| 183 |
if ($resultat->numRows() != 0) {
|
183 |
if ($resultat->numRows() != 0) {
|
| 184 |
$this->_isSuperAdmin = true ;
|
184 |
$this->_isSuperAdmin = true ;
|
| 185 |
} else {
|
185 |
} else {
|
| 186 |
$this->_isSuperAdmin = false ;
|
186 |
$this->_isSuperAdmin = false ;
|
| 187 |
}
|
187 |
}
|
| 188 |
return $this->_isSuperAdmin;
|
188 |
return $this->_isSuperAdmin;
|
| 189 |
}
|
189 |
}
|
| 190 |
|
190 |
|
| 191 |
}
|
191 |
}
|
| Line 192... |
Line 192... |
| 192 |
|
192 |
|
| 193 |
|
193 |
|
| Line 194... |
Line 194... |
| 194 |
|
194 |
|
| 195 |
define ('BAZAR_NOTIFICATION_NOUVELLE_FICHE', 1);
|
195 |
define ('BAZAR_NOTIFICATION_NOUVELLE_FICHE', 1);
|
| 196 |
define ('BAZAR_NOTIFICATION_MODIFICATION_FICHE', 2);
|
196 |
define ('BAZAR_NOTIFICATION_MODIFICATION_FICHE', 2);
|
| 197 |
|
197 |
|
| 198 |
|
198 |
|
| 199 |
class bazar extends PEAR {
|
199 |
class bazar extends PEAR {
|
| 200 |
|
200 |
|
| 201 |
/**
|
201 |
/**
|
| 202 |
* getMailAdmin Renvoie un tableau de mail des administrateurs du type
|
202 |
* getMailAdmin Renvoie un tableau de mail des administrateurs du type
|
| 203 |
* de fiche passe en parametre
|
203 |
* de fiche passe en parametre
|
| 204 |
*
|
204 |
*
|
| Line 216... |
Line 216... |
| 216 |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
|
216 |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
|
| 217 |
array_push ($tableau_mail, $ligne[BAZ_CHAMPS_EMAIL]) ;
|
217 |
array_push ($tableau_mail, $ligne[BAZ_CHAMPS_EMAIL]) ;
|
| 218 |
}
|
218 |
}
|
| 219 |
return $tableau_mail;
|
219 |
return $tableau_mail;
|
| 220 |
}
|
220 |
}
|
| 221 |
|
221 |
|
| 222 |
/**
|
222 |
/**
|
| 223 |
* getMailAdmin Renvoie un tableau de mail des super administrateurs
|
223 |
* getMailAdmin Renvoie un tableau de mail des super administrateurs
|
| 224 |
*
|
224 |
*
|
| 225 |
* @global DB Un objet DB de PEAR $GLOBALS['_BAZAR_']['db']
|
225 |
* @global DB Un objet DB de PEAR $GLOBALS['_BAZAR_']['db']
|
| 226 |
*/
|
226 |
*/
|
| 227 |
function getMailSuperAdmin() {
|
227 |
function getMailSuperAdmin() {
|
| 228 |
$requete = 'select '.BAZ_CHAMPS_EMAIL.' from '.BAZ_ANNUAIRE.', bazar_droits ' .
|
228 |
$requete = 'select '.BAZ_CHAMPS_EMAIL.' from '.BAZ_ANNUAIRE.', bazar_droits ' .
|
| 229 |
'where bd_niveau_droit="'.BAZ_DROIT_SUPER_ADMINISTRATEUR.'"' .
|
229 |
'where bd_niveau_droit="'.BAZ_DROIT_SUPER_ADMINISTRATEUR.'"' .
|
| Line 237... |
Line 237... |
| 237 |
}
|
237 |
}
|
| 238 |
return $tableau_mail;
|
238 |
return $tableau_mail;
|
| 239 |
}
|
239 |
}
|
| 240 |
/**
|
240 |
/**
|
| 241 |
* notifier() envoie un message aux administrateurs
|
241 |
* notifier() envoie un message aux administrateurs
|
| 242 |
*
|
242 |
*
|
| 243 |
* par defaut lors du depot ou de la modification d une fiche
|
243 |
* par defaut lors du depot ou de la modification d une fiche
|
| 244 |
*/
|
244 |
*/
|
| 245 |
function notifier($type = BAZAR_NOTIFICATION_NOUVELLE_FICHE) {
|
245 |
function notifier($type = BAZAR_NOTIFICATION_NOUVELLE_FICHE) {
|
| 246 |
|
246 |
|
| 247 |
switch ($type) {
|
247 |
switch ($type) {
|
| 248 |
case BAZAR_NOTIFICATION_NOUVELLE_FICHE :
|
248 |
case BAZAR_NOTIFICATION_NOUVELLE_FICHE :
|
| 249 |
$id_sujet = BAZ_TEMPLATE_MAIL_NOUVELLE_FICHE_SUJET;
|
249 |
$id_sujet = BAZ_TEMPLATE_MAIL_NOUVELLE_FICHE_SUJET;
|
| 250 |
$id_corps = BAZ_TEMPLATE_MAIL_NOUVELLE_FICHE_CORPS;
|
250 |
$id_corps = BAZ_TEMPLATE_MAIL_NOUVELLE_FICHE_CORPS;
|
| 251 |
break ;
|
251 |
break ;
|
| 252 |
case BAZAR_NOTIFICATION_MODIFICATION_FICHE :
|
252 |
case BAZAR_NOTIFICATION_MODIFICATION_FICHE :
|
| 253 |
$id_sujet = BAZ_TEMPLATE_MAIL_MODIFIER_FICHE_SUJET;
|
253 |
$id_sujet = BAZ_TEMPLATE_MAIL_MODIFIER_FICHE_SUJET;
|
| 254 |
$id_corps = BAZ_TEMPLATE_MAIL_MODIFIER_FICHE_CORPS;
|
254 |
$id_corps = BAZ_TEMPLATE_MAIL_MODIFIER_FICHE_CORPS;
|
| 255 |
break;
|
255 |
break;
|
| 256 |
}
|
256 |
}
|
| 257 |
|
257 |
|
| 258 |
$template = new bazarTemplate($GLOBALS['_BAZAR_']['db']);
|
258 |
$template = new bazarTemplate($GLOBALS['_BAZAR_']['db']);
|
| 259 |
//print ('toto'.$id_sujet);
|
259 |
//print ('toto'.$id_sujet);
|
| 260 |
$sujet = html_entity_decode($template->getTemplate($id_sujet, $GLOBALS['_BAZAR_']['langue'], $GLOBALS['_BAZAR_']['id_typeannonce']));
|
260 |
$sujet = html_entity_decode($template->getTemplate($id_sujet, $GLOBALS['_BAZAR_']['langue'], $GLOBALS['_BAZAR_']['id_typeannonce']));
|
| 261 |
$corps = html_entity_decode($template->getTemplate($id_corps, $GLOBALS['_BAZAR_']['langue'], $GLOBALS['_BAZAR_']['id_typeannonce']));
|
261 |
$corps = html_entity_decode($template->getTemplate($id_corps, $GLOBALS['_BAZAR_']['langue'], $GLOBALS['_BAZAR_']['id_typeannonce']));
|
| 262 |
$corps.= $GLOBALS['_BAZAR_']['id_fiche'].'&typeannonce='.$GLOBALS['_BAZAR_']['id_typeannonce'] ;
|
262 |
$corps.= $GLOBALS['_BAZAR_']['id_fiche'].'&typeannonce='.$GLOBALS['_BAZAR_']['id_typeannonce'] ;
|
| 263 |
|
263 |
|
| 264 |
$mails = bazar::getMailSuperAdmin($GLOBALS['_BAZAR_']['id_typeannonce']);
|
264 |
$mails = bazar::getMailSuperAdmin($GLOBALS['_BAZAR_']['id_typeannonce']);
|
| 265 |
if (is_array ($mails)) {
|
265 |
if (is_array ($mails)) {
|
| 266 |
foreach ($mails as $mail) {
|
266 |
foreach ($mails as $mail) {
|
| 267 |
mail ($mail, $sujet, $corps);
|
267 |
mail ($mail, $sujet, $corps);
|
| 268 |
}
|
268 |
}
|
| 269 |
}
|
269 |
}
|
| 270 |
}
|
270 |
}
|
| 271 |
|
271 |
|
| 272 |
/** Effectue une requete sur bazar_nature pour remplir diverses
|
272 |
/** Effectue une requete sur bazar_nature pour remplir diverses
|
| 273 |
* globales
|
273 |
* globales
|
| 274 |
*
|
274 |
*
|
| 275 |
* @global string la globale de langue (ex fr-FR)
|
275 |
* @global string la globale de langue (ex fr-FR)
|
| 276 |
* @global int $GLOBALS['_BAZAR_']['id_typeannonce']
|
276 |
* @global int $GLOBALS['_BAZAR_']['id_typeannonce']
|
| 277 |
*
|
277 |
*
|
| 278 |
* @return mixed true ou PEAR_Error
|
278 |
* @return mixed true ou PEAR_Error
|
| 279 |
*/
|
279 |
*/
|
| 280 |
function chargeNature() {
|
280 |
function chargeNature() {
|
| 281 |
|
281 |
|
| 282 |
$requete = 'SELECT bn_label_nature, bn_condition, bn_template, bn_commentaire, bn_appropriation, bn_image_titre, bn_image_logo';
|
282 |
$requete = 'SELECT bn_label_nature, bn_condition, bn_template, bn_commentaire, bn_appropriation, bn_image_titre, bn_image_logo';
|
| 283 |
$requete .= ' FROM bazar_nature WHERE bn_id_nature = '.$GLOBALS['_BAZAR_']['id_typeannonce'];
|
283 |
$requete .= ' FROM bazar_nature WHERE bn_id_nature = '.$GLOBALS['_BAZAR_']['id_typeannonce'];
|
| 284 |
if (isset($GLOBALS['_BAZAR_']['langue'])) {
|
284 |
if (isset($GLOBALS['_BAZAR_']['langue'])) {
|
| 285 |
$requete .= ' and bn_ce_i18n like "'.$GLOBALS['_BAZAR_']['langue'].'%"';
|
285 |
$requete .= ' and bn_ce_i18n like "'.$GLOBALS['_BAZAR_']['langue'].'%"';
|
| 286 |
}
|
286 |
}
|
| Line 293... |
Line 293... |
| 293 |
$GLOBALS['_BAZAR_']['condition']=$ligne['bn_condition'];
|
293 |
$GLOBALS['_BAZAR_']['condition']=$ligne['bn_condition'];
|
| 294 |
$GLOBALS['_BAZAR_']['template']=$ligne['bn_template'];
|
294 |
$GLOBALS['_BAZAR_']['template']=$ligne['bn_template'];
|
| 295 |
$GLOBALS['_BAZAR_']['commentaire']=$ligne['bn_commentaire'];
|
295 |
$GLOBALS['_BAZAR_']['commentaire']=$ligne['bn_commentaire'];
|
| 296 |
$GLOBALS['_BAZAR_']['appropriation']=$ligne['bn_appropriation'];
|
296 |
$GLOBALS['_BAZAR_']['appropriation']=$ligne['bn_appropriation'];
|
| 297 |
$GLOBALS['_BAZAR_']['image_titre']=$ligne['bn_image_titre'];
|
297 |
$GLOBALS['_BAZAR_']['image_titre']=$ligne['bn_image_titre'];
|
| 298 |
$GLOBALS['_BAZAR_']['image_logo']=$ligne['bn_image_logo'];
|
298 |
$GLOBALS['_BAZAR_']['image_logo']=$ligne['bn_image_logo'];
|
| 299 |
return true;
|
299 |
return true;
|
| 300 |
}
|
300 |
}
|
| 301 |
/** Renvoie un element de formulaire de type select ou radio
|
301 |
/** Renvoie un element de formulaire de type select ou radio
|
| 302 |
* au vue de filtrer les resultats du bazar
|
302 |
* au vue de filtrer les resultats du bazar
|
| 303 |
* @global mixed $GLOBALS['_BAZAR_']['db'] identifiant de connexion a la bd
|
303 |
* @global mixed $GLOBALS['_BAZAR_']['db'] identifiant de connexion a la bd
|
| 304 |
*
|
304 |
*
|
| 305 |
* @return string html
|
305 |
* @return string html
|
| 306 |
*/
|
306 |
*/
|
| 307 |
function getFiltre($numero_liste, $multiple = false, $type = 'select') {
|
307 |
function getFiltre($numero_liste, $multiple = false, $type = 'select') {
|
| 308 |
$type == 'select' ? $balise = 'select' : $balise = 'radio' ;
|
308 |
$type == 'select' ? $balise = 'select' : $balise = 'radio' ;
|
| 309 |
|
309 |
|
| 310 |
// chargement du template
|
310 |
// chargement du template
|
| 311 |
$tableau_template = baz_valeurs_template($GLOBALS['_BAZAR_']['template']);
|
311 |
$tableau_template = baz_valeurs_template($GLOBALS['_BAZAR_']['template']);
|
| 312 |
|
312 |
|
| 313 |
$html_filtre = '<select name="bazar_filtre_'.$numero_liste.'" onchange="javascript:this.form.submit();">'."\n";
|
313 |
$html_filtre = '<select name="bazar_filtre_'.$numero_liste.'" onchange="javascript:this.form.submit();">'."\n";
|
| 314 |
|
314 |
|
| 315 |
// Requete dans bazar_liste_valeurs
|
315 |
// Requete dans bazar_liste_valeurs
|
| 316 |
$requete = 'select blv_valeur, blv_label from bazar_liste_valeurs where blv_ce_liste="'.$numero_liste.'"';
|
316 |
$requete = 'select blv_valeur, blv_label from bazar_liste_valeurs where blv_ce_liste="'.$numero_liste.'"';
|
| 317 |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete);
|
317 |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete);
|
| 318 |
|
318 |
|
| 319 |
if (DB::isError($resultat)) {
|
319 |
if (DB::isError($resultat)) {
|
| 320 |
return $resultat->getMessage().$resultat->getDebugInfo() ;
|
320 |
return $resultat->getMessage().$resultat->getDebugInfo() ;
|
| 321 |
}
|
321 |
}
|
| 322 |
$html_filtre .= '<option id="filtre_tous" value="*" ';
|
322 |
$html_filtre .= '<option id="filtre_tous" value="*" ';
|
| 323 |
if (isset($_POST['bazar_filtre_'.$numero_liste]) && '*' == $_POST['bazar_filtre_'.$numero_liste]) {
|
323 |
if (isset($_POST['bazar_filtre_'.$numero_liste]) && '*' == $_POST['bazar_filtre_'.$numero_liste]) {
|
| 324 |
$html_filtre .= 'selected="selected" ';
|
324 |
$html_filtre .= 'selected="selected" ';
|
| 325 |
}
|
325 |
}
|
| 326 |
$html_filtre .= '>'.'Tout afficher'.'</option>';
|
326 |
$html_filtre .= '>'.'Tout afficher'.'</option>';
|
| 327 |
|
327 |
|
| 328 |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
|
328 |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
|
| 329 |
$html_filtre .= '<option class="filtre_'.$ligne->blv_valeur.'" value="'.$ligne->blv_valeur.'"';
|
329 |
$html_filtre .= '<option class="filtre_'.$ligne->blv_valeur.'" value="'.$ligne->blv_valeur.'"';
|
| 330 |
if (isset($_POST['bazar_filtre_'.$numero_liste]) && $ligne->blv_valeur == $_POST['bazar_filtre_'.$numero_liste]) {
|
330 |
if (isset($_POST['bazar_filtre_'.$numero_liste]) && $ligne->blv_valeur == $_POST['bazar_filtre_'.$numero_liste]) {
|
| 331 |
$html_filtre .= 'selected="selected" ';
|
331 |
$html_filtre .= 'selected="selected" ';
|
| 332 |
}
|
332 |
}
|
| 333 |
$html_filtre .= '>'.$ligne->blv_label.'</option>'."\n";
|
333 |
$html_filtre .= '>'.$ligne->blv_label.'</option>'."\n";
|
| 334 |
}
|
334 |
}
|
| 335 |
$html_filtre .= '</select>'."\n";
|
335 |
$html_filtre .= '</select>'."\n";
|
| 336 |
$resultat->free();
|
336 |
$resultat->free();
|
| 337 |
return $html_filtre;
|
337 |
return $html_filtre;
|
| 338 |
}
|
338 |
}
|
| 339 |
|
339 |
|
| 340 |
function getFiltrePlageDeDate () {
|
340 |
function getFiltrePlageDeDate () {
|
| 341 |
if (isset ($_POST['date_debut'])) {
|
341 |
if (isset ($_POST['date_debut'])) {
|
| 342 |
$defaut_debut = $_POST['date_debut'];
|
342 |
$defaut_debut = $_POST['date_debut'];
|
| 343 |
} else {
|
343 |
} else {
|
| 344 |
$defaut_debut = '';
|
344 |
$defaut_debut = '';
|
| 345 |
}
|
345 |
}
|
| 346 |
if (isset ($_POST['date_fin'])) {
|
346 |
if (isset ($_POST['date_fin'])) {
|
| 347 |
$defaut_fin = $_POST['date_fin'];
|
347 |
$defaut_fin = $_POST['date_fin'];
|
| 348 |
} else {
|
348 |
} else {
|
| 349 |
$defaut_fin = '';
|
349 |
$defaut_fin = '';
|
| 350 |
}
|
350 |
}
|
| - |
|
351 |
$formulaire_filtre = '';
|
| 351 |
$formulaire_filtre .= 'de <input type="text" readonly size="10" name="date_debut" class="inputDate" id="date_debut" value="'.$defaut_debut.'" />';
|
352 |
$formulaire_filtre .= 'de <input type="text" readonly size="10" name="date_debut" class="inputDate" id="date_debut" value="'.$defaut_debut.'" />';
|
| 352 |
$formulaire_filtre .= ' à <input type="text" readonly size="10" name="date_fin" class="inputDate" id="date_fin" value="'.$defaut_fin.'" />';
|
353 |
$formulaire_filtre .= ' à <input type="text" readonly size="10" name="date_fin" class="inputDate" id="date_fin" value="'.$defaut_fin.'" />';
|
| 353 |
$formulaire_filtre .= "\n".'<script language="javascript" type="text/javascript">' ."\n".
|
354 |
$formulaire_filtre .= "\n".'<script language="javascript" type="text/javascript">' ."\n".
|
| 354 |
'$(document).ready(function() { $(\'#date_debut, #date_fin\').datepicker($.extend({}, $.datepicker.regional["fr-FR"],{
|
355 |
'$(document).ready(function() { $(\'#date_debut, #date_fin\').datepicker($.extend({}, $.datepicker.regional["fr-FR"],{
|
| 355 |
dateFormat:\'dd-mm-yy\',
|
356 |
dateFormat:\'dd-mm-yy\',
|
| 356 |
buttonImage: "client/bazar/images/cal.png",
|
357 |
buttonImage: "client/bazar/images/cal.png",
|
| 357 |
showOn: "both",
|
358 |
showOn: "both",
|
| 358 |
beforeShow: customRange,
|
359 |
beforeShow: customRange,
|
| 359 |
buttonImageOnly: true'."\n".
|
360 |
buttonImageOnly: true'."\n".
|
| 360 |
'}));})' ."\n".
|
361 |
'}));})' ."\n".
|
| 361 |
'function customRange(input) { return {minDate: (input.id == "date_fin" ? $("#date_debut").datepicker("getDate") : null),
|
362 |
'function customRange(input) { return {minDate: (input.id == "date_fin" ? $("#date_debut").datepicker("getDate") : null),
|
| 362 |
maxDate: (input.id == "date_debut" ? $("#date_fin").datepicker("getDate") : null)};}' ."\n".
|
363 |
maxDate: (input.id == "date_debut" ? $("#date_fin").datepicker("getDate") : null)};}' ."\n".
|
| 363 |
'</script>';
|
364 |
'</script>';
|
| 364 |
return $formulaire_filtre;
|
365 |
return $formulaire_filtre;
|
| 365 |
}
|
366 |
}
|
| 366 |
|
367 |
|
| 367 |
/** Renvoie le formulaire d un filtre
|
368 |
/** Renvoie le formulaire d un filtre
|
| 368 |
* utile dans la carte google ou dans le calendrier
|
369 |
* utile dans la carte google ou dans le calendrier
|
| 369 |
*
|
370 |
*
|
| 370 |
* @param string le template avec des filtres ecrits comme {filtre liste="12"}
|
371 |
* @param string le template avec des filtres ecrits comme {filtre liste="12"}
|
| 371 |
* @global mixed $GLOBALS['_BAZAR_']['url']
|
372 |
* @global mixed $GLOBALS['_BAZAR_']['url']
|
| 372 |
* @return string html
|
373 |
* @return string html
|
| 373 |
*/
|
374 |
*/
|
| 374 |
function getFormulaireFiltre($template) {
|
375 |
function getFormulaireFiltre($template) {
|
| 375 |
if (preg_match_all ('/{filtre liste="([0-9]+)"}/', $template, $subpattern)) {
|
376 |
if (preg_match_all ('/{filtre liste="([0-9]+)"}/', $template, $subpattern)) {
|
| 376 |
|
377 |
|
| 377 |
$formulaire_filtre = '<form action="'.$GLOBALS['_BAZAR_']['url']->getURL().'" method="post">'."\n";
|
378 |
$formulaire_filtre = '<form action="'.$GLOBALS['_BAZAR_']['url']->getURL().'" method="post">'."\n";
|
| 378 |
$formulaire_filtre .= '<fieldset><legend>Filtrer : </legend>';
|
379 |
$formulaire_filtre .= '<fieldset><legend>Filtrer : </legend>';
|
| 379 |
for ($i = 0; $i <count($subpattern[1]); $i++) {
|
380 |
for ($i = 0; $i <count($subpattern[1]); $i++) {
|
| 380 |
$formulaire_filtre .= bazar::getFiltre($subpattern[1][$i]) ;
|
381 |
$formulaire_filtre .= bazar::getFiltre($subpattern[1][$i]) ;
|
| 381 |
}
|
382 |
}
|
| 382 |
$formulaire_filtre .= bazar::getFiltrePlageDeDate();
|
383 |
$formulaire_filtre .= bazar::getFiltrePlageDeDate();
|
| 383 |
$formulaire_filtre .= '<input type="submit" value="Filtrer" />';
|
384 |
$formulaire_filtre .= '<input type="submit" value="Filtrer" />';
|
| 384 |
$formulaire_filtre .= '</fieldset>';
|
385 |
$formulaire_filtre .= '</fieldset>';
|
| 385 |
$formulaire_filtre .= '</form>'."\n";
|
386 |
$formulaire_filtre .= '</form>'."\n";
|
| Line 388... |
Line 389... |
| 388 |
return $html;
|
389 |
return $html;
|
| 389 |
}
|
390 |
}
|
| 390 |
}
|
391 |
}
|
| Line 391... |
Line 392... |
| 391 |
|
392 |
|
| 392 |
class Bazar_element {
|
393 |
class Bazar_element {
|
| 393 |
|
394 |
|
| 394 |
function &factory($type, $options = false)
|
395 |
function &factory($type, $options = false)
|
| 395 |
{
|
396 |
{
|
| 396 |
|
397 |
|
| 397 |
if (file_exists (BAZ_CHEMIN_APPLI."bibliotheque/elements/{$type}.php")) include_once BAZ_CHEMIN_APPLI."bibliotheque/elements/{$type}.php";
|
398 |
if (file_exists (BAZ_CHEMIN_APPLI."bibliotheque/elements/{$type}.php")) include_once BAZ_CHEMIN_APPLI."bibliotheque/elements/{$type}.php";
|
| 398 |
else return PEAR::raiseError("Impossible d inclure le fichier /{$type}.php", "Impossible d inclure le fichier ".
|
399 |
else return PEAR::raiseError("Impossible d inclure le fichier /{$type}.php", "Impossible d inclure le fichier ".
|
| 399 |
BAZ_CHEMIN_APPLI."bibliotheque/elements/{$type}.php<br />", null, null,
|
400 |
BAZ_CHEMIN_APPLI."bibliotheque/elements/{$type}.php<br />", null, null,
|
| 400 |
"Impossible d inclure le fichier /{$type}.php"
|
401 |
"Impossible d inclure le fichier /{$type}.php"
|