Subversion Repositories Applications.bazar

Rev

Rev 392 | Rev 446 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 392 Rev 398
Line 17... Line 17...
17
// |                                                                                                      |
17
// |                                                                                                      |
18
// | You should have received a copy of the GNU Lesser General Public                                     |
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                                  |
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.10 2008-09-17 14:08:45 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
30
*@version       $Revision: 1.10 $
30
*@version       $Revision: 1.11 $
31
// +------------------------------------------------------------------------------------------------------+
31
// +------------------------------------------------------------------------------------------------------+
32
*/
32
*/
Line 33... Line 33...
33
 
33
 
34
// +------------------------------------------------------------------------------------------------------+
34
// +------------------------------------------------------------------------------------------------------+
Line 42... Line 42...
42
// +------------------------------------------------------------------------------------------------------+
42
// +------------------------------------------------------------------------------------------------------+
43
// |                                            ENTETE du PROGRAMME                                       |
43
// |                                            ENTETE du PROGRAMME                                       |
44
// +------------------------------------------------------------------------------------------------------+
44
// +------------------------------------------------------------------------------------------------------+
Line 45... Line 45...
45
 
45
 
-
 
46
include_once PAP_CHEMIN_API_PEAR.'PEAR.php';
Line 46... Line 47...
46
include_once PAP_CHEMIN_API_PEAR.'PEAR.php';
47
include_once BAZ_CHEMIN_APPLI.'bibliotheque/bazarTemplate.class.php';
Line 47... Line 48...
47
 
48
 
Line 189... Line 190...
189
	
190
	
Line -... Line 191...
-
 
191
}
-
 
192
 
-
 
193
 
Line 190... Line 194...
190
}
194
 
Line 191... Line 195...
191
 
195
define ('BAZAR_NOTIFICATION_NOUVELLE_FICHE', 1);
192
 
196
define ('BAZAR_NOTIFICATION_MODIFICATION_FICHE', 2);
Line 231... Line 235...
231
		while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
235
		while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
232
			array_push ($tableau_mail, $ligne[BAZ_CHAMPS_EMAIL]) ;
236
			array_push ($tableau_mail, $ligne[BAZ_CHAMPS_EMAIL]) ;
233
		}
237
		}
234
		return $tableau_mail;
238
		return $tableau_mail;
235
	}
239
	}
-
 
240
	/**
-
 
241
	 *  notifier() envoie un message aux administrateurs
-
 
242
	 * 
-
 
243
	 * par defaut lors du depot ou de la modification d une fiche
-
 
244
	 */
-
 
245
	function notifier($type = BAZAR_NOTIFICATION_NOUVELLE_FICHE) {
-
 
246
		
-
 
247
		switch ($type) {
-
 
248
			case BAZAR_NOTIFICATION_NOUVELLE_FICHE :
-
 
249
				$id_sujet = BAZ_TEMPLATE_MAIL_NOUVELLE_FICHE_SUJET;
-
 
250
				$id_corps = BAZ_TEMPLATE_MAIL_NOUVELLE_FICHE_CORPS;
-
 
251
			break ;
-
 
252
			case BAZAR_NOTIFICATION_MODIFICATION_FICHE :
-
 
253
				$id_sujet = BAZ_TEMPLATE_MAIL_MODIFIER_FICHE_SUJET;
-
 
254
				$id_corps = BAZ_TEMPLATE_MAIL_MODIFIER_FICHE_CORPS;
-
 
255
			break;
-
 
256
		}
-
 
257
		
-
 
258
		$template = new bazarTemplate($GLOBALS['_BAZAR_']['db']);
-
 
259
		//print ('toto'.$id_sujet);
-
 
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']));
-
 
262
		
-
 
263
		$mails = bazar::getMailSuperAdmin($GLOBALS['_BAZAR_']['id_typeannonce']);
-
 
264
		if (is_array ($mails)) {
-
 
265
			foreach ($mails as $mail) {
-
 
266
				mail ($mail, $sujet, $corps);
-
 
267
			}
-
 
268
		}
-
 
269
	}
-
 
270
	
-
 
271
	/** Effectue une requete sur bazar_nature pour remplir diverses
-
 
272
	 * globales
-
 
273
	 * 
-
 
274
	 * @global string la globale de langue (ex fr-FR)
-
 
275
	 * @global	int $GLOBALS['_BAZAR_']['id_typeannonce']
-
 
276
	 * 
-
 
277
	 * @return mixed	true ou PEAR_Error
-
 
278
	 */
-
 
279
	function chargeNature() {
-
 
280
		
-
 
281
		$requete = 'SELECT bn_label_nature, bn_condition, bn_template, bn_commentaire, bn_appropriation, bn_image_titre, bn_image_logo';
-
 
282
		$requete .= ' FROM bazar_nature WHERE bn_id_nature = '.$GLOBALS['_BAZAR_']['id_typeannonce'];
-
 
283
		if (isset($GLOBALS['_BAZAR_']['langue'])) {
-
 
284
			$requete .= ' and bn_ce_i18n like "'.$GLOBALS['_BAZAR_']['langue'].'%"';
-
 
285
		}
-
 
286
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
-
 
287
		if (DB::isError($resultat)) {
-
 
288
			return $resultat->getMessage().$resultat->getDebugInfo() ;
-
 
289
		}
-
 
290
		$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
-
 
291
		$GLOBALS['_BAZAR_']['typeannonce']=$ligne['bn_label_nature'];
-
 
292
		$GLOBALS['_BAZAR_']['condition']=$ligne['bn_condition'];
-
 
293
	    $GLOBALS['_BAZAR_']['template']=$ligne['bn_template'];
-
 
294
		$GLOBALS['_BAZAR_']['commentaire']=$ligne['bn_commentaire'];
-
 
295
		$GLOBALS['_BAZAR_']['appropriation']=$ligne['bn_appropriation'];
-
 
296
		$GLOBALS['_BAZAR_']['image_titre']=$ligne['bn_image_titre'];
-
 
297
		$GLOBALS['_BAZAR_']['image_logo']=$ligne['bn_image_logo'];	
-
 
298
		return true;
-
 
299
	}  
-
 
300
	/** Renvoie un element de formulaire de type select ou radio
-
 
301
	 *  au vue de filtrer les resultats du bazar
-
 
302
	 * @global	mixed	$GLOBALS['_BAZAR_']['db'] identifiant de connexion a la bd
-
 
303
	 * 
-
 
304
	 * @return string	html
-
 
305
	 */
-
 
306
	function getFiltre($numero_liste, $multiple = false, $type = 'select') {
-
 
307
		$type == 'select' ? $balise = 'select' : $balise = 'radio' ;
-
 
308
		
-
 
309
		// chargement du template
-
 
310
		$tableau_template = baz_valeurs_template($GLOBALS['_BAZAR_']['template']);
-
 
311
		
-
 
312
		$html_filtre = '<select name="bazar_filtre_'.$numero_liste.'" onchange="javascript:this.form.submit();">'."\n";
-
 
313
		
-
 
314
		// Requete dans bazar_liste_valeurs
-
 
315
		$requete = 'select blv_valeur, blv_label from bazar_liste_valeurs where blv_ce_liste="'.$numero_liste.'"';
-
 
316
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete);
-
 
317
		
-
 
318
		if (DB::isError($resultat)) {
-
 
319
			return $resultat->getMessage().$resultat->getDebugInfo() ;
-
 
320
		}
-
 
321
		$html_filtre .= '<option id="filtre_tous" value="*" ';
-
 
322
		if (isset($_POST['bazar_filtre_'.$numero_liste]) && '*' == $_POST['bazar_filtre_'.$numero_liste]) {
-
 
323
			$html_filtre .= 'selected="selected" ';
-
 
324
		}
-
 
325
		$html_filtre .= '>'.'Tout afficher'.'</option>';
-
 
326
		
-
 
327
		while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
-
 
328
			$html_filtre .= '<option class="filtre_'.$ligne->blv_valeur.'" value="'.$ligne->blv_valeur.'"';
-
 
329
			if (isset($_POST['bazar_filtre_'.$numero_liste]) && $ligne->blv_valeur == $_POST['bazar_filtre_'.$numero_liste]) {
-
 
330
				$html_filtre .= 'selected="selected" ';
-
 
331
			}
-
 
332
			$html_filtre .= '>'.$ligne->blv_label.'</option>'."\n";
-
 
333
		} 
-
 
334
		$html_filtre .= '</select>'."\n";
-
 
335
		$resultat->free();
-
 
336
		return $html_filtre;
-
 
337
	}
-
 
338
	
-
 
339
	function getFiltrePlageDeDate () {
-
 
340
		if (isset ($_POST['date_debut'])) {
-
 
341
				$defaut_debut = $_POST['date_debut'];
-
 
342
			} else {
-
 
343
				$defaut_debut = '';
-
 
344
			} 
-
 
345
			if (isset ($_POST['date_fin'])) {
-
 
346
				$defaut_fin = $_POST['date_fin'];
-
 
347
			} else {
-
 
348
				$defaut_fin = '';
-
 
349
			}
-
 
350
			$formulaire_filtre .= 'de <input type="text" readonly size="10" name="date_debut" class="inputDate" id="date_debut" value="'.$defaut_debut.'" />'; 
-
 
351
			$formulaire_filtre .= ' &agrave; <input type="text" readonly size="10" name="date_fin" class="inputDate" id="date_fin" value="'.$defaut_fin.'" />'; 
-
 
352
			$formulaire_filtre .= "\n".'<script language="javascript" type="text/javascript">' ."\n".
-
 
353
					'$(document).ready(function() { $(\'#date_debut, #date_fin\').datepicker($.extend({}, $.datepicker.regional["fr-FR"],{
-
 
354
	dateFormat:\'dd-mm-yy\',
-
 
355
	buttonImage: "client/bazar/images/cal.png", 
-
 
356
	showOn: "both",
-
 
357
	beforeShow: customRange,
-
 
358
	buttonImageOnly: true'."\n". 
-
 
359
					'}));})' ."\n".
-
 
360
'function customRange(input) { return {minDate: (input.id == "date_fin" ? $("#date_debut").datepicker("getDate") : null), 
-
 
361
        maxDate: (input.id == "date_debut" ? $("#date_fin").datepicker("getDate") : null)};}' ."\n".
-
 
362
'</script>';
-
 
363
	return $formulaire_filtre;
-
 
364
	}
-
 
365
	
-
 
366
	/** Renvoie le formulaire d un filtre
-
 
367
	 *  utile dans la carte google ou dans le calendrier
-
 
368
	 * 
-
 
369
	 * @param	string	le template avec des filtres ecrits comme {filtre liste="12"}
-
 
370
	 * @global	mixed	$GLOBALS['_BAZAR_']['url']
-
 
371
	 * @return	string html
-
 
372
	 */
-
 
373
	function getFormulaireFiltre($template) {
-
 
374
		if (preg_match_all ('/{filtre liste="([0-9]+)"}/', $template, $subpattern)) {
-
 
375
			
-
 
376
			$formulaire_filtre = '<form action="'.$GLOBALS['_BAZAR_']['url']->getURL().'" method="post">'."\n";
-
 
377
			$formulaire_filtre .= '<fieldset><legend>Filtrer : </legend>';
-
 
378
			for ($i = 0; $i <count($subpattern[1]); $i++) {
-
 
379
				$formulaire_filtre .= bazar::getFiltre($subpattern[1][$i]) ; 
-
 
380
			}
-
 
381
			$formulaire_filtre .= bazar::getFiltrePlageDeDate();
-
 
382
			$formulaire_filtre .= '<input type="submit" value="Filtrer" />';
-
 
383
			$formulaire_filtre .= '</fieldset>';
-
 
384
			$formulaire_filtre .= '</form>'."\n";
-
 
385
			$html = preg_replace ('/{filtre liste="([0-9]+)"}/', $formulaire_filtre, $template);
-
 
386
		}
-
 
387
		return $html;
-
 
388
	}
236
}
389
}
Line 237... Line 390...
237
 
390
 
Line 238... Line 391...
238
class Bazar_element {
391
class Bazar_element {
Line 261... Line 414...
261
}
414
}
Line 262... Line 415...
262
 
415
 
263
/* +--Fin du code ----------------------------------------------------------------------------------------+
416
/* +--Fin du code ----------------------------------------------------------------------------------------+
264
*
417
*
-
 
418
* $Log: not supported by cvs2svn $
-
 
419
* Revision 1.10  2008-09-17 14:08:45  alexandre_tb
-
 
420
* merge depuis aha
265
* $Log: not supported by cvs2svn $
421
*
266
* Revision 1.9  2007-10-10 13:27:06  alexandre_tb
422
* Revision 1.9  2007-10-10 13:27:06  alexandre_tb
267
* encodage et remplacement de die en return
423
* encodage et remplacement de die en return
268
*
424
*
269
* Revision 1.8  2007-10-01 10:35:14  alexandre_tb
425
* Revision 1.8  2007-10-01 10:35:14  alexandre_tb