Subversion Repositories Applications.bazar

Compare Revisions

Ignore whitespace Rev 467 → Rev 468

/trunk/bibliotheque/bazar.fonct.formulaire.controles.php
1,51 → 1,51
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: bazar.fonct.formulaire.controles.php,v 1.1 2005-11-07 17:05:45 florian Exp $
/**
* Formulaire controles
*
* Les fonctions de controles de saisie des formulaires
*
*@package bazar
//Auteur original :
*@author Florian SCHMITT <florian@ecole-et-nature.org>
*@copyright Tela-Botanica 2000-2004
*@version $Revision: 1.1 $ $Date: 2005-11-07 17:05:45 $
// +------------------------------------------------------------------------------------------------------+
*/
 
//-------------------FONCTIONS DE MISE EN PAGE DES FORMULAIRES
 
/** liste_choisir() - Teste si une valeur à été choisie pour une liste
*
*
*/
function liste_choisir($element_name,$element_value) {
if ($element_value == 0) {
return false;
}
else {
return true;
}
}
 
?>
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: bazar.fonct.formulaire.controles.php,v 1.1 2005-11-07 17:05:45 florian Exp $
/**
* Formulaire controles
*
* Les fonctions de controles de saisie des formulaires
*
*@package bazar
//Auteur original :
*@author Florian SCHMITT <florian@ecole-et-nature.org>
*@copyright Tela-Botanica 2000-2004
*@version $Revision: 1.1 $ $Date: 2005-11-07 17:05:45 $
// +------------------------------------------------------------------------------------------------------+
*/
 
//-------------------FONCTIONS DE MISE EN PAGE DES FORMULAIRES
 
/** liste_choisir() - Teste si une valeur à été choisie pour une liste
*
*
*/
function liste_choisir($element_name,$element_value) {
if ($element_value == 0) {
return false;
}
else {
return true;
}
}
 
?>
/trunk/bibliotheque/bazar.fonct.google.php
1,132 → 1,162
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: bazar.fonct.google.php,v 1.1 2007-06-04 15:24:00 alexandre_tb Exp $
/**
* Formulaire
*
* Les fonctions et script specifique a un carto google
*
*@package bazar
//Auteur original :
*@author Aleandre GRANIER <alexandre@tela-botanica.org>
*@copyright Tela-Botanica 2000-2007
*@version $Revision: 1.1 $
// +------------------------------------------------------------------------------------------------------+
*/
 
$script = '
// Variables globales
var map = null;
var geocoder = null;
var lat = document.getElementById("latitude");
var lon = document.getElementById("longitude");
function load() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.addControl(new GScaleControl());
map.enableContinuousZoom();
// On centre la carte sur le languedoc roussillon
center = new GLatLng(43.84245116699036, 3.768310546875);
map.setCenter(center, 7);
//marker = new GMarker(center, {draggable: true}) ;
GEvent.addListener(map, "click", function(marker, point) {
if (marker) {
map.removeOverlay(marker);
var lat = document.getElementById("latitude");
var lon = document.getElementById("longitude");
lat.value = "";
lon.value = "";
} else {
// On ajoute un marqueur a l endroit du clic et on place les coordonnees dans les champs latitude et longitude
marker = new GMarker(point, {draggable: true}) ;
GEvent.addListener(marker, "dragend", function () {
coordMarker = marker.getPoint() ;
var lat = document.getElementById("latitude");
var lon = document.getElementById("longitude");
lat.value = coordMarker.lat();
lon.value = coordMarker.lng();
});
map.addOverlay(marker);
setLatLonForm(marker);
}
});' ;
if ($formtemplate->getElementValue ('latitude') != '' && $formtemplate->getElementValue('longitude') != '') {
$script .= '
point = new GLatLng('.$formtemplate->getElementValue('latitude').', '.$formtemplate->getElementValue('longitude').');
marker = new GMarker(point, {draggable: true});
map.addOverlay(marker);' ;
}
$script .= 'geocoder = new GClientGeocoder();
}
};
function showAddress() {
var adresse = document.getElementById("bf_adresse").value ;
var ville = document.getElementById("bf_ville").value ;
var cp = document.getElementById("bf_cp_lieu_evenement").value ;
var selectIndex = document.getElementById("liste30").selectedIndex;
var pays = document.getElementById("liste30").options[selectIndex].text ;
var address = adresse + \' \' + \' \' + cp + \' \' + ville + \' \' +pays ;
if (geocoder) {
geocoder.getLatLng(
address,
function(point) {
if (!point) {
alert(address + " not found");
} else {
map.setCenter(point, 13);
var marker = new GMarker(point, {draggable: true});
GEvent.addListener(marker, "dragend", function () {
coordMarker = marker.getPoint() ;
var lat = document.getElementById("latitude");
var lon = document.getElementById("longitude");
lat.value = coordMarker.lat();
lon.value = coordMarker.lng();
});
 
map.addOverlay(marker);
setLatLonForm(marker)
marker.openInfoWindowHtml(address+ "'.BAZ_GOOGLE_MSG.'");
}
}
);
}
}
function setLatLonForm(marker) {
coordMarker = marker.getPoint() ;
var lat = document.getElementById("latitude");
var lon = document.getElementById("longitude");
lat.value = coordMarker.lat();
lon.value = coordMarker.lng();
}
';
 
/*
* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: bazar.fonct.google.php,v 1.1 2007-06-04 15:24:00 alexandre_tb Exp $
/**
* Formulaire
*
* Les fonctions et script specifique a un carto google
*
*@package bazar
//Auteur original :
*@author Aleandre GRANIER <alexandre@tela-botanica.org>
*@copyright Tela-Botanica 2000-2007
*@version $Revision: 1.1 $
// +------------------------------------------------------------------------------------------------------+
*/
 
$script = '
// Variables globales
var map = null;
var geocoder = null;
var marker = null;
var flat = null;
var flon = null;
 
// cette fonction peut d�j� �tre pr�sente
// fonction portable pour ajout de listeners
function addListener(element, baseName, handler)
{
if (element.addEventListener) {
element.addEventListener(baseName, handler, false) ;
} else if (element.attachEvent) {
element.attachEvent(\'on\'+baseName, handler) ;
}
}
addListener(window,\'load\',loadMap) ;
function loadMap() {
flat = document.getElementById("latitude");
flon = document.getElementById("longitude");
 
var optionsGoogleMapsv3 = {
// On centre la carte sur le languedoc roussillon
center: new google.maps.LatLng(43.84245116699036, 3.768310546875),
zoom: 7,
mapTypeId: google.maps.MapTypeId.G_HYBRID_MAP,
mapTypeControl: true,
scaleControl: true
};
map = new google.maps.Map(document.getElementById("map"), optionsGoogleMapsv3);
 
google.maps.event.addListener(map, "click", function(event) {
if (marker != null) {
marker.setMap(null);
marker = null;
}
// On ajoute un marqueur a l endroit du clic et on place les coordonnees dans les champs latitude et longitude
marker = event.overlay;
marker = new google.maps.Marker({
position: event.latLng,
draggable: true,
map: map
});
google.maps.event.addListener(marker, "dragend", function () {
coordMarker = marker.getPosition() ;
flat.value = coordMarker.lat();
flon.value = coordMarker.lng();
});
setLatLonForm(marker);
});';
if ($formtemplate->getElementValue ('latitude') != '' && $formtemplate->getElementValue('longitude') != '') {
$script .= '
point = new google.maps.LatLng('.$formtemplate->getElementValue('latitude').', '.$formtemplate->getElementValue('longitude').');
marker = new google.maps.Marker({
position: point,
draggable: true,
map: map
});
google.maps.event.addListener(marker, "dragend", function () {
coordMarker = marker.getPosition() ;
flat.value = coordMarker.lat();
flon.value = coordMarker.lng();
});
map.setCenter(point);
' ;
}
$script .= 'geocoder = new google.maps.Geocoder();
};
function showAddress() {
var adresse = document.getElementById("bf_adresse").value;
var ville = "";
if (document.getElementById("bf_ville")) {
ville = document.getElementById("bf_ville").value ;
}
var cp = document.getElementById("bf_cp_lieu_evenement").value ;
var pays;
if (document.getElementById("liste30")) {
var selectIndex = document.getElementById("liste30").selectedIndex;
pays = document.getElementById("liste30").options[selectIndex].text ;
} else {
pays = document.getElementById("bf_pays").value;
}
var address = adresse + \' \' + \' \' + cp + \' \' + ville + \' \' +pays ;
if (geocoder) {
geocoder.geocode({
address: address
}, function(result, status) {
if (status != google.maps.GeocoderStatus.OK) {
alert(address + " not found");
} else {
marker.setMap(null);
marker = null;
//map.setCenter(point, 13);
map.fitBounds(result[0].geometry.viewport);
marker = new google.maps.Marker({
position: result[0].geometry.location,
draggable: true,
map: map
});
google.maps.event.addListener(marker, "dragend", function () {
coordMarker = marker.getPosition() ;
flat.value = coordMarker.lat();
flon.value = coordMarker.lng();
});
setLatLonForm(marker);
//marker.openInfoWindowHtml(address+ "'.BAZ_GOOGLE_MSG.'");
}
});
}
}
function setLatLonForm(marker) {
coordMarker = marker.getPosition() ;
flat.value = coordMarker.lat();
flon.value = coordMarker.lng();
}
';
 
 
 
/*
* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
/trunk/bibliotheque/bazar.class.php
1,456 → 1,479
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: bazar.class.php,v 1.11 2008-10-29 10:38:14 alexandre_tb Exp $
/**
*
*@package bazar
//Auteur original :
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
*@author Florian Schmitt <florian@ecole-et-nature.org>
*@copyright Tela-Botanica 2000-2004
*@version $Revision: 1.11 $
// +------------------------------------------------------------------------------------------------------+
*/
 
// +------------------------------------------------------------------------------------------------------+
// | LES CONSTANTES DES NIVEAUX DE DROIT |
// +------------------------------------------------------------------------------------------------------+
 
define ('BAZ_DROIT_SUPER_ADMINISTRATEUR', 0);
define ('BAZ_DROIT_ADMINISTRATEUR', 2);
define ('BAZ_DROIT_REDACTEUR', 1);
 
// +------------------------------------------------------------------------------------------------------+
// | ENTETE du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
 
include_once PAP_CHEMIN_API_PEAR.'PEAR.php';
include_once BAZ_CHEMIN_APPLI.'bibliotheque/bazarTemplate.class.php';
 
class Administrateur_bazar {
 
var $_auth ;
 
/**
* Identifiant de l'utilisateur
*/
 
var $_id_utilisateur ;
 
/**
* Vaut true si l'utilisateur est un administrateur
*/
var $_isSuperAdmin ;
 
/** Constructeur
*
* @param object Un objet authentification
* @return void
*
*/
 
function Administrateur_bazar (&$AUTH) {
$this->_auth = $AUTH ;
if ($AUTH->getAuth())$this->_id_utilisateur = $this->_auth->getAuthData(BAZ_CHAMPS_ID) ;
}
 
/** isSuperAdmin () - Renvoie true si l'utilisateur est un super administrateur
*
*/
function isSuperAdmin() {
 
if(empty($this->_id_utilisateur))
return FALSE;
 
// On court-circuite si la question a déjà été posé pour ne pas refaire la requete
if (isset ($this->_isSuperAdmin)) return $this->_isSuperAdmin ;
 
// On court-circuite si l'utilisateur n'est pas logué
if (!$this->_auth->getAuth()) return false ;
 
// Sinon on interroge la base
$requete = 'SELECT bd_niveau_droit FROM bazar_droits WHERE bd_id_utilisateur='.
$this->_id_utilisateur.
' AND bd_niveau_droit=0';
 
$resultat = $GLOBALS['_BAZAR_']['db']->query ($requete) ;
if (DB::isError($resultat)) {
return ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
}
if ($resultat->numRows() != 0) {
$this->_isSuperAdmin = true ;
} else {
$this->_isSuperAdmin = false ;
}
return $this->_isSuperAdmin;
}
 
/** isAdmin () - Renvoie true si l'utilisateur est administrateur du type de fiche spécifié
*
* @param interger type_annonce Le type de l'annonce
*
*/
 
function isAdmin($id_nature) {
// on court-circuite si l'utilisateur n'est pas logué
if (!$this->_auth->getAuth()) return false ;
 
return $this->_requeteDroit ($id_nature, 2) ;
}
 
/** isRedacteur() - Renvoie true si l'utilisateur est redacteur du type de fiche specifie
*
*/
 
function isRedacteur($id_nature) {
if (isset($GLOBALS['droit_depot']) && $GLOBALS['droit_depot'] == 3) return true;
return $this->_requeteDroit ($id_nature, 1) ;
}
 
/** _requeteDroit() - fait une requete sur la table bazar_droit
*
*/
 
function _requeteDroit ($id_nature, $niveau) {
 
if(empty($this->_id_utilisateur))
return false;
 
$requete = 'SELECT bd_niveau_droit FROM bazar_droits WHERE bd_id_utilisateur='
.$this->_id_utilisateur.
' AND bd_id_nature_offre="'.$id_nature.'" and bd_niveau_droit='.$niveau;
 
$resultat = $GLOBALS['_BAZAR_']['db']->query ($requete) ;
if (DB::isError($resultat)) {
return ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
}
if ($resultat->numRows() != 0) {
return true ;
}
return false ;
}
}
 
class Utilisateur_bazar extends Administrateur_bazar {
 
function Utilisateur_bazar($id_utilisateur) {
$this->_id_utilisateur = $id_utilisateur ;
}
 
function isAdmin($id_nature) {
return $this->_requeteDroit ($id_nature, 2) ;
}
 
/** isSuperAdmin () - Renvoie true si l'utilisateur est un super administrateur
*
*/
function isSuperAdmin() {
 
if(empty($this->_id_utilisateur))
return false;
 
// On court-circuite si la question a déjà été posé pour ne pas refaire la requete
if (isset ($this->_isSuperAdmin)) return $this->_isSuperAdmin ;
 
// Sinon on interroge la base
$requete = 'SELECT bd_niveau_droit FROM bazar_droits WHERE bd_id_utilisateur='.
$this->_id_utilisateur.
' AND bd_niveau_droit=0';
 
$resultat = $GLOBALS['_BAZAR_']['db']->query ($requete) ;
if (DB::isError($resultat)) {
return ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
}
if ($resultat->numRows() != 0) {
$this->_isSuperAdmin = true ;
} else {
$this->_isSuperAdmin = false ;
}
return $this->_isSuperAdmin;
}
 
}
 
 
 
define ('BAZAR_NOTIFICATION_NOUVELLE_FICHE', 1);
define ('BAZAR_NOTIFICATION_MODIFICATION_FICHE', 2);
 
 
class bazar extends PEAR {
 
/**
* getMailAdmin Renvoie un tableau de mail des administrateurs du type
* de fiche passe en parametre
*
* @global DB Un objet DB de PEAR $GLOBALS['_BAZAR_']['db']
* @param integer L identifiant de la nature
*/
function getMailAdmin($id_nature) {
$requete = 'select '.BAZ_CHAMPS_EMAIL.' from '.BAZ_ANNUAIRE.', bazar_droits ' .
'where bd_id_nature_offre="'.$id_nature.'" and bd_niveau_droit="'.BAZ_DROIT_ADMINISTRATEUR.'"' .
' and '.BAZ_CHAMPS_ID.'= bd_id_utilisateur';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete);
if (DB::isError($resultat)) $this->raiseError();
$tableau_mail = array();
if ($resultat->numRows() == 0) return false;
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
array_push ($tableau_mail, $ligne[BAZ_CHAMPS_EMAIL]) ;
}
return $tableau_mail;
}
 
/**
* getMailAdmin Renvoie un tableau de mail des super administrateurs
*
* @global DB Un objet DB de PEAR $GLOBALS['_BAZAR_']['db']
*/
function getMailSuperAdmin() {
$requete = 'select '.BAZ_CHAMPS_EMAIL.' from '.BAZ_ANNUAIRE.', bazar_droits ' .
'where bd_niveau_droit="'.BAZ_DROIT_SUPER_ADMINISTRATEUR.'"' .
' and '.BAZ_CHAMPS_ID.'= bd_id_utilisateur';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete);
if (DB::isError($resultat)) $this->raiseError();
$tableau_mail = array();
if ($resultat->numRows() == 0) return false;
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
array_push ($tableau_mail, $ligne[BAZ_CHAMPS_EMAIL]) ;
}
return $tableau_mail;
}
/**
* notifier() envoie un message aux administrateurs
*
* par defaut lors du depot ou de la modification d une fiche
*/
function notifier($type = BAZAR_NOTIFICATION_NOUVELLE_FICHE) {
 
switch ($type) {
case BAZAR_NOTIFICATION_NOUVELLE_FICHE :
$id_sujet = BAZ_TEMPLATE_MAIL_NOUVELLE_FICHE_SUJET;
$id_corps = BAZ_TEMPLATE_MAIL_NOUVELLE_FICHE_CORPS;
break ;
case BAZAR_NOTIFICATION_MODIFICATION_FICHE :
$id_sujet = BAZ_TEMPLATE_MAIL_MODIFIER_FICHE_SUJET;
$id_corps = BAZ_TEMPLATE_MAIL_MODIFIER_FICHE_CORPS;
break;
}
 
$template = new bazarTemplate($GLOBALS['_BAZAR_']['db']);
//print ('toto'.$id_sujet);
$sujet = html_entity_decode($template->getTemplate($id_sujet, $GLOBALS['_BAZAR_']['langue'], $GLOBALS['_BAZAR_']['id_typeannonce']));
$corps = html_entity_decode($template->getTemplate($id_corps, $GLOBALS['_BAZAR_']['langue'], $GLOBALS['_BAZAR_']['id_typeannonce']));
$corps.= $GLOBALS['_BAZAR_']['id_fiche'].'&typeannonce='.$GLOBALS['_BAZAR_']['id_typeannonce'] ;
 
$mails = bazar::getMailSuperAdmin($GLOBALS['_BAZAR_']['id_typeannonce']);
if (is_array ($mails)) {
foreach ($mails as $mail) {
mail ($mail, $sujet, $corps);
}
}
}
 
/** Effectue une requete sur bazar_nature pour remplir diverses
* globales
*
* @global string la globale de langue (ex fr-FR)
* @global int $GLOBALS['_BAZAR_']['id_typeannonce']
*
* @return mixed true ou PEAR_Error
*/
function chargeNature() {
 
$requete = 'SELECT bn_label_nature, bn_condition, bn_template, bn_commentaire, bn_appropriation, bn_image_titre, bn_image_logo';
$requete .= ' FROM bazar_nature WHERE bn_id_nature = '.$GLOBALS['_BAZAR_']['id_typeannonce'];
if (isset($GLOBALS['_BAZAR_']['langue'])) {
$requete .= ' and bn_ce_i18n like "'.$GLOBALS['_BAZAR_']['langue'].'%"';
}
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
return $resultat->getMessage().$resultat->getDebugInfo() ;
}
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
$GLOBALS['_BAZAR_']['typeannonce']=$ligne['bn_label_nature'];
$GLOBALS['_BAZAR_']['condition']=$ligne['bn_condition'];
$GLOBALS['_BAZAR_']['template']=$ligne['bn_template'];
$GLOBALS['_BAZAR_']['commentaire']=$ligne['bn_commentaire'];
$GLOBALS['_BAZAR_']['appropriation']=$ligne['bn_appropriation'];
$GLOBALS['_BAZAR_']['image_titre']=$ligne['bn_image_titre'];
$GLOBALS['_BAZAR_']['image_logo']=$ligne['bn_image_logo'];
return true;
}
/** Renvoie un element de formulaire de type select ou radio
* au vue de filtrer les resultats du bazar
* @global mixed $GLOBALS['_BAZAR_']['db'] identifiant de connexion a la bd
*
* @return string html
*/
function getFiltre($numero_liste, $multiple = false, $type = 'select') {
$type == 'select' ? $balise = 'select' : $balise = 'radio' ;
 
// chargement du template
$tableau_template = baz_valeurs_template($GLOBALS['_BAZAR_']['template']);
 
$html_filtre = '<select name="bazar_filtre_'.$numero_liste.'" onchange="javascript:this.form.submit();">'."\n";
 
// Requete dans bazar_liste_valeurs
$requete = 'select blv_valeur, blv_label from bazar_liste_valeurs where blv_ce_liste="'.$numero_liste.'"';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete);
 
if (DB::isError($resultat)) {
return $resultat->getMessage().$resultat->getDebugInfo() ;
}
$html_filtre .= '<option id="filtre_tous" value="*" ';
if (isset($_POST['bazar_filtre_'.$numero_liste]) && '*' == $_POST['bazar_filtre_'.$numero_liste]) {
$html_filtre .= 'selected="selected" ';
}
$html_filtre .= '>'.'Tout afficher'.'</option>';
 
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
$html_filtre .= '<option class="filtre_'.$ligne->blv_valeur.'" value="'.$ligne->blv_valeur.'"';
if (isset($_POST['bazar_filtre_'.$numero_liste]) && $ligne->blv_valeur == $_POST['bazar_filtre_'.$numero_liste]) {
$html_filtre .= 'selected="selected" ';
}
$html_filtre .= '>'.$ligne->blv_label.'</option>'."\n";
}
$html_filtre .= '</select>'."\n";
$resultat->free();
return $html_filtre;
}
 
function getFiltrePlageDeDate () {
if (isset ($_POST['date_debut'])) {
$defaut_debut = $_POST['date_debut'];
} else {
$defaut_debut = '';
}
if (isset ($_POST['date_fin'])) {
$defaut_fin = $_POST['date_fin'];
} else {
$defaut_fin = '';
}
$formulaire_filtre = '';
$formulaire_filtre .= 'de <input type="text" readonly size="10" name="date_debut" class="inputDate" id="date_debut" value="'.$defaut_debut.'" />';
$formulaire_filtre .= ' &agrave; <input type="text" readonly size="10" name="date_fin" class="inputDate" id="date_fin" value="'.$defaut_fin.'" />';
$formulaire_filtre .= "\n".'<script language="javascript" type="text/javascript">' ."\n".
'$(document).ready(function() { $(\'#date_debut, #date_fin\').datepicker($.extend({}, $.datepicker.regional["fr-FR"],{
dateFormat:\'dd-mm-yy\',
buttonImage: "client/bazar/images/cal.png",
showOn: "both",
beforeShow: customRange,
buttonImageOnly: true'."\n".
'}));})' ."\n".
'function customRange(input) { return {minDate: (input.id == "date_fin" ? $("#date_debut").datepicker("getDate") : null),
maxDate: (input.id == "date_debut" ? $("#date_fin").datepicker("getDate") : null)};}' ."\n".
'</script>';
return $formulaire_filtre;
}
 
/** Renvoie le formulaire d un filtre
* utile dans la carte google ou dans le calendrier
*
* @param string le template avec des filtres ecrits comme {filtre liste="12"}
* @global mixed $GLOBALS['_BAZAR_']['url']
* @return string html
*/
function getFormulaireFiltre($template) {
if (preg_match_all ('/{filtre liste="([0-9]+)"}/', $template, $subpattern)) {
 
$formulaire_filtre = '<form action="'.$GLOBALS['_BAZAR_']['url']->getURL().'" method="post">'."\n";
$formulaire_filtre .= '<fieldset><legend>Filtrer : </legend>';
for ($i = 0; $i <count($subpattern[1]); $i++) {
$formulaire_filtre .= bazar::getFiltre($subpattern[1][$i]) ;
}
$formulaire_filtre .= bazar::getFiltrePlageDeDate();
$formulaire_filtre .= '<input type="submit" value="Filtrer" />';
$formulaire_filtre .= '</fieldset>';
$formulaire_filtre .= '</form>'."\n";
$html = preg_replace ('/{filtre liste="([0-9]+)"}/', $formulaire_filtre, $template);
}
return $html;
}
}
 
class Bazar_element {
 
function &factory($type, $options = false)
{
 
if (file_exists (BAZ_CHEMIN_APPLI."bibliotheque/elements/{$type}.php")) include_once BAZ_CHEMIN_APPLI."bibliotheque/elements/{$type}.php";
else return PEAR::raiseError("Impossible d inclure le fichier /{$type}.php", "Impossible d inclure le fichier ".
BAZ_CHEMIN_APPLI."bibliotheque/elements/{$type}.php<br />", null, null,
"Impossible d inclure le fichier /{$type}.php"
, 'PEAR_Error', true);;
$classname = "Bazar_{$type}";
 
if (!class_exists($classname)) {
$tmp = PEAR::raiseError(null, -2, null, null,
"la classe $classname n'existe pas"
, 'PEAR_Error', true);
return $tmp;
}
 
@$obj =& new $classname($options);
 
return $obj;
}
}
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
* Revision 1.10 2008-09-17 14:08:45 alexandre_tb
* merge depuis aha
*
* Revision 1.9 2007-10-10 13:27:06 alexandre_tb
* encodage et remplacement de die en return
*
* Revision 1.8 2007-10-01 10:35:14 alexandre_tb
* petit hack pour tester la presence de $GLOBALS['droit_depot'] qui indique le niveau de droit minimum pour pouvoir deposer une fiche.
*
* Revision 1.7 2007-07-04 09:59:09 alexandre_tb
* ajout de la classe bazar, premices d une structuration du code
*
* Revision 1.6 2007/04/20 09:58:06 neiluj
* correction bug $this->_id_utilisateur
*
* Revision 1.5 2007/04/11 08:30:12 neiluj
* remise en état du CVS...
*
* Revision 1.3.2.1 2007/03/07 16:49:21 jp_milcent
* Mise en majuscule de select
*
* Revision 1.3 2006/03/29 13:05:12 alexandre_tb
* ajout de la classe Administrateur_bazar
*
* Revision 1.2 2006/02/09 11:06:12 alexandre_tb
* changement dans les id des droit
* 0 => super administrateur
* 1 => redacteur
* 2 => administrateur
*
* Revision 1.1 2006/02/07 11:08:06 alexandre_tb
* version initiale
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: bazar.class.php,v 1.10 2008-09-17 14:08:45 alexandre_tb Exp $
/**
*
*@package bazar
//Auteur original :
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
*@author Florian Schmitt <florian@ecole-et-nature.org>
*@copyright Tela-Botanica 2000-2004
*@version $Revision: 1.10 $
// +------------------------------------------------------------------------------------------------------+
*/
 
// +------------------------------------------------------------------------------------------------------+
// | LES CONSTANTES DES NIVEAUX DE DROIT |
// +------------------------------------------------------------------------------------------------------+
 
define ('BAZ_DROIT_SUPER_ADMINISTRATEUR', 0);
define ('BAZ_DROIT_ADMINISTRATEUR', 2);
define ('BAZ_DROIT_REDACTEUR', 1);
 
// +------------------------------------------------------------------------------------------------------+
// | ENTETE du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
 
include_once PAP_CHEMIN_API_PEAR.'PEAR.php';
include_once BAZ_CHEMIN_APPLI.'bibliotheque/bazarTemplate.class.php';
 
class Administrateur_bazar {
 
var $_auth ;
/**
* Identifiant de l'utilisateur
*/
var $_id_utilisateur ;
 
/**
* Vaut true si l'utilisateur est un administrateur
*/
var $_isSuperAdmin ;
/** Constructeur
*
* @param object Un objet authentification
* @return void
*
*/
function Administrateur_bazar (&$AUTH) {
$this->_auth = $AUTH ;
if ($AUTH->getAuth())$this->_id_utilisateur = $this->_auth->getAuthData(BAZ_CHAMPS_ID) ;
}
/** isSuperAdmin () - Renvoie true si l'utilisateur est un super administrateur
*
*/
function isSuperAdmin() {
if(empty($this->_id_utilisateur))
return FALSE;
// On court-circuite si la question a d�j� �t� pos� pour ne pas refaire la requete
if (isset ($this->_isSuperAdmin)) return $this->_isSuperAdmin ;
// On court-circuite si l'utilisateur n'est pas loggu�
if (!$this->_auth->getAuth()) return false ;
// Sinon on interroge la base
$requete = 'SELECT bd_niveau_droit FROM bazar_droits WHERE bd_id_utilisateur='.
$this->_id_utilisateur.
' AND bd_niveau_droit=0';
 
$resultat = $GLOBALS['_BAZAR_']['db']->query ($requete) ;
if (DB::isError($resultat)) {
return ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
}
if ($resultat->numRows() != 0) {
$this->_isSuperAdmin = true ;
} else {
$this->_isSuperAdmin = false ;
}
return $this->_isSuperAdmin;
}
/** isAdmin () - Renvoie true si l'utilisateur est administrateur du type de fiche sp�cifi�
*
* @param interger type_annonce Le type de l'annonce
*
*/
function isAdmin($id_nature) {
// on court-circuite si l'utilisateur n'est pas loggu�
if (!$this->_auth->getAuth()) return false ;
return $this->_requeteDroit ($id_nature, 2) ;
}
/** isRedacteur() - Renvoie true si l'utilisateur est redacteur du type de fiche specifie
*
*/
function isRedacteur($id_nature) {
if (isset($GLOBALS['droit_depot']) && $GLOBALS['droit_depot'] == 3) return true;
return $this->_requeteDroit ($id_nature, 1) ;
}
/** _requeteDroit() - fait une requete sur la table bazar_droit
*
*/
function _requeteDroit ($id_nature, $niveau) {
if(empty($this->_id_utilisateur))
return false;
$requete = 'SELECT bd_niveau_droit FROM bazar_droits WHERE bd_id_utilisateur='
.$this->_id_utilisateur.
' AND bd_id_nature_offre="'.$id_nature.'"and bd_niveau_droit='.$niveau;
$resultat = $GLOBALS['_BAZAR_']['db']->query ($requete) ;
if (DB::isError($resultat)) {
return ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
}
if ($resultat->numRows() != 0) {
return true ;
}
return false ;
}
}
 
class Utilisateur_bazar extends Administrateur_bazar {
function Utilisateur_bazar($id_utilisateur) {
$this->_id_utilisateur = $id_utilisateur ;
}
function isAdmin($id_nature) {
return $this->_requeteDroit ($id_nature, 2) ;
}
/** isSuperAdmin () - Renvoie true si l'utilisateur est un super administrateur
*
*/
function isSuperAdmin() {
if(empty($this->_id_utilisateur))
return false;
// On court-circuite si la question a d�j� �t� pos� pour ne pas refaire la requete
if (isset ($this->_isSuperAdmin)) return $this->_isSuperAdmin ;
// Sinon on interroge la base
$requete = 'SELECT bd_niveau_droit FROM bazar_droits WHERE bd_id_utilisateur='.
$this->_id_utilisateur.
' AND bd_niveau_droit=0';
 
$resultat = $GLOBALS['_BAZAR_']['db']->query ($requete) ;
if (DB::isError($resultat)) {
return ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
}
if ($resultat->numRows() != 0) {
$this->_isSuperAdmin = true ;
} else {
$this->_isSuperAdmin = false ;
}
return $this->_isSuperAdmin;
}
}
 
 
 
define ('BAZAR_NOTIFICATION_NOUVELLE_FICHE', 1);
define ('BAZAR_NOTIFICATION_MODIFICATION_FICHE', 2);
 
 
class bazar extends PEAR {
/**
* getMailAdmin Renvoie un tableau de mail des administrateurs du type
* de fiche passe en parametre
*
* @global DB Un objet DB de PEAR $GLOBALS['_BAZAR_']['db']
* @param integer L identifiant de la nature
*/
function getMailAdmin($id_nature) {
$requete = 'select '.BAZ_CHAMPS_EMAIL.' from '.BAZ_ANNUAIRE.', bazar_droits ' .
'where bd_id_nature_offre="'.$id_nature.'" and bd_niveau_droit="'.BAZ_DROIT_ADMINISTRATEUR.'"' .
' and '.BAZ_CHAMPS_ID.'= bd_id_utilisateur';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete);
if (DB::isError($resultat)) $this->raiseError();
$tableau_mail = array();
if ($resultat->numRows() == 0) return false;
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
array_push ($tableau_mail, $ligne[BAZ_CHAMPS_EMAIL]) ;
}
return $tableau_mail;
}
/**
* getMailAdmin Renvoie un tableau de mail des super administrateurs
*
* @global DB Un objet DB de PEAR $GLOBALS['_BAZAR_']['db']
*/
function getMailSuperAdmin() {
$requete = 'select '.BAZ_CHAMPS_EMAIL.' from '.BAZ_ANNUAIRE.', bazar_droits ' .
'where bd_niveau_droit="'.BAZ_DROIT_SUPER_ADMINISTRATEUR.'"' .
' and '.BAZ_CHAMPS_ID.'= bd_id_utilisateur';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete);
if (DB::isError($resultat)) $this->raiseError();
$tableau_mail = array();
if ($resultat->numRows() == 0) return false;
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
array_push ($tableau_mail, $ligne[BAZ_CHAMPS_EMAIL]) ;
}
return $tableau_mail;
}
/**
* notifier() envoie un message aux administrateurs
*
* par defaut lors du depot ou de la modification d une fiche
*/
function notifier($type = BAZAR_NOTIFICATION_NOUVELLE_FICHE) {
switch ($type) {
case BAZAR_NOTIFICATION_NOUVELLE_FICHE :
$id_sujet = BAZ_TEMPLATE_MAIL_NOUVELLE_FICHE_SUJET;
$id_corps = BAZ_TEMPLATE_MAIL_NOUVELLE_FICHE_CORPS;
break ;
case BAZAR_NOTIFICATION_MODIFICATION_FICHE :
$id_sujet = BAZ_TEMPLATE_MAIL_MODIFIER_FICHE_SUJET;
$id_corps = BAZ_TEMPLATE_MAIL_MODIFIER_FICHE_CORPS;
break;
}
$template = new bazarTemplate($GLOBALS['_BAZAR_']['db']);
 
$sujet = html_entity_decode($template->getTemplate($id_sujet, $GLOBALS['_BAZAR_']['langue'], $GLOBALS['_BAZAR_']['id_typeannonce']));
$corps = html_entity_decode($template->getTemplate($id_corps, $GLOBALS['_BAZAR_']['langue'], $GLOBALS['_BAZAR_']['id_typeannonce']));
$corps.= $GLOBALS['_BAZAR_']['id_fiche'].'&typeannonce='.$GLOBALS['_BAZAR_']['id_typeannonce'] ;
$mails = bazar::getMailSuperAdmin($GLOBALS['_BAZAR_']['id_typeannonce']);
if (is_array ($mails)) {
foreach ($mails as $mail) {
mail ($mail, $sujet, $corps);
}
}
}
/** Effectue une requete sur bazar_nature pour remplir diverses
* globales
*
* @global string la globale de langue (ex fr-FR)
* @global int $GLOBALS['_BAZAR_']['id_typeannonce']
*
* @return mixed true ou PEAR_Error
*/
function chargeNature() {
$requete = 'SELECT bn_label_nature, bn_condition, bn_template, bn_commentaire, bn_appropriation, bn_image_titre, bn_image_logo';
$requete .= ' FROM bazar_nature WHERE bn_id_nature = '.$GLOBALS['_BAZAR_']['id_typeannonce'];
if (isset($GLOBALS['_BAZAR_']['langue'])) {
$requete .= ' and bn_ce_i18n like "'.$GLOBALS['_BAZAR_']['langue'].'%"';
}
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
return $resultat->getMessage().$resultat->getDebugInfo() ;
}
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
$GLOBALS['_BAZAR_']['typeannonce']=$ligne['bn_label_nature'];
$GLOBALS['_BAZAR_']['condition']=$ligne['bn_condition'];
$GLOBALS['_BAZAR_']['template']=$ligne['bn_template'];
$GLOBALS['_BAZAR_']['commentaire']=$ligne['bn_commentaire'];
$GLOBALS['_BAZAR_']['appropriation']=$ligne['bn_appropriation'];
$GLOBALS['_BAZAR_']['image_titre']=$ligne['bn_image_titre'];
$GLOBALS['_BAZAR_']['image_logo']=$ligne['bn_image_logo'];
return true;
}
/** Renvoie un element de formulaire de type select ou radio
* au vue de filtrer les resultats du bazar
* @global mixed $GLOBALS['_BAZAR_']['db'] identifiant de connexion a la bd
*
* @return string html
*/
function getFiltre($numero_liste, $multiple = false, $type = 'select') {
$type == 'select' ? $balise = 'select' : $balise = 'radio' ;
// chargement du template
$tableau_template = baz_valeurs_template($GLOBALS['_BAZAR_']['template']);
$html_filtre = '<select name="bazar_filtre_'.$numero_liste.'" onchange="javascript:this.form.submit();">'."\n";
// Requete dans bazar_liste_valeurs
$requete = 'select blv_valeur, blv_label from bazar_liste_valeurs where blv_ce_liste="'.$numero_liste.'"';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete);
if (DB::isError($resultat)) {
return $resultat->getMessage().$resultat->getDebugInfo() ;
}
$html_filtre .= '<option id="filtre_tous" value="*" ';
if (isset($_POST['bazar_filtre_'.$numero_liste]) && '*' == $_POST['bazar_filtre_'.$numero_liste]) {
$html_filtre .= 'selected="selected" ';
}
$html_filtre .= '>'.'Tous les événements'.'</option>';
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
$html_filtre .= '<option class="filtre_'.$ligne->blv_valeur.'" value="'.$ligne->blv_valeur.'"';
if (isset($_POST['bazar_filtre_'.$numero_liste]) && $ligne->blv_valeur == $_POST['bazar_filtre_'.$numero_liste]) {
$html_filtre .= 'selected="selected" ';
}
$html_filtre .= '>'.$ligne->blv_label.'</option>'."\n";
}
$html_filtre .= '</select>'."\n";
$resultat->free();
return $html_filtre;
}
function getFiltrePlageDeDate () {
if (isset ($_POST['date_debut'])) {
$defaut_debut = $_POST['date_debut'];
} else {
$defaut_debut = '';
}
if (isset ($_POST['date_fin'])) {
$defaut_fin = $_POST['date_fin'];
} else {
$defaut_fin = '';
}
 
$formulaire_filtre = 'du <input type="text" readonly size="10" name="date_debut" class="inputDate" id="date_debut" value="'.$defaut_debut.'" />';
$formulaire_filtre .= ' au <input type="text" readonly size="10" name="date_fin" class="inputDate" id="date_fin" value="'.$defaut_fin.'" />';
$formulaire_filtre .= "\n".'<script language="javascript" type="text/javascript">' ."\n".
'
if (typeof(addListener) != \'function\') {
// fonction portable pour ajout de listeners
function addListener(element, baseName, handler)
{
if (element.addEventListener) {
element.addEventListener(baseName, handler, false) ;
} else if (element.attachEvent) {
element.attachEvent(\'on\'+baseName, handler) ;
}
}
}
function verifDate()
{
if (document.getElementById("date_debut") != null && document.getElementById("date_fin") != null) {
this.form.submit() ;
}
}
var calDateFin = document.getElementById("date_fin") ;
addListener(calDateFin,\'change\',verifDate) ;
var calDateDeb = document.getElementById("date_debut") ;
addListener(calDateDeb,\'change\',verifDate) ;
$(document).ready(function() { $(\'#date_debut, #date_fin\').datepicker($.extend({}, $.datepicker.regional["fr-FR"],{
dateFormat:\'dd-mm-yy\',
buttonImage: "client/bazar/images/cal.png",
showOn: "both",
beforeShow: customRange,
buttonImageOnly: true'."\n".
'}));})' ."\n".
'function customRange(input) { return {minDate: (input.id == "date_fin" ? $("#date_debut").datepicker("getDate") : null),
maxDate: (input.id == "date_debut" ? $("#date_fin").datepicker("getDate") : null)};}' ."\n".
'</script>';
 
return $formulaire_filtre;
}
/** Renvoie le formulaire d un filtre
* utile dans la carte google ou dans le calendrier
*
* @param string le template avec des filtres ecrits comme {filtre liste="12"}
* @global mixed $GLOBALS['_BAZAR_']['url']
* @return string html
*/
function getFormulaireFiltre($template) {
if (preg_match_all ('/{filtre liste="([0-9]+)"}/', $template, $subpattern)) {
$formulaire_filtre = '<form action="'.$GLOBALS['_BAZAR_']['url']->getURL().'" method="post">'."\n";
$formulaire_filtre .= '<fieldset><legend>Filtrer : </legend>';
for ($i = 0; $i <count($subpattern[1]); $i++) {
$formulaire_filtre .= bazar::getFiltre($subpattern[1][$i]) ;
}
$formulaire_filtre .= bazar::getFiltrePlageDeDate();
$formulaire_filtre .= '<input type="submit" value="Filtrer" />';
$formulaire_filtre .= '</fieldset>';
$formulaire_filtre .= '</form>'."\n";
$html = preg_replace ('/{filtre liste="([0-9]+)"}/', $formulaire_filtre, $template);
}
return $html;
}
}
 
class Bazar_element {
function &factory($type, $options = false)
{
if (file_exists (BAZ_CHEMIN_APPLI."bibliotheque/elements/{$type}.php")) include_once BAZ_CHEMIN_APPLI."bibliotheque/elements/{$type}.php";
else return PEAR::raiseError("Impossible d inclure le fichier /{$type}.php", "Impossible d inclure le fichier ".
BAZ_CHEMIN_APPLI."bibliotheque/elements/{$type}.php<br />", null, null,
"Impossible d inclure le fichier /{$type}.php"
, 'PEAR_Error', true);;
$classname = "Bazar_{$type}";
 
if (!class_exists($classname)) {
$tmp = PEAR::raiseError(null, -2, null, null,
"la classe $classname n'existe pas"
, 'PEAR_Error', true);
return $tmp;
}
 
@$obj =& new $classname($options);
 
return $obj;
}
}
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: bazar.class.php,v $
* Revision 1.10 2008-09-17 14:08:45 alexandre_tb
* merge depuis aha
*
* Revision 1.9 2007-10-10 13:27:06 alexandre_tb
* encodage et remplacement de die en return
*
* Revision 1.8 2007-10-01 10:35:14 alexandre_tb
* petit hack pour tester la presence de $GLOBALS['droit_depot'] qui indique le niveau de droit minimum pour pouvoir deposer une fiche.
*
* Revision 1.7 2007-07-04 09:59:09 alexandre_tb
* ajout de la classe bazar, premices d une structuration du code
*
* Revision 1.6 2007/04/20 09:58:06 neiluj
* correction bug $this->_id_utilisateur
*
* Revision 1.5 2007/04/11 08:30:12 neiluj
* remise en état du CVS...
*
* Revision 1.3.2.1 2007/03/07 16:49:21 jp_milcent
* Mise en majuscule de select
*
* Revision 1.3 2006/03/29 13:05:12 alexandre_tb
* ajout de la classe Administrateur_bazar
*
* Revision 1.2 2006/02/09 11:06:12 alexandre_tb
* changement dans les id des droit
* 0 => super administrateur
* 1 => redacteur
* 2 => administrateur
*
* Revision 1.1 2006/02/07 11:08:06 alexandre_tb
* version initiale
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>
/trunk/bibliotheque/bazar.fonct.cal.php
1,506 → 1,511
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: bazar.fonct.cal.php,v 1.29 2008-10-29 10:38:51 alexandre_tb Exp $
/**
*
* Fonctions calendrier du module bazar
*
* TODO : ajouter la gestion du multilinguisme
*
*@package bazar
//Auteur original :
*@author David Delon <david.delon@clapas.net>
//Autres auteurs :
*@copyright Tela-Botanica 2000-2004
*@version $Revision: 1.29 $ $Date: 2008-10-29 10:38:51 $
// +------------------------------------------------------------------------------------------------------+
*/
 
// +------------------------------------------------------------------------------------------------------+
// | ENTETE du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
 
require_once PAP_CHEMIN_RACINE.'api/pear/Calendar/Month/Weekdays.php';
require_once PAP_CHEMIN_RACINE.'api/pear/Calendar/Day.php';
require_once PAP_CHEMIN_RACINE.'api/pear/Calendar/Decorator.php';
 
// +------------------------------------------------------------------------------------------------------+
// | LISTE de FONCTIONS |
// +------------------------------------------------------------------------------------------------------+
 
// Classe Utilitaire pour Calendrier
class DiaryEvent extends Calendar_Decorator {
var $entry = array();
function DiaryEvent($calendar)
{
Calendar_Decorator::Calendar_Decorator($calendar);
}
function setEntry($entry)
{
$this->entry[] = $entry;
 
}
function getEntry()
{
return $this->entry;
}
}
 
 
// $type : calendrier
// $type : calendrier_appplette
function GestionAffichageCalendrier($arguments = array(), $type = 'calendrier') {
$script = '';
// recuperation des arguments de l applette
$balise = isset ($arguments[0]) ? $arguments[0] : '';
$tab_arguments = $arguments;
if (is_string ($tab_arguments)) {
$tab_arguments = substr($tab_arguments, 1);
} else {
unset($tab_arguments[0]);
}
if (is_array($tab_arguments)) {
foreach($tab_arguments as $argument) {
if ($argument != '') {
$tab_parametres = explode('=', $argument, 2);
if (is_array($tab_parametres)) {
$options[$tab_parametres[0]] =
(isset($tab_parametres[1])? trim($tab_parametres[1], '"') : '') ;
}
}
}
}
 
if (!isset($options['template'])) {
$options['template'] = BAZ_CHEMIN_SQUELETTE.BAZ_SQUELETTE_DEFAUT;
} else {
if (file_exists(BAZ_CHEMIN_SQUELETTE.$options['template'])) {
$options['template'] = BAZ_CHEMIN_SQUELETTE.$options['template'];
}
}
 
$retour = '';
 
$url = $GLOBALS['_GEN_commun']['url'] ;
$db =& $GLOBALS['_GEN_commun']['pear_db'] ;
$auth =& $GLOBALS['_GEN_commun']['pear_auth'] ;
 
// Nettoyage de l'url de la query string
$chaine_url = $url->getQueryString();
$tab_params = explode('&amp;', $chaine_url);
if (count($tab_params) == 0) {
$tab_params = explode('&', $chaine_url);
}
foreach ($tab_params as $param) {
$tab_parametre = explode('=', $param);
$url->removeQueryString($tab_parametre[0]);
}
 
if (!isset($_GET['y'])) {
$_GET['y'] = date('Y');
}
 
if (!isset($_GET['m'])) {
$_GET['m'] = date('m');
}
 
// Construction Mois en Cours
$month = new Calendar_Month_Weekdays($_GET['y'],$_GET['m']);
 
$curStamp = $month->getTimeStamp();
$url->addQueryString('y', date('Y',$curStamp));
$url->addQueryString('m', date('n',$curStamp));
$url->addQueryString('d', date('j',$curStamp));
$cur = $url->getUrl();
 
// Gestion de l'affichage du filtre des natures d'évènements
$cal_num_annonce = BAZ_NUM_ANNONCE_CALENDRIER;
$ficnat_id = null;
if (isset($_GET['ficnat']) && $_GET['ficnat'] != '*') {
$ficnat_id = $_GET['ficnat'];
$url->addQueryString('ficnat', $_GET['ficnat']);
$cal_num_annonce = $_GET['ficnat'];
}
 
// Gestion de l'affichage des titres des évènements
if (isset($_GET['ctt']) && $_GET['ctt'] == '1') {
$url->addQueryString('tt', '0');
if (isset($_GET['tt']) && $_GET['tt'] == '0') {
$url->addQueryString('tt', '1');
}
$tc_lien = $url->getUrl();
} else {
$url->addQueryString('tt', '0');
if (isset($_GET['tt']) && $_GET['tt'] == '0') {
$url->addQueryString('tt', '1');
}
$url->addQueryString('ctt', '1');
$tc_lien = $url->getUrl();
}
$url->removeQueryString('ctt');
$url->removeQueryString('tt');
$tc_txt = 'Afficher les titres complets des évènements';
if (isset($_GET['tt']) && $_GET['tt'] == '0') {
$tc_txt = 'Tronquer les titres des évènements';
$url->addQueryString('tt', $_GET['tt']);
}
 
// Gestion des champs cachés pour le formulaire de filtre
// Attention à la position dans le fichier...
$ficnat_chps_cache = $url->querystring;
unset($ficnat_chps_cache['ficnat']);
 
// Navigation
$prevStamp = $month->prevMonth(true);
$url->addQueryString('y', date('Y',$prevStamp));
$url->addQueryString('m', date('n',$prevStamp));
$url->addQueryString('d', date('j',$prevStamp));
$prev = $url->getUrl();
 
$nextStamp = $month->nextMonth(true);
$url->addQueryString('y', date('Y',$nextStamp));
$url->addQueryString('m', date('n',$nextStamp));
$url->addQueryString('d', date('j',$nextStamp));
$next = $url->getUrl();
 
// Suppression du paramêtre de troncage des titres
$url->removeQueryString('tt');
 
$fr_month = array( "1"=>BAZ_JANVIER,"2"=>BAZ_FEVRIER,"3"=>BAZ_MARS,"4"=>BAZ_AVRIL,"5"=>BAZ_MAI,"6"=>BAZ_JUIN,
"7"=>BAZ_JUILLET,"8"=>BAZ_AOUT,"9"=>BAZ_SEPTEMBRE,"10"=>BAZ_OCTOBRE,"11"=>BAZ_NOVEMBRE,"12"=>BAZ_DECEMBRE);
 
// Récupération des infos sur les natures des fiches pour le filtre
$requete_nature_fiche = 'SELECT DISTINCT bn_id_nature, bn_ce_i18n, bn_label_nature '.
'FROM bazar_nature '.
'WHERE bn_id_nature IN ('.BAZ_NUM_ANNONCE_CALENDRIER.') ';
$resultat_nature_fiche = $db->query($requete_nature_fiche);
(DB::isError($resultat_nature_fiche)) ? trigger_error(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat_nature_fiche->getMessage(), $requete_nature_fiche), E_USER_WARNING) : '';
 
// Ajout du javascript et des styles du bazar
if (defined('PAP_VERSION')) { //si on est dans Papyrus
GEN_stockerStyleExterne( 'bazar_interne', 'client/bazar/bazar.interne.css');
GEN_stockerFichierScript('domLib', '/api/js/domtooltip/domLib.js');
GEN_stockerFichierScript('domTT', '/api/js/domtooltip/domTT.js');
 
// DomToolTip
$script = 'var domTT_styleClass = "niceTitle";'."\n";
$script .= 'function nicetitleDecorator(el) {'."\n";
$script .= ' var result = el.title;'."\n";
$script .= ' result = result.replace(new RegExp("\n", "g"), "<br />");'."\n";
$script .= ' //if (el.href) {'."\n";
$script .= ' //result += "<p>" + el.href + "<\/p>";'."\n";
$script .= ' //}'."\n";
$script .= ' return result;'."\n";
$script .= '}'."\n";
$script .= 'domTT_replaceTitles(nicetitleDecorator);'."\n";
GEN_stockerCodeScript('var domTT_styleClass = "niceTitle";'."\n");
}
 
// Titre
if ($type == 'calendrier') {
$retour .= '<div id="cal_entete">'."\n";
$retour .= '<span class="cal_navigation">'."\n";
$retour .= '<a id="cal_precedent_lien" href="'.$prev.'" title="Allez au mois précédent"><img id="cal_precedent_img" src="client/bazar/images/cal_precedent.png" alt="&lt;&lt;"/></a>'."\n";
$retour .= '&nbsp;&nbsp;'."\n";
$retour .= '<span id="cal_encadre_mois_courrant"><a id="cal_mois_courrant" href="'.$cur.'">';
$retour .= $fr_month[(date('n',$curStamp))];
$retour .= '&nbsp;';
$retour .= (date('Y',$curStamp));
$retour .= '</a></span>'."\n";
$retour .= '&nbsp;&nbsp;'."\n";
$retour .= '<a id="cal_suivant_lien" href="'.$next.'" title="Allez au mois suivant"><img id="cal_suivant_img" src="client/bazar/images/cal_suivant.png" alt="&gt;&gt;"/></a>'."\n";
$retour .= '</span>'."\n";
$retour .= '<h1 id="cal_titre"><img id="cal_titre_img" src="client/bazar/images/cal_titre.png" alt="Calendrier"/></h1>'."\n";
$retour .= '</div>'."\n";
 
$retour .= '<form action="'.$tc_lien.'" method="get">'."\n";
$retour .= '<a href="'.$tc_lien.'">'.$tc_txt.'</a>'."\n";
$retour .= '<fieldset>'."\n";
$retour .= '<legend>'.'Filtrer : '.'</legend>'."\n";
$retour .= '<select id="ficnat" name="ficnat" class="filtre_'.((!is_null($ficnat_id)) ? $ficnat_id: 'tous').'" onchange="javascript:this.form.submit();">'."\n";
 
$retour .= '<option id="filtre_tous" value="*" ';
if (isset($_GET['ficnat']) && '*' == $_GET['ficnat']) {
$retour .= 'selected="selected" ';
}
$retour .= '>'.'Tout afficher'.'</option>';
 
while ($ligne_nature_fiche = $resultat_nature_fiche->fetchRow(DB_FETCHMODE_OBJECT)) {
$opt = '<option class="filtre_'.$ligne_nature_fiche->bn_id_nature.'" value="'.$ligne_nature_fiche->bn_id_nature.'" ';
if (isset($_GET['ficnat']) && $ligne_nature_fiche->bn_id_nature == $_GET['ficnat']) {
$opt .= 'selected="selected" ';
}
$opt .= '>';
 
$retour .= $opt.$ligne_nature_fiche->bn_label_nature.'</option>'."\n";
}
 
$retour .= '</select>'."\n";
$retour .= '<input id="ficnat_ok" type="submit" value="'.'OK'.'" onload="javascript:this.setAttribute(\'style\', \'display:none;\')"/>'."\n";
$script_ok = 'if (document.getElementById(\'ficnat_ok\')) {'.
' document.getElementById(\'ficnat_ok\').style.display = \'none\';'.
'}';
$retour.= '<script type="text/javascript">//<![CDATA['."\n".$script_ok.'//]]></script>'."\n";
foreach ($ficnat_chps_cache as $cle => $val) {
$retour .= '<input id="'.$cle.'" name="'.$cle.'" type="hidden" value="'.$val.'" />'."\n";
}
$retour .= '</fieldset>'."\n";
$retour .= '</form>'."\n";
 
} else {
// Appel du template
ob_start();
include $options['template'];
$retour .= ob_get_contents();
ob_end_clean();
}
// Vue Mois calendrier ou vue applette
 
if ((!isset($_GET['id_fiche']) && $type == 'calendrier') || ($type == 'calendrier_applette')){
// trigger_error('ICI', E_USER_NOTICE);
// Recherche evenement de la periode selectionnée
$ts_jour_fin_mois = $month->nextMonth('timestamp');
$ts_jour_debut_mois = $month->thisMonth('timestamp');;
$requete_evenements = "SELECT DISTINCT bf_id_fiche, bf_titre, bf_lieu_evenement, ".
" DAY(bf_date_debut_evenement) AS bf_jour_debut_evenement, bf_date_debut_evenement, ".
" bf_date_fin_evenement, bf_description, bn_id_nature ".
"FROM bazar_fiche, bazar_nature ".
"WHERE bf_date_debut_evenement < '".date('Y-m-d', $ts_jour_fin_mois)."' ".
"AND bf_date_fin_evenement >= '".date('Y-m-d', $ts_jour_debut_mois)."' ".
"AND bf_ce_nature = bn_id_nature ".
"AND bn_id_nature IN (".$cal_num_annonce.") ".
"AND bf_statut_fiche = 1 ".
"ORDER BY bf_jour_debut_evenement";
 
$resultat_evenement = $db->query($requete_evenements);
 
(DB::isError($resultat_evenement)) ? trigger_error(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat_evenement->getMessage(), $requete_evenements), E_USER_WARNING) : '';
 
$selection = array();
$evenements = array();
$annee = date('Y', $curStamp);
$mois = date('m', $curStamp);
$tablo_jours = array();
while ($ligne_evenements = $resultat_evenement->fetchRow(DB_FETCHMODE_OBJECT)) {
list($annee_debut, $mois_debut, $jour_debut) = explode('-', $ligne_evenements->bf_date_debut_evenement);
list($annee_fin, $mois_fin, $jour_fin) = explode('-', $ligne_evenements->bf_date_fin_evenement);
 
$Calendrier = new Calendar($annee_debut, $mois_debut, $jour_debut);
$ts_jour_suivant = $Calendrier->thisDay('timestamp');
$ts_jour_fin = mktime(0,0,0,$mois_fin, $jour_fin, $annee_fin);
 
$naviguer = true;
while ($naviguer && ($ts_jour_suivant <= $ts_jour_fin)) {
// Si le jours suivant est inferieur a la date de fin du mois courrant, on continue...
if ($ts_jour_suivant < $ts_jour_fin_mois) {
$cle_j = date('Y-m-d', $ts_jour_suivant);
if (!isset($tablo_jours[$cle_j])) {
$tablo_jours[$cle_j]['Calendar_Day'] = new Calendar_Day(date('Y', $ts_jour_suivant),date('m', $ts_jour_suivant), date('d', $ts_jour_suivant));
$tablo_jours[$cle_j]['Diary_Event'] = new DiaryEvent($tablo_jours[$cle_j]['Calendar_Day']);
}
$tablo_jours[$cle_j]['Diary_Event']->setEntry($ligne_evenements);
 
$ts_jour_suivant = $Calendrier->nextDay('timestamp');
//echo "ici$ts_jour_suivant-";
$Calendrier->setTimestamp($ts_jour_suivant);
//echo "la".$Calendrier->thisDay('timestamp')."-";
} else {
$naviguer = false;
}
}
}
 
 
// Add the decorator to the selection
foreach ($tablo_jours as $jour) {
$selection[] = $jour['Diary_Event'];
}
 
// Affichage Calendrier
$month->build($selection);
if ($type == 'calendrier') {
$retour.= '<table class="calendrier">'.
'<colgroup>'.
'<col class="cal_lundi"/>'.
'<col class="cal_mardi"/>'.
'<col class="cal_mercredi"/>'.
'<col class="cal_jeudi"/>'.
'<col class="cal_vendredi"/>'.
'<col class="cal_samedi"/>'.
'<col class="cal_dimanche"/>'.
'</colgroup>'.
'<thead>'.
"<tr>
 
<th> ". BAZ_LUNDI ."</th>
<th> ". BAZ_MARDI ."</th>
<th> ". BAZ_MERCREDI ."</th>
<th> ". BAZ_JEUDI ."</th>
<th> ". BAZ_VENDREDI ."</th>
<th> ". BAZ_SAMEDI ."</th>
<th> ". BAZ_DIMANCHE ."</th>
</tr>
".'</thead>'.'<tbody>';
} else {
$retour.= '<table class="calendrier_applette">'.
'<colgroup>'.
'<col class="cal_lundi"/>'.
'<col class="cal_mardi"/>'.
'<col class="cal_mercredi"/>'.
'<col class="cal_jeudi"/>'.
'<col class="cal_vendredi"/>'.
'<col class="cal_samedi"/>'.
'<col class="cal_dimanche"/>'.
'</colgroup>'.
'<thead>'.
"<tr>
 
<th> ". BAZ_LUNDI_COURT ."</th>
<th> ". BAZ_MARDI_COURT ."</th>
<th> ". BAZ_MERCREDI_COURT ."</th>
<th> ". BAZ_JEUDI_COURT ."</th>
<th> ". BAZ_VENDREDI_COURT ."</th>
<th> ". BAZ_SAMEDI_COURT ."</th>
<th> ". BAZ_DIMANCHE_COURT ."</th>
</tr>
".'</thead>'.'<tbody>';
}
 
$todayStamp=time();
$today_ymd=date('Ymd',$todayStamp);
 
// Other month : mois
while ($day = $month->fetch() ) {
$dayStamp = $day->thisDay(true);
$day_ymd = date('Ymd',$dayStamp);
if ( $day->isEmpty() ) {
$class = "cal_ma other_month";
} else {
if (($day_ymd < $today_ymd)) {
$class= "cal_mp previous_month";
} else {
if ($day_ymd == $today_ymd) {
$class= "cal_jc current_day";
} else {
$class="cal_mc current_month";
}
}
}
 
$url->addQueryString ('y', date('Y',$dayStamp));
$url->addQueryString ('m', date('n',$dayStamp));
$url->addQueryString ('d', date('j',$dayStamp));
$link = $url->getUrl();
 
// isFirst() to find start of week
if ($day->isFirst()) {
$retour.= ( "<tr>\n" );
}
if ($type == 'calendrier') {
$retour.= "<td class=\"".$class."\">".'<span class="cal_j">'.$day->thisDay().'</span>'."\n";
if ($day->isSelected() ) {
$evenements = $day->getEntry();
$evenements_nbre = count($evenements);
$evenemt_xhtml = '';
while ($ligne_evenement = array_pop($evenements)) {
$id_fiches = array();
$id_fiches[] = $ligne_evenement->bf_id_fiche;
$url->addQueryString ('id_fiches',$id_fiches);
$link = $url->getUrl();
 
if (!isset($_GET['tt']) || (isset($_GET['tt']) && $_GET['tt'] == '1')) {
$titre_taille = strlen($ligne_evenement->bf_titre);
$titre = ($titre_taille > 20)?substr($ligne_evenement->bf_titre, 0, 20).'...':$ligne_evenement->bf_titre;
} else {
$titre = $ligne_evenement->bf_titre;
}
$evenemt_xhtml .= '<li class="tooltip nature_'.$ligne_evenement->bn_id_nature.'" title="'.str_replace('"', '\'', $ligne_evenement->bf_titre).'"><a class="cal_evenemt" href="'.$link.'">'.$titre.'</a></li>'."\n";
$url->removeQueryString ('id_fiches');
}
if ($evenements_nbre > 0) {
$retour .= '<ul class="cal_evenemt_liste">';
$retour .= $evenemt_xhtml;
$retour .= '</ul>';
}
}
} else {
$lien_date= "<td class=\"".$class."\">".$day->thisDay();
if ($day->isSelected() ) {
$evenements = $day->getEntry();
$id_fiches = array();
$info_fiches = null;
while ($ligne_evenement = array_pop($evenements)) {
$id_fiches[] = $ligne_evenement->bf_id_fiche;
$info_fiches .= '&rArr; '.str_replace('"', '\'', $ligne_evenement->bf_titre)."\n";
}
$url->addQueryString('id_fiches', $id_fiches);
$link = $url->getUrl();
$lien_date = '<td class="'.$class.'"><a href="'.$link.'" class="tooltip" title="'.$info_fiches.'">'.$day->thisDay()."</a>\n";
$url->removeQueryString('id_fiches');
}
$retour .= $lien_date;
}
$retour.= ( "</td>\n" );
 
// isLast() to find end of week
if ( $day->isLast() ) {
$retour.= ( "</tr>\n" );
}
}
$retour.= "</tbody></table>";
}
$retour.= '<script type="text/javascript">//<![CDATA['."\n".$script.'//]]></script>'."\n";
// Vue detail
 
if ((isset($_GET['id_fiches']))) {
// Ajout d'un titre pour la page avec la date
$jours = array ('dimanche', 'lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi') ;
$mois = array ('janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre',
'octobre', 'novembre', 'décembre') ;
$timestamp = strtotime ($_GET['y'].'/'.$_GET['m'].'/'.$_GET['d']) ;
 
$GLOBALS['_PAPYRUS_']['rendu']['CONTENU_NAVIGATION'] = '';
$GLOBALS['_PAPYRUS_']['rendu']['CONTENU_TETE'] = '';
$GLOBALS['_PAPYRUS_']['rendu']['CONTENU_CORPS'] = '<h1>'.$jours[date('w', $timestamp)].
' '.$_GET['d'].' '.$mois[$_GET['m']-1].' '.$_GET['y'].'</h1>' ;
$GLOBALS['_PAPYRUS_']['rendu']['CONTENU_CORPS'] .= baz_voir_fiches(0,$_GET['id_fiches'] );
 
$GLOBALS['_GEN_commun']['info_menu'] = '';
 
// Un lien pour retourner au calendrier
$url->removeQueryString('id_fiches');
$url->removeQueryString('y');
$url->removeQueryString('m');
$url->removeQueryString('d');
$GLOBALS['_PAPYRUS_']['rendu']['CONTENU_PIED'] = '<div class="retour"><a href="'.$url->getURL().'">Retour au calendrier</a></div>';
}
 
// Nettoyage de l'url
$url->removeQueryString('id_fiches');
$url->removeQueryString('y');
$url->removeQueryString('m');
$url->removeQueryString('d');
 
 
return $retour;
}
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: bazar.fonct.cal.php,v 1.29 2008-10-29 10:38:51 alexandre_tb Exp $
/**
*
* Fonctions calendrier du module bazar
*
* TODO : ajouter la gestion du multilinguisme
*
*@package bazar
//Auteur original :
*@author David Delon <david.delon@clapas.net>
//Autres auteurs :
*@copyright Tela-Botanica 2000-2004
*@version $Revision: 1.29 $ $Date: 2008-10-29 10:38:51 $
// +------------------------------------------------------------------------------------------------------+
*/
 
// +------------------------------------------------------------------------------------------------------+
// | ENTETE du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
 
require_once PAP_CHEMIN_RACINE.'api/pear/Calendar/Month/Weekdays.php';
require_once PAP_CHEMIN_RACINE.'api/pear/Calendar/Day.php';
require_once PAP_CHEMIN_RACINE.'api/pear/Calendar/Decorator.php';
 
// +------------------------------------------------------------------------------------------------------+
// | LISTE de FONCTIONS |
// +------------------------------------------------------------------------------------------------------+
 
// Classe Utilitaire pour Calendrier
class DiaryEvent extends Calendar_Decorator {
var $entry = array();
function DiaryEvent($calendar)
{
Calendar_Decorator::Calendar_Decorator($calendar);
}
function setEntry($entry)
{
$this->entry[] = $entry;
}
function getEntry()
{
return $this->entry;
}
}
 
 
// $type : calendrier
// $type : calendrier_appplette
function GestionAffichageCalendrier($arguments = array(), $type = 'calendrier') {
$script = '';
// recuperation des arguments de l applette
$balise = isset ($arguments[0]) ? $arguments[0] : '';
$tab_arguments = $arguments;
if (is_string ($tab_arguments)) {
$tab_arguments = substr($tab_arguments, 1);
} else {
unset($tab_arguments[0]);
}
if (is_array($tab_arguments)) {
foreach($tab_arguments as $argument) {
if ($argument != '') {
$tab_parametres = explode('=', $argument, 2);
if (is_array($tab_parametres)) {
$options[$tab_parametres[0]] =
(isset($tab_parametres[1])? trim($tab_parametres[1], '"') : '') ;
}
}
}
}
if (!isset($options['template'])) {
$options['template'] = BAZ_CHEMIN_SQUELETTE.BAZ_SQUELETTE_DEFAUT;
} else {
if (file_exists(BAZ_CHEMIN_SQUELETTE.$options['template'])) {
$options['template'] = BAZ_CHEMIN_SQUELETTE.$options['template'];
}
}
$retour = '';
 
$url = $GLOBALS['_GEN_commun']['url'] ;
$db =& $GLOBALS['_GEN_commun']['pear_db'] ;
$auth =& $GLOBALS['_GEN_commun']['pear_auth'] ;
// Nettoyage de l'url de la query string
$chaine_url = $url->getQueryString();
$tab_params = explode('&amp;', $chaine_url);
if (count($tab_params) == 0) {
$tab_params = explode('&', $chaine_url);
}
foreach ($tab_params as $param) {
$tab_parametre = explode('=', $param);
// note d'Aurélien, si on nettoie l'URL on perd la vue en cours
//$url->removeQueryString($tab_parametre[0]);
}
if (!isset($_GET['y'])) {
$_GET['y'] = date('Y');
}
if (!isset($_GET['m'])) {
$_GET['m'] = date('m');
}
// Construction Mois en Cours
$month = new Calendar_Month_Weekdays($_GET['y'],$_GET['m']);
 
$curStamp = $month->getTimeStamp();
$url->addQueryString('y', date('Y',$curStamp));
$url->addQueryString('m', date('n',$curStamp));
$url->addQueryString('d', date('j',$curStamp));
$cur = $url->getUrl();
 
// Gestion de l'affichage du filtre des natures d'évènements
$cal_num_annonce = BAZ_NUM_ANNONCE_CALENDRIER;
$ficnat_id = null;
if (isset($_GET['ficnat']) && $_GET['ficnat'] != '*') {
$ficnat_id = $_GET['ficnat'];
$url->addQueryString('ficnat', $_GET['ficnat']);
$cal_num_annonce = $_GET['ficnat'];
}
 
// Gestion de l'affichage des titres des évènements
if (isset($_GET['ctt']) && $_GET['ctt'] == '1') {
$url->addQueryString('tt', '0');
if (isset($_GET['tt']) && $_GET['tt'] == '0') {
$url->addQueryString('tt', '1');
}
$tc_lien = $url->getUrl();
} else {
$url->addQueryString('tt', '0');
if (isset($_GET['tt']) && $_GET['tt'] == '0') {
$url->addQueryString('tt', '1');
}
$url->addQueryString('ctt', '1');
$tc_lien = $url->getUrl();
}
$url->removeQueryString('ctt');
$url->removeQueryString('tt');
$tc_txt = 'Afficher les titres complets des évènements';
if (isset($_GET['tt']) && $_GET['tt'] == '0') {
$tc_txt = 'Tronquer les titres des évènements';
$url->addQueryString('tt', $_GET['tt']);
}
 
// Gestion des champs cachés pour le formulaire de filtre
// Attention à la position dans le fichier...
$ficnat_chps_cache = $url->querystring;
unset($ficnat_chps_cache['ficnat']);
// Navigation
$prevStamp = $month->prevMonth(true);
$url->addQueryString('y', date('Y',$prevStamp));
$url->addQueryString('m', date('n',$prevStamp));
$url->addQueryString('d', date('j',$prevStamp));
$prev = $url->getUrl();
$nextStamp = $month->nextMonth(true);
$url->addQueryString('y', date('Y',$nextStamp));
$url->addQueryString('m', date('n',$nextStamp));
$url->addQueryString('d', date('j',$nextStamp));
$next = $url->getUrl();
// Suppression du paramêtre de troncage des titres
$url->removeQueryString('tt');
$fr_month = array( "1"=>BAZ_JANVIER,"2"=>BAZ_FEVRIER,"3"=>BAZ_MARS,"4"=>BAZ_AVRIL,"5"=>BAZ_MAI,"6"=>BAZ_JUIN,
"7"=>BAZ_JUILLET,"8"=>BAZ_AOUT,"9"=>BAZ_SEPTEMBRE,"10"=>BAZ_OCTOBRE,"11"=>BAZ_NOVEMBRE,"12"=>BAZ_DECEMBRE);
 
// Récupération des infos sur les natures des fiches pour le filtre
$requete_nature_fiche = 'SELECT DISTINCT bn_id_nature, bn_ce_i18n, bn_label_nature '.
'FROM bazar_nature '.
'WHERE bn_id_nature IN ('.BAZ_NUM_ANNONCE_CALENDRIER.') ';
$resultat_nature_fiche = $db->query($requete_nature_fiche);
(DB::isError($resultat_nature_fiche)) ? trigger_error(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat_nature_fiche->getMessage(), $requete_nature_fiche), E_USER_WARNING) : '';
// Ajout du javascript et des styles du bazar
if (defined('PAP_VERSION')) { //si on est dans Papyrus
GEN_stockerStyleExterne( 'bazar_interne', 'client/bazar/bazar.interne.css');
GEN_stockerFichierScript('domLib', '/api/js/domtooltip/domLib.js');
GEN_stockerFichierScript('domTT', '/api/js/domtooltip/domTT.js');
// DomToolTip
$script = 'var domTT_styleClass = "niceTitle";'."\n";
$script .= 'function nicetitleDecorator(el) {'."\n";
$script .= ' var result = el.title;'."\n";
$script .= ' result = result.replace(new RegExp("\n", "g"), "<br />");'."\n";
$script .= ' //if (el.href) {'."\n";
$script .= ' //result += "<p>" + el.href + "<\/p>";'."\n";
$script .= ' //}'."\n";
$script .= ' return result;'."\n";
$script .= '}'."\n";
$script .= 'domTT_replaceTitles(nicetitleDecorator);'."\n";
GEN_stockerCodeScript('var domTT_styleClass = "niceTitle";'."\n");
}
// Titre
if ($type == 'calendrier') {
$retour .= '<div id="cal_entete">'."\n";
$retour .= '<span class="cal_navigation">'."\n";
$retour .= '<a id="cal_precedent_lien" href="'.$prev.'" title="Allez au mois précédent"><img id="cal_precedent_img" src="client/bazar/images/cal_precedent.png" alt="&lt;&lt;"/></a>'."\n";
$retour .= '&nbsp;&nbsp;'."\n";
$retour .= '<span id="cal_encadre_mois_courrant"><a id="cal_mois_courrant" href="'.$cur.'">';
$retour .= $fr_month[(date('n',$curStamp))];
$retour .= '&nbsp;';
$retour .= (date('Y',$curStamp));
$retour .= '</a></span>'."\n";
$retour .= '&nbsp;&nbsp;'."\n";
$retour .= '<a id="cal_suivant_lien" href="'.$next.'" title="Allez au mois suivant"><img id="cal_suivant_img" src="client/bazar/images/cal_suivant.png" alt="&gt;&gt;"/></a>'."\n";
$retour .= '</span>'."\n";
$retour .= '<h1 id="cal_titre"><img id="cal_titre_img" src="client/bazar/images/cal_titre.png" alt="Calendrier"/></h1>'."\n";
$retour .= '</div>'."\n";
$retour .= '<form action="'.$tc_lien.'" method="get">'."\n";
$retour .= '<a href="'.$tc_lien.'">'.$tc_txt.'</a>'."\n";
$retour .= '<fieldset>'."\n";
$retour .= '<legend>'.'Filtrer : '.'</legend>'."\n";
$retour .= '<select id="ficnat" name="ficnat" class="filtre_'.((!is_null($ficnat_id)) ? $ficnat_id: 'tous').'" onchange="javascript:this.form.submit();">'."\n";
$retour .= '<option id="filtre_tous" value="*" ';
if (isset($_GET['ficnat']) && '*' == $_GET['ficnat']) {
$retour .= 'selected="selected" ';
}
$retour .= '>'.'Tout afficher'.'</option>';
while ($ligne_nature_fiche = $resultat_nature_fiche->fetchRow(DB_FETCHMODE_OBJECT)) {
$opt = '<option class="filtre_'.$ligne_nature_fiche->bn_id_nature.'" value="'.$ligne_nature_fiche->bn_id_nature.'" ';
if (isset($_GET['ficnat']) && $ligne_nature_fiche->bn_id_nature == $_GET['ficnat']) {
$opt .= 'selected="selected" ';
}
$opt .= '>';
$retour .= $opt.$ligne_nature_fiche->bn_label_nature.'</option>'."\n";
}
$retour .= '</select>'."\n";
$retour .= '<input id="ficnat_ok" type="submit" value="'.'OK'.'" onload="javascript:this.setAttribute(\'style\', \'display:none;\')"/>'."\n";
$script_ok = 'if (document.getElementById(\'ficnat_ok\')) {'.
' document.getElementById(\'ficnat_ok\').style.display = \'none\';'.
'}';
$retour.= '<script type="text/javascript">//<![CDATA['."\n".$script_ok.'//]]></script>'."\n";
foreach ($ficnat_chps_cache as $cle => $val) {
$retour .= '<input id="'.$cle.'" name="'.$cle.'" type="hidden" value="'.$val.'" />'."\n";
}
$retour .= '</fieldset>'."\n";
$retour .= '</form>'."\n";
} else {
// Appel du template
ob_start();
include $options['template'];
$retour .= ob_get_contents();
ob_end_clean();
}
// Vue Mois calendrier ou vue applette
if ((!isset($_GET['id_fiche']) && $type == 'calendrier') || ($type == 'calendrier_applette')){
// trigger_error('ICI', E_USER_NOTICE);
// Recherche evenement de la periode selectionnée
$ts_jour_fin_mois = $month->nextMonth('timestamp');
$ts_jour_debut_mois = $month->thisMonth('timestamp');;
$requete_evenements = "SELECT DISTINCT bf_id_fiche, bf_titre, bf_lieu_evenement, ".
" DAY(bf_date_debut_evenement) AS bf_jour_debut_evenement, bf_date_debut_evenement, ".
" bf_date_fin_evenement, bf_description, bn_id_nature ".
"FROM bazar_fiche, bazar_nature ".
"WHERE bf_date_debut_evenement < '".date('Y-m-d', $ts_jour_fin_mois)."' ".
"AND bf_date_fin_evenement >= '".date('Y-m-d', $ts_jour_debut_mois)."' ".
"AND bf_ce_nature = bn_id_nature ".
"AND bn_id_nature IN (".$cal_num_annonce.") ".
"AND bf_statut_fiche = 1 ".
"ORDER BY bf_jour_debut_evenement";
$resultat_evenement = $db->query($requete_evenements);
(DB::isError($resultat_evenement)) ? trigger_error(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat_evenement->getMessage(), $requete_evenements), E_USER_WARNING) : '';
 
$selection = array();
$evenements = array();
$annee = date('Y', $curStamp);
$mois = date('m', $curStamp);
$tablo_jours = array();
while ($ligne_evenements = $resultat_evenement->fetchRow(DB_FETCHMODE_OBJECT)) {
list($annee_debut, $mois_debut, $jour_debut) = explode('-', $ligne_evenements->bf_date_debut_evenement);
list($annee_fin, $mois_fin, $jour_fin) = explode('-', $ligne_evenements->bf_date_fin_evenement);
$Calendrier = new Calendar($annee_debut, $mois_debut, $jour_debut);
$ts_jour_suivant = $Calendrier->thisDay('timestamp');
$ts_jour_fin = mktime(0,0,0,$mois_fin, $jour_fin, $annee_fin);
$naviguer = true;
while ($naviguer && ($ts_jour_suivant <= $ts_jour_fin)) {
// Si le jours suivant est inferieur a la date de fin du mois courrant, on continue...
if ($ts_jour_suivant < $ts_jour_fin_mois) {
$cle_j = date('Y-m-d', $ts_jour_suivant);
if (!isset($tablo_jours[$cle_j])) {
$tablo_jours[$cle_j]['Calendar_Day'] = new Calendar_Day(date('Y', $ts_jour_suivant),date('m', $ts_jour_suivant), date('d', $ts_jour_suivant));
$tablo_jours[$cle_j]['Diary_Event'] = new DiaryEvent($tablo_jours[$cle_j]['Calendar_Day']);
}
$tablo_jours[$cle_j]['Diary_Event']->setEntry($ligne_evenements);
$ts_jour_suivant = $Calendrier->nextDay('timestamp');
//echo "ici$ts_jour_suivant-";
$Calendrier->setTimestamp($ts_jour_suivant);
//echo "la".$Calendrier->thisDay('timestamp')."-";
} else {
$naviguer = false;
}
}
}
// Add the decorator to the selection
foreach ($tablo_jours as $jour) {
$selection[] = $jour['Diary_Event'];
}
// Affichage Calendrier
$month->build($selection);
if ($type == 'calendrier') {
$retour.= '<table class="calendrier">'.
'<colgroup>'.
'<col class="cal_lundi"/>'.
'<col class="cal_mardi"/>'.
'<col class="cal_mercredi"/>'.
'<col class="cal_jeudi"/>'.
'<col class="cal_vendredi"/>'.
'<col class="cal_samedi"/>'.
'<col class="cal_dimanche"/>'.
'</colgroup>'.
'<thead>'.
"<tr>
<th> ". BAZ_LUNDI ."</th>
<th> ". BAZ_MARDI ."</th>
<th> ". BAZ_MERCREDI ."</th>
<th> ". BAZ_JEUDI ."</th>
<th> ". BAZ_VENDREDI ."</th>
<th> ". BAZ_SAMEDI ."</th>
<th> ". BAZ_DIMANCHE ."</th>
</tr>
".'</thead>'.'<tbody>';
} else {
$retour.= '<table class="calendrier_applette">'.
'<colgroup>'.
'<col class="cal_lundi"/>'.
'<col class="cal_mardi"/>'.
'<col class="cal_mercredi"/>'.
'<col class="cal_jeudi"/>'.
'<col class="cal_vendredi"/>'.
'<col class="cal_samedi"/>'.
'<col class="cal_dimanche"/>'.
'</colgroup>'.
'<thead>'.
"<tr>
<th> ". BAZ_LUNDI_COURT ."</th>
<th> ". BAZ_MARDI_COURT ."</th>
<th> ". BAZ_MERCREDI_COURT ."</th>
<th> ". BAZ_JEUDI_COURT ."</th>
<th> ". BAZ_VENDREDI_COURT ."</th>
<th> ". BAZ_SAMEDI_COURT ."</th>
<th> ". BAZ_DIMANCHE_COURT ."</th>
</tr>
".'</thead>'.'<tbody>';
}
$todayStamp=time();
$today_ymd=date('Ymd',$todayStamp);
 
// Other month : mois
while ($day = $month->fetch() ) {
$dayStamp = $day->thisDay(true);
$day_ymd = date('Ymd',$dayStamp);
if ( $day->isEmpty() ) {
$class = "cal_ma other_month";
} else {
if (($day_ymd < $today_ymd)) {
$class= "cal_mp previous_month";
} else {
if ($day_ymd == $today_ymd) {
$class= "cal_jc current_day";
} else {
$class="cal_mc current_month";
}
}
}
$url->addQueryString ('y', date('Y',$dayStamp));
$url->addQueryString ('m', date('n',$dayStamp));
$url->addQueryString ('d', date('j',$dayStamp));
$link = $url->getUrl();
// isFirst() to find start of week
if ($day->isFirst()) {
$retour.= ( "<tr>\n" );
}
if ($type == 'calendrier') {
$retour.= "<td class=\"".$class."\">".'<span class="cal_j">'.$day->thisDay().'</span>'."\n";
if ($day->isSelected() ) {
$evenements = $day->getEntry();
$evenements_nbre = count($evenements);
$evenemt_xhtml = '';
while ($ligne_evenement = array_pop($evenements)) {
 
$id_fiches = array();
$id_fiches[] = $ligne_evenement->bf_id_fiche;
$url->addQueryString ('id_fiches',$id_fiches);
 
$lien_voir = new Net_Url(BAZ_URL_BASE_APPLI);
$lien_voir->addQueryString(BAZ_VARIABLE_ACTION, BAZ_VOIR_FICHE);
$lien_voir->addQueryString('id_fiche', $ligne_evenement->bf_id_fiche);
$lien_voir->addQueryString('typeannonce', $ligne_evenement->bn_id_nature);
$link=$lien_voir->getURL();
if (!isset($_GET['tt']) || (isset($_GET['tt']) && $_GET['tt'] == '1')) {
$titre_taille = strlen($ligne_evenement->bf_titre);
$titre = ($titre_taille > 20)?substr($ligne_evenement->bf_titre, 0, 20).'...':$ligne_evenement->bf_titre;
} else {
$titre = $ligne_evenement->bf_titre;
}
$evenemt_xhtml .= '<li class="tooltip nature_'.$ligne_evenement->bn_id_nature.'" title="'.str_replace('"', '\'', $ligne_evenement->bf_titre).'"><a class="cal_evenemt" href="'.$link.'">'.$titre.'</a></li>'."\n";
$url->removeQueryString ('id_fiches');
}
if ($evenements_nbre > 0) {
$retour .= '<ul class="cal_evenemt_liste">';
$retour .= $evenemt_xhtml;
$retour .= '</ul>';
}
}
} else {
$lien_date= "<td class=\"".$class."\">".$day->thisDay();
if ($day->isSelected() ) {
$evenements = $day->getEntry();
$id_fiches = array();
$info_fiches = null;
while ($ligne_evenement = array_pop($evenements)) {
$id_fiches[] = $ligne_evenement->bf_id_fiche;
$info_fiches .= '&rArr; '.str_replace('"', '\'', $ligne_evenement->bf_titre)."\n";
}
$url->addQueryString('id_fiches', $id_fiches);
$link = $url->getUrl();
$lien_date = '<td class="'.$class.'"><a href="'.$link.'" class="tooltip" title="'.$info_fiches.'">'.$day->thisDay()."</a>\n";
$url->removeQueryString('id_fiches');
}
$retour .= $lien_date;
}
$retour.= ( "</td>\n" );
// isLast() to find end of week
if ( $day->isLast() ) {
$retour.= ( "</tr>\n" );
}
}
$retour.= "</tbody></table>";
}
$retour.= '<script type="text/javascript">//<![CDATA['."\n".$script.'//]]></script>'."\n";
// Vue detail
if ((isset($_GET['id_fiches']))) {
// Ajout d'un titre pour la page avec la date
$jours = array ('dimanche', 'lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi') ;
$mois = array ('janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre',
'octobre', 'novembre', 'décembre') ;
$timestamp = strtotime ($_GET['y'].'/'.$_GET['m'].'/'.$_GET['d']) ;
$GLOBALS['_PAPYRUS_']['rendu']['CONTENU_NAVIGATION'] = '';
$GLOBALS['_PAPYRUS_']['rendu']['CONTENU_TETE'] = '';
$GLOBALS['_PAPYRUS_']['rendu']['CONTENU_CORPS'] = '<h1>'.$jours[date('w', $timestamp)].
' '.$_GET['d'].' '.$mois[$_GET['m']-1].' '.$_GET['y'].'</h1>' ;
$GLOBALS['_PAPYRUS_']['rendu']['CONTENU_CORPS'] .= baz_voir_fiches(1,$_GET['id_fiches'] );
 
$GLOBALS['_GEN_commun']['info_menu'] = '';
// Un lien pour retourner au calendrier
$url->removeQueryString('id_fiches');
$url->removeQueryString('y');
$url->removeQueryString('m');
$url->removeQueryString('d');
$GLOBALS['_PAPYRUS_']['rendu']['CONTENU_PIED'] = '<div class="retour"><a href="'.$url->getURL().'">Retour au calendrier</a></div>';
}
 
// Nettoyage de l'url
$url->removeQueryString('id_fiches');
$url->removeQueryString('y');
$url->removeQueryString('m');
$url->removeQueryString('d');
return $retour;
}
?>
/trunk/bibliotheque/elements/labelhtml.php
1,67 → 1,68
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: labelhtml.php,v 1.2 2008-09-17 14:18:12 alexandre_tb Exp $
/**
*
*@package bazar
//Auteur original :
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
//Autres auteurs :
*@copyright Tela-Botanica 2000-2008
*@version $Revision: 1.2 $
// +------------------------------------------------------------------------------------------------------+
*/
 
include_once PAP_CHEMIN_API_PEAR.'PEAR.php';
 
 
class Bazar_labelhtml extends PEAR {
var $option = array();
function Bazar_labelhtml($options) {
$this->options = $options;
}
function toHTML($valeur) {
$html = '';
$val = $this->options['nom_bdd'];
// On ecrit le label uniquement si le champs obligatoire est a 1
if ($this->options['obligatoire'] == 1) {
$html .= '<div class="BAZ_label BAZ_rubrique_'.$GLOBALS['_BAZAR_']['class'].'">'.
$this->options['label'].'</div>'."\n";
}
 
return $html;
}
}
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
* Revision 1.1.2.1 2008-04-16 12:35:25 alexandre_tb
* version initiale
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: labelhtml.php,v 1.2 2008-09-17 14:18:12 alexandre_tb Exp $
/**
*
*@package bazar
//Auteur original :
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
//Autres auteurs :
*@copyright Tela-Botanica 2000-2008
*@version $Revision: 1.2 $
// +------------------------------------------------------------------------------------------------------+
*/
 
include_once PAP_CHEMIN_API_PEAR.'PEAR.php';
 
 
class Bazar_labelhtml extends PEAR {
var $option = array();
function Bazar_labelhtml($options) {
$this->options = $options;
}
function toHTML($valeur) {
$html = '';
$val = $this->options['nom_bdd'];
// On ecrit le label uniquement si le champs obligatoire est a 1
if ($this->options['obligatoire'] == 1) $res .= '<div class="BAZ_label BAZ_rubrique_'.$GLOBALS['_BAZAR_']['class'].'">'.
$this->options['label'].'</div>'."\n";
 
return $html;
}
}
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: labelhtml.php,v $
* Revision 1.2 2008-09-17 14:18:12 alexandre_tb
* fusion avec aha
*
* Revision 1.1.2.1 2008-04-16 12:35:25 alexandre_tb
* version initiale
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>
/trunk/bibliotheque/elements/checkbox.php
1,85 → 1,85
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: checkbox.php,v 1.3 2008-11-19 09:28:46 aperonnet Exp $
/**
*
*@package bazar
//Auteur original :
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
//Autres auteurs :
*@copyright Tela-Botanica 2000-2008
*@version $Revision: 1.3 $
// +------------------------------------------------------------------------------------------------------+
*/
 
include_once PAP_CHEMIN_API_PEAR.'PEAR.php';
 
 
class Bazar_checkbox extends PEAR {
var $option = array();
function Bazar_checkbox($options) {
$this->options = $options;
}
function toHTML($valeur) {
$html = '';
$val = $this->options['nom_bdd'];
//pour les champs renseignes par une liste, on va chercher le label de la liste, plutot que l'id
$requete = 'SELECT blv_label FROM bazar_fiche_valeur_liste, bazar_liste_valeurs WHERE bfvl_ce_fiche='.
$GLOBALS['_BAZAR_']['id_fiche'].' AND bfvl_ce_liste='.$this->options['nom_bdd'].
' AND bfvl_valeur=blv_valeur AND blv_ce_liste='.$this->options['nom_bdd'].
' AND blv_ce_i18n="'.$GLOBALS['_BAZAR_']['langue'].'"';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError ($resultat)) {
return ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
}
$val='';$nb=0;
while ($tab = $resultat->fetchRow()) {
if ($nb>0) $val .= ', ';
$val .= $tab[0];
$nb++;
}
if ($val != '' and $val != BAZ_CHOISIR and $val != BAZ_NON_PRECISE) {
$html .= '<div class="BAZ_rubrique BAZ_rubrique_'.$GLOBALS['_BAZAR_']['class'].'">'.
"\n".'<span class="BAZ_label" id="rubrique_'.$this->options['nom_bdd'].'">'.$this->options['label'].' : </span>'."\n";
$html .= '<span class="BAZ_texte BAZ_texte_'.$GLOBALS['_BAZAR_']['class'].'" id="description_'.$this->options['nom_bdd'].
'"> '.$val.'</span>'."\n".'</div>'."\n";
}
return $html;
}
}
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
* Revision 1.2 2008-09-17 14:18:12 alexandre_tb
* fusion avec aha
*
* Revision 1.1.2.1 2008-04-16 12:35:25 alexandre_tb
* version initiale
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: checkbox.php,v 1.2 2008-09-17 14:18:12 alexandre_tb Exp $
/**
*
*@package bazar
//Auteur original :
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
//Autres auteurs :
*@copyright Tela-Botanica 2000-2008
*@version $Revision: 1.2 $
// +------------------------------------------------------------------------------------------------------+
*/
 
include_once PAP_CHEMIN_API_PEAR.'PEAR.php';
 
 
class Bazar_checkbox extends PEAR {
var $option = array();
function Bazar_checkbox($options) {
$this->options = $options;
}
function toHTML($valeur) {
$html = '';
$val = $this->options['nom_bdd'];
//pour les champs renseignes par une liste, on va chercher le label de la liste, plutot que l'id
$requete = 'SELECT blv_label FROM bazar_fiche_valeur_liste, bazar_liste_valeurs WHERE bfvl_ce_fiche='.
$GLOBALS['_BAZAR_']['id_fiche'].' AND bfvl_ce_liste='.$this->options['nom_bdd'].
' AND bfvl_valeur=blv_valeur AND blv_ce_liste='.$this->options['nom_bdd'].
' AND blv_ce_i18n="'.$GLOBALS['_BAZAR_']['langue'].'"';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError ($resultat)) {
return ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
}
$val='';$nb=0;
while ($tab = $resultat->fetchRow()) {
if ($nb>0) $val .= ', ';
$val .= $tab[0];
$nb++;
}
if ($val != '' and $val != BAZ_CHOISIR and $val != BAZ_NON_PRECISE) {
$html .= '<div class="BAZ_rubrique BAZ_rubrique_'.$GLOBALS['_BAZAR_']['class'].'">'.
"\n".'<span class="BAZ_label" id="rubrique_'.$this->options['nom_bdd'].'">'.$this->options['label'].' : </span>'."\n";
$html .= '<span class="BAZ_texte BAZ_texte_'.$GLOBALS['_BAZAR_']['class'].'" id="description_'.$this->options['nom_bdd'].
'"> '.$val.'</span>'."\n".'</div>'."\n";
}
return $html;
}
}
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: checkbox.php,v $
* Revision 1.2 2008-09-17 14:18:12 alexandre_tb
* fusion avec aha
*
* Revision 1.1.2.1 2008-04-16 12:35:25 alexandre_tb
* version initiale
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>
/trunk/bibliotheque/elements/listedatedeb.php
1,102 → 1,102
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: listedatedeb.php,v 1.3 2008-11-19 09:28:46 aperonnet Exp $
/**
*
*@package bazar
//Auteur original :
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
//Autres auteurs :
*@copyright Tela-Botanica 2000-2008
*@version $Revision: 1.3 $
// +------------------------------------------------------------------------------------------------------+
*/
 
include_once PAP_CHEMIN_API_PEAR.'PEAR.php';
 
 
class Bazar_listedatedeb extends PEAR {
var $option = array();
function Bazar_listedatedeb($options) {
$this->options = $options;
}
function toHTML($valeur) {
$html = '';
$val = $this->options['nom_bdd'];
 
if (!in_array($val, array ('bf_date_debut_validite_fiche', 'bf_date_fin_validite_fiche'))) {
if ($valeur != '' && $valeur != '0000-00-00') {
// Petit test pour afficher la date de debut et de fin d evenement
if ($val == 'bf_date_debut_evenement' || $val == 'bf_date_fin_evenement') {
if ($GLOBALS['_BAZAR_']['ligne_resultat']['bf_date_debut_evenement'] == $GLOBALS['_BAZAR_']['ligne_resultat']['bf_date_fin_evenement']) {
if ($val == 'bf_date_debut_evenement') return;
$html .= '<div class="BAZ_rubrique BAZ_rubrique_'.$GLOBALS['_BAZAR_']['class'].'">'."\n".
'<span class="BAZ_label" id="'.$this->options['nom_bdd'].'_rubrique">'.BAZ_LE.' : </span>'."\n";
$html .= '<span class="BAZ_texte BAZ_texte_'.$GLOBALS['_BAZAR_']['class'].'" id="'.$this->options['nom_bdd'].
'_description"> '.strftime('%d.%m.%Y',strtotime($GLOBALS['_BAZAR_']['ligne_resultat']['bf_date_debut_evenement'])).'</span>'.
"\n".'</div>'."\n";
continue;
} else {
if ($val == 'bf_date_debut_evenement') {
$html .= '<div class="BAZ_rubrique BAZ_rubrique_'.$GLOBALS['_BAZAR_']['class'].'">'."\n".
'<span class="BAZ_label" id="'.$this->options['nom_bdd'].'_rubrique">';
$html .= BAZ_DU;
$html .= '</span>'."\n".'<span class="BAZ_texte BAZ_texte_'.$GLOBALS['_BAZAR_']['class'].'" id="'.
$this->options['nom_bdd'].'_description"> '.strftime('%d.%m.%Y',strtotime($valeur)).'</span>'."\n";
} else {
$html .= '<span class="BAZ_label" id="'.$this->options['nom_bdd'].'_rubrique">'.BAZ_AU;
$html .= '</span>'."\n".'<span class="BAZ_texte BAZ_texte_'.$GLOBALS['_BAZAR_']['class'].'" id="'.
$this->options['nom_bdd'].'_description"> '.strftime('%d.%m.%Y',strtotime($valeur)).
'</span>'."\n".'</div>'."\n";
}
return $html;
}
}
$html .= '<div class="BAZ_rubrique BAZ_rubrique_'.$GLOBALS['_BAZAR_']['class'].'">'."\n".
'<span class="BAZ_label" id="'.$this->options['nom_bdd'].'_rubrique">'.$this->options['label'].' : </span>'."\n";
$html .= '<span class="BAZ_texte BAZ_texte_'.$GLOBALS['_BAZAR_']['class'].'" id="'.$this->options['nom_bdd'].
'_description"> '.strftime('%d.%m.%Y',strtotime($valeur)).'</span>'."\n".'</div>'."\n";
}
}
return $html;
}
}
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
* Revision 1.2 2008-09-17 14:18:12 alexandre_tb
* fusion avec aha
*
* Revision 1.1.2.1 2008-04-16 12:35:25 alexandre_tb
* version initiale
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: listedatedeb.php,v 1.2 2008-09-17 14:18:12 alexandre_tb Exp $
/**
*
*@package bazar
//Auteur original :
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
//Autres auteurs :
*@copyright Tela-Botanica 2000-2008
*@version $Revision: 1.2 $
// +------------------------------------------------------------------------------------------------------+
*/
 
include_once PAP_CHEMIN_API_PEAR.'PEAR.php';
 
 
class Bazar_listedatedeb extends PEAR {
var $option = array();
function Bazar_listedatedeb($options) {
$this->options = $options;
}
function toHTML($valeur) {
$html = '';
$val = $this->options['nom_bdd'];
 
if (!in_array($val, array ('bf_date_debut_validite_fiche', 'bf_date_fin_validite_fiche'))) {
if ($valeur != '' && $valeur != '0000-00-00') {
// Petit test pour afficher la date de debut et de fin d evenement
if ($val == 'bf_date_debut_evenement' || $val == 'bf_date_fin_evenement') {
if ($GLOBALS['_BAZAR_']['ligne_resultat']['bf_date_debut_evenement'] == $GLOBALS['_BAZAR_']['ligne_resultat']['bf_date_fin_evenement']) {
if ($val == 'bf_date_debut_evenement') return;
$html .= '<div class="BAZ_rubrique BAZ_rubrique_'.$GLOBALS['_BAZAR_']['class'].'">'."\n".
'<span class="BAZ_label" id="'.$this->options['nom_bdd'].'_rubrique">'.BAZ_LE.' : </span>'."\n";
$html .= '<span class="BAZ_texte BAZ_texte_'.$GLOBALS['_BAZAR_']['class'].'" id="'.$this->options['nom_bdd'].
'_description"> '.strftime('%d.%m.%Y',strtotime($GLOBALS['_BAZAR_']['ligne_resultat']['bf_date_debut_evenement'])).'</span>'.
"\n".'</div>'."\n";
continue;
} else {
if ($val == 'bf_date_debut_evenement') {
$html .= '<div class="BAZ_rubrique BAZ_rubrique_'.$GLOBALS['_BAZAR_']['class'].'">'."\n".
'<span class="BAZ_label" id="'.$this->options['nom_bdd'].'_rubrique">';
$html .= BAZ_DU;
$html .= '</span>'."\n".'<span class="BAZ_texte BAZ_texte_'.$GLOBALS['_BAZAR_']['class'].'" id="'.
$this->options['nom_bdd'].'_description"> '.strftime('%d.%m.%Y',strtotime($valeur)).'</span>'."\n";
} else {
$html .= '<span class="BAZ_label" id="'.$this->options['nom_bdd'].'_rubrique">'.BAZ_AU;
$html .= '</span>'."\n".'<span class="BAZ_texte BAZ_texte_'.$GLOBALS['_BAZAR_']['class'].'" id="'.
$this->options['nom_bdd'].'_description"> '.strftime('%d.%m.%Y',strtotime($valeur)).
'</span>'."\n".'</div>'."\n";
}
return $html;
}
}
$html .= '<div class="BAZ_rubrique BAZ_rubrique_'.$GLOBALS['_BAZAR_']['class'].'">'."\n".
'<span class="BAZ_label" id="'.$this->options['nom_bdd'].'_rubrique">'.$this->options['label'].' : </span>'."\n";
$html .= '<span class="BAZ_texte BAZ_texte_'.$GLOBALS['_BAZAR_']['class'].'" id="'.$this->options['nom_bdd'].
'_description"> '.strftime('%d.%m.%Y',strtotime($valeur)).'</span>'."\n".'</div>'."\n";
}
}
return $html;
}
}
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: listedatedeb.php,v $
* Revision 1.2 2008-09-17 14:18:12 alexandre_tb
* fusion avec aha
*
* Revision 1.1.2.1 2008-04-16 12:35:25 alexandre_tb
* version initiale
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>
/trunk/bibliotheque/elements/texte.php
1,83 → 1,83
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: texte.php,v 1.4 2008-11-19 09:28:46 aperonnet Exp $
/**
*
*@package bazar
//Auteur original :
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
//Autres auteurs :
*@copyright Tela-Botanica 2000-2008
*@version $Revision: 1.4 $
// +------------------------------------------------------------------------------------------------------+
*/
 
include_once PAP_CHEMIN_API_PEAR.'PEAR.php';
 
 
class Bazar_texte extends PEAR {
var $option = array();
function Bazar_texte($options) {
$this->options = $options;
}
function toHTML($valeur) {
if ($valeur == '') return ;
$html = '';
$val = $this->options['nom_bdd'];
//if (!in_array($val, array ('bf_titre', 'bf_description'))) {
$html .= '<div class="BAZ_rubrique BAZ_rubrique_'.$GLOBALS['_BAZAR_']['class'].'">'."\n".
'<span class="BAZ_label" id="'.$this->options['nom_bdd'].'_rubrique">'.$this->options['label'].' : </span>'."\n";
$html .= '<span class="BAZ_texte BAZ_texte_'.$GLOBALS['_BAZAR_']['class'].'" id="'.$this->options['nom_bdd'].'_description"> '.
nl2br($valeur).'</span>'."\n".'</div>'."\n";
//}
return $html;
}
function toForm($valeur_defaut = '') {
if ($valeur_defaut != '') $this->option['defaut'] = $valeur_defaut;
 
$html = $this->options['label'].'<input type="text" size="'.$this->option['limite1'].
'" maxlength="'.$this->option['limite2'].'" id="'.$this->option['nom_bdd'].
'" value="'.$this->option['defaut'].'" />';
return $html;
}
}
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
* Revision 1.3 2008-10-29 10:36:44 alexandre_tb
* l'element texte s affiche meme pour le titre et la description
*
* Revision 1.2 2008-09-17 14:18:12 alexandre_tb
* fusion avec aha
*
* Revision 1.1.2.1 2008-04-16 12:35:25 alexandre_tb
* version initiale
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: texte.php,v 1.3 2008-10-29 10:36:44 alexandre_tb Exp $
/**
*
*@package bazar
//Auteur original :
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
//Autres auteurs :
*@copyright Tela-Botanica 2000-2008
*@version $Revision: 1.3 $
// +------------------------------------------------------------------------------------------------------+
*/
 
include_once PAP_CHEMIN_API_PEAR.'PEAR.php';
 
 
class Bazar_texte extends PEAR {
var $option = array();
function Bazar_texte($options) {
$this->options = $options;
}
function toHTML($valeur) {
if ($valeur == '') return ;
$html = '';
$val = $this->options['nom_bdd'];
//if (!in_array($val, array ('bf_titre', 'bf_description'))) {
$html .= '<div class="BAZ_rubrique BAZ_rubrique_'.$GLOBALS['_BAZAR_']['class'].'">'."\n".
'<span class="BAZ_label" id="'.$this->options['nom_bdd'].'_rubrique">'.$this->options['label'].' : </span>'."\n";
$html .= '<span class="BAZ_texte BAZ_texte_'.$GLOBALS['_BAZAR_']['class'].'" id="'.$this->options['nom_bdd'].'_description"> '.
nl2br($valeur).'</span>'."\n".'</div>'."\n";
//}
return $html;
}
function toForm($valeur_defaut = '') {
if ($valeur_defaut != '') $this->option['defaut'] = $valeur_defaut;
 
$html = $this->options['label'].'<input type="text" size="'.$this->option['limite1'].
'" maxlength="'.$this->option['limite2'].'" id="'.$this->option['nom_bdd'].
'" value="'.$this->option['defaut'].'" />';
return $html;
}
}
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: texte.php,v $
* Revision 1.3 2008-10-29 10:36:44 alexandre_tb
* l'element texte s affiche meme pour le titre et la description
*
* Revision 1.2 2008-09-17 14:18:12 alexandre_tb
* fusion avec aha
*
* Revision 1.1.2.1 2008-04-16 12:35:25 alexandre_tb
* version initiale
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>
/trunk/bibliotheque/elements/textelong.php
1,73 → 1,73
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: textelong.php,v 1.4 2008-11-19 09:28:46 aperonnet Exp $
/**
*
*@package bazar
//Auteur original :
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
//Autres auteurs :
*@copyright Tela-Botanica 2000-2008
*@version $Revision: 1.4 $
// +------------------------------------------------------------------------------------------------------+
*/
 
include_once PAP_CHEMIN_API_PEAR.'PEAR.php';
 
 
class Bazar_textelong extends PEAR {
var $option = array();
function Bazar_textelong($options) {
$this->options = $options;
}
function toHTML($valeur) {
$html = '';
$val = $this->options['nom_bdd'];
//if (!in_array($val, array ('bf_titre', 'bf_description'))) {
$html .= '<div class="BAZ_rubrique BAZ_rubrique_'.$GLOBALS['_BAZAR_']['class'].'">'."\n".
'<span class="BAZ_label" id="'.$this->options['nom_bdd'].'_rubrique">'.$this->options['label'].' : </span>'."\n";
$html .= '<span class="BAZ_texte BAZ_texte_'.$GLOBALS['_BAZAR_']['class'].'" id="'.$this->options['nom_bdd'].'_description"> '.
nl2br($valeur).'</span>'."\n".'</div>'."\n";
//}
return $html;
}
}
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
* Revision 1.3 2008-10-29 10:35:40 alexandre_tb
* l'element textlong s affiche meme pour le titre et la description
*
* Revision 1.2 2008-09-17 14:18:12 alexandre_tb
* fusion avec aha
*
* Revision 1.1.2.1 2008-04-16 12:35:25 alexandre_tb
* version initiale
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: textelong.php,v 1.3 2008-10-29 10:35:40 alexandre_tb Exp $
/**
*
*@package bazar
//Auteur original :
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
//Autres auteurs :
*@copyright Tela-Botanica 2000-2008
*@version $Revision: 1.3 $
// +------------------------------------------------------------------------------------------------------+
*/
 
include_once PAP_CHEMIN_API_PEAR.'PEAR.php';
 
 
class Bazar_textelong extends PEAR {
var $option = array();
function Bazar_textelong($options) {
$this->options = $options;
}
function toHTML($valeur) {
$html = '';
$val = $this->options['nom_bdd'];
//if (!in_array($val, array ('bf_titre', 'bf_description'))) {
$html .= '<div class="BAZ_rubrique BAZ_rubrique_'.$GLOBALS['_BAZAR_']['class'].'">'."\n".
'<span class="BAZ_label" id="'.$this->options['nom_bdd'].'_rubrique">'.$this->options['label'].' : </span>'."\n";
$html .= '<span class="BAZ_texte BAZ_texte_'.$GLOBALS['_BAZAR_']['class'].'" id="'.$this->options['nom_bdd'].'_description"> '.
nl2br($valeur).'</span>'."\n".'</div>'."\n";
//}
return $html;
}
}
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: textelong.php,v $
* Revision 1.3 2008-10-29 10:35:40 alexandre_tb
* l'element textlong s affiche meme pour le titre et la description
*
* Revision 1.2 2008-09-17 14:18:12 alexandre_tb
* fusion avec aha
*
* Revision 1.1.2.1 2008-04-16 12:35:25 alexandre_tb
* version initiale
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>
/trunk/bibliotheque/elements/carte_google.php
1,92 → 1,104
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: carte_google.php,v 1.2 2008-09-17 14:18:12 alexandre_tb Exp $
/**
*
*@package bazar
//Auteur original :
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
//Autres auteurs :
*@copyright Tela-Botanica 2000-2008
*@version $Revision: 1.2 $
// +------------------------------------------------------------------------------------------------------+
*/
 
include_once PAP_CHEMIN_API_PEAR.'PEAR.php';
 
 
class Bazar_carte_google extends PEAR {
var $option = array();
function Bazar_carte_google($options) {
$this->options = $options;
}
function toHTML($valeur) {
if ($GLOBALS['pas_de_carte']) return;
$html = '';
$val = $this->options['nom_bdd'];
$script = '
// Variables globales
var map = null;
var geocoder = null;
var lat = document.getElementById("latitude");
var lon = document.getElementById("longitude");
function load() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map"), G_HYBRID_MAP);
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.addControl(new GScaleControl());
map.enableContinuousZoom();
// On centre la carte sur le marqueur
center = new GLatLng('.$GLOBALS['_BAZAR_']['ligne_resultat']['bf_latitude'].', '.$GLOBALS['_BAZAR_']['ligne_resultat']['bf_longitude'].');
map.setCenter(center, 7);map.setMapType(G_HYBRID_MAP);
point = new GLatLng('.$GLOBALS['_BAZAR_']['ligne_resultat']['bf_latitude'].', '.$GLOBALS['_BAZAR_']['ligne_resultat']['bf_longitude'].');
marker = new GMarker(point, {draggable: true});
map.addOverlay(marker);
}
};' ;
GEN_stockerCodeScript($script);
GEN_stockerFichierScript('googleMapScript', $this->options['nom_bdd']);
// On ajoute l attribut load a la balise body
GEN_AttributsBody('onload', 'load()');
$html = '<div id="map" style="width: 400px; height: 300px"></div>';
return $html;
}
}
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
* Revision 1.1.2.1 2008-04-16 12:35:25 alexandre_tb
* version initiale
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: carte_google.php,v 1.1.2.1 2008-04-16 12:35:25 alexandre_tb Exp $
/**
*
*@package bazar
//Auteur original :
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
//Autres auteurs :
*@copyright Tela-Botanica 2000-2008
*@version $Revision: 1.1.2.1 $
// +------------------------------------------------------------------------------------------------------+
*/
 
include_once PAP_CHEMIN_API_PEAR.'PEAR.php';
 
 
class Bazar_carte_google extends PEAR {
var $option = array();
function Bazar_carte_google($options) {
unset ($options['nom_bdd']); // fout la merde avec google maps v2
$this->options = $options;
}
function toHTML($valeur) {
if ($GLOBALS['pas_de_carte']) return;
$html = '';
$val = $this->options['nom_bdd'];
$script = '
// Variables globales
// cette fonction peut déjà être présente
if (typeof(addListener) != \'function\') {
// fonction portable pour ajout de listeners
function addListener(element, baseName, handler)
{
if (element.addEventListener) {
element.addEventListener(baseName, handler, false) ;
} else if (element.attachEvent) {
element.attachEvent(\'on\'+baseName, handler) ;
}
}
}
var map = null;
addListener(window,\'load\',loadMap) ;
var geocoder = null;
var lat = document.getElementById("latitude");
var lon = document.getElementById("longitude");
function loadMap() {
var point = new google.maps.LatLng('.$GLOBALS['_BAZAR_']['ligne_resultat']['bf_latitude'].', '.$GLOBALS['_BAZAR_']['ligne_resultat']['bf_longitude'].');
var optionsGoogleMapsv3 = {
// On centre la carte sur le languedoc roussillon
center: point,
zoom: 7,
mapTypeId: google.maps.MapTypeId.G_HYBRID_MAP,
mapTypeControl: true,
scaleControl: true
};
map = new google.maps.Map(document.getElementById("map"), optionsGoogleMapsv3);
 
marker = new google.maps.Marker({
position: point,
map: map
});
};' ;
GEN_stockerCodeScript($script);
//GEN_stockerFichierScript('googleMapScript', $this->options['nom_bdd']);
GEN_stockerFichierScript('googleMapScript', "http://maps.googleapis.com/maps/api/js?sensor=false&key=".BAZ_GOOGLE_KEY);
// On ajoute l attribut load a la balise body
//GEN_AttributsBody('onload', 'load()');
$html = '<div id="map" style="width: 400px; height: 300px"></div>';
return $html;
}
}
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>
/trunk/bibliotheque/elements/listedatefin.php
1,102 → 1,102
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: listedatefin.php,v 1.3 2008-11-19 09:28:46 aperonnet Exp $
/**
*
*@package bazar
//Auteur original :
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
//Autres auteurs :
*@copyright Tela-Botanica 2000-2008
*@version $Revision: 1.3 $
// +------------------------------------------------------------------------------------------------------+
*/
 
include_once PAP_CHEMIN_API_PEAR.'PEAR.php';
 
 
class Bazar_listedatefin extends PEAR {
var $option = array();
function Bazar_listedatefin($options) {
$this->options = $options;
}
function toHTML($valeur) {
$html = '';
$val = $this->options['nom_bdd'];
 
if (!in_array($val, array ('bf_date_debut_validite_fiche', 'bf_date_fin_validite_fiche'))) {
if ($valeur != '' && $valeur != '0000-00-00') {
// Petit test pour afficher la date de debut et de fin d evenement
if ($val == 'bf_date_debut_evenement' || $val == 'bf_date_fin_evenement') {
if ($GLOBALS['_BAZAR_']['ligne_resultat']['bf_date_debut_evenement'] == $GLOBALS['_BAZAR_']['ligne_resultat']['bf_date_fin_evenement']) {
if ($val == 'bf_date_debut_evenement') continue;
$html .= '<div class="BAZ_rubrique BAZ_rubrique_'.$GLOBALS['_BAZAR_']['class'].'">'."\n".
'<span class="BAZ_label" id="'.$this->options['nom_bdd'].'_rubrique">'.BAZ_LE.' : </span>'."\n";
$html .= '<span class="BAZ_texte BAZ_texte_'.$GLOBALS['_BAZAR_']['class'].'" id="'.$this->options['nom_bdd'].
'_description"> '.strftime('%d.%m.%Y',strtotime($GLOBALS['_BAZAR_']['ligne_resultat']['bf_date_debut_evenement'])).'</span>'.
"\n".'</div>'."\n";
return $html;
} else {
if ($val == 'bf_date_debut_evenement') {
$html .= '<div class="BAZ_rubrique BAZ_rubrique_'.$GLOBALS['_BAZAR_']['class'].'">'."\n".
'<span class="BAZ_label" id="'.$this->options['nom_bdd'].'_rubrique">';
$html .= BAZ_DU;
$html .= '</span>'."\n".'<span class="BAZ_texte BAZ_texte_'.$GLOBALS['_BAZAR_']['class'].'" id="'.
$this->options['nom_bdd'].'_description"> '.strftime('%d.%m.%Y',strtotime($valeur)).'</span>'."\n";
} else {
$html .= '<span class="BAZ_label" id="'.$this->options['nom_bdd'].'_rubrique">'.BAZ_AU;
$html .= '</span>'."\n".'<span class="BAZ_texte BAZ_texte_'.$GLOBALS['_BAZAR_']['class'].'" id="'.
$this->options['nom_bdd'].'_description"> '.strftime('%d.%m.%Y',strtotime($valeur)).
'</span>'."\n".'</div>'."\n";
}
return $html;
}
}
$html .= '<div class="BAZ_rubrique BAZ_rubrique_'.$GLOBALS['_BAZAR_']['class'].'">'."\n".
'<span class="BAZ_label" id="'.$this->options['nom_bdd'].'_rubrique">'.$this->options['label'].' : </span>'."\n";
$html .= '<span class="BAZ_texte BAZ_texte_'.$GLOBALS['_BAZAR_']['class'].'" id="'.$this->options['nom_bdd'].
'_description"> '.strftime('%d.%m.%Y',strtotime($valeur)).'</span>'."\n".'</div>'."\n";
}
}
return $html;
}
}
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
* Revision 1.2 2008-09-17 14:18:12 alexandre_tb
* fusion avec aha
*
* Revision 1.1.2.1 2008-04-16 12:35:25 alexandre_tb
* version initiale
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: listedatefin.php,v 1.2 2008-09-17 14:18:12 alexandre_tb Exp $
/**
*
*@package bazar
//Auteur original :
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
//Autres auteurs :
*@copyright Tela-Botanica 2000-2008
*@version $Revision: 1.2 $
// +------------------------------------------------------------------------------------------------------+
*/
 
include_once PAP_CHEMIN_API_PEAR.'PEAR.php';
 
 
class Bazar_listedatefin extends PEAR {
var $option = array();
function Bazar_listedatefin($options) {
$this->options = $options;
}
function toHTML($valeur) {
$html = '';
$val = $this->options['nom_bdd'];
 
if (!in_array($val, array ('bf_date_debut_validite_fiche', 'bf_date_fin_validite_fiche'))) {
if ($valeur != '' && $valeur != '0000-00-00') {
// Petit test pour afficher la date de debut et de fin d evenement
if ($val == 'bf_date_debut_evenement' || $val == 'bf_date_fin_evenement') {
if ($GLOBALS['_BAZAR_']['ligne_resultat']['bf_date_debut_evenement'] == $GLOBALS['_BAZAR_']['ligne_resultat']['bf_date_fin_evenement']) {
if ($val == 'bf_date_debut_evenement') continue;
$html .= '<div class="BAZ_rubrique BAZ_rubrique_'.$GLOBALS['_BAZAR_']['class'].'">'."\n".
'<span class="BAZ_label" id="'.$this->options['nom_bdd'].'_rubrique">'.BAZ_LE.' : </span>'."\n";
$html .= '<span class="BAZ_texte BAZ_texte_'.$GLOBALS['_BAZAR_']['class'].'" id="'.$this->options['nom_bdd'].
'_description"> '.strftime('%d.%m.%Y',strtotime($GLOBALS['_BAZAR_']['ligne_resultat']['bf_date_debut_evenement'])).'</span>'.
"\n".'</div>'."\n";
return $html;
} else {
if ($val == 'bf_date_debut_evenement') {
$html .= '<div class="BAZ_rubrique BAZ_rubrique_'.$GLOBALS['_BAZAR_']['class'].'">'."\n".
'<span class="BAZ_label" id="'.$this->options['nom_bdd'].'_rubrique">';
$html .= BAZ_DU;
$html .= '</span>'."\n".'<span class="BAZ_texte BAZ_texte_'.$GLOBALS['_BAZAR_']['class'].'" id="'.
$this->options['nom_bdd'].'_description"> '.strftime('%d.%m.%Y',strtotime($valeur)).'</span>'."\n";
} else {
$html .= '<span class="BAZ_label" id="'.$this->options['nom_bdd'].'_rubrique">'.BAZ_AU;
$html .= '</span>'."\n".'<span class="BAZ_texte BAZ_texte_'.$GLOBALS['_BAZAR_']['class'].'" id="'.
$this->options['nom_bdd'].'_description"> '.strftime('%d.%m.%Y',strtotime($valeur)).
'</span>'."\n".'</div>'."\n";
}
return $html;
}
}
$html .= '<div class="BAZ_rubrique BAZ_rubrique_'.$GLOBALS['_BAZAR_']['class'].'">'."\n".
'<span class="BAZ_label" id="'.$this->options['nom_bdd'].'_rubrique">'.$this->options['label'].' : </span>'."\n";
$html .= '<span class="BAZ_texte BAZ_texte_'.$GLOBALS['_BAZAR_']['class'].'" id="'.$this->options['nom_bdd'].
'_description"> '.strftime('%d.%m.%Y',strtotime($valeur)).'</span>'."\n".'</div>'."\n";
}
}
return $html;
}
}
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: listedatefin.php,v $
* Revision 1.2 2008-09-17 14:18:12 alexandre_tb
* fusion avec aha
*
* Revision 1.1.2.1 2008-04-16 12:35:25 alexandre_tb
* version initiale
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>
/trunk/bibliotheque/elements/champs_mail.php
1,71 → 1,71
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: champs_mail.php,v 1.3 2008-11-19 09:28:46 aperonnet Exp $
/**
*
*@package bazar
//Auteur original :
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
//Autres auteurs :
*@copyright Tela-Botanica 2000-2008
*@version $Revision: 1.3 $
// +------------------------------------------------------------------------------------------------------+
*/
 
include_once PAP_CHEMIN_API_PEAR.'PEAR.php';
 
 
class Bazar_champs_mail extends PEAR {
var $option = array();
function Bazar_champs_mail($options) {
$this->options = $options;
}
function toHTML($valeur) {
$html = '';
$val = $this->options['nom_bdd'];
if (!in_array($val, array ('bf_titre', 'bf_description'))) {
$html .= '<div class="BAZ_rubrique BAZ_rubrique_'.$GLOBALS['_BAZAR_']['class'].'">'."\n".
'<span class="BAZ_label" id="'.$this->options['nom_bdd'].'_rubrique">'.$this->options['label'].' :</span>'."\n";
$html .= '<span class="BAZ_texte BAZ_texte_'.$GLOBALS['_BAZAR_']['class'].'" id="'.$this->options['nom_bdd'].'_description"> '.
'<a href="mailto:'.$valeur.'">'.
nl2br($valeur).'</a></span>'."\n".'</div>'."\n";
}
return $html;
}
}
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
* Revision 1.2 2008-09-17 14:18:12 alexandre_tb
* fusion avec aha
*
* Revision 1.1.2.1 2008-04-16 12:35:25 alexandre_tb
* version initiale
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: champs_mail.php,v 1.2 2008-09-17 14:18:12 alexandre_tb Exp $
/**
*
*@package bazar
//Auteur original :
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
//Autres auteurs :
*@copyright Tela-Botanica 2000-2008
*@version $Revision: 1.2 $
// +------------------------------------------------------------------------------------------------------+
*/
 
include_once PAP_CHEMIN_API_PEAR.'PEAR.php';
 
 
class Bazar_champs_mail extends PEAR {
var $option = array();
function Bazar_champs_mail($options) {
$this->options = $options;
}
function toHTML($valeur) {
$html = '';
$val = $this->options['nom_bdd'];
if (!in_array($val, array ('bf_titre', 'bf_description'))) {
$html .= '<div class="BAZ_rubrique BAZ_rubrique_'.$GLOBALS['_BAZAR_']['class'].'">'."\n".
'<span class="BAZ_label" id="'.$this->options['nom_bdd'].'_rubrique">'.$this->options['label'].' :</span>'."\n";
$html .= '<span class="BAZ_texte BAZ_texte_'.$GLOBALS['_BAZAR_']['class'].'" id="'.$this->options['nom_bdd'].'_description"> '.
'<a href="mailto:'.$valeur.'">'.
nl2br($valeur).'</a></span>'."\n".'</div>'."\n";
}
return $html;
}
}
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: champs_mail.php,v $
* Revision 1.2 2008-09-17 14:18:12 alexandre_tb
* fusion avec aha
*
* Revision 1.1.2.1 2008-04-16 12:35:25 alexandre_tb
* version initiale
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>
/trunk/bibliotheque/elements/liste.php
1,89 → 1,85
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: liste.php,v 1.3 2008-11-19 09:28:46 aperonnet Exp $
/**
*
*@package bazar
//Auteur original :
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
//Autres auteurs :
*@copyright Tela-Botanica 2000-2008
*@version $Revision: 1.3 $
// +------------------------------------------------------------------------------------------------------+
*/
 
// TODO : Semble inutilise cf ; formulaire.fonct.inc
 
 
include_once PAP_CHEMIN_API_PEAR.'PEAR.php';
 
 
class Bazar_liste extends PEAR {
var $option = array();
function Bazar_liste($options) {
$this->options = $options;
}
function toHTML($valeur) {
$html = '';
$val = $this->options['nom_bdd'];
//pour les champs renseignes par une liste, on va chercher le label de la liste, plutot que l'id
$requete = 'SELECT blv_label FROM bazar_fiche_valeur_liste, bazar_liste_valeurs WHERE bfvl_ce_fiche='.
$GLOBALS['_BAZAR_']['id_fiche'].' AND bfvl_ce_liste='.$this->options['nom_bdd'].
' AND bfvl_valeur=blv_valeur AND blv_ce_liste='.$this->options['nom_bdd'].
' AND blv_ce_i18n="'.$GLOBALS['_BAZAR_']['langue'].'" ORDER by blv_valeur';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError ($resultat)) {
return ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
}
$val='';$nb=0;
while ($tab = $resultat->fetchRow()) {
if ($nb>0) $val .= ', ';
$val .= $tab[0];
$nb++;
}
if ($val != '' and $val != BAZ_CHOISIR and $val != BAZ_NON_PRECISE) {
$html .= '<div class="BAZ_rubrique BAZ_rubrique_'.$GLOBALS['_BAZAR_']['class'].'">'.
"\n".'<span class="BAZ_label" id="rubrique_'.$this->options['nom_bdd'].'">'.$this->options['label'].' : </span>'."\n";
$html .= '<span class="BAZ_texte BAZ_texte_'.$GLOBALS['_BAZAR_']['class'].'" id="description_'.$this->options['nom_bdd'].
'"> '.$val.'</span>'."\n".'</div>'."\n";
}
return $html;
}
}
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
* Revision 1.2 2008-09-17 14:18:12 alexandre_tb
* fusion avec aha
*
* Revision 1.1.2.1 2008-04-16 12:35:25 alexandre_tb
* version initiale
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: liste.php,v 1.2 2008-09-17 14:18:12 alexandre_tb Exp $
/**
*
*@package bazar
//Auteur original :
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
//Autres auteurs :
*@copyright Tela-Botanica 2000-2008
*@version $Revision: 1.2 $
// +------------------------------------------------------------------------------------------------------+
*/
 
include_once PAP_CHEMIN_API_PEAR.'PEAR.php';
 
 
class Bazar_liste extends PEAR {
var $option = array();
function Bazar_liste($options) {
$this->options = $options;
}
function toHTML($valeur) {
$html = '';
$val = $this->options['nom_bdd'];
//pour les champs renseignes par une liste, on va chercher le label de la liste, plutot que l'id
$requete = 'SELECT blv_label FROM bazar_fiche_valeur_liste, bazar_liste_valeurs WHERE bfvl_ce_fiche='.
$GLOBALS['_BAZAR_']['id_fiche'].' AND bfvl_ce_liste='.$this->options['nom_bdd'].
' AND bfvl_valeur=blv_valeur AND blv_ce_liste='.$this->options['nom_bdd'].
' AND blv_ce_i18n="'.$GLOBALS['_BAZAR_']['langue'].'"';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError ($resultat)) {
return ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
}
$val='';$nb=0;
while ($tab = $resultat->fetchRow()) {
if ($nb>0) $val .= ', ';
$val .= $tab[0];
$nb++;
}
if ($val != '' and $val != BAZ_CHOISIR and $val != BAZ_NON_PRECISE) {
$html .= '<div class="BAZ_rubrique BAZ_rubrique_'.$GLOBALS['_BAZAR_']['class'].'">'.
"\n".'<span class="BAZ_label" id="rubrique_'.$this->options['nom_bdd'].'">'.$this->options['label'].' : </span>'."\n";
$html .= '<span class="BAZ_texte BAZ_texte_'.$GLOBALS['_BAZAR_']['class'].'" id="description_'.$this->options['nom_bdd'].
'"> '.$val.'</span>'."\n".'</div>'."\n";
}
return $html;
}
}
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: liste.php,v $
* Revision 1.2 2008-09-17 14:18:12 alexandre_tb
* fusion avec aha
*
* Revision 1.1.2.1 2008-04-16 12:35:25 alexandre_tb
* version initiale
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>
/trunk/bibliotheque/bazar.fonct.php
1,1878 → 1,1838
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: bazar.fonct.php,v 1.79 2008-10-29 10:41:48 alexandre_tb Exp $
/**
*
* Fonctions du module bazar
*
*
*@package bazar
//Auteur original :
*@author Alexandre Granier <alexandre@tela-botanica.org>
*@author Florian Schmitt <florian@ecole-et-nature.org>
//Autres auteurs :
*@copyright Tela-Botanica 2000-2004
*@version $Revision: 1.79 $ $Date: 2008-10-29 10:41:48 $
// +------------------------------------------------------------------------------------------------------+
*/
 
// +------------------------------------------------------------------------------------------------------+
// | ENTETE du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm.php' ;
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm/checkbox.php' ;
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm/textarea.php' ;
require_once PAP_CHEMIN_API_PEAR.'HTML/Table.php' ;
require_once GEN_CHEMIN_API.'formulaire/formulaire.fonct.inc.php';
require_once 'bazar.fonct.rss.php';
 
 
/** fiches_a_valider () - Renvoie les annonces restant a valider par un administrateur
*
* @return string HTML
*/
function fiches_a_valider() {
$utilisateur = new Administrateur_bazar($GLOBALS['AUTH']);
// sortie anticipée en cas d'accès non autorisé
// ceci limite l'accès au supers admins
// TODO: voir si l'on ne pourrait afficher que les fiches
// des catégories dont la personne est admin
// des catégories dont la personne est admin, ce qui permettrait un accès plus fin
if(!$utilisateur->isSuperAdmin()) {
return;
}
// Pour les administrateurs d'une rubrique, on affiche les fiches a valider de cette rubrique
// On effectue une requete sur le bazar pour voir les fiches a administrer
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_VOIR, BAZ_VOIR_ADMIN);
$res= '<h2>'.BAZ_ANNONCES_A_ADMINISTRER.'</h2><br />'."\n";
$requete = 'SELECT * FROM bazar_fiche, bazar_nature WHERE bf_statut_fiche=0 AND ' .
'bn_id_nature=bf_ce_nature AND bn_ce_id_menu IN ('.$GLOBALS['_BAZAR_']['categorie_nature'].') ' ;
if (isset($GLOBALS['_BAZAR_']['langue'])) {
$requete .= ' and bn_ce_i18n like "'.$GLOBALS['_BAZAR_']['langue'].'%" ';
}
$requete .= 'ORDER BY bf_date_maj_fiche DESC' ;
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ('Echec de la requete<br />'.$resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
}
if ($resultat->numRows() != 0) {
$tableAttr = array('id' => 'table_bazar') ;
$table = new HTML_Table($tableAttr) ;
$entete = array (BAZ_TITREANNONCE ,BAZ_ANNONCEUR, BAZ_TYPEANNONCE, BAZ_PUBLIER, BAZ_SUPPRIMER) ;
$table->addRow($entete) ;
$table->setRowType (0, 'th') ;
 
// On affiche une ligne par proposition
while ($ligne = $resultat->fetchRow (DB_FETCHMODE_ASSOC)) {
//Requete pour trouver le nom et prenom de l'annonceur
$requetenomprenom = 'SELECT '.BAZ_CHAMPS_PRENOM.', '.BAZ_CHAMPS_NOM.' FROM '.BAZ_ANNUAIRE.
' WHERE '.BAZ_CHAMPS_ID.'='.$ligne['bf_ce_utilisateur'] ;
$resultatnomprenom = $GLOBALS['_BAZAR_']['db']->query ($requetenomprenom) ;
if (DB::isError($resultatnomprenom)) {
echo ("Echec de la requete<br />".$resultatnomprenom->getMessage()."<br />".$resultatnomprenom->getDebugInfo()) ;
}
while ($lignenomprenom = $resultatnomprenom->fetchRow (DB_FETCHMODE_ASSOC)) {
$annonceur=$lignenomprenom[BAZ_CHAMPS_PRENOM]." ".$lignenomprenom[BAZ_CHAMPS_NOM];
}
$lien_voir=$GLOBALS['_BAZAR_']['url'];
$lien_voir->addQueryString(BAZ_VARIABLE_ACTION, BAZ_VOIR_FICHE);
$lien_voir->addQueryString('id_fiche', $ligne['bf_id_fiche']);
$lien_voir->addQueryString('typeannonce', $ligne['bn_id_nature']);
 
// Nettoyage de l'url
// NOTE (jpm - 23 mai 2007): pour �tre compatible avec PHP5 il faut utiliser tjrs $GLOBALS['_BAZAR_']['url'] car en php4 on
// copie bien une variable mais pas en php5, cela reste une r�f�rence...
$GLOBALS['_BAZAR_']['url']->removeQueryString('action');
$GLOBALS['_BAZAR_']['url']->removeQueryString('id_fiche');
$GLOBALS['_BAZAR_']['url']->removeQueryString('typeannonce');
 
$GLOBALS['_BAZAR_']['url']->addQueryString('id_fiche', $ligne['bf_id_fiche']);
$GLOBALS['_BAZAR_']['url']->addQueryString('typeannonce', $ligne['bn_id_nature']);
 
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_ACTION, BAZ_VOIR_FICHE);
$lien_voir = $GLOBALS['_BAZAR_']['url']->getURL();
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
 
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_PUBLIER);
$lien_publie_oui = $GLOBALS['_BAZAR_']['url']->getURL();
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
 
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_PAS_PUBLIER);
$lien_publie_non = $GLOBALS['_BAZAR_']['url']->getURL();
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
 
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_SUPPRESSION);
$lien_supprimer = $GLOBALS['_BAZAR_']['url']->getURL();
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
 
$GLOBALS['_BAZAR_']['url']->removeQueryString('id_fiche');
$GLOBALS['_BAZAR_']['url']->removeQueryString('typeannonce');
 
$table->addRow (array(
'<a href="'.$lien_voir.'">'.$ligne['bf_titre'].'</a>'."\n", // col 1 : le nom
$annonceur."\n", // col 2 : annonceur
$ligne['bn_label_nature']."\n", // col 3 : type annonce
"<a href=\"".$lien_publie_oui."\">".BAZ_OUI."</a> / \n".
"<a href=\"".$lien_publie_non."\">".BAZ_NON."</a>", // col 4 : publier ou pas
"<a href=\"".$lien_supprimer."\"".
" onclick=\"javascript:return confirm('".BAZ_CONFIRMATION_SUPPRESSION."');\">".BAZ_SUPPRIMER."</a>\n")) ; // col 5 : supprimer
 
}
$table->altRowAttributes(1, array("class" => "ligne_impaire"), array("class" => "ligne_paire"));
$table->updateColAttributes(1, array("align" => "center"));
$table->updateColAttributes(2, array("align" => "center"));
$table->updateColAttributes(3, array("align" => "center"));
$table->updateColAttributes(4, array("align" => "center"));
$res .= $table->toHTML() ;
}
else {
$res .= '<p class="zone_info">'.BAZ_PAS_DE_FICHE_A_VALIDER.'</p>'."\n" ;
}
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_ACTION, BAZ_VOIR_TOUTES_ANNONCES);
 
//$res .= '<br /><ul style="clear:both;"><li><a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'" title="'.BAZ_CONSULTER_FICHES_VALIDEES.'">'.BAZ_CONSULTER_FICHES_VALIDEES.'</a></li></ul>';
 
// Nettoyage de l'url
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
$GLOBALS['_BAZAR_']['url']->removeQueryString('id_fiche');
$GLOBALS['_BAZAR_']['url']->removeQueryString('typeannonce');
 
// Les autres fiches, deja validees
$res .= '<h2>'.BAZ_TOUTES_LES_FICHES.'</h2>'."\n";
$requete = 'SELECT * FROM bazar_fiche, bazar_nature WHERE bf_statut_fiche=1 AND ' .
'bn_id_nature=bf_ce_nature AND bn_ce_id_menu IN ('.$GLOBALS['_BAZAR_']['categorie_nature'].') ';
if (isset($GLOBALS['_BAZAR_']['langue'])) {
$requete .= ' and bn_ce_i18n like "'.$GLOBALS['_BAZAR_']['langue'].'%" ';
}
$requete .= 'ORDER BY bf_date_maj_fiche DESC' ;
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ('Echec de la requete<br />'.$resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
}
if ($resultat->numRows() != 0) {
$tableAttr = array('id' => 'table_bazar') ;
$table = new HTML_Table($tableAttr) ;
$entete = array (BAZ_TITREANNONCE ,BAZ_ANNONCEUR, BAZ_TYPEANNONCE, BAZ_PUBLIER, BAZ_SUPPRIMER) ;
$table->addRow($entete) ;
$table->setRowType (0, 'th') ;
 
// On affiche une ligne par proposition
while ($ligne = $resultat->fetchRow (DB_FETCHMODE_ASSOC)) {
//Requete pour trouver le nom et prenom de l'annonceur
$requetenomprenom = 'SELECT '.BAZ_CHAMPS_PRENOM.', '.BAZ_CHAMPS_NOM.' FROM '.BAZ_ANNUAIRE.
' WHERE '.BAZ_CHAMPS_ID.'='.$ligne['bf_ce_utilisateur'] ;
$resultatnomprenom = $GLOBALS['_BAZAR_']['db']->query ($requetenomprenom) ;
if (DB::isError($resultatnomprenom)) {
echo ("Echec de la requete<br />".$resultatnomprenom->getMessage()."<br />".$resultatnomprenom->getDebugInfo()) ;
}
while ($lignenomprenom = $resultatnomprenom->fetchRow (DB_FETCHMODE_ASSOC)) {
$annonceur=$lignenomprenom[BAZ_CHAMPS_PRENOM]." ".$lignenomprenom[BAZ_CHAMPS_NOM];
}
$lien_voir=$GLOBALS['_BAZAR_']['url'];
$lien_voir->addQueryString(BAZ_VARIABLE_ACTION, BAZ_VOIR_FICHE);
$lien_voir->addQueryString('id_fiche', $ligne['bf_id_fiche']);
$lien_voir->addQueryString('typeannonce', $ligne['bn_id_nature']);
 
// Nettoyage de l'url
// NOTE (jpm - 23 mai 2007): pour �tre compatible avec PHP5 il faut utiliser tjrs $GLOBALS['_BAZAR_']['url'] car en php4 on
// copie bien une variable mais pas en php5, cela reste une r�f�rence...
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
$GLOBALS['_BAZAR_']['url']->removeQueryString('id_fiche');
$GLOBALS['_BAZAR_']['url']->removeQueryString('typeannonce');
 
$GLOBALS['_BAZAR_']['url']->addQueryString('id_fiche', $ligne['bf_id_fiche']);
$GLOBALS['_BAZAR_']['url']->addQueryString('typeannonce', $ligne['bn_id_nature']);
 
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_ACTION, BAZ_VOIR_FICHE);
$lien_voir = $GLOBALS['_BAZAR_']['url']->getURL();
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
 
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_PUBLIER);
$lien_publie_oui = $GLOBALS['_BAZAR_']['url']->getURL();
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
 
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_PAS_PUBLIER);
$lien_publie_non = $GLOBALS['_BAZAR_']['url']->getURL();
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
 
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_SUPPRESSION);
$lien_supprimer = $GLOBALS['_BAZAR_']['url']->getURL();
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
 
$GLOBALS['_BAZAR_']['url']->removeQueryString('id_fiche');
$GLOBALS['_BAZAR_']['url']->removeQueryString('typeannonce');
 
$table->addRow (array(
'<a href="'.$lien_voir.'">'.$ligne['bf_titre'].'</a>'."\n", // col 1 : le nom
$annonceur."\n", // col 2 : annonceur
$ligne['bn_label_nature']."\n", // col 3 : type annonce
"<a href=\"".$lien_publie_oui."\">".BAZ_OUI."</a> / \n".
"<a href=\"".$lien_publie_non."\">".BAZ_NON."</a>", // col 4 : publier ou pas
"<a href=\"".$lien_supprimer."\"".
" onclick=\"javascript:return confirm('".BAZ_CONFIRMATION_SUPPRESSION."');\">".BAZ_SUPPRIMER."</a>\n")) ; // col 5 : supprimer
 
}
$table->altRowAttributes(1, array("class" => "ligne_impaire"), array("class" => "ligne_paire"));
$table->updateColAttributes(1, array("align" => "center"));
$table->updateColAttributes(2, array("align" => "center"));
$table->updateColAttributes(3, array("align" => "center"));
$table->updateColAttributes(4, array("align" => "center"));
$res .= $table->toHTML() ;
}
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_VOIR);
return $res;
}
 
 
/** mes_fiches () - Renvoie les fiches bazar d'un utilisateur
*
* @return string HTML
*/
function mes_fiches() {
$res= '<h2>'.BAZ_VOS_ANNONCES.'</h2><br />'."\n";
if ($GLOBALS['AUTH']->getAuth()) {
// requete pour voir si l'utilisateur a des fiches a son nom, classees par date de MAJ et nature d'annonce
$requete = 'SELECT * FROM bazar_fiche, bazar_nature WHERE bf_ce_utilisateur='. $GLOBALS['id_user'].
' AND bn_id_nature=bf_ce_nature AND bn_ce_id_menu IN ('.$GLOBALS['_BAZAR_']['categorie_nature'].') ';
if (isset($GLOBALS['_BAZAR_']['langue'])) $requete .= ' and bn_ce_i18n like "'.$GLOBALS['_BAZAR_']['langue'].'%" ';
$requete .= ' ORDER BY bf_date_maj_fiche DESC,bf_ce_nature ASC';
 
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ('Echec de la requete<br />'.$resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
}
if ($resultat->numRows() != 0) {
$tableAttr = array('id' => 'table_bazar') ;
$table = new HTML_Table($tableAttr) ;
$entete = array (BAZ_TITREANNONCE , BAZ_TYPEANNONCE, BAZ_ETATPUBLICATION, BAZ_MODIFIER, BAZ_SUPPRIMER, 'Dupliquer') ;
$table->addRow($entete) ;
$table->setRowType (0, "th") ;
 
// On affiche une ligne par proposition
while ($ligne = $resultat->fetchRow (DB_FETCHMODE_ASSOC)) {
if ($ligne['bf_statut_fiche']==1) $publiee=BAZ_PUBLIEE;
elseif ($ligne['bf_statut_fiche']==0) $publiee=BAZ_ENCOURSDEVALIDATION;
else $publiee=BAZ_REJETEE;
 
$lien_voir = $GLOBALS['_BAZAR_']['url'];
$lien_voir->addQueryString(BAZ_VARIABLE_ACTION, BAZ_VOIR_FICHE);
$lien_voir->addQueryString('id_fiche', $ligne['bf_id_fiche']);
$lien_voir->addQueryString('typeannonce', $ligne['bn_id_nature']);
$lien_voir_url=$lien_voir->getURL();
 
$lien_modifier = $GLOBALS['_BAZAR_']['url'];
$lien_modifier->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_MODIFIER);
$lien_modifier->addQueryString('id_fiche', $ligne['bf_id_fiche']);
$lien_modifier->addQueryString('typeannonce', $ligne['bn_id_nature']);
$lien_modifier_url=$lien_modifier->getURL();
 
$lien_supprimer = $GLOBALS['_BAZAR_']['url'];
$lien_supprimer->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_SUPPRESSION);
$lien_supprimer->addQueryString('id_fiche', $ligne['bf_id_fiche']);
$lien_supprimer->addQueryString('typeannonce', $ligne['bn_id_nature']);
$lien_supprimer_url=$lien_supprimer->getURL();
 
$lien_dupliquer = $GLOBALS['_BAZAR_']['url'];
$lien_dupliquer->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_NOUVEAU);
$lien_dupliquer->addQueryString(BAZ_VARIABLE_ID_FICHE, $ligne['bf_id_fiche']);
$lien_dupliquer->addQueryString(BAZ_VARIABLE_DUPLICATION, 1);
$lien_dupliquer=$lien_dupliquer->getURL();
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_DUPLICATION);
 
 
$table->addRow (array(
'<a href="'.$lien_voir_url.'">'.$ligne['bf_titre'].'</a>'."\n", // col 1 : le nom
$ligne['bn_label_nature']."\n", // col 2: type annonce
$publiee."\n", // col 3 : publiee ou non
'<a href="'.$lien_modifier_url.'">'.BAZ_MODIFIER.'</a>'."\n", // col 4 : modifier
'<a href="'.$lien_supprimer_url.'" onclick="javascript:return '.
'confirm(\''.BAZ_CONFIRMATION_SUPPRESSION.'\');" >'.BAZ_SUPPRIMER.'</a>'."\n", // col 5 : supprimer
'<a href="'.$lien_dupliquer.'">Dupliquer</a>'."\n")) ;
}
$table->altRowAttributes(1, array("class" => "ligne_impaire"), array("class" => "ligne_paire"));
$table->updateColAttributes(1, array("align" => "left"));
$table->updateColAttributes(2, array("align" => "center"));
$table->updateColAttributes(3, array("align" => "center"));
$table->updateColAttributes(4, array("align" => "center"));
$res .= $table->toHTML() ;
}
else {
$res .= '<p class="zone_info">'.BAZ_PAS_DE_FICHE.'</p>'."\n" ;
}
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_VOIR, BAZ_VOIR_SAISIR);
$GLOBALS['_BAZAR_']['url']->removeQueryString('id_fiche');
$GLOBALS['_BAZAR_']['url']->removeQueryString('typeannonce');
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
$res .= '<br /><ul id="liste_liens"><li id="lien_saisir"><a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'" title="'.BAZ_SAISIR_UNE_NOUVELLE_FICHE.'">'.BAZ_SAISIR_UNE_NOUVELLE_FICHE.'</a></li></ul>';
 
}
else {
 
include_once BAZ_CHEMIN_APPLI.'bibliotheque/bazarTemplate.class.php';
$modele = new bazarTemplate($GLOBALS['_BAZAR_']['db']);
$res .= $modele->getTemplate(BAZ_TEMPLATE_MESSAGE_LOGIN, $GLOBALS['_BAZAR_']['langue'], $GLOBALS['_BAZAR_']['categorie_nature']);
}
return $res;
}
 
/** baz_gestion_droits() interface de gestion des droits
*
* return string le code HTML
*/
function baz_gestion_droits() {
$lien_formulaire=$GLOBALS['_BAZAR_']['url'];
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_GERER_DROITS);
 
//contruction du squelette du formulaire
$formtemplate = new HTML_QuickForm('formulaire', 'post', preg_replace ('/&amp;/', '&', $lien_formulaire->getURL()) );
$squelette =& $formtemplate->defaultRenderer();
$squelette->setFormTemplate("\n".'<form {attributes}>'."\n".'<table style="border:0;">'."\n".'{content}'."\n".'</table>'."\n".'</form>'."\n");
$squelette->setElementTemplate( '<tr>'."\n".'<td style="font-size:12px;width:150px;text-align:right;">'."\n".'{label} :</td>'."\n".'<td style="text-align:left;padding:5px;"> '."\n".'{element}'."\n".
'<!-- BEGIN required --><span class="symbole_obligatoire">*</span><!-- END required -->'."\n".
'<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n".
'</td>'."\n".'</tr>'."\n");
$squelette->setElementTemplate( '<tr>'."\n".'<td colspan="2" class="liste_a_cocher"><strong>{label}&nbsp;{element}</strong>'."\n".
'<!-- BEGIN required --><span class="symbole_obligatoire">&nbsp;*</span><!-- END required -->'."\n".'</td>'."\n".'</tr>'."\n", 'accept_condition');
$squelette->setElementTemplate( '<tr><td colspan="2" class="bouton">{label}{element}</td></tr>'."\n", 'valider');
$squelette->setRequiredNoteTemplate("\n".'<tr>'."\n".'<td colspan="2" class="symbole_obligatoire">* {requiredNote}</td></tr>'."\n");
//Traduction de champs requis
$formtemplate->setRequiredNote(BAZ_CHAMPS_REQUIS) ;
$formtemplate->setJsWarnings(BAZ_ERREUR_SAISIE,BAZ_VEUILLEZ_CORRIGER);
//Initialisation de la variable personne
if ( isset($_POST['personnes']) ) {
$personne=$_POST['personnes'];
}
else $personne=0;
 
//Cas ou les droits ont etes changes
if (isset($_GET['pers'])) {
$personne=$_GET['pers'];
//CAS DES DROITS POUR UN TYPE D'ANNONCE: On efface tous les droits de la personne pour ce type d'annonce
if (isset($_GET['idtypeannonce'])) {
$requete = 'DELETE FROM bazar_droits WHERE bd_id_utilisateur='.$_GET['pers'].
' AND bd_id_nature_offre='.$_GET['idtypeannonce'];
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
}
//CAS DU SUPER ADMIN: On efface tous les droits de la personne en general
else {
$requete = 'DELETE FROM bazar_droits WHERE bd_id_utilisateur='.$_GET['pers'];
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
}
if ($_GET['droits']=='superadmin') {
$requete = 'INSERT INTO bazar_droits VALUES ('.$_GET['pers'].',0,0)';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
}
elseif ($_GET['droits']=='redacteur') {
$requete = 'INSERT INTO bazar_droits VALUES ('.$_GET['pers'].','.$_GET['idtypeannonce'].',1)';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
}
elseif ($_GET['droits']=='admin') {
$requete = 'INSERT INTO bazar_droits VALUES ('.$_GET['pers'].','.$_GET['idtypeannonce'].',2)';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
}
}
 
//requete pour obtenir l'id, le nom et prenom des personnes inscrites a l'annuaire sauf soi meme
$requete = 'SELECT '.BAZ_CHAMPS_ID.', '.BAZ_CHAMPS_NOM.', '.BAZ_CHAMPS_PRENOM.' FROM '.BAZ_ANNUAIRE.
' WHERE '.BAZ_CHAMPS_ID." != ".$GLOBALS['id_user'].' ORDER BY '.BAZ_CHAMPS_NOM.' ASC';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
echo ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
$res='<h2>'.BAZ_GESTION_DES_DROITS.'</h2><br />'."\n";
$res.=BAZ_DESCRIPTION_GESTION_DES_DROITS.'<br /><br />'."\n";
$personnes_select[0]=BAZ_SELECTION;
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
$personnes_select[$ligne[BAZ_CHAMPS_ID]] = $ligne[BAZ_CHAMPS_NOM]." ".$ligne[BAZ_CHAMPS_PRENOM] ;
}
$java=array ('style'=>'width:250px;','onchange'=>'this.form.submit();');
$formtemplate->addElement ('select', 'personnes', BAZ_LABEL_CHOIX_PERSONNE, $personnes_select, $java) ;
$defauts=array ('personnes'=>$personne);
$formtemplate->setDefaults($defauts);
$res.= $formtemplate->toHTML().'<br />'."\n" ;
 
if ($personne!=0) {
//cas du super utilisateur
$utilisateur = new Utilisateur_bazar($personne) ;
if ($utilisateur->isSuperAdmin()) {
$res.= '<br />'.BAZ_EST_SUPERADMINISTRATEUR.'<br /><br />'."\n";
$lien_enlever_superadmin=$GLOBALS['_BAZAR_']['url'];
$lien_enlever_superadmin->addQueryString(BAZ_VARIABLE_ACTION, BAZ_GERER_DROITS);
$lien_enlever_superadmin->addQueryString('pers', $personne);
$lien_enlever_superadmin->addQueryString('droits', 'aucun');
$res.= '<a href='.$lien_enlever_superadmin->getURL().'>'.BAZ_CHANGER_SUPERADMINISTRATEUR.'</a><br />'."\n";
}
else {
$lien_passer_superadmin=$GLOBALS['_BAZAR_']['url'];
$lien_passer_superadmin->addQueryString(BAZ_VARIABLE_ACTION, BAZ_GERER_DROITS);
$lien_passer_superadmin->addQueryString('pers', $personne);
$lien_passer_superadmin->addQueryString('droits', 'superadmin');
$res.= '<a href='.$lien_passer_superadmin->getURL().'>'.BAZ_PASSER_SUPERADMINISTRATEUR.'</a><br />'."\n";
 
//on cherche les differentes rubriques d'annonces
$requete = 'SELECT bn_id_nature, bn_label_nature, bn_image_titre FROM bazar_nature';
if (isset($GLOBALS['_BAZAR_']['langue'])) $requete .= ' where bn_ce_i18n like "'.$GLOBALS['_BAZAR_']['langue'].'%"';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
$res.='<br /><b>'.BAZ_DROITS_PAR_TYPE.'</b><br /><br />';
 
$table = new HTML_Table(array ('width' => '100%', 'class' => 'table_bazar')) ;
$table->addRow(array ('<strong>'.BAZ_TYPE_ANNONCES.'</strong>',
'<strong>'.BAZ_DROITS_ACTUELS.'</strong>',
'<strong>'.BAZ_PASSER_EN.'</strong>',
'<strong>'.BAZ_OU_PASSER_EN.'</strong>')) ;
$table->setRowType (0, 'th') ;
 
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
$lien_aucun_droit=$GLOBALS['_BAZAR_']['url'];
$lien_aucun_droit->addQueryString(BAZ_VARIABLE_ACTION, BAZ_GERER_DROITS);
$lien_aucun_droit->addQueryString('pers', $personne);
$lien_aucun_droit->addQueryString('droits', 'aucun');
$lien_aucun_droit->addQueryString('idtypeannonce', $ligne["bn_id_nature"]);
 
$lien_passer_redacteur=$GLOBALS['_BAZAR_']['url'];
$lien_passer_redacteur->addQueryString(BAZ_VARIABLE_ACTION, BAZ_GERER_DROITS);
$lien_passer_redacteur->addQueryString('pers', $personne);
$lien_passer_redacteur->addQueryString('droits', 'redacteur');
$lien_passer_redacteur->addQueryString('idtypeannonce', $ligne["bn_id_nature"]);
 
$lien_passer_admin=$GLOBALS['_BAZAR_']['url'];
$lien_passer_admin->addQueryString(BAZ_VARIABLE_ACTION, BAZ_GERER_DROITS);
$lien_passer_admin->addQueryString('pers', $personne);
$lien_passer_admin->addQueryString('droits', 'admin');
$lien_passer_admin->addQueryString('idtypeannonce', $ligne["bn_id_nature"]);
if (isset($ligne['bn_image_titre'])) {
$titre='&nbsp;<img src="client/bazar/images/'.$ligne['bn_image_titre'].'" alt="'.$ligne['bn_label_nature'].'" />'."\n";
} else {
$titre='<strong>&nbsp;'.$ligne['bn_label_nature'].'</strong>'."\n";
}
if ($utilisateur->isAdmin($ligne['bn_id_nature'])) {
$table->addRow(array($titre,
BAZ_DROIT_ADMIN,
'<a href='.$lien_aucun_droit->getURL().'>'.BAZ_AUCUN_DROIT.'</a>',
'<a href='.$lien_passer_redacteur->getURL().'>'.BAZ_LABEL_REDACTEUR.'</a>'));
}
elseif ($utilisateur->isRedacteur($ligne['bn_id_nature'])) {
$table->addRow(array($titre,
BAZ_LABEL_REDACTEUR,
'<a href='.$lien_aucun_droit->getURL().'>'.BAZ_AUCUN_DROIT.'</a>',
'<a href='.$lien_passer_admin->getURL().'>'.BAZ_DROIT_ADMIN.'</a>'));
}
else {
$table->addRow(array($titre,
BAZ_AUCUN_DROIT,
'<a href='.$lien_passer_redacteur->getURL().'>'.BAZ_LABEL_REDACTEUR.'</a>',
'<a href='.$lien_passer_admin->getURL().'>'.BAZ_DROIT_ADMIN.'</a>'));
 
}
}
 
$table->altRowAttributes(1, array('class' => 'ligne_impaire'), array('class' => 'ligne_paire'));
$table->updateColAttributes(0, array('align' => 'left'));
$table->updateColAttributes(1, array('align' => 'left'));
$table->updateColAttributes(2, array('align' => 'left'));
$table->updateColAttributes(3, array('align' => 'left'));
$res.=$table->toHTML() ;
}
}
 
// Nettoyage de l'url
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
$GLOBALS['_BAZAR_']['url']->removeQueryString('pers');
$GLOBALS['_BAZAR_']['url']->removeQueryString('droits');
$GLOBALS['_BAZAR_']['url']->removeQueryString('idtypeannonce');
 
return $res;
}
 
/** baz_formulaire() - Renvoie le menu pour les saisies et modification des annonces
*
* @param string choix du formulaire a afficher (soit formulaire personnalise de
* l'annonce, soit choix du type d'annonce)
*
* @return string HTML
*/
function baz_formulaire($mode) {
$res = '';
if ($GLOBALS['AUTH']->getAuth()) {
$lien_formulaire=$GLOBALS['_BAZAR_']['url'];
 
//Definir le lien du formulaire en fonction du mode de formulaire choisi
if ($mode == BAZ_DEPOSER_ANNONCE) {
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_NOUVEAU);
if (isset($GLOBALS['_BAZAR_']['id_typeannonce']) && $GLOBALS['_BAZAR_']['id_typeannonce'] != 'toutes') {
$mode = BAZ_ACTION_NOUVEAU ;
}
}
if ($mode == BAZ_ACTION_NOUVEAU) {
if ((!isset($_POST['accept_condition']))and($GLOBALS['_BAZAR_']['condition']!=NULL)) {
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_NOUVEAU);
} else {
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_NOUVEAU_V);
}
}
if ($mode == BAZ_ACTION_MODIFIER) {
if (!isset($_POST['accept_condition'])and($GLOBALS['_BAZAR_']['condition']!=NULL)) {
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_MODIFIER);
} else {
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_MODIFIER_V);
if (isset ($_SESSION['_BAZAR_']['fichier'])) unset($_SESSION['_BAZAR_']['fichier']) ;
if (isset ($_SESSION['_BAZAR_']['image'])) unset($_SESSION['_BAZAR_']['image']);
if (isset ($_SESSION['_BAZAR_']['lien'])) unset($_SESSION['_BAZAR_']['lien']);
}
$lien_formulaire->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
}
if ($mode == BAZ_ACTION_MODIFIER_V) {
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_MODIFIER_V);
$lien_formulaire->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
}
 
//contruction du squelette du formulaire
$formtemplate = new HTML_QuickForm('formulaire', 'post', preg_replace ('/&amp;/', '&', $lien_formulaire->getURL()) );
$squelette =& $formtemplate->defaultRenderer();
$squelette->setFormTemplate("\n".'<form {attributes}>'."\n".'<table style="border:0;width:100%;">'."\n".'{content}'."\n".'</table>'."\n".'</form>'."\n");
$squelette->setElementTemplate( '<tr>'."\n".'<td>'."\n".'{label}'.
'<!-- BEGIN required --><span class="symbole_obligatoire">&nbsp;*</span><!-- END required -->'."\n".
' </td>'."\n".'<td style="text-align:left;padding:5px;"> '."\n".'{element}'."\n".
'<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n".
'</td>'."\n".'</tr>'."\n");
$squelette->setElementTemplate( '<tr>'."\n".'<td colspan="2" class="liste_a_cocher"><strong>{label}&nbsp;{element}</strong>'."\n".
'<!-- BEGIN required --><span class="symbole_obligatoire">&nbsp;*</span><!-- END required -->'."\n".'</td>'."\n".'</tr>'."\n", 'accept_condition');
$squelette->setElementTemplate( '<tr><td colspan="2" class="bouton">{label}{element}</td></tr>'."\n", 'valider');
 
$squelette->setRequiredNoteTemplate("\n".'<tr>'."\n".'<td colspan="2" class="symbole_obligatoire">* {requiredNote}</td></tr>'."\n");
//Traduction de champs requis
$formtemplate->setRequiredNote(BAZ_CHAMPS_REQUIS) ;
$formtemplate->setJsWarnings(BAZ_ERREUR_SAISIE,BAZ_VEUILLEZ_CORRIGER);
 
//------------------------------------------------------------------------------------------------
//AFFICHAGE DU FORMULAIRE GENERAL DE CHOIX DU TYPE D'ANNONCE
//------------------------------------------------------------------------------------------------
if ($mode == BAZ_DEPOSER_ANNONCE) {
$res = '';
//requete pour obtenir le nom et la description des types d'annonce
$requete = 'SELECT * FROM bazar_nature WHERE bn_ce_id_menu IN ('.$GLOBALS['_BAZAR_']['categorie_nature'].') ';
 
if (isset($GLOBALS['_BAZAR_']['langue'])) {
$requete .= ' and bn_ce_i18n like "'.$GLOBALS['_BAZAR_']['langue'].'%" ';
}
$requete .= 'ORDER BY bn_label_nature ASC';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
return ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
//$res.='<h2>'.BAZ_DEPOSE_UNE_NOUVELLE_ANNONCE.'</h2>'."\n";
include_once BAZ_CHEMIN_APPLI.'bibliotheque/bazarTemplate.class.php';
$modele = new bazarTemplate($GLOBALS['_BAZAR_']['db']);
$res .= $modele->getTemplate(BAZ_TEMPLATE_FORMULAIRE_ACCUEIL, $GLOBALS['_BAZAR_']['langue'], $GLOBALS['_BAZAR_']['categorie_nature']);
if ($resultat->numRows()==1) {
$ligne = $resultat->fetchRow (DB_FETCHMODE_ASSOC);
$GLOBALS['_BAZAR_']['id_typeannonce']=$ligne['bn_id_nature'];
$GLOBALS['_BAZAR_']['typeannonce']=$ligne['bn_label_nature'];
$GLOBALS['_BAZAR_']['condition']=$ligne['bn_condition'];
$GLOBALS['_BAZAR_']['template']=$ligne['bn_template'];
$GLOBALS['_BAZAR_']['commentaire']=$ligne['bn_commentaire'];
$GLOBALS['_BAZAR_']['appropriation']=$ligne['bn_appropriation'];
$GLOBALS['_BAZAR_']['image_titre']=$ligne['bn_image_titre'];
$GLOBALS['_BAZAR_']['image_logo']=$ligne['bn_image_logo'];
$mode = BAZ_ACTION_NOUVEAU;
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_NOUVEAU_V);
 
} else {
//$res.='<br />'.BAZ_CHOIX_TYPEANNONCE.'<br /><br />'."\n";
while ($ligne = $resultat->fetchRow (DB_FETCHMODE_ASSOC)) {
$utilisateur = new Administrateur_bazar($GLOBALS['AUTH']);
if (($utilisateur->isRedacteur($ligne['bn_id_nature'])) || ($utilisateur->isAdmin($ligne['bn_id_nature']))
|| ($utilisateur->isSuperAdmin() || !BAZ_RESTREINDRE_DEPOT)) {
if ($ligne['bn_image_titre']!='') {
$titre='&nbsp;<img src="client/bazar/images/'.$ligne['bn_image_titre'].'" alt="'.
$ligne['bn_label_nature'].'" />'.'<br />'."\n";
} else {
$titre='<h3>'.$ligne['bn_label_nature'].' : </h3>'."\n";
}
$formtemplate->addElement('radio', 'typeannonce', '',
$titre.$ligne['bn_description'].'<br /><br />'."\n",
$ligne['bn_id_nature'], array("id" => 'select'.$ligne['bn_id_nature'],
"style" => 'float:left;'));
$formtemplate->addRule('typeannonce', 'Il faut choisir un type de fiche', 'required', '', 'client') ;
}
}
$squelette->setElementTemplate( '<div class="listechoix">'."\n".'{element}'."\n".'</div>'."\n");
 
//Mettre les annonces en choix par defaut
$formtemplate->setdefaults(array('typeannonce'=>'1'));
 
// Bouton d annulation
$lien_formulaire->removeQueryString('action');
$buttons[] = &HTML_QuickForm::createElement('link', 'annuler', BAZ_ANNULER,
preg_replace ("/&amp;/", "&", $lien_formulaire->getURL()), BAZ_ANNULER); // Le preg_replace contourne un pb de QuickForm et Net_URL
// ce qui fait �chouer le lien
//Bouton de validation du formulaire
$buttons[] = &HTML_QuickForm::createElement('submit', 'valider', BAZ_VALIDER);
$formtemplate->addGroup($buttons, null, null, '&nbsp;');
 
//Affichage a l'ecran
$res.= $formtemplate->toHTML()."\n";
}
}
 
//------------------------------------------------------------------------------------------------
//AFFICHAGE DU FORMULAIRE CORRESPONDANT AU TYPE DE L'ANNONCE CHOISI PAR L'UTILISATEUR
//------------------------------------------------------------------------------------------------
if ($mode == BAZ_ACTION_NOUVEAU) {
$utilisateur = new Administrateur_bazar($GLOBALS['AUTH']);
if ($utilisateur->isRedacteur($GLOBALS['_BAZAR_']['id_typeannonce']) ||
$utilisateur->isAdmin($GLOBALS['_BAZAR_']['id_typeannonce'])||
$utilisateur->isSuperAdmin()) {
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_NOUVEAU_V);
$formtemplate->updateAttributes(array('action' => str_replace('&amp;', '&', $lien_formulaire->getURL())));
// Appel du modele
include_once BAZ_CHEMIN_APPLI.'bibliotheque/bazarTemplate.class.php';
$modele = new bazarTemplate($GLOBALS['_BAZAR_']['db']);
$html = $modele->getTemplate(BAZ_TEMPLATE_FORMULAIRE, $GLOBALS['_BAZAR_']['langue'],$GLOBALS['_BAZAR_']['categorie_nature']);
if (!PEAR::isError($html)) {
if (isset($_GET[BAZ_VARIABLE_DUPLICATION])) {
$res = str_replace ('{FORMULAIRE}', baz_afficher_formulaire_annonce('duplication',$formtemplate), $html);
} else {
$res = str_replace ('{FORMULAIRE}', baz_afficher_formulaire_annonce('insertion',$formtemplate), $html);
}
} else {
if (isset($_GET[BAZ_VARIABLE_DUPLICATION])) {
$res = baz_afficher_formulaire_annonce('duplication',$formtemplate);
} else {
$res = baz_afficher_formulaire_annonce('insertion',$formtemplate);
}
}
} else {
// Pas de droit pour deposer un annonce
return '<div>Pas de droits suffisants</div>';
}
}
 
//------------------------------------------------------------------------------------------------
//CAS DE LA MODIFICATION D'UNE ANNONCE (FORMULAIRE DE MODIFICATION)
//------------------------------------------------------------------------------------------------
if ($mode == BAZ_ACTION_MODIFIER) {
$res=baz_afficher_formulaire_annonce('modification',$formtemplate);
}
 
// Nettoyage de l'url avant les return : apparement inutile sinon pose pb (url applette deconnexion et moteur de recherche) [jpm le 17 mars 2008]
//$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
//$GLOBALS['_BAZAR_']['url']->removeQueryString('id_fiche');
 
//------------------------------------------------------------------------------------------------
//CAS DE L'INSCRIPTION D'UNE ANNONCE
//------------------------------------------------------------------------------------------------
if ($mode == BAZ_ACTION_NOUVEAU_V) {
if ($formtemplate->validate() && !isset($_SESSION['formulaire_annonce_valide'])) {
//$formtemplate->process('baz_insertion', false) ;
$id_fiche = baz_insertion ($formtemplate->getSubmitValues());
// Redirection vers mes_fiches pour eviter la revalidation du formulaire
$GLOBALS['_BAZAR_']['url']->addQueryString (BAZ_VARIABLE_ACTION, BAZ_ACTION_POST_VALIDATION);
$GLOBALS['_BAZAR_']['url']->addQueryString (BAZ_VARIABLE_ID_FICHE, $id_fiche);
 
return baz_post_validation();
 
}
}
 
//------------------------------------------------------------------------------------------------
//CAS DE LA MODIFICATION D'UNE ANNONCE (VALIDATION ET MAJ)
//------------------------------------------------------------------------------------------------
if ($mode == BAZ_ACTION_MODIFIER_V) {
if ($formtemplate->validate()) {
$formtemplate->process('baz_mise_a_jour', false) ;
 
// Redirection vers mes_fiches pour eviter la revalidation du formulaire
$GLOBALS['_BAZAR_']['url']->addQueryString (BAZ_VARIABLE_VOIR, BAZ_VOIR_MES_FICHES);
header ('Location: '.str_replace ('&amp;', '&', $GLOBALS['_BAZAR_']['url']->getURL())) ;
exit();
}
}
} else {
include_once BAZ_CHEMIN_APPLI.'bibliotheque/bazarTemplate.class.php';
$modele = new bazarTemplate($GLOBALS['_BAZAR_']['db']);
$res .= $modele->getTemplate(BAZ_TEMPLATE_MESSAGE_LOGIN, $GLOBALS['_BAZAR_']['langue'], $GLOBALS['_BAZAR_']['categorie_nature']);
}
 
return $res;
}
 
/** baz_afficher_formulaire_annonce() - Genere le formulaire de saisie d'une annonce
*
* @param string type de formulaire: insertion ou modification
* @param mixed objet quickform du formulaire
*
* @return string code HTML avec formulaire
*/
function baz_afficher_formulaire_annonce($mode='insertion',$formtemplate) {
if ($mode=='modification' || $mode == 'duplication') {
//initialisation de la variable globale id_fiche
$GLOBALS['_BAZAR_']['id_fiche'] = $_REQUEST[BAZ_VARIABLE_ID_FICHE];
 
//suppression eventuelle d'une url, d'un fichier ou d'une image
if (isset($_GET['id_url'])) {
baz_suppression_url($_GET['id_url']);
}
if (isset($_GET['id_fichier'])) {
baz_suppression_fichier($_GET['id_fichier']);
}
if (isset($_GET['image'])) {
baz_suppression_image($GLOBALS['_BAZAR_']['id_fiche']);
}
}
$res = '';
//titre de la rubrique
if (!BAZ_UTILISE_TEMPLATE) $res= '<h2>'.BAZ_TITRE_SAISIE_ANNONCE.'&nbsp;'.$GLOBALS['_BAZAR_']['typeannonce'].'</h2><br />'."\n";
if (($GLOBALS['_BAZAR_']['condition']!='')AND(!isset($_POST['accept_condition']))AND(!isset($_GET['url'])OR(!isset($_GET['fichier']))OR(!isset($_GET['image'])))) {
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm/html.php';
$conditions= new HTML_QuickForm_html('<tr><td colspan="2" style="padding:5px; margin:5px; width: 90%; background: #C1CBA7;">'.$GLOBALS['_BAZAR_']['condition'].'</td>'."\n".'</tr>'."\n");
$formtemplate->addElement($conditions);
$formtemplate->addElement('checkbox', 'accept_condition',BAZ_ACCEPTE_CONDITIONS) ;
$formtemplate->addElement('hidden', 'typeannonce', $GLOBALS['_BAZAR_']['id_typeannonce']);
$formtemplate->addRule('accept_condition', BAZ_ACCEPTE_CONDITIONS_REQUIS, 'required', '', 'client') ;
$formtemplate->addElement('submit', 'valider', BAZ_VALIDER);
}
//affichage du formulaire si conditions acceptees
else {
//Parcours du fichier de templates, pour mettre les valeurs des champs
$tableau=baz_valeurs_template($GLOBALS['_BAZAR_']['template']);
if ($mode=='modification' || $mode == 'duplication') {
//Ajout des valeurs par defaut
$valeurs_par_defaut = baz_valeurs_fiche($GLOBALS['_BAZAR_']['id_fiche']) ;
 
for ($i=0; $i<count($tableau); $i++) {
 
if (isset($ligne[$tableau[$i]['nom_bdd']])) {
$type = $tableau[$i]['type'];
$valeur = $ligne[$tableau[$i]['nom_bdd']];
} else {
$type = $tableau[$i]['type'];
$valeur = '';
}
/*
$element = Bazar_element::factory($type, $tableau[$i]);
if (!PEAR::isError($element)) {
if (method_exists($element, 'toForm'))$res .= $element->toForm($valeur);
}
*/
if ( $tableau[$i]['type']=='liste' || $tableau[$i]['type']=='checkbox' || $tableau[$i]['type']=='radio') {
$def=$tableau[$i]['type'].$tableau[$i]['nom_bdd'];
}
elseif ( $tableau[$i]['type']=='texte' || $tableau[$i]['type']=='textelong' || $tableau[$i]['type']=='listedatedeb'
|| $tableau[$i]['type']=='listedatefin' || $tableau[$i]['type']=='champs_cache'
|| $tableau[$i]['type']=='labelhtml' ) {
$def=$tableau[$i]['nom_bdd'];
} elseif ($tableau[$i]['type']=='carte_google') {
$def = 'carte_google';
$valeurs_par_defaut[$def] = array ('latitude' => $valeurs_par_defaut['bf_latitude'], 'longitude' => $valeurs_par_defaut['bf_longitude']);
}
// certain type n ont pas de valeur par defaut (labelhtml par exemple)
// on teste l existence de $valeur_par_defaut[$def] avant de le passer en parametre
$tableau[$i]['type']($formtemplate, $tableau[$i]['nom_bdd'], $tableau[$i]['label'], $tableau[$i]['limite1'],
$tableau[$i]['limite2'],
isset ($valeurs_par_defaut[$def]) ? $valeurs_par_defaut[$def] : '',
$tableau[$i]['table_source'], $tableau[$i]['obligatoire']) ;
 
if ($tableau[$i]['type']=='carte_google') {
include_once GEN_CHEMIN_API.'formulaire/formulaire.fonct.google.php';
GEN_stockerCodeScript($script);
// On ajoute l attribut load a la balise body
GEN_AttributsBody('onload', 'load()');
}
}
}
else {
for ($i=0; $i<count($tableau); $i++) {
if($tableau[$i]['type'] != '') {
$tableau[$i]['type']($formtemplate, $tableau[$i]['nom_bdd'], $tableau[$i]['label'], $tableau[$i]['limite1'],
$tableau[$i]['limite2'], $tableau[$i]['defaut'], $tableau[$i]['table_source'], $tableau[$i]['obligatoire']) ;
if ($tableau[$i]['type'] == 'carte_google') {
include_once GEN_CHEMIN_API.'formulaire/formulaire.fonct.google.php';
GEN_stockerCodeScript($script);
// On ajoute l attribut load a la balise body
GEN_AttributsBody('onload', 'load()');
}
}
}
}
$formtemplate->addElement('hidden', 'typeannonce', $GLOBALS['_BAZAR_']['id_typeannonce']);
 
// Un champs cache pour la duplication
if ($mode == 'duplication') $formtemplate->addElement('hidden', 'fiche_dupliquee', $GLOBALS['_BAZAR_']['id_fiche']);
// Bouton d annulation
$attr = $formtemplate->getAttributes();
$lien_formulaire = new Net_URL($attr[BAZ_VARIABLE_ACTION]);
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_VOIR_VOS_ANNONCES);
$buttons[] = &HTML_QuickForm::createElement('link', 'annuler', BAZ_ANNULER,
preg_replace ("/&amp;/", "&", $lien_formulaire->getURL()), BAZ_ANNULER); // Le preg_replace contourne un pb de QuickForm et Net_URL
// qui remplacent deux fois les & par des &amp;
//Bouton de validation du formulaire // ce qui fait �chouer le lien
$buttons[] = &HTML_QuickForm::createElement('submit', 'valider', BAZ_VALIDER);
$formtemplate->addGroup($buttons, null, null, '&nbsp;');
 
}
 
//Affichage a l'ecran
$res .= $formtemplate->toHTML()."\n";
return $res;
}
 
 
/** requete_bazar_fiche() - preparer la requete d'insertion ou de MAJ de la table bazar_fiche a partir du template
*
* @global mixed L'objet contenant les valeurs issues de la saisie du formulaire
* @return void
*/
function requete_bazar_fiche(&$valeur) {
$requete=NULL;
//l'annonce est directement publi�e pour les admins
$utilisateur = new Administrateur_bazar($GLOBALS['AUTH']);
 
if ($utilisateur->isAdmin($GLOBALS['_BAZAR_']['id_typeannonce']) ||
$utilisateur->isSuperAdmin()) {
$requete.='bf_statut_fiche=1, ';
}
else {
$requete.='bf_statut_fiche="'.BAZ_ETAT_VALIDATION.'", ';
}
$tableau=baz_valeurs_template($GLOBALS['_BAZAR_']['template']);
for ($i=0; $i<count($tableau); $i++) {
//cas des checkbox et des listes
if ($tableau[$i]['type']=='checkbox' || $tableau[$i]['type']=='liste') {
//on supprime les anciennes valeurs de la table bazar_fiche_valeur_liste
$requetesuppression='DELETE FROM bazar_fiche_valeur_liste WHERE bfvl_ce_fiche='.$GLOBALS['_BAZAR_']['id_fiche'].' AND bfvl_ce_liste='.$tableau[$i]['nom_bdd'];
$resultat = $GLOBALS['_BAZAR_']['db']->query($requetesuppression) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
if (isset($valeur[$tableau[$i]['type'].$tableau[$i]['nom_bdd']]) && ($valeur[$tableau[$i]['type'].$tableau[$i]['nom_bdd']]!=0)) {
//on insere les nouvelles valeurs
$requeteinsertion='INSERT INTO bazar_fiche_valeur_liste (bfvl_ce_fiche, bfvl_ce_liste, bfvl_valeur) VALUES ';
//pour les checkbox, les diff�rentes valeurs sont dans un tableau
if (is_array($valeur[$tableau[$i]['type'].$tableau[$i]['nom_bdd']])) {
$nb=0;
while (list($cle, $val) = each($valeur[$tableau[$i]['type'].$tableau[$i]['nom_bdd']])) {
 
if ($nb>0) $requeteinsertion .= ', ';
$requeteinsertion .= '('.$GLOBALS['_BAZAR_']['id_fiche'].', '.$tableau[$i]['nom_bdd'].', '.$cle.') ';
$nb++;
}
}
//pour les listes, une insertion de la valeur suffit
else {
$requeteinsertion .= '('.$GLOBALS['_BAZAR_']['id_fiche'].', '.$tableau[$i]['nom_bdd'].', '.$valeur[$tableau[$i]['type'].$tableau[$i]['nom_bdd']].')';
}
$resultat = $GLOBALS['_BAZAR_']['db']->query($requeteinsertion) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
}
}
//cas des fichiers
elseif ($tableau[$i]['type']=='fichier') {
if ((isset($valeur['texte_fichier'.$tableau[$i]['nom_bdd']]) && $valeur['texte_fichier'.$tableau[$i]['nom_bdd']]!='')
|| isset($_POST['fiche_dupliquee'])){
baz_insertion_fichier($valeur['texte_fichier'.$tableau[$i]['nom_bdd']], $GLOBALS['_BAZAR_']['id_fiche'], 'fichier'.$tableau[$i]['nom_bdd']);
}
}
//cas des urls
// On affine les criteres pour l insertion d une url
// il faut que le lien soit saisie, different de http:// ET que le texte du lien soit saisie aussi
// et ce afin d eviter d avoir des liens vides
elseif ($tableau[$i]['type']=='url') {
if ((isset($valeur['url_lien'.$tableau[$i]['nom_bdd']]) &&
$valeur['url_lien'.$tableau[$i]['nom_bdd']]!='http://'
&& isset($valeur['url_texte'.$tableau[$i]['nom_bdd']]) &&
strlen ($valeur['url_texte'.$tableau[$i]['nom_bdd']])) || isset($_POST['fiche_dupliquee'])) {
baz_insertion_url($valeur['url_lien'.$tableau[$i]['nom_bdd']], $valeur['url_texte'.$tableau[$i]['nom_bdd']], $GLOBALS['_BAZAR_']['id_fiche']);
}
}
//cas des images
elseif ($tableau[$i]['type']=='image') {
if (isset($_FILES['image']['name']) && $_FILES['image']['name']!='') {
$requete .= baz_insertion_image($GLOBALS['_BAZAR_']['id_fiche']);
}
}
//cas des dates
elseif ( $tableau[$i]['type']=='listedatedeb' || $tableau[$i]['type']=='listedatefin' ) {
 
// On construit la date selon le format YYYY-mm-dd
$date = $valeur[$tableau[$i]['nom_bdd']]['Y'].'-'.$valeur[$tableau[$i]['nom_bdd']]['m'].'-'.$valeur[$tableau[$i]['nom_bdd']]['d'] ;
 
// si la date de fin evenement est anterieure a la date de debut, on met la date de debut
// pour eviter les incoherence
 
if ($tableau[$i]['nom_bdd'] == 'bf_date_fin_evenement' &&
mktime(0,0,0, $valeur['bf_date_debut_evenement']['m'], $valeur['bf_date_debut_evenement']['d'], $valeur['bf_date_debut_evenement']['Y']) >
mktime(0,0,0, $valeur['bf_date_fin_evenement']['m'], $valeur['bf_date_fin_evenement']['d'], $valeur['bf_date_fin_evenement']['Y'])) {
$val = $valeur['bf_date_debut_evenement']['Y'].'-'.$valeur['bf_date_debut_evenement']['m'].'-'.$valeur['bf_date_debut_evenement']['d'] ;
} else {
$val = $valeur[$tableau[$i]['nom_bdd']]['Y'].'-'.$valeur[$tableau[$i]['nom_bdd']]['m'].'-'.$valeur[$tableau[$i]['nom_bdd']]['d'] ;
}
$requete .= $tableau[$i]['nom_bdd'].'="'.$val.'", ' ;
}
//cas des champs texte
elseif ( $tableau[$i]['type']=='texte' || $tableau[$i]['type']=='textelong' || $tableau[$i]['type']=='champs_cache' || $tableau[$i]['type']=='champs_mail' ) {
//on mets les slashes pour les saisies dans les champs texte et textearea
$val=addslashes($valeur[$tableau[$i]['nom_bdd']]) ;
$requete .= $tableau[$i]['nom_bdd'].'="'.$val.'", ' ;
}
/*
//cas des wikinis
elseif ( $tableau[$i]['type']=='wikini' && $_REQUEST[BAZ_VARIABLE_ACTION]==BAZ_ACTION_NOUVEAU_V ) {
//on appelle les pages des apis et de l'integrateur wikini
include_once PAP_CHEMIN_RACINE.'api/sql/SQL_manipulation.fonct.php';
include_once PAP_CHEMIN_RACINE.'client/integrateur_wikini/configuration/adwi_configuration.inc.php' ;
include_once PAP_CHEMIN_RACINE.'client/integrateur_wikini/bibliotheque/adwi_wikini.fonct.php' ;
//g�n�ration du titre du wiki, sous la forme id-titre du projet
$titre=baz_titre_wiki($valeur["bf_titre"]);
//cr�ation du wiki
$valeur=array ("action"=> "nouveau_v", "code_alpha_wikini"=>$titre, "page"=>"AccueiL", "bdd_hote"=> "",
"bdd_nom"=> "", "bdd_utilisateur"=> "", "bdd_mdp" => "", "table_prefix"=> "", "chemin" => "wikini/".$titre, "valider"=> "Valider");
$val = insertion($valeur, $GLOBALS['_BAZAR_']['db']);
}
*/
// Cas de la carte google
elseif ($tableau[$i]['type'] == 'carte_google') {
$requete .= 'bf_latitude="'.$valeur['latitude'].'", bf_longitude="'.$valeur['longitude'].'",';
}
}
$requete.=' bf_date_maj_fiche=NOW()';
return $requete;
}
 
/** baz_insertion() - inserer une nouvelle fiche
*
* @array Le tableau des valeurs a inserer
* @integer Valeur de l'identifiant de la fiche
* @return void
*/
function baz_insertion($valeur) {
// =========== Insertion d'une nouvelle fiche ===================
//requete d'insertion dans bazar_fiche
$GLOBALS['_BAZAR_']['id_fiche'] = baz_nextid('bazar_fiche', 'bf_id_fiche', $GLOBALS['_BAZAR_']['db']) ;
$requete = 'INSERT INTO bazar_fiche SET bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'].','.
'bf_ce_utilisateur='.$GLOBALS['id_user'].', bf_ce_nature='.$GLOBALS['_BAZAR_']['id_typeannonce'].','.
'bf_date_creation_fiche=NOW(),';
if (!isset($_REQUEST['bf_date_debut_validite_fiche'])) {
$requete .= 'bf_date_debut_validite_fiche=now(), bf_date_fin_validite_fiche="0000-00-00", ' ;
}
$requete .=requete_bazar_fiche($valeur) ;
 
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
return ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
// Envoie d un mail aux administrateurs
$utilisateur = new Administrateur_bazar($GLOBALS['AUTH']);
if (!$utilisateur->isAdmin($GLOBALS['_BAZAR_']['id_typeannonce']) || !$utilisateur->isSuperAdmin()) {
bazar::notifier();
}
 
// On redirige
return $GLOBALS['_BAZAR_']['id_fiche'];
}
 
 
/** baz_insertion_url() - inserer un lien URL a une fiche
*
* @global string L'url du lien
* @global string Le texte du lien
* @global integer L'identifiant de la fiche
* @return void
*/
function baz_insertion_url($url_lien, $url_texte, $idfiche) {
 
if (isset ($_POST['fiche_dupliquee'])) {
$id_url = baz_nextId('bazar_url', 'bu_id_url', $GLOBALS['_BAZAR_']['db']) ;
$requete = 'insert into bazar_url select '.$id_url.','.$idfiche.',bu_url, bu_descriptif_url '.
' from bazar_url where bu_ce_fiche="'.$_POST['fiche_dupliquee'].'"';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
return;
}
//requete d'insertion dans bazar_url
if (!isset($_SESSION['_BAZAR_']['lien'])) {
$id_url = baz_nextId('bazar_url', 'bu_id_url', $GLOBALS['_BAZAR_']['db']) ;
$requete = 'INSERT INTO bazar_url SET bu_id_url='.$id_url.', bu_ce_fiche='.$idfiche.', '.
'bu_url="'.$url_lien.'", bu_descriptif_url="'.addslashes($url_texte).'"';
 
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
return $resultat->getMessage().$resultat->getDebugInfo() ;
}
$_SESSION['_BAZAR_']['lien'] = 1;
return;
}
}
 
 
/** baz_insertion_fichier() - inserer un fichier a une fiche
*
* @global string Le label du fichier
* @global string La description du fichier
* @global integer L'identifiant de la fiche
* @return void
*/
function baz_insertion_fichier($fichier_description, $idfiche, $nom_fichier='fichier_joint') {
//verification de la presence de ce fichier
 
// En cas de duplication on ajoute simplement une ligne dans la base de donnee
// pour chaque fichier associe a la fiche d origine
 
if (isset ($_POST['fiche_dupliquee'])) {
$id_fichier_joint = baz_nextId('bazar_fichier_joint', 'bfj_id_fichier', $GLOBALS['_BAZAR_']['db']) ;
$requete = 'insert into bazar_fichier_joint select '.$id_fichier_joint.','.$idfiche.',bfj_description,bfj_fichier '.
' from bazar_fichier_joint where bfj_ce_fiche="'.$_POST['fiche_dupliquee'].'"';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
return;
}
$requete = 'SELECT bfj_id_fichier FROM bazar_fichier_joint WHERE bfj_fichier="'.$_FILES[$nom_fichier]['name'].'"';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
if (!isset ($_SESSION['_BAZAR_']['fichier'])) {
if ($resultat->numRows()==0) {
$chemin_destination=BAZ_CHEMIN_APPLI.'upload/'.$_FILES[$nom_fichier]['name'];
move_uploaded_file($_FILES[$nom_fichier]['tmp_name'], $chemin_destination);
chmod ($chemin_destination, 0755);
}
$id_fichier_joint = baz_nextId('bazar_fichier_joint', 'bfj_id_fichier', $GLOBALS['_BAZAR_']['db']) ;
$requete = 'INSERT INTO bazar_fichier_joint SET bfj_id_fichier='.$id_fichier_joint.', bfj_ce_fiche='.$idfiche.
', bfj_description="'.addslashes($fichier_description).'", bfj_fichier="'.$_FILES[$nom_fichier]['name'].'"';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
return $resultat->getMessage().$resultat->getDebugInfo() ;
}
}
$_SESSION['_BAZAR_']['fichier'] = 1;
return;
}
 
 
/** baz_insertion_image() - inserer une image a une fiche
*
* @global integer L'identifiant de la fiche
* @return string requete SQL
*/
function baz_insertion_image($idfiche) {
 
 
//verification de la presence de ce fichier
$requete = 'SELECT bf_id_fiche FROM bazar_fiche WHERE bf_url_image="'.$_FILES['image']['name'].'" AND bf_id_fiche!='.$idfiche;
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
if ($resultat->numRows()==0) {
$chemin_destination=BAZ_CHEMIN_APPLI.'upload/'.$_FILES['image']['name'];
move_uploaded_file($_FILES['image']['tmp_name'], $chemin_destination);
chmod ($chemin_destination, 0755);
}
$_SESSION['_BAZAR_']['image'] = 1;
return 'bf_url_image="'.$_FILES['image']['name'].'", ' ;
}
 
 
/** baz_mise_a_jour() - Mettre a jour une fiche
*
* @global Le contenu du formulaire de saisie de l'annonce
* @return void
*/
function baz_mise_a_jour($valeur) {
//MAJ de bazar_fiche
$requete = 'UPDATE bazar_fiche SET '.requete_bazar_fiche($valeur,$GLOBALS['_BAZAR_']['id_typeannonce']);
$requete.= ' WHERE bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
return ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
// Envoie d un mail aux administrateurs
$utilisateur = new Administrateur_bazar($GLOBALS['AUTH']);
if (!$utilisateur->isAdmin($GLOBALS['_BAZAR_']['id_typeannonce']) || !$utilisateur->isSuperAdmin()) {
bazar::notifier(BAZAR_NOTIFICATION_MODIFICATION_FICHE);
}
return;
}
 
/** baz_post_validation ()
*
* Cette fonction renvoie une page qui invite l utilisateur a :
* - saisir une nouvelle fiche a partir de celle qu il vient de saisir (pour changer de date)
* - retour a la liste de ces fiches
* - saisir une nouvelle fiche
*
*/
 
function baz_post_validation() {
 
$lien_duplication = clone $GLOBALS['_BAZAR_']['url'];
$lien_nouvelle_fiche = clone $GLOBALS['_BAZAR_']['url'];
$lien_mes_fiches = clone $GLOBALS['_BAZAR_']['url'];
$lien_visualiser_fiche = clone $GLOBALS['_BAZAR_']['url'];
 
$lien_duplication->addQueryString(BAZ_VARIABLE_DUPLICATION, 1);
$lien_duplication->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_NOUVEAU);
$lien_duplication = $lien_duplication->getURL();
 
$lien_visualiser_fiche->addQueryString(BAZ_VARIABLE_VOIR, BAZ_GERER_DROITS);
$lien_visualiser_fiche->addQueryString(BAZ_VARIABLE_ACTION, BAZ_VOIR_FICHE);
$lien_visualiser_fiche = $lien_visualiser_fiche->getUrl() ;
 
$lien_nouvelle_fiche->removeQueryString(BAZ_VARIABLE_ID_FICHE);
 
$lien_nouvelle_fiche->addQueryString(BAZ_VARIABLE_ACTION, BAZ_DEPOSER_ANNONCE);
$lien_nouvelle_fiche->addQueryString(BAZ_VARIABLE_CATEGORIE_NATURE, $GLOBALS['_BAZAR_']['categorie_nature']);
$lien_nouvelle_fiche = $lien_nouvelle_fiche->getURL();
 
$lien_mes_fiches->removeQueryString(BAZ_VARIABLE_ID_FICHE);
 
$lien_mes_fiches->addQueryString(BAZ_VARIABLE_VOIR, BAZ_VOIR_MES_FICHES);
$lien_mes_fiches = $lien_mes_fiches->getURL();
 
ob_start();
if (file_exists(BAZ_CHEMIN_SQUELETTE.'baz_post_validation.tpl.html')) {
include_once BAZ_CHEMIN_SQUELETTE.'baz_post_validation.tpl.html';
}
$res = ob_get_contents();
ob_end_clean();
return $res ;
}
/** baz_suppression() - Supprime une fiche
*
* @global L'identifiant de la fiche a supprimer
* @return void
*/
function baz_suppression() {
if ($GLOBALS['AUTH']->getAuth()) {
$valeurs = baz_valeurs_fiche($_GET['id_fiche']);
 
//suppression des wikinis associes
//g�n�ration du titre du wiki, sous la forme id-titre du projet
/*
$titre=baz_titre_wiki($valeurs["bf_titre"]);
$requete = 'SELECT gewi_id_wikini FROM gen_wikini WHERE gewi_code_alpha_wikini = "'.$titre.'"';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if ($resultat->numRows()>0) {
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
$id_wikini=$ligne['gewi_id_wikini'];
}
include_once PAP_CHEMIN_RACINE.'api/sql/SQL_manipulation.fonct.php';
include_once PAP_CHEMIN_RACINE.'client/integrateur_wikini/configuration/adwi_configuration.inc.php' ;
include_once PAP_CHEMIN_RACINE.'client/integrateur_wikini/bibliotheque/adwi_wikini.fonct.php' ;
adwi_supprimer_wikini($id_wikini, $GLOBALS['_BAZAR_']['db']);
}
*/
 
// suppression des valeurs des listes et des cases � cocher
$requete = 'DELETE FROM bazar_fiche_valeur_liste WHERE bfvl_ce_fiche='.$_GET['id_fiche'];
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
return ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
 
//suppression des urls associes
$requete = 'SELECT bu_id_url FROM bazar_url WHERE bu_ce_fiche = '.$_GET['id_fiche'];
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
return ('Echec de la requete<br />'.$resultat->getMessage().'<br />'.$resultat->getDebugInfo().'<br />'."\n") ;
}
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
baz_suppression_url($ligne['bu_id_url']);
}
 
//suppression des fichiers associes
$requete = 'SELECT bfj_id_fichier FROM bazar_fichier_joint WHERE bfj_ce_fiche = '.$_GET['id_fiche'];
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
return ('Echec de la requete<br />'.$resultat->getMessage().'<br />'.$resultat->getDebugInfo().'<br />'."\n") ;
}
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
baz_suppression_fichier($ligne['bfj_id_fichier']);
}
 
//suppression dans bazar_fiche
$requete = 'DELETE FROM bazar_fiche WHERE bf_id_fiche = '.$_GET['id_fiche'];
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
return ('Echec de la requete<br />'.$resultat->getMessage().'<br />'.$resultat->getDebugInfo().'<br />'."\n") ;
}
// Redirection vers Mes fiches
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_VOIR, BAZ_VOIR_MES_FICHES);
$GLOBALS['_BAZAR_']['url']->removeQueryString('id_fiche');
header ('Location:'.$GLOBALS['_BAZAR_']['url']->getURL());
exit;
return ;
}
}
 
 
/** baz_suppression_url() - Supprimer un lien d'une fiche
*
* @global integer L'identifiant du lien
* @return void
*/
function baz_suppression_url($id_url) {
 
if ($GLOBALS['AUTH']->getAuth()) {
//suppression dans bazar_url
$requete = 'DELETE FROM bazar_url WHERE bu_id_url = '.$id_url;
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ('Echec de la requete<br />'.$resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
}
return;
}
}
 
 
/** baz_suppression_fichier() - Supprimer un fichier d'une fiche
*
* @global integer L'identifiant du fichier
* @return void
*/
function baz_suppression_fichier($id_fichier) {
 
if ($GLOBALS['AUTH']->getAuth()) {
//verification de l'utilisation du fichier joint pour une autre annonce
$requete = 'SELECT bfj_fichier FROM bazar_fichier_joint WHERE bfj_id_fichier='.$id_fichier;
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
$requete = 'SELECT bfj_fichier FROM bazar_fichier_joint WHERE bfj_fichier="'.$ligne['bfj_fichier'].'"';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
//si le fichier n'est que utilise dans cette fiche, on le supprime, on le laisse sinon
if ($resultat->numRows()==1) {
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
unlink(BAZ_CHEMIN_APPLI.'upload/'.$ligne['bfj_fichier']);
}
 
//suppression dans la table bazar_fichier
$requete = 'DELETE FROM bazar_fichier_joint WHERE bfj_id_fichier = '.$id_fichier;
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ('Echec de la requete<br />'.$resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
}
return;
}
}
 
 
/** baz_suppression_image() - Supprimer une image d'une fiche
*
* @global integer L'identifiant de la fiche
* @return void
*/
function baz_suppression_image($id_fiche) {
 
if ($GLOBALS['AUTH']->getAuth()) {
//verification de l'utilisation de l'image pour une autre annonce
$requete = 'SELECT bf_url_image FROM bazar_fiche WHERE bf_id_fiche='.$id_fiche;
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
$requete = 'SELECT bf_url_image FROM bazar_fiche WHERE bf_url_image="'.$ligne['bf_url_image'].'"';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
//si le fichier n'est que utilise dans cette fiche, on le supprime, on le laisse sinon
if ($resultat->numRows()==1) {
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
unlink(BAZ_CHEMIN_APPLI.'upload/'.$ligne['bf_url_image']);
}
 
//suppression dans la table bazar_fiche
$requete = 'UPDATE bazar_fiche SET bf_url_image=NULL WHERE bf_id_fiche = '.$id_fiche;
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ('Echec de la requete<br />'.$resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
}
return;
}
}
 
 
/** publier_fiche () - Publie ou non dans les fichiers XML la fiche bazar d'un utilisateur
*
* @global boolean Valide: oui ou non
* @return void
*/
function publier_fiche($valid) {
 
$utilisateur = new Administrateur_bazar($GLOBALS['AUTH']);
// sortie anticipée en cas d'accès non autorisé
// ceci limite l'accès au supers admins
// TODO: voir si l'on ne pourrait valider que les fiches
// des catégories dont la personne est admin, ce qui permettrait un accès plus fin
if(!$utilisateur->isSuperAdmin()) {
return;
}
 
if (isset($_GET['id_fiche'])) $GLOBALS['_BAZAR_']['id_fiche']=$_GET['id_fiche'];
 
if(isset($_POST['date_validite']) && date('Y-m-d', strtotime($_POST['date_validite']))) {
$date_validite = '"'.date('Y-m-d', strtotime($_POST['date_validite'])).'"';
} else {
$date_validite = 'now()';
}
 
if (isset($_GET['typeannonce'])) $typeannonce=$_GET['typeannonce'];
if ($valid==0) {
$requete = 'UPDATE bazar_fiche SET bf_statut_fiche=2 WHERE bf_id_fiche="'.$GLOBALS['_BAZAR_']['id_fiche'].'"' ;
}
else {
$requete = 'UPDATE bazar_fiche SET bf_date_debut_validite_fiche='.$date_validite.' , bf_statut_fiche=1 WHERE bf_id_fiche="'.$GLOBALS['_BAZAR_']['id_fiche'].'"' ;
}
 
 
// ====================Mise a jour de la table bazar_fiche====================
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
unset ($resultat) ;
//TODO envoie mail annonceur
return;
}
 
 
/** baz_s_inscrire() affiche le formulaire qui permet de s'inscrire pour recevoir des annonces d'un type
*
* @return string le code HTML
*/
function baz_s_inscrire() {
$res= '<h2>'.BAZ_S_INSCRIRE_AUX_ANNONCES.'</h2>'."\n";
if (isset($_GET['inscrip'])) {
//cas d'une desinscription
if ($_GET['inscrip']==0) {
$requete='DELETE FROM bazar_abonnement WHERE ba_id_utilisateur='.$GLOBALS['id_user'].' AND ba_id_rubrique='.$_GET['idtypeannonce'];
}
//cas d'une inscription
else {
$requete='INSERT INTO bazar_abonnement VALUES ('.$GLOBALS['id_user'].', '.$_GET['idtypeannonce'].')';
}
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
}
 
if ($GLOBALS['AUTH']->getAuth()) {
$res .= '<p id="laius_abonnement">'.BAZ_LAIUS_S_ABONNER.'</p>'."\n";
//requete pour obtenir l'id et le label des types d'annonces
$requete = 'SELECT bn_id_nature, bn_label_nature, bn_image_titre '.
'FROM bazar_nature WHERE 1'; /*bn_ce_id_menu='.$GLOBALS['_BAZAR_']['categorie_nature'];*/
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
 
// Nettoyage de l url
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_VOIR);
 
//$table = new HTML_Table(array ('width' => '100%', 'class' => 'table_bazar'));
//$table->addRow(array(BAZ_TYPE_ANNONCES,/* BAZ_STATUT, BAZ_PASSER_EN, */ BAZ_RSS));
//$table->setRowType(0, 'th');*/
$res .= '<div>'.BAZ_TYPE_ANNONCES.'</div>' ;
$res .= '<ul>' ;
 
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
 
$lien_RSS=$GLOBALS['_BAZAR_']['url'];
$lien_RSS->addQueryString('action', BAZ_VOIR_FLUX_RSS);
 
//requete pour savoir si la personne est inscrite a ce type d'annonce
$requete = 'SELECT ba_id_utilisateur '.
'FROM bazar_abonnement '.
'WHERE ba_id_utilisateur='.$GLOBALS['id_user'].' AND ba_id_rubrique='.$ligne['bn_id_nature'];
$resultat2 = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat2)) {
die ($resultat2->getMessage().$resultat2->getDebugInfo()) ;
}
$lien_RSS->addQueryString('annonce', $ligne['bn_id_nature']);
$res .= '<li>'. '<a href="'.$lien_RSS->getURL().'">'.$ligne['bn_label_nature'].'</a></li>' ;
$lien_RSS->removeQueryString('annonce');
}
$res .= '</ul>' ;
}
else {
$res .= '<p class="zone_info">'.BAZ_IDENTIFIEZ_VOUS_POUR_SAISIR.'</p>'."\n" ;
$res .= '<form id="form_connexion" style="clear:both;" class="form_identification" action="' ;
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_ACTION, BAZ_S_INSCRIRE);
$res .= $GLOBALS['_BAZAR_']['url']->getURL();
$res .= '" method="post">
<fieldset>
<legend>Identifiez vous</legend>
<label for="username">Courriel : </label>
<input type="text" id="username" name="username" maxlength="80" tabindex="1" value="courriel" />
<label for="password">Mot de passe : </label>
<input type="password" id="password" name="password" maxlength="80" tabindex="2" value="mot de passe" />
<input type="submit" id="connexion" name="connexion" tabindex="3" value="ok" />
</fieldset>
</form>';
}
 
// Nettoyage de l'url
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
$GLOBALS['_BAZAR_']['url']->removeQueryString('idtypeannonce');
$GLOBALS['_BAZAR_']['url']->removeQueryString('inscrip');
 
return $res;
}
 
 
/** baz_valeurs_fiche() - Renvoie un tableau avec les valeurs par defaut du formulaire d'inscription
*
* @param integer Identifiant de la fiche
*
* @return array Valeurs enregistrees pour cette fiche
*/
function baz_valeurs_fiche($idfiche) {
$requete = 'SELECT * FROM bazar_fiche WHERE bf_id_fiche='.$idfiche;
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
}
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC) ;
$valeurs_fiche = array() ;
$tableau = baz_valeurs_template($GLOBALS['_BAZAR_']['template']);
for ($i=0; $i<count($tableau); $i++) {
if ($tableau[$i]['type']=='liste' || $tableau[$i]['type']=='checkbox' || $tableau[$i]['type']=='radio') {
$requete = 'SELECT bfvl_valeur FROM bazar_fiche_valeur_liste WHERE bfvl_ce_fiche='.$idfiche.
' AND bfvl_ce_liste='.$tableau[$i]['nom_bdd'];
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError ($resultat)) {
die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
}
$nb=0;$val='';
while ($result = $resultat->fetchRow()) {
if ($nb>0) $val .= ', ';
$val .= $result[0];
$nb++;
}
$valeurs_fiche[$tableau[$i]['type'].$tableau[$i]['nom_bdd']] = $val;
}
elseif ($tableau[$i]['type']=='champs_cache' || $tableau[$i]['type']=='texte' || $tableau[$i]['type']=='textelong' || $tableau[$i]['type']=='listedatedeb' || $tableau[$i]['type']=='listedatefin') {
$valeurs_fiche[$tableau[$i]['nom_bdd']] = stripslashes($ligne[$tableau[$i]['nom_bdd']]);
} elseif ($tableau[$i]['type']=='carte_google') {
$valeurs_fiche['bf_latitude'] = $ligne['bf_latitude'];
$valeurs_fiche['bf_longitude'] = $ligne['bf_longitude'];
}
}
return $valeurs_fiche;
}
 
/** baz_valeurs_champ() - Renvoie les valeurs d'un champ pour une fiche donn�e
*
* @param string le nom du champ de la fiche
* @param integer Identifiant de la fiche
*
* @return string Valeurs enregistrees pour cette fiche
*/
function baz_valeur_champs($nom_champs,$id_fiche) {
 
$requete = 'SELECT blv_label FROM bazar_fiche_valeur_liste, bazar_liste_valeurs WHERE bfvl_ce_fiche='.
$id_fiche.' AND bfvl_ce_liste='.$nom_champs.
' AND bfvl_valeur=blv_valeur AND blv_ce_liste='.$nom_champs.
' AND blv_ce_i18n="'.$GLOBALS['_BAZAR_']['langue'].'"';
 
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError ($resultat)) {
return ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
}
else {
$res = '';
while($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
if($ligne['blv_label'] != 'Autre') {
$res .= $ligne['blv_label'].', ';
}
}
$res = rtrim($res,', ');
 
return $res;
}
}
 
/** function baz_nextId () Renvoie le prochain identifiant numerique libre d'une table
*
* @param string Nom de la table
* @param string Nom du champs identifiant
* @param mixed Objet DB de PEAR pour la connexion a la base de donnees
*
* return integer Le prochain numero d'identifiant disponible
*/
function baz_nextId($table, $colonne_identifiant, $bdd) {
$requete = 'SELECT MAX('.$colonne_identifiant.') AS maxi FROM '.$table;
$resultat = $bdd->query($requete) ;
if (DB::isError($resultat)) {
die (__FILE__ . __LINE__ . $resultat->getMessage() . $requete);
return $bdd->raiseError($resultat) ;
}
 
if ($resultat->numRows() > 1) {
return $bdd->raiseError('<br />La table '.$table.' a un identifiant non unique<br />') ;
}
$ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT) ;
return $ligne->maxi + 1 ;
}
 
/** function baz_titre_wiki () Renvoie la chaine de caractere sous une forme compatible avec wikini
*
* @param string mot � transformer (enlever accents, espaces)
*
* return string mot transform�
*/
function baz_titre_wiki($nom) {
$titre=trim($nom);
for ($j = 0; $j < strlen ($titre); $j++) {
if (!preg_match ('/[a-zA-Z0-9]/', $titre[$j])) {
$titre[$j] = '_' ;
}
}
return $titre;
}
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
* Revision 1.78 2008-09-17 14:08:45 alexandre_tb
* merge depuis aha
*
* Revision 1.77 2008-03-17 11:02:59 jp_milcent
* Ajout de l'authentification n�cessaire pour d�poser des commentaires.
* Corrections sur la gestion des param�tres dans les urls (compatibilit� applette Identification et Moteur de Recherche).
*
* Revision 1.76 2007-12-14 09:56:02 alexandre_tb
* Fusion avec la livraison AHA : 14 decembre 2007
*
* Revision 1.75 2007-12-04 09:07:21 alexandre_tb
* Fusion avec la livraison AHA : 4 d�c 2007
*
* Revision 1.74 2007-10-25 09:41:31 alexandre_tb
* mise en place de variable de session pour eviter que les formulaires soit valider 2 fois, pour les url, fichiers et image
*
* Revision 1.73 2007-10-24 13:27:00 alexandre_tb
* bug : double saisie d url
* suppression de warning sur variable
*
* Revision 1.72 2007-10-22 10:09:21 florian
* correction template
*
* Revision 1.71 2007-10-22 09:18:39 alexandre_tb
* prise en compte de la langue dans les requetes sur bazar_nature
*
* Revision 1.70 2007-10-10 13:26:36 alexandre_tb
* utilisation de la classe Administrateur_bazar a la place de niveau_droit
* suppression de fonction niveau_droit
*
* Revision 1.69 2007-09-18 07:39:42 alexandre_tb
* correction d un bug lors d une insertion
*
* Revision 1.68 2007-08-27 12:31:31 alexandre_tb
* mise en place de modele
*
* Revision 1.67 2007-07-04 10:01:30 alexandre_tb
* mise en place de divers templates :
* - mail pour admin (sujet et corps)
* - modele carte_google
* ajout de lignes dans bazar_template
*
* Revision 1.66 2007-06-25 12:15:06 alexandre_tb
* merge from narmer
*
* Revision 1.65 2007-06-25 08:31:17 alexandre_tb
* utilisation de la bibliotheque generale api/formulaire/formulaire.fonct.inc.php a la place de bazar.fonct.formulaire.php
*
* Revision 1.64 2007-06-04 15:25:39 alexandre_tb
* ajout de la carto google
*
* Revision 1.63 2007/04/11 08:30:12 neiluj
* remise en �tat du CVS...
*
* Revision 1.57.2.12 2007/03/16 14:49:24 alexandre_tb
* si la date de debut d evenement est superieure a la date de fin alors on met
* la meme date dans les deux champs (coherence)
*
* Revision 1.57.2.11 2007/03/07 17:40:57 jp_milcent
* Ajout d'id sur les colonnes et gestion par les CSS des styles du tableau des abonnements.
*
* Revision 1.57.2.10 2007/03/07 17:20:19 jp_milcent
* Ajout du nettoyage syst�matique des URLs.
*
* Revision 1.57.2.9 2007/03/06 16:23:24 jp_milcent
* Nettoyage de l'url pour la gestion des droits.
*
* Revision 1.57.2.8 2007/03/05 14:33:44 jp_milcent
* Suppression de l'appel � Mes_Fiches dans la fonction baz_formulaire
*
* Revision 1.57.2.7 2007/03/05 10:28:03 alexandre_tb
* correction d un commentaire
*
* Revision 1.57.2.6 2007/02/15 13:42:16 jp_milcent
* Utilisation de IN � la place du = dans les requ�tes traitant les cat�gories de fiches.
* Permet d'utiliser la syntaxe 1,2,3 dans la configuration de categorie_nature.
*
* Revision 1.57.2.5 2007/02/12 16:16:31 alexandre_tb
* suppression du style clear:both dans les attribut du formulaire d identification
*
* Revision 1.57.2.4 2007/02/01 16:19:30 alexandre_tb
* correction erreur de requete sur insertion bazar_fiche
*
* Revision 1.57.2.3 2007/02/01 16:11:05 alexandre_tb
* correction erreur de requete sur insertion bazar_fiche
*
* Revision 1.57.2.2 2007/01/22 16:05:39 alexandre_tb
* insertion de la date du jour dans bf_date_debut_validite_fiche quand il n'y a pas ce champs dans le formulaire (�vite le 0000-00-00)
*
* Revision 1.57.2.1 2006/12/13 13:23:03 alexandre_tb
* Remplacement de l appel d une constante par un appel direct. -> warning
*
* Revision 1.58 2006/12/13 13:20:16 alexandre_tb
* Remplacement de l appel d une constante par un appel direct. -> warning
*
* Revision 1.57 2006/10/05 08:53:50 florian
* amelioration moteur de recherche, correction de bugs
*
* Revision 1.56 2006/09/28 15:41:36 alexandre_tb
* Le formulaire pour se logguer dans l'action saisir reste sur l'action saisir apr�s
*
* Revision 1.55 2006/09/21 14:19:39 florian
* am�lioration des fonctions li�s au wikini
*
* Revision 1.54 2006/09/14 15:11:23 alexandre_tb
* suppression temporaire de la gestion des wikinis
*
* Revision 1.53 2006/07/25 13:24:44 florian
* correction bug image
*
* Revision 1.52 2006/07/25 13:05:00 alexandre_tb
* Remplacement d un die par un echo
*
* Revision 1.51 2006/07/18 14:17:32 alexandre_tb
* Ajout d'un formulaire d identification
*
* Revision 1.50 2006/06/21 08:37:59 alexandre_tb
* Correction de bug, d'un appel constant (....) qui ne fonctionnais plus.
*
* Revision 1.49 2006/06/02 09:29:07 florian
* debut d'integration de wikini
*
* Revision 1.48 2006/05/19 13:54:11 florian
* stabilisation du moteur de recherche, corrections bugs, lien recherche avancee
*
* Revision 1.47 2006/04/28 12:46:14 florian
* integration des liens vers annuaire
*
* Revision 1.46 2006/03/29 13:04:35 alexandre_tb
* utilisation de la classe Administrateur_bazar
*
* Revision 1.45 2006/03/24 09:28:02 alexandre_tb
* utilisation de la variable globale $GLOBALS['_BAZAR_']['categorie_nature']
*
* Revision 1.44 2006/03/14 17:10:21 florian
* ajout des fonctions de syndication, changement du moteur de recherche
*
* Revision 1.43 2006/03/02 20:36:52 florian
* les entrees du formulaire de saisir ne sont plus dans les constantes mias dans des tables qui gerent le multilinguisme.
*
* Revision 1.42 2006/03/01 16:23:22 florian
* modifs textes fr et correction bug "undefined index"
*
* Revision 1.41 2006/03/01 16:05:51 florian
* ajout des fichiers joints
*
* Revision 1.40 2006/02/06 09:33:00 alexandre_tb
* correction de bug
*
* Revision 1.39 2006/01/30 17:25:38 alexandre_tb
* correction de bugs
*
* Revision 1.38 2006/01/30 10:27:04 florian
* - ajout des entr�es de formulaire fichier, url, et image
* - correction bug d'affichage du mode de saisie
*
* Revision 1.37 2006/01/24 14:11:11 alexandre_tb
* correction de bug sur l'ajout d'une image et d'un fichier
*
* Revision 1.36 2006/01/19 17:42:11 florian
* ajout des cases � cocher pr�-coch�es pour les maj
*
* Revision 1.35 2006/01/18 11:06:51 florian
* correction erreur saisie date
*
* Revision 1.34 2006/01/18 10:53:28 florian
* corrections bugs affichage fiche
*
* Revision 1.33 2006/01/18 10:07:34 florian
* recodage de l'insertion et de la maj des donn�es relatives aux listes et checkbox dans des formulaires
*
* Revision 1.32 2006/01/18 10:03:36 florian
* recodage de l'insertion et de la maj des donn�es relatives aux listes et checkbox dans des formulaires
*
* Revision 1.31 2006/01/17 10:07:08 alexandre_tb
* en cours
*
* Revision 1.30 2006/01/16 09:42:57 alexandre_tb
* en cours
*
* Revision 1.29 2006/01/13 14:12:51 florian
* utilisation des temlates dans la table bazar_nature
*
* Revision 1.28 2006/01/05 16:28:24 alexandre_tb
* prise en chage des checkbox, reste la mise � jour � g�rer
*
* Revision 1.27 2006/01/04 15:30:56 alexandre_tb
* mise en forme du code
*
* Revision 1.26 2006/01/03 10:19:31 florian
* 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...
*
* Revision 1.25 2005/12/20 14:49:35 ddelon
* Fusion Head vers Livraison
*
* Revision 1.24 2005/12/16 15:44:40 alexandre_tb
* ajout de l'option restreindre d�p�t
*
* Revision 1.23 2005/12/01 17:03:34 florian
* changement des chemins pour appli Pear
*
* Revision 1.22 2005/12/01 16:05:41 florian
* changement des chemins pour appli Pear
*
* Revision 1.21 2005/12/01 15:31:30 florian
* correction bug modifs et saisies
*
* Revision 1.20 2005/11/30 13:58:45 florian
* ajouts graphisme (logos, boutons), changement structure SQL bazar_fiche
*
* Revision 1.19 2005/11/24 16:17:13 florian
* corrections bugs, ajout des cases � cocher
*
* Revision 1.18 2005/11/18 16:03:23 florian
* correction bug html entites
*
* Revision 1.17 2005/11/17 18:48:02 florian
* corrections bugs + am�lioration de l'application d'inscription
*
* Revision 1.16 2005/11/07 17:30:36 florian
* ajout controle sur les listes pour la saisie
*
* Revision 1.15 2005/11/07 17:05:45 florian
* am�lioration validation conditions de saisie, ajout des r�gles sp�cifiques de saisie des formulaires
*
* Revision 1.14 2005/11/07 08:48:02 florian
* correction pb guillemets pour saisie et modif de fiche
*
* Revision 1.13 2005/10/21 16:15:04 florian
* mise a jour appropriation
*
* Revision 1.11 2005/10/12 17:20:33 ddelon
* Reorganisation calendrier + applette
*
* Revision 1.10 2005/10/12 15:14:06 florian
* am�lioration de l'interface de bazar, de mani�re a simplifier les consultations, et � harmoniser par rapport aux Ressources
*
* Revision 1.9 2005/10/10 16:22:52 alexandre_tb
* Correction de bug. Lorsqu'on revient en arri�re apr�s avoir valid� un formulaire.
*
* Revision 1.8 2005/09/30 13:50:07 alexandre_tb
* correction bug date parution ressource
*
* Revision 1.7 2005/09/30 13:15:58 ddelon
* compatibilit� php5
*
* Revision 1.6 2005/09/30 13:00:05 ddelon
* Fiche bazar generique
*
* Revision 1.5 2005/09/30 12:22:54 florian
* Ajouts commentaires pour fiche, modifications graphiques, maj SQL
*
* Revision 1.3 2005/07/21 19:03:12 florian
* nouveaut�s bazar: templates fiches, correction de bugs, ...
*
* Revision 1.1.1.1 2005/02/17 18:05:11 florian
* Import initial de Bazar
*
* Revision 1.1.1.1 2005/02/17 11:09:50 florian
* Import initial
*
* Revision 1.1.1.1 2005/02/16 18:06:35 florian
* import de la nouvelle version
*
* Revision 1.10 2004/07/08 17:25:25 florian
* ajout commentaires + petits debuggages
*
* Revision 1.8 2004/07/07 14:30:19 florian
* d�bogage RSS
*
* Revision 1.7 2004/07/06 16:22:01 florian
* d�bogage modification + MAJ flux RSS
*
* Revision 1.6 2004/07/06 09:28:26 florian
* changement interface de modification
*
* Revision 1.5 2004/07/05 15:10:23 florian
* changement interface de saisie
*
* Revision 1.4 2004/07/02 14:51:14 florian
* ajouts divers pour faire fonctionner l'insertion de fiches
*
* Revision 1.3 2004/07/01 16:37:42 florian
* ajout de fonctions pour les templates
*
* Revision 1.2 2004/07/01 13:00:13 florian
* modif Florian
*
* Revision 1.1 2004/06/23 09:58:32 alex
* version initiale
*
* Revision 1.1 2004/06/18 09:00:37 alex
* version initiale
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
 
?>
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: bazar.fonct.php,v 1.74.2.13 2008-08-27 13:21:40 alexandre_tb Exp $
/**
*
* Fonctions du module bazar
*
*
*@package bazar
//Auteur original :
*@author Alexandre Granier <alexandre@tela-botanica.org>
*@author Florian Schmitt <florian@ecole-et-nature.org>
//Autres auteurs :
*@copyright Tela-Botanica 2000-2004
*@version $Revision: 1.74.2.13 $ $Date: 2008-08-27 13:21:40 $
// +------------------------------------------------------------------------------------------------------+
*/
 
// +------------------------------------------------------------------------------------------------------+
// | ENTETE du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm.php' ;
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm/checkbox.php' ;
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm/textarea.php' ;
require_once PAP_CHEMIN_API_PEAR.'HTML/Table.php' ;
require_once GEN_CHEMIN_API.'formulaire/formulaire.fonct.inc.php';
require_once 'bazar.fonct.rss.php';
 
 
/** fiches_a_valider () - Renvoie les annonces restant a valider par un administrateur
*
* @return string HTML
*/
function fiches_a_valider() {
 
$utilisateur = new Administrateur_bazar($GLOBALS['AUTH']);
// sortie anticipée en cas d'accès non autorisé
// ceci limite l'accès au supers admins
// TODO: voir si l'on ne pourrait afficher que les fiches
// des catégories dont la personne est admin
// des catégories dont la personne est admin, ce qui permettrait un accès plus fin
if(!$utilisateur->isSuperAdmin()) {
return;
}
 
// Pour les administrateurs d'une rubrique, on affiche les fiches a valider de cette rubrique
// On effectue une requete sur le bazar pour voir les fiches a administrer
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_VOIR, BAZ_VOIR_ADMIN);
$res= '<h2>'.BAZ_ANNONCES_A_ADMINISTRER.'</h2><br />'."\n";
$requete = 'SELECT * FROM bazar_fiche, bazar_nature WHERE bf_statut_fiche=0 AND ' .
'bn_id_nature=bf_ce_nature ' ;
if (isset($GLOBALS['_BAZAR_']['langue'])) {
$requete .= ' and bn_ce_i18n like "'.$GLOBALS['_BAZAR_']['langue'].'%" ';
}
$requete .= 'ORDER BY bf_date_maj_fiche DESC' ;
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ('Echec de la requete<br />'.$resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
}
if ($resultat->numRows() != 0) {
$tableAttr = array('id' => 'table_bazar') ;
$table = new HTML_Table($tableAttr) ;
$entete = array (BAZ_TITREANNONCE ,BAZ_ANNONCEUR, BAZ_TYPEANNONCE, BAZ_PUBLIER, BAZ_SUPPRIMER, BAZ_DATE_DEBUT_EVENEMENT) ;
$table->addRow($entete) ;
$table->setRowType (0, 'th') ;
// On affiche une ligne par proposition
while ($ligne = $resultat->fetchRow (DB_FETCHMODE_ASSOC)) {
//Requete pour trouver le nom et prenom de l'annonceur
$requetenomprenom = 'SELECT '.BAZ_CHAMPS_PRENOM.', '.BAZ_CHAMPS_NOM.' FROM '.BAZ_ANNUAIRE.
' WHERE '.BAZ_CHAMPS_ID.'='.$ligne['bf_ce_utilisateur'] ;
$resultatnomprenom = $GLOBALS['_BAZAR_']['db']->query ($requetenomprenom) ;
if (DB::isError($resultatnomprenom)) {
echo ("Echec de la requete<br />".$resultatnomprenom->getMessage()."<br />".$resultatnomprenom->getDebugInfo()) ;
}
while ($lignenomprenom = $resultatnomprenom->fetchRow (DB_FETCHMODE_ASSOC)) {
$annonceur=$lignenomprenom[BAZ_CHAMPS_PRENOM]." ".$lignenomprenom[BAZ_CHAMPS_NOM];
}
$lien_voir=$GLOBALS['_BAZAR_']['url'];
$lien_voir->addQueryString(BAZ_VARIABLE_ACTION, BAZ_VOIR_FICHE);
$lien_voir->addQueryString('id_fiche', $ligne['bf_id_fiche']);
$lien_voir->addQueryString('typeannonce', $ligne['bn_id_nature']);
// Nettoyage de l'url
// NOTE (jpm - 23 mai 2007): pour être compatible avec PHP5 il faut utiliser tjrs $GLOBALS['_BAZAR_']['url'] car en php4 on
// copie bien une variable mais pas en php5, cela reste une référence...
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
$GLOBALS['_BAZAR_']['url']->removeQueryString('id_fiche');
$GLOBALS['_BAZAR_']['url']->removeQueryString('typeannonce');
$GLOBALS['_BAZAR_']['url']->addQueryString('id_fiche', $ligne['bf_id_fiche']);
$GLOBALS['_BAZAR_']['url']->addQueryString('typeannonce', $ligne['bn_id_nature']);
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_ACTION, BAZ_VOIR_FICHE);
$lien_voir = $GLOBALS['_BAZAR_']['url']->getURL();
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
 
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_PUBLIER);
$lien_publie_oui = $GLOBALS['_BAZAR_']['url']->getURL();
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_PAS_PUBLIER);
$lien_publie_non = $GLOBALS['_BAZAR_']['url']->getURL();
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_SUPPRESSION);
$lien_supprimer = $GLOBALS['_BAZAR_']['url']->getURL();
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
$GLOBALS['_BAZAR_']['url']->removeQueryString('id_fiche');
$GLOBALS['_BAZAR_']['url']->removeQueryString('typeannonce');
$table->addRow (array(
'<a href="'.$lien_voir.'">'.$ligne['bf_titre'].'</a>'."\n", // col 1 : le nom
$annonceur."\n", // col 2 : annonceur
$ligne['bn_label_nature']."\n", // col 3 : type annonce
"<a href=\"".$lien_publie_oui."\">".BAZ_OUI."</a> / \n".
"<a href=\"".$lien_publie_non."\">".BAZ_NON."</a>", // col 4 : publier ou pas
"<a href=\"".$lien_supprimer."\"".
" onclick=\"javascript:return confirm('".BAZ_CONFIRMATION_SUPPRESSION."');\">".BAZ_SUPPRIMER."</a>\n", // col 5 : supprimer
date('d', strtotime($ligne['bf_date_debut_evenement'])).' '.$GLOBALS['mois'][date('n', strtotime ($ligne['bf_date_debut_evenement']))].' '.date('Y', strtotime ($ligne['bf_date_debut_evenement'])) // col 6 date début d'évenement
)) ;
}
$table->altRowAttributes(1, array("class" => "ligne_impaire"), array("class" => "ligne_paire"));
$table->updateColAttributes(1, array("align" => "center"));
$table->updateColAttributes(2, array("align" => "center"));
$table->updateColAttributes(3, array("align" => "center"));
$table->updateColAttributes(4, array("align" => "center"));
$table->updateColAttributes(5, array("align" => "center"));
$res .= $table->toHTML() ;
}
else {
$res .= '<p class="zone_info">'.BAZ_PAS_DE_FICHE_A_VALIDER.'</p>'."\n" ;
}
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_ACTION, BAZ_VOIR_TOUTES_ANNONCES);
// Nettoyage de l'url
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
$GLOBALS['_BAZAR_']['url']->removeQueryString('id_fiche');
$GLOBALS['_BAZAR_']['url']->removeQueryString('typeannonce');
// Les autres fiches, deja validees
$res .= '<h2>'.BAZ_TOUTES_LES_FICHES.'</h2>'."\n";
$requete = 'SELECT * FROM bazar_fiche, bazar_nature WHERE bf_statut_fiche=1 AND ' .
'bn_id_nature=bf_ce_nature AND bn_ce_id_menu IN ('.$GLOBALS['_BAZAR_']['categorie_nature'].') ';
if (isset($GLOBALS['_BAZAR_']['langue'])) {
$requete .= ' and bn_ce_i18n like "'.$GLOBALS['_BAZAR_']['langue'].'%" ';
}
$requete .= 'ORDER BY bf_date_maj_fiche DESC' ;
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ('Echec de la requete<br />'.$resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
}
if ($resultat->numRows() != 0) {
$tableAttr = array('id' => 'table_bazar') ;
$table = new HTML_Table($tableAttr) ;
$entete = array (BAZ_TITREANNONCE ,BAZ_ANNONCEUR, BAZ_TYPEANNONCE, BAZ_PUBLIER, BAZ_SUPPRIMER, BAZ_DATE_DEBUT_EVENEMENT, BAZ_DATE_CREATION) ;
$table->addRow($entete) ;
$table->setRowType (0, 'th') ;
// On affiche une ligne par proposition
while ($ligne = $resultat->fetchRow (DB_FETCHMODE_ASSOC)) {
//Requete pour trouver le nom et prenom de l'annonceur
$requetenomprenom = 'SELECT '.BAZ_CHAMPS_PRENOM.', '.BAZ_CHAMPS_NOM.' FROM '.BAZ_ANNUAIRE.
' WHERE '.BAZ_CHAMPS_ID.'='.$ligne['bf_ce_utilisateur'] ;
$resultatnomprenom = $GLOBALS['_BAZAR_']['db']->query ($requetenomprenom) ;
if (DB::isError($resultatnomprenom)) {
echo ("Echec de la requete<br />".$resultatnomprenom->getMessage()."<br />".$resultatnomprenom->getDebugInfo()) ;
}
while ($lignenomprenom = $resultatnomprenom->fetchRow (DB_FETCHMODE_ASSOC)) {
$annonceur=$lignenomprenom[BAZ_CHAMPS_PRENOM]." ".$lignenomprenom[BAZ_CHAMPS_NOM];
}
$lien_voir=$GLOBALS['_BAZAR_']['url'];
$lien_voir->addQueryString(BAZ_VARIABLE_ACTION, BAZ_VOIR_FICHE);
$lien_voir->addQueryString('id_fiche', $ligne['bf_id_fiche']);
$lien_voir->addQueryString('typeannonce', $ligne['bn_id_nature']);
// Nettoyage de l'url
// NOTE (jpm - 23 mai 2007): pour être compatible avec PHP5 il faut utiliser tjrs $GLOBALS['_BAZAR_']['url'] car en php4 on
// copie bien une variable mais pas en php5, cela reste une référence...
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
$GLOBALS['_BAZAR_']['url']->removeQueryString('id_fiche');
$GLOBALS['_BAZAR_']['url']->removeQueryString('typeannonce');
$GLOBALS['_BAZAR_']['url']->addQueryString('id_fiche', $ligne['bf_id_fiche']);
$GLOBALS['_BAZAR_']['url']->addQueryString('typeannonce', $ligne['bn_id_nature']);
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_ACTION, BAZ_VOIR_FICHE);
$lien_voir = $GLOBALS['_BAZAR_']['url']->getURL();
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
 
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_PUBLIER);
$lien_publie_oui = $GLOBALS['_BAZAR_']['url']->getURL();
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_PAS_PUBLIER);
$lien_publie_non = $GLOBALS['_BAZAR_']['url']->getURL();
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_SUPPRESSION);
$lien_supprimer = $GLOBALS['_BAZAR_']['url']->getURL();
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
$GLOBALS['_BAZAR_']['url']->removeQueryString('id_fiche');
$GLOBALS['_BAZAR_']['url']->removeQueryString('typeannonce');
$table->addRow (array(
'<a href="'.$lien_voir.'">'.$ligne['bf_titre'].'</a>'."\n", // col 1 : le nom
$annonceur."\n", // col 2 : annonceur
$ligne['bn_label_nature']."\n", // col 3 : type annonce
"<a href=\"".$lien_publie_oui."\">".BAZ_OUI."</a> / \n".
"<a href=\"".$lien_publie_non."\">".BAZ_NON."</a>", // col 4 : publier ou pas
"<a href=\"".$lien_supprimer."\"".
" onclick=\"javascript:return confirm('".BAZ_CONFIRMATION_SUPPRESSION."');\">".BAZ_SUPPRIMER."</a>\n", // col 5 : supprimer
date('d', strtotime($ligne['bf_date_debut_evenement'])).' '.$GLOBALS['mois'][date('n', strtotime ($ligne['bf_date_debut_evenement']))].' '.date('Y', strtotime ($ligne['bf_date_debut_evenement'])), // col 6 date début d'évenement
date('d', strtotime($ligne['bf_date_creation_fiche'])).' '.$GLOBALS['mois'][date('n', strtotime ($ligne['bf_date_creation_fiche']))].' '.date('Y', strtotime ($ligne['bf_date_creation_fiche'])) // col 7 date de création
)) ;
}
$table->altRowAttributes(1, array("class" => "ligne_impaire"), array("class" => "ligne_paire"));
$table->updateColAttributes(1, array("align" => "center"));
$table->updateColAttributes(2, array("align" => "center"));
$table->updateColAttributes(3, array("align" => "center"));
$table->updateColAttributes(4, array("align" => "center"));
$res .= $table->toHTML() ;
}
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_VOIR);
return $res;
}
 
 
/** mes_fiches () - Renvoie les fiches bazar d'un utilisateur
*
* @return string HTML
*/
function mes_fiches() {
$res= '<h2>'.BAZ_VOS_ANNONCES.'</h2><br />'."\n";
if ($GLOBALS['AUTH']->getAuth()) {
// requete pour voir si l'utilisateur a des fiches a son nom, classees par date de MAJ et nature d'annonce
$requete = 'SELECT * FROM bazar_fiche, bazar_nature WHERE bf_ce_utilisateur='. $GLOBALS['id_user'].
' AND bn_id_nature=bf_ce_nature ';
if (isset($GLOBALS['_BAZAR_']['langue'])) $requete .= ' and bn_ce_i18n like "'.$GLOBALS['_BAZAR_']['langue'].'%" ';
$requete .= ' ORDER BY bf_date_maj_fiche DESC,bf_ce_nature ASC';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ('Echec de la requete<br />'.$resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
}
if ($resultat->numRows() != 0) {
$tableAttr = array('id' => 'table_bazar') ;
$table = new HTML_Table($tableAttr) ;
$entete = array (BAZ_TITREANNONCE , BAZ_TYPEANNONCE, BAZ_ETATPUBLICATION, BAZ_MODIFIER, BAZ_SUPPRIMER, 'Dupliquer') ;
$table->addRow($entete) ;
$table->setRowType (0, "th") ;
// On affiche une ligne par proposition
while ($ligne = $resultat->fetchRow (DB_FETCHMODE_ASSOC)) {
if ($ligne['bf_statut_fiche']==1) $publiee=BAZ_PUBLIEE;
elseif ($ligne['bf_statut_fiche']==0) $publiee=BAZ_ENCOURSDEVALIDATION;
else $publiee=BAZ_REJETEE;
$lien_voir = $GLOBALS['_BAZAR_']['url'];
$lien_voir->addQueryString(BAZ_VARIABLE_ACTION, BAZ_VOIR_FICHE);
$lien_voir->addQueryString('id_fiche', $ligne['bf_id_fiche']);
$lien_voir->addQueryString('typeannonce', $ligne['bn_id_nature']);
$lien_voir_url=$lien_voir->getURL();
$lien_modifier = $GLOBALS['_BAZAR_']['url'];
$lien_modifier->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_MODIFIER);
$lien_modifier->addQueryString('id_fiche', $ligne['bf_id_fiche']);
$lien_modifier->addQueryString('typeannonce', $ligne['bn_id_nature']);
$lien_modifier_url=$lien_modifier->getURL();
$lien_supprimer = $GLOBALS['_BAZAR_']['url'];
$lien_supprimer->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_SUPPRESSION);
$lien_supprimer->addQueryString('id_fiche', $ligne['bf_id_fiche']);
$lien_supprimer->addQueryString('typeannonce', $ligne['bn_id_nature']);
$lien_supprimer_url=$lien_supprimer->getURL();
$lien_dupliquer = $GLOBALS['_BAZAR_']['url'];
$lien_dupliquer->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_NOUVEAU);
$lien_dupliquer->addQueryString(BAZ_VARIABLE_ID_FICHE, $ligne['bf_id_fiche']);
$lien_dupliquer->addQueryString(BAZ_VARIABLE_DUPLICATION, 1);
$lien_dupliquer=$lien_dupliquer->getURL();
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_DUPLICATION);
$table->addRow (array(
'<a href="'.$lien_voir_url.'">'.$ligne['bf_titre'].'</a>'."\n", // col 1 : le nom
$ligne['bn_label_nature']."\n", // col 2: type annonce
$publiee."\n", // col 3 : publiee ou non
'<a href="'.$lien_modifier_url.'">'.BAZ_MODIFIER.'</a>'."\n", // col 4 : modifier
'<a href="'.$lien_supprimer_url.'" onclick="javascript:return '.
'confirm(\''.BAZ_CONFIRMATION_SUPPRESSION.'\');" >'.BAZ_SUPPRIMER.'</a>'."\n", // col 5 : supprimer
'<a href="'.$lien_dupliquer.'">Dupliquer</a>'."\n")) ;
}
$table->altRowAttributes(1, array("class" => "ligne_impaire"), array("class" => "ligne_paire"));
$table->updateColAttributes(1, array("align" => "left"));
$table->updateColAttributes(2, array("align" => "center"));
$table->updateColAttributes(3, array("align" => "center"));
$table->updateColAttributes(4, array("align" => "center"));
$res .= $table->toHTML() ;
}
else {
$res .= '<p class="zone_info">'.BAZ_PAS_DE_FICHE.'</p>'."\n" ;
}
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_VOIR, BAZ_VOIR_SAISIR);
$GLOBALS['_BAZAR_']['url']->removeQueryString('id_fiche');
$GLOBALS['_BAZAR_']['url']->removeQueryString('typeannonce');
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
$res .= '<br /><ul id="liste_liens"><li id="lien_saisir"><a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'" title="'.BAZ_SAISIR_UNE_NOUVELLE_FICHE.'">'.BAZ_SAISIR_UNE_NOUVELLE_FICHE.'</a></li></ul>';
}
else {
include_once BAZ_CHEMIN_APPLI.'bibliotheque/bazarTemplate.class.php';
$modele = new bazarTemplate($GLOBALS['_BAZAR_']['db']);
$res .= $modele->getTemplate(BAZ_TEMPLATE_MESSAGE_LOGIN, $GLOBALS['_BAZAR_']['langue'], $GLOBALS['_BAZAR_']['categorie_nature']);
}
return $res;
}
 
 
/** baz_gestion_droits() interface de gestion des droits
*
* return string le code HTML
*/
function baz_gestion_droits() {
$lien_formulaire=$GLOBALS['_BAZAR_']['url'];
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_GERER_DROITS);
 
//contruction du squelette du formulaire
$formtemplate = new HTML_QuickForm('formulaire', 'post', preg_replace ('/&amp;/', '&', $lien_formulaire->getURL()) );
$squelette =& $formtemplate->defaultRenderer();
$squelette->setFormTemplate("\n".'<form {attributes}>'."\n".'<table style="border:0;">'."\n".'{content}'."\n".'</table>'."\n".'</form>'."\n");
$squelette->setElementTemplate( '<tr>'."\n".'<td style="font-size:12px;width:150px;text-align:right;">'."\n".'{label} :</td>'."\n".'<td style="text-align:left;padding:5px;"> '."\n".'{element}'."\n".
'<!-- BEGIN required --><span class="symbole_obligatoire">*</span><!-- END required -->'."\n".
'<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n".
'</td>'."\n".'</tr>'."\n");
$squelette->setElementTemplate( '<tr>'."\n".'<td colspan="2" class="liste_a_cocher"><strong>{label}&nbsp;{element}</strong>'."\n".
'<!-- BEGIN required --><span class="symbole_obligatoire">&nbsp;*</span><!-- END required -->'."\n".'</td>'."\n".'</tr>'."\n", 'accept_condition');
$squelette->setElementTemplate( '<tr><td colspan="2" class="bouton">{label}{element}</td></tr>'."\n", 'valider');
$squelette->setRequiredNoteTemplate("\n".'<tr>'."\n".'<td colspan="2" class="symbole_obligatoire">* {requiredNote}</td></tr>'."\n");
//Traduction de champs requis
$formtemplate->setRequiredNote(BAZ_CHAMPS_REQUIS) ;
$formtemplate->setJsWarnings(BAZ_ERREUR_SAISIE,BAZ_VEUILLEZ_CORRIGER);
//Initialisation de la variable personne
if ( isset($_POST['personnes']) ) {
$personne=$_POST['personnes'];
}
else $personne=0;
//Cas ou les droits ont etes changes
if (isset($_GET['pers'])) {
$personne=$_GET['pers'];
//CAS DES DROITS POUR UN TYPE D'ANNONCE: On efface tous les droits de la personne pour ce type d'annonce
if (isset($_GET['idtypeannonce'])) {
$requete = 'DELETE FROM bazar_droits WHERE bd_id_utilisateur='.$_GET['pers'].
' AND bd_id_nature_offre='.$_GET['idtypeannonce'];
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
}
//CAS DU SUPER ADMIN: On efface tous les droits de la personne en general
else {
$requete = 'DELETE FROM bazar_droits WHERE bd_id_utilisateur='.$_GET['pers'];
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
}
if ($_GET['droits']=='superadmin') {
$requete = 'INSERT INTO bazar_droits VALUES ('.$_GET['pers'].',0,0)';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
}
elseif ($_GET['droits']=='redacteur') {
$requete = 'INSERT INTO bazar_droits VALUES ('.$_GET['pers'].','.$_GET['idtypeannonce'].',1)';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
}
elseif ($_GET['droits']=='admin') {
$requete = 'INSERT INTO bazar_droits VALUES ('.$_GET['pers'].','.$_GET['idtypeannonce'].',2)';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
}
}
//requete pour obtenir l'id, le nom et prenom des personnes inscrites a l'annuaire sauf soi meme
$requete = 'SELECT '.BAZ_CHAMPS_ID.', '.BAZ_CHAMPS_NOM.', '.BAZ_CHAMPS_PRENOM.' FROM '.BAZ_ANNUAIRE.
' WHERE '.BAZ_CHAMPS_ID." != ".$GLOBALS['id_user'].' ORDER BY '.BAZ_CHAMPS_NOM.' ASC';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die($resultat->getMessage().$resultat->getDebugInfo()) ;
}
$res='<h2>'.BAZ_GESTION_DES_DROITS.'</h2><br />'."\n";
$res.=BAZ_DESCRIPTION_GESTION_DES_DROITS.'<br /><br />'."\n";
$personnes_select[0]=BAZ_SELECTION;
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
$personnes_select[$ligne[BAZ_CHAMPS_ID]] = $ligne[BAZ_CHAMPS_NOM]." ".$ligne[BAZ_CHAMPS_PRENOM] ;
}
$java=array ('style'=>'width:250px;','onchange'=>'this.form.submit();');
$formtemplate->addElement ('select', 'personnes', BAZ_LABEL_CHOIX_PERSONNE, $personnes_select, $java) ;
$defauts=array ('personnes'=>$personne);
$formtemplate->setDefaults($defauts);
$res.= $formtemplate->toHTML().'<br />'."\n" ;
if ($personne!=0) {
//cas du super utilisateur
$utilisateur = new Utilisateur_bazar($personne) ;
if ($utilisateur->isSuperAdmin()) {
$res.= '<br />'.BAZ_EST_SUPERADMINISTRATEUR.'<br /><br />'."\n";
$lien_enlever_superadmin=$GLOBALS['_BAZAR_']['url'];
$lien_enlever_superadmin->addQueryString(BAZ_VARIABLE_ACTION, BAZ_GERER_DROITS);
$lien_enlever_superadmin->addQueryString('pers', $personne);
$lien_enlever_superadmin->addQueryString('droits', 'aucun');
$res.= '<a href='.$lien_enlever_superadmin->getURL().'>'.BAZ_CHANGER_SUPERADMINISTRATEUR.'</a><br />'."\n";
}
else {
$lien_passer_superadmin=$GLOBALS['_BAZAR_']['url'];
$lien_passer_superadmin->addQueryString(BAZ_VARIABLE_ACTION, BAZ_GERER_DROITS);
$lien_passer_superadmin->addQueryString('pers', $personne);
$lien_passer_superadmin->addQueryString('droits', 'superadmin');
$res.= '<a href='.$lien_passer_superadmin->getURL().'>'.BAZ_PASSER_SUPERADMINISTRATEUR.'</a><br />'."\n";
//on cherche les differentes rubriques d'annonces
$requete = 'SELECT bn_id_nature, bn_label_nature, bn_image_titre FROM bazar_nature';
if (isset($GLOBALS['_BAZAR_']['langue'])) $requete .= ' where bn_ce_i18n like "'.$GLOBALS['_BAZAR_']['langue'].'%"';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
$res.='<br /><b>'.BAZ_DROITS_PAR_TYPE.'</b><br /><br />';
$table = new HTML_Table(array ('width' => '100%', 'class' => 'table_bazar')) ;
$table->addRow(array ('<strong>'.BAZ_TYPE_ANNONCES.'</strong>',
'<strong>'.BAZ_DROITS_ACTUELS.'</strong>',
'<strong>'.BAZ_PASSER_EN.'</strong>',
'<strong>'.BAZ_OU_PASSER_EN.'</strong>')) ;
$table->setRowType (0, 'th') ;
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
$lien_aucun_droit=$GLOBALS['_BAZAR_']['url'];
$lien_aucun_droit->addQueryString(BAZ_VARIABLE_ACTION, BAZ_GERER_DROITS);
$lien_aucun_droit->addQueryString('pers', $personne);
$lien_aucun_droit->addQueryString('droits', 'aucun');
$lien_aucun_droit->addQueryString('idtypeannonce', $ligne["bn_id_nature"]);
$lien_passer_redacteur=$GLOBALS['_BAZAR_']['url'];
$lien_passer_redacteur->addQueryString(BAZ_VARIABLE_ACTION, BAZ_GERER_DROITS);
$lien_passer_redacteur->addQueryString('pers', $personne);
$lien_passer_redacteur->addQueryString('droits', 'redacteur');
$lien_passer_redacteur->addQueryString('idtypeannonce', $ligne["bn_id_nature"]);
$lien_passer_admin=$GLOBALS['_BAZAR_']['url'];
$lien_passer_admin->addQueryString(BAZ_VARIABLE_ACTION, BAZ_GERER_DROITS);
$lien_passer_admin->addQueryString('pers', $personne);
$lien_passer_admin->addQueryString('droits', 'admin');
$lien_passer_admin->addQueryString('idtypeannonce', $ligne["bn_id_nature"]);
if (isset($ligne['bn_image_titre'])) {
$titre='&nbsp;<img src="client/bazar/images/'.$ligne['bn_image_titre'].'" alt="'.$ligne['bn_label_nature'].'" />'."\n";
} else {
$titre='<strong>&nbsp;'.$ligne['bn_label_nature'].'</strong>'."\n";
}
if ($utilisateur->isAdmin($ligne['bn_id_nature'])) {
$table->addRow(array($titre,
BAZ_DROIT_ADMIN,
'<a href='.$lien_aucun_droit->getURL().'>'.BAZ_AUCUN_DROIT.'</a>',
'<a href='.$lien_passer_redacteur->getURL().'>'.BAZ_LABEL_REDACTEUR.'</a>'));
}
elseif ($utilisateur->isRedacteur($ligne['bn_id_nature'])) {
$table->addRow(array($titre,
BAZ_LABEL_REDACTEUR,
'<a href='.$lien_aucun_droit->getURL().'>'.BAZ_AUCUN_DROIT.'</a>',
'<a href='.$lien_passer_admin->getURL().'>'.BAZ_DROIT_ADMIN.'</a>'));
}
else {
$table->addRow(array($titre,
BAZ_AUCUN_DROIT,
'<a href='.$lien_passer_redacteur->getURL().'>'.BAZ_LABEL_REDACTEUR.'</a>',
'<a href='.$lien_passer_admin->getURL().'>'.BAZ_DROIT_ADMIN.'</a>'));
}
}
$table->altRowAttributes(1, array('class' => 'ligne_impaire'), array('class' => 'ligne_paire'));
$table->updateColAttributes(0, array('align' => 'left'));
$table->updateColAttributes(1, array('align' => 'left'));
$table->updateColAttributes(2, array('align' => 'left'));
$table->updateColAttributes(3, array('align' => 'left'));
$res.=$table->toHTML() ;
}
}
 
// Nettoyage de l'url
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
$GLOBALS['_BAZAR_']['url']->removeQueryString('pers');
$GLOBALS['_BAZAR_']['url']->removeQueryString('droits');
$GLOBALS['_BAZAR_']['url']->removeQueryString('idtypeannonce');
 
return $res;
}
 
/** baz_formulaire() - Renvoie le menu pour les saisies et modification des annonces
*
* @param string choix du formulaire a afficher (soit formulaire personnalise de
* l'annonce, soit choix du type d'annonce)
*
* @return string HTML
*/
function baz_formulaire($mode) {
$res = '';
if ($GLOBALS['AUTH']->getAuth()) {
$lien_formulaire=$GLOBALS['_BAZAR_']['url'];
//Definir le lien du formulaire en fonction du mode de formulaire choisi
if ($mode == BAZ_DEPOSER_ANNONCE) {
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_NOUVEAU);
if (isset($GLOBALS['_BAZAR_']['id_typeannonce']) && $GLOBALS['_BAZAR_']['id_typeannonce'] != 'toutes') {
$mode = BAZ_ACTION_NOUVEAU ;
}
}
if ($mode == BAZ_ACTION_NOUVEAU) {
if ((!isset($_POST['accept_condition']))and($GLOBALS['_BAZAR_']['condition']!=NULL)) {
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_NOUVEAU);
} else {
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_NOUVEAU_V);
}
}
if ($mode == BAZ_ACTION_MODIFIER) {
if (!isset($_POST['accept_condition'])and($GLOBALS['_BAZAR_']['condition']!=NULL)) {
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_MODIFIER);
} else {
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_MODIFIER_V);
if (isset ($_SESSION['_BAZAR_']['fichier'])) unset($_SESSION['_BAZAR_']['fichier']) ;
if (isset ($_SESSION['_BAZAR_']['image'])) unset($_SESSION['_BAZAR_']['image']);
if (isset ($_SESSION['_BAZAR_']['lien'])) unset($_SESSION['_BAZAR_']['lien']);
}
$lien_formulaire->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
}
if ($mode == BAZ_ACTION_MODIFIER_V) {
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_MODIFIER_V);
$lien_formulaire->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
}
//contruction du squelette du formulaire
$formtemplate = new HTML_QuickForm('formulaire', 'post', preg_replace ('/&amp;/', '&', $lien_formulaire->getURL()) );
$squelette =& $formtemplate->defaultRenderer();
$squelette->setFormTemplate("\n".'<form {attributes}>'."\n".'<table style="border:0;width:100%;">'."\n".'{content}'."\n".'</table>'."\n".'</form>'."\n");
$squelette->setElementTemplate( '<tr>'."\n".'<td>'."\n".'{label}'.
'<!-- BEGIN required --><span class="symbole_obligatoire">&nbsp;*</span><!-- END required -->'."\n".
' </td>'."\n".'<td style="text-align:left;padding:5px;"> '."\n".'{element}'."\n".
'<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n".
'</td>'."\n".'</tr>'."\n");
$squelette->setElementTemplate( '<tr>'."\n".'<td colspan="2" class="liste_a_cocher"><strong>{label}&nbsp;{element}</strong>'."\n".
'<!-- BEGIN required --><span class="symbole_obligatoire">&nbsp;*</span><!-- END required -->'."\n".'</td>'."\n".'</tr>'."\n", 'accept_condition');
$squelette->setElementTemplate( '<tr><td colspan="2" class="bouton">{label}{element}</td></tr>'."\n", 'valider');
$squelette->setRequiredNoteTemplate("\n".'<tr>'."\n".'<td colspan="2" class="symbole_obligatoire">* {requiredNote}</td></tr>'."\n");
//Traduction de champs requis
$formtemplate->setRequiredNote(BAZ_CHAMPS_REQUIS) ;
$formtemplate->setJsWarnings(BAZ_ERREUR_SAISIE,BAZ_VEUILLEZ_CORRIGER);
//------------------------------------------------------------------------------------------------
//AFFICHAGE DU FORMULAIRE GENERAL DE CHOIX DU TYPE D'ANNONCE
//------------------------------------------------------------------------------------------------
if ($mode == BAZ_DEPOSER_ANNONCE) {
$res = '';
//requete pour obtenir le nom et la description des types d'annonce
$requete = 'SELECT * FROM bazar_nature WHERE bn_ce_id_menu IN ('.$GLOBALS['_BAZAR_']['categorie_nature'].') ';
if (isset($GLOBALS['_BAZAR_']['langue'])) {
$requete .= ' and bn_ce_i18n like "'.$GLOBALS['_BAZAR_']['langue'].'%" ';
}
$requete .= 'ORDER BY bn_label_nature ASC';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
return ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
//$res.='<h2>'.BAZ_DEPOSE_UNE_NOUVELLE_ANNONCE.'</h2>'."\n";
include_once BAZ_CHEMIN_APPLI.'bibliotheque/bazarTemplate.class.php';
$modele = new bazarTemplate($GLOBALS['_BAZAR_']['db']);
$res .= $modele->getTemplate(BAZ_TEMPLATE_FORMULAIRE_ACCUEIL, $GLOBALS['_BAZAR_']['langue'], $GLOBALS['_BAZAR_']['categorie_nature']);
if ($resultat->numRows()==1) {
$ligne = $resultat->fetchRow (DB_FETCHMODE_ASSOC);
$GLOBALS['_BAZAR_']['id_typeannonce']=$ligne['bn_id_nature'];
$GLOBALS['_BAZAR_']['typeannonce']=$ligne['bn_label_nature'];
$GLOBALS['_BAZAR_']['condition']=$ligne['bn_condition'];
$GLOBALS['_BAZAR_']['template']=$ligne['bn_template'];
$GLOBALS['_BAZAR_']['commentaire']=$ligne['bn_commentaire'];
$GLOBALS['_BAZAR_']['appropriation']=$ligne['bn_appropriation'];
$GLOBALS['_BAZAR_']['image_titre']=$ligne['bn_image_titre'];
$GLOBALS['_BAZAR_']['image_logo']=$ligne['bn_image_logo'];
$mode = BAZ_ACTION_NOUVEAU;
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_NOUVEAU_V);
} else {
//$res.='<br />'.BAZ_CHOIX_TYPEANNONCE.'<br /><br />'."\n";
while ($ligne = $resultat->fetchRow (DB_FETCHMODE_ASSOC)) {
$utilisateur = new Administrateur_bazar($GLOBALS['AUTH']);
if (($utilisateur->isRedacteur($ligne['bn_id_nature'])) || ($utilisateur->isAdmin($ligne['bn_id_nature']))
|| ($utilisateur->isSuperAdmin() || !BAZ_RESTREINDRE_DEPOT)) {
if ($ligne['bn_image_titre']!='') {
$titre='&nbsp;<img src="client/bazar/images/'.$ligne['bn_image_titre'].'" alt="'.
$ligne['bn_label_nature'].'" />'.'<br />'."\n";
} else {
$titre='<h3>'.$ligne['bn_label_nature'].' : </h3>'."\n";
}
$formtemplate->addElement('radio', 'typeannonce', '',
$titre.$ligne['bn_description'].'<br /><br />'."\n",
$ligne['bn_id_nature'], array("id" => 'select'.$ligne['bn_id_nature'],
"style" => 'float:left;'));
$formtemplate->addRule('typeannonce', 'Il faut choisir un type de fiche', 'required', '', 'client') ;
}
}
$squelette->setElementTemplate( '<div class="listechoix">'."\n".'{element}'."\n".'</div>'."\n");
//Mettre les annonces en choix par defaut
$formtemplate->setdefaults(array('typeannonce'=>'1'));
// Bouton d annulation
$lien_formulaire->removeQueryString('action');
$buttons[] = &HTML_QuickForm::createElement('link', 'annuler', BAZ_ANNULER,
preg_replace ("/&amp;/", "&", $lien_formulaire->getURL()), BAZ_ANNULER); // Le preg_replace contourne un pb de QuickForm et Net_URL
// qui remplacent deux fois les & par des &amp;
//Bouton de validation du formulaire // ce qui fait échouer le lien
$buttons[] = &HTML_QuickForm::createElement('submit', 'valider', BAZ_VALIDER);
$formtemplate->addGroup($buttons, null, null, '&nbsp;');
//Affichage a l'ecran
$res.= $formtemplate->toHTML()."\n";
}
}
//------------------------------------------------------------------------------------------------
//AFFICHAGE DU FORMULAIRE CORRESPONDANT AU TYPE DE L'ANNONCE CHOISI PAR L'UTILISATEUR
//------------------------------------------------------------------------------------------------
if ($mode == BAZ_ACTION_NOUVEAU) {
$utilisateur = new Administrateur_bazar($GLOBALS['AUTH']);
if ($utilisateur->isRedacteur($GLOBALS['_BAZAR_']['id_typeannonce']) ||
$utilisateur->isAdmin($GLOBALS['_BAZAR_']['id_typeannonce'])||
$utilisateur->isSuperAdmin()) {
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_NOUVEAU_V);
$formtemplate->updateAttributes(array('action' => str_replace('&amp;', '&', $lien_formulaire->getURL())));
// Appel du modele
include_once BAZ_CHEMIN_APPLI.'bibliotheque/bazarTemplate.class.php';
$modele = new bazarTemplate($GLOBALS['_BAZAR_']['db']);
$html = $modele->getTemplate(BAZ_TEMPLATE_FORMULAIRE, $GLOBALS['_BAZAR_']['langue'],$GLOBALS['_BAZAR_']['categorie_nature']);
if (!PEAR::isError($html)) {
if (isset($_GET[BAZ_VARIABLE_DUPLICATION])) {
$res = str_replace ('{FORMULAIRE}', baz_afficher_formulaire_annonce('duplication',$formtemplate), $html);
} else {
$res = str_replace ('{FORMULAIRE}', baz_afficher_formulaire_annonce('insertion',$formtemplate), $html);
}
} else {
if (isset($_GET[BAZ_VARIABLE_DUPLICATION])) {
$res = baz_afficher_formulaire_annonce('duplication',$formtemplate);
} else {
$res = baz_afficher_formulaire_annonce('insertion',$formtemplate);
}
}
} else {
// Pas de droit pour deposer un annonce
return '<div>Pas de droits suffisants</div>';
}
}
//------------------------------------------------------------------------------------------------
//CAS DE LA MODIFICATION D'UNE ANNONCE (FORMULAIRE DE MODIFICATION)
//------------------------------------------------------------------------------------------------
if ($mode == BAZ_ACTION_MODIFIER) {
$res=baz_afficher_formulaire_annonce('modification',$formtemplate);
}
// Nettoyage de l'url avant les return : apparement inutile sinon pose pb (url applette deconnexion et moteur de recherche) [jpm le 17 mars 2008]
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
$GLOBALS['_BAZAR_']['url']->removeQueryString('id_fiche');
//------------------------------------------------------------------------------------------------
//CAS DE L'INSCRIPTION D'UNE ANNONCE
//------------------------------------------------------------------------------------------------
if ($mode == BAZ_ACTION_NOUVEAU_V) {
if ($formtemplate->validate() && !isset($_SESSION['formulaire_annonce_valide'])) {
//$formtemplate->process('baz_insertion', false) ;
$id_fiche = baz_insertion ($formtemplate->getSubmitValues());
// Redirection vers mes_fiches pour eviter la revalidation du formulaire
$GLOBALS['_BAZAR_']['url']->addQueryString (BAZ_VARIABLE_ACTION, BAZ_ACTION_POST_VALIDATION);
$GLOBALS['_BAZAR_']['url']->addQueryString (BAZ_VARIABLE_ID_FICHE, $id_fiche);
header ('Location: '.str_replace ('&amp;', '&', $GLOBALS['_BAZAR_']['url']->getURL())) ;
exit();
}
}
//------------------------------------------------------------------------------------------------
//CAS DE LA MODIFICATION D'UNE ANNONCE (VALIDATION ET MAJ)
//------------------------------------------------------------------------------------------------
if ($mode == BAZ_ACTION_MODIFIER_V) {
if ($formtemplate->validate()) {
$formtemplate->process('baz_mise_a_jour', false) ;
$id_fiche = $GLOBALS['_BAZAR_']['id_fiche'] ;
// Redirection vers la fiche modifiée
$GLOBALS['_BAZAR_']['url']->addQueryString (BAZ_VARIABLE_VOIR, BAZ_GERER_DROITS);
$GLOBALS['_BAZAR_']['url']->addQueryString (BAZ_VARIABLE_ACTION, BAZ_VOIR_FICHE);
$GLOBALS['_BAZAR_']['url']->addQueryString (BAZ_VARIABLE_ID_FICHE,$id_fiche);
header ('Location: '.str_replace ('&amp;', '&', $GLOBALS['_BAZAR_']['url']->getURL())) ;
exit();
}
}
} else {
include_once BAZ_CHEMIN_APPLI.'bibliotheque/bazarTemplate.class.php';
$modele = new bazarTemplate($GLOBALS['_BAZAR_']['db']);
$res .= $modele->getTemplate(BAZ_TEMPLATE_MESSAGE_LOGIN, $GLOBALS['_BAZAR_']['langue'], $GLOBALS['_BAZAR_']['categorie_nature']);
}
 
return $res;
}
 
/** baz_afficher_formulaire_annonce() - Genere le formulaire de saisie d'une annonce
*
* @param string type de formulaire: insertion ou modification
* @param mixed objet quickform du formulaire
*
* @return string code HTML avec formulaire
*/
function baz_afficher_formulaire_annonce($mode='insertion',$formtemplate) {
if ($mode=='modification' || $mode == 'duplication') {
//initialisation de la variable globale id_fiche
$GLOBALS['_BAZAR_']['id_fiche'] = $_REQUEST[BAZ_VARIABLE_ID_FICHE];
//suppression eventuelle d'une url, d'un fichier ou d'une image
if (isset($_GET['id_url'])) {
baz_suppression_url($_GET['id_url']);
}
if (isset($_GET['id_fichier'])) {
baz_suppression_fichier($_GET['id_fichier']);
}
if (isset($_GET['image'])) {
baz_suppression_image($GLOBALS['_BAZAR_']['id_fiche']);
}
}
$res = '';
//titre de la rubrique
if (!BAZ_UTILISE_TEMPLATE) $res= '<h2>'.BAZ_TITRE_SAISIE_ANNONCE.'&nbsp;'.$GLOBALS['_BAZAR_']['typeannonce'].'</h2><br />'."\n";
if (($GLOBALS['_BAZAR_']['condition']!='')AND(!isset($_POST['accept_condition']))AND(!isset($_GET['url'])OR(!isset($_GET['fichier']))OR(!isset($_GET['image'])))) {
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm/html.php';
$conditions= new HTML_QuickForm_html('<tr><td colspan="2" style="padding:5px; margin:5px; width: 90%; background: #C1CBA7;">'.$GLOBALS['_BAZAR_']['condition'].'</td>'."\n".'</tr>'."\n");
$formtemplate->addElement($conditions);
$formtemplate->addElement('checkbox', 'accept_condition',BAZ_ACCEPTE_CONDITIONS) ;
$formtemplate->addElement('hidden', 'typeannonce', $GLOBALS['_BAZAR_']['id_typeannonce']);
$formtemplate->addRule('accept_condition', BAZ_ACCEPTE_CONDITIONS_REQUIS, 'required', '', 'client') ;
$formtemplate->addElement('submit', 'valider', BAZ_VALIDER);
}
//affichage du formulaire si conditions acceptees
else {
//Parcours du fichier de templates, pour mettre les valeurs des champs
$tableau=baz_valeurs_template($GLOBALS['_BAZAR_']['template']);
if ($mode=='modification' || $mode == 'duplication') {
//Ajout des valeurs par defaut
$valeurs_par_defaut = baz_valeurs_fiche($GLOBALS['_BAZAR_']['id_fiche']) ;
for ($i=0; $i<count($tableau); $i++) {
if (isset($ligne[$tableau[$i]['nom_bdd']])) {
$type = $tableau[$i]['type'];
$valeur = $ligne[$tableau[$i]['nom_bdd']];
} else {
$type = $tableau[$i]['type'];
$valeur = '';
}
/*
$element = Bazar_element::factory($type, $tableau[$i]);
if (!PEAR::isError($element)) {
if (method_exists($element, 'toForm'))$res .= $element->toForm($valeur);
}
*/
if ( $tableau[$i]['type']=='liste' || $tableau[$i]['type']=='checkbox') {
$def=$tableau[$i]['type'].$tableau[$i]['nom_bdd'];
}
elseif ( $tableau[$i]['type']=='texte' || $tableau[$i]['type']=='textelong' || $tableau[$i]['type']=='listedatedeb'
|| $tableau[$i]['type']=='listedatefin' || $tableau[$i]['type']=='champs_cache'
|| $tableau[$i]['type']=='labelhtml' ) {
$def=$tableau[$i]['nom_bdd'];
} elseif ($tableau[$i]['type']=='carte_google') {
$def = 'carte_google';
$valeurs_par_defaut[$def] = array ('latitude' => $valeurs_par_defaut['bf_latitude'], 'longitude' => $valeurs_par_defaut['bf_longitude']);
}
// certain type n ont pas de valeur par defaut (labelhtml par exemple)
// on teste l existence de $valeur_par_defaut[$def] avant de le passer en parametre
if($tableau[$i]['type'] != null) {
$tableau[$i]['type']($formtemplate, $tableau[$i]['nom_bdd'], $tableau[$i]['label'], $tableau[$i]['limite1'],
$tableau[$i]['limite2'],
isset ($valeurs_par_defaut[$def]) ? $valeurs_par_defaut[$def] : '',
$tableau[$i]['table_source'], $tableau[$i]['obligatoire']) ;
}
if ($tableau[$i]['type']=='carte_google') {
include_once 'bazar.fonct.google.php';
GEN_stockerCodeScript($script);
// On ajoute l attribut load a la balise body
GEN_AttributsBody('onload', 'load()');
}
}
}
else {
for ($i=0; $i<count($tableau); $i++) {
if($tableau[$i]['type'] != null) {
$tableau[$i]['type']($formtemplate, $tableau[$i]['nom_bdd'], $tableau[$i]['label'], $tableau[$i]['limite1'],$tableau[$i]['limite2'], $tableau[$i]['defaut'], $tableau[$i]['table_source'], $tableau[$i]['obligatoire']) ;
}
if ($tableau[$i]['type'] == 'carte_google') {
include_once 'bazar.fonct.google.php';
GEN_stockerCodeScript($script);
// On ajoute l attribut load a la balise body
GEN_AttributsBody('onload', 'load()');
}
}
}
$formtemplate->addElement('hidden', 'typeannonce', $GLOBALS['_BAZAR_']['id_typeannonce']);
// Un champs cache pour la duplication
if ($mode == 'duplication') $formtemplate->addElement('hidden', 'fiche_dupliquee', $GLOBALS['_BAZAR_']['id_fiche']);
// Bouton d annulation
$attr = $formtemplate->getAttributes();
$lien_formulaire = new Net_URL($attr[BAZ_VARIABLE_ACTION]);
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_VOIR_VOS_ANNONCES);
$buttons[] = &HTML_QuickForm::createElement('link', 'annuler', BAZ_ANNULER,
preg_replace ("/&amp;/", "&", $lien_formulaire->getURL()), BAZ_ANNULER); // Le preg_replace contourne un pb de QuickForm et Net_URL
// qui remplacent deux fois les & par des &amp;
//Bouton de validation du formulaire // ce qui fait échouer le lien
$buttons[] = &HTML_QuickForm::createElement('submit', 'valider', BAZ_VALIDER);
$formtemplate->addGroup($buttons, null, null, '&nbsp;');
}
 
//Affichage a l'ecran
$res .= $formtemplate->toHTML()."\n";
return $res;
}
 
 
/** requete_bazar_fiche() - preparer la requete d'insertion ou de MAJ de la table bazar_fiche a partir du template
*
* @global mixed L'objet contenant les valeurs issues de la saisie du formulaire
* @return void
*/
function requete_bazar_fiche($valeur) {
$requete=NULL;
//l'annonce est directement publiée pour les admins
$utilisateur = new Administrateur_bazar($GLOBALS['AUTH']);
if ($utilisateur->isAdmin($GLOBALS['_BAZAR_']['id_typeannonce']) ||
$utilisateur->isSuperAdmin()) {
$requete.='bf_statut_fiche=1, ';
}
else {
$requete.='bf_statut_fiche="'.BAZ_ETAT_VALIDATION.'", ';
}
$tableau=baz_valeurs_template($GLOBALS['_BAZAR_']['template']);
for ($i=0; $i<count($tableau); $i++) {
//cas des checkbox et des listes
if ($tableau[$i]['type']=='checkbox' || $tableau[$i]['type']=='liste') {
//on supprime les anciennes valeurs de la table bazar_fiche_valeur_liste
$requetesuppression='DELETE FROM bazar_fiche_valeur_liste WHERE bfvl_ce_fiche='.$GLOBALS['_BAZAR_']['id_fiche'].' AND bfvl_ce_liste='.$tableau[$i]['nom_bdd'];
$resultat = $GLOBALS['_BAZAR_']['db']->query($requetesuppression) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
if (isset($valeur[$tableau[$i]['type'].$tableau[$i]['nom_bdd']]) && ($valeur[$tableau[$i]['type'].$tableau[$i]['nom_bdd']]!=0)) {
//on insere les nouvelles valeurs
$requeteinsertion='INSERT INTO bazar_fiche_valeur_liste (bfvl_ce_fiche, bfvl_ce_liste, bfvl_valeur) VALUES ';
//pour les checkbox, les différentes valeurs sont dans un tableau
if (is_array($valeur[$tableau[$i]['type'].$tableau[$i]['nom_bdd']])) {
$nb=0;
while (list($cle, $val) = each($valeur[$tableau[$i]['type'].$tableau[$i]['nom_bdd']])) {
if ($nb>0) $requeteinsertion .= ', ';
$requeteinsertion .= '('.$GLOBALS['_BAZAR_']['id_fiche'].', '.$tableau[$i]['nom_bdd'].', '.$cle.') ';
$nb++;
}
}
//pour les listes, une insertion de la valeur suffit
else {
$requeteinsertion .= '('.$GLOBALS['_BAZAR_']['id_fiche'].', '.$tableau[$i]['nom_bdd'].', '.$valeur[$tableau[$i]['type'].$tableau[$i]['nom_bdd']].')';
}
$resultat = $GLOBALS['_BAZAR_']['db']->query($requeteinsertion) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
}
}
//cas des fichiers
elseif ($tableau[$i]['type']=='fichier') {
if (isset($valeur['texte_fichier'.$tableau[$i]['nom_bdd']]) && $valeur['texte_fichier'.$tableau[$i]['nom_bdd']]!='') {
baz_insertion_fichier($valeur['texte_fichier'.$tableau[$i]['nom_bdd']], $GLOBALS['_BAZAR_']['id_fiche'], 'fichier'.$tableau[$i]['nom_bdd']);
}
}
//cas des urls
// On affine les criteres pour l insertion d une url
// il faut que le lien soit saisie, different de http:// ET que le texte du lien soit saisie aussi
// et ce afin d eviter d avoir des liens vides
elseif ($tableau[$i]['type']=='url') {
if (isset($valeur['url_lien'.$tableau[$i]['nom_bdd']]) &&
$valeur['url_lien'.$tableau[$i]['nom_bdd']]!='http://'
&& isset($valeur['url_texte'.$tableau[$i]['nom_bdd']]) &&
strlen ($valeur['url_texte'.$tableau[$i]['nom_bdd']])) {
baz_insertion_url($valeur['url_lien'.$tableau[$i]['nom_bdd']], $valeur['url_texte'.$tableau[$i]['nom_bdd']], $GLOBALS['_BAZAR_']['id_fiche']);
}
}
//cas des images
elseif ($tableau[$i]['type']=='image') {
if (isset($_FILES['image']['name']) && $_FILES['image']['name']!='') {
$requete .= baz_insertion_image($GLOBALS['_BAZAR_']['id_fiche']);
}
}
//cas des dates
elseif ( $tableau[$i]['type']=='listedatedeb' || $tableau[$i]['type']=='listedatefin' ) {
// On construit la date selon le format YYYY-mm-dd
$date = $valeur[$tableau[$i]['nom_bdd']]['Y'].'-'.$valeur[$tableau[$i]['nom_bdd']]['m'].'-'.$valeur[$tableau[$i]['nom_bdd']]['d'] ;
// si la date de fin evenement est anterieure a la date de debut, on met la date de debut
// pour eviter les incoherence
if ($tableau[$i]['nom_bdd'] == 'bf_date_fin_evenement' &&
mktime(0,0,0, $valeur['bf_date_debut_evenement']['m'], $valeur['bf_date_debut_evenement']['d'], $valeur['bf_date_debut_evenement']['Y']) >
mktime(0,0,0, $valeur['bf_date_fin_evenement']['m'], $valeur['bf_date_fin_evenement']['d'], $valeur['bf_date_fin_evenement']['Y'])) {
$val = $valeur['bf_date_debut_evenement']['Y'].'-'.$valeur['bf_date_debut_evenement']['m'].'-'.$valeur['bf_date_debut_evenement']['d'] ;
} else {
$val = $valeur[$tableau[$i]['nom_bdd']]['Y'].'-'.$valeur[$tableau[$i]['nom_bdd']]['m'].'-'.$valeur[$tableau[$i]['nom_bdd']]['d'] ;
}
$requete .= $tableau[$i]['nom_bdd'].'="'.$val.'", ' ;
}
//cas des champs texte
elseif ( $tableau[$i]['type']=='texte' || $tableau[$i]['type']=='textelong' || $tableau[$i]['type']=='champs_cache' || $tableau[$i]['type']=='champs_mail' ) {
//on mets les slashes pour les saisies dans les champs texte et textearea
$val=addslashes($valeur[$tableau[$i]['nom_bdd']]) ;
$requete .= $tableau[$i]['nom_bdd'].'="'.$val.'", ' ;
}
//cas des wikinis
elseif ( $tableau[$i]['type']=='wikini' && $_REQUEST[BAZ_VARIABLE_ACTION]==BAZ_ACTION_NOUVEAU_V ) {
//on appelle les pages des apis et de l'integrateur wikini
include_once PAP_CHEMIN_RACINE.'api/sql/SQL_manipulation.fonct.php';
include_once PAP_CHEMIN_RACINE.'client/integrateur_wikini/configuration/adwi_configuration.inc.php' ;
include_once PAP_CHEMIN_RACINE.'client/integrateur_wikini/bibliotheque/adwi_wikini.fonct.php' ;
//génération du titre du wiki, sous la forme id-titre du projet
$titre=baz_titre_wiki($valeur["bf_titre"]);
//création du wiki
$valeur=array ("action"=> "nouveau_v", "code_alpha_wikini"=>$titre, "page"=>"AccueiL", "bdd_hote"=> "",
"bdd_nom"=> "", "bdd_utilisateur"=> "", "bdd_mdp" => "", "table_prefix"=> "", "chemin" => "wikini/".$titre, "valider"=> "Valider");
$val = insertion($valeur, $GLOBALS['_BAZAR_']['db']);
}
// Cas de la carte google
elseif ($tableau[$i]['type'] == 'carte_google') {
$requete .= 'bf_latitude="'.$valeur['latitude'].'", bf_longitude="'.$valeur['longitude'].'",';
}
}
$requete.=' bf_date_maj_fiche=NOW()';
/*if($utilisateur->isSuperAdmin()) {
$requete.=', bf_date_debut_validite_fiche=NOW()';
}*/
return $requete;
}
 
/** baz_insertion() - inserer une nouvelle fiche
*
* @array Le tableau des valeurs a inserer
* @integer Valeur de l'identifiant de la fiche
* @return void
*/
function baz_insertion($valeur) {
// =========== Insertion d'une nouvelle fiche ===================
// dans le cas où on traite le type d'évenements, on le récupère dans la globale id_typeannonce
if (isset($valeur['liste31']) && $valeur['liste31'] != '') {
$GLOBALS['_BAZAR_']['id_typeannonce'] = $valeur['liste31'] ;
}
//requete d'insertion dans bazar_fiche
$GLOBALS['_BAZAR_']['id_fiche'] = baz_nextid('bazar_fiche', 'bf_id_fiche', $GLOBALS['_BAZAR_']['db']) ;
$requete = 'INSERT INTO bazar_fiche SET bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'].','.
'bf_ce_utilisateur='.$GLOBALS['id_user'].', bf_ce_nature='.$GLOBALS['_BAZAR_']['id_typeannonce'].','.
'bf_date_creation_fiche=NOW() , '.requete_bazar_fiche($valeur);
if (!isset($_REQUEST['bf_date_debut_validite_fiche'])) {
$requete .= ', bf_date_debut_validite_fiche=now(), bf_date_fin_validite_fiche="0000-00-00" ' ;
}
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die($resultat->getMessage().$resultat->getDebugInfo()) ;
}
// Envoie d un mail aux administrateurs
$utilisateur = new Administrateur_bazar($GLOBALS['AUTH']);
if (!$utilisateur->isAdmin($GLOBALS['_BAZAR_']['id_typeannonce']) && !$utilisateur->isSuperAdmin()) {
bazar::notifier(BAZAR_NOTIFICATION_NOUVELLE_FICHE);
}
// On redirige
return $GLOBALS['_BAZAR_']['id_fiche'];
}
 
 
/** baz_insertion_url() - inserer un lien URL a une fiche
*
* @global string L'url du lien
* @global string Le texte du lien
* @global integer L'identifiant de la fiche
* @return void
*/
function baz_insertion_url($url_lien, $url_texte, $idfiche) {
//requete d'insertion dans bazar_url
if (!isset($_SESSION['_BAZAR_']['lien'])) {
$id_url = baz_nextId('bazar_url', 'bu_id_url', $GLOBALS['_BAZAR_']['db']) ;
$requete = 'INSERT INTO bazar_url SET bu_id_url='.$id_url.', bu_ce_fiche='.$idfiche.', '.
'bu_url="'.$url_lien.'", bu_descriptif_url="'.addslashes($url_texte).'"';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
return $resultat->getMessage().$resultat->getDebugInfo() ;
}
$_SESSION['_BAZAR_']['lien'] = 1;
return;
}
}
 
 
/** baz_insertion_fichier() - inserer un fichier a une fiche
*
* @global string Le label du fichier
* @global string La description du fichier
* @global integer L'identifiant de la fiche
* @return void
*/
function baz_insertion_fichier($fichier_description, $idfiche, $nom_fichier='fichier_joint') {
//verification de la presence de ce fichier
$requete = 'SELECT bfj_id_fichier FROM bazar_fichier_joint WHERE bfj_fichier="'.$_FILES[$nom_fichier]['name'].'"';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
if (!isset ($_SESSION['_BAZAR_']['fichier'])) {
if ($resultat->numRows()==0) {
$chemin_destination=BAZ_CHEMIN_APPLI.'upload/'.$_FILES[$nom_fichier]['name'];
move_uploaded_file($_FILES[$nom_fichier]['tmp_name'], $chemin_destination);
chmod ($chemin_destination, 0755);
}
$id_fichier_joint = baz_nextId('bazar_fichier_joint', 'bfj_id_fichier', $GLOBALS['_BAZAR_']['db']) ;
$requete = 'INSERT INTO bazar_fichier_joint SET bfj_id_fichier='.$id_fichier_joint.', bfj_ce_fiche='.$idfiche.
', bfj_description="'.addslashes($fichier_description).'", bfj_fichier="'.$_FILES[$nom_fichier]['name'].'"';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
return $resultat->getMessage().$resultat->getDebugInfo() ;
}
}
$_SESSION['_BAZAR_']['fichier'] = 1;
return;
}
 
 
/** baz_insertion_image() - inserer une image a une fiche
*
* @global integer L'identifiant de la fiche
* @return string requete SQL
*/
function baz_insertion_image($idfiche) {
//verification de la presence de ce fichier
$requete = 'SELECT bf_id_fiche FROM bazar_fiche WHERE bf_url_image="'.$_FILES['image']['name'].'" AND bf_id_fiche!='.$idfiche;
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
if ($resultat->numRows()==0) {
$chemin_destination=BAZ_CHEMIN_APPLI.'upload/'.$_FILES['image']['name'];
move_uploaded_file($_FILES['image']['tmp_name'], $chemin_destination);
chmod ($chemin_destination, 0755);
}
$_SESSION['_BAZAR_']['image'] = 1;
return 'bf_url_image="'.$_FILES['image']['name'].'", ' ;
}
 
 
/** baz_mise_a_jour() - Mettre a jour une fiche
*
* @global Le contenu du formulaire de saisie de l'annonce
* @return void
*/
function baz_mise_a_jour($valeur) {
if (isset($valeur['liste31']) && $valeur['liste31'] != '') {
$GLOBALS['_BAZAR_']['id_typeannonce'] = $valeur['liste31'] ;
}
 
//MAJ de bazar_fiche
$requete = 'UPDATE bazar_fiche SET '.requete_bazar_fiche(&$valeur);
if (isset($valeur['liste31']) && $valeur['liste31'] != '') {
$requete .= ' ,bf_ce_nature = '.$GLOBALS['_BAZAR_']['id_typeannonce'] ;
}
$requete.= ' WHERE bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
 
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
// Envoie d un mail aux administrateurs
$utilisateur = new Administrateur_bazar($GLOBALS['AUTH']);
if (!$utilisateur->isAdmin($GLOBALS['_BAZAR_']['id_typeannonce']) || !$utilisateur->isSuperAdmin()) {
bazar::notifier(BAZAR_NOTIFICATION_MODIFICATION_FICHE);
}
return;
}
 
function baz_post_validation() {
$lien_duplication = clone $GLOBALS['_BAZAR_']['url'];
$lien_nouvelle_fiche = clone $GLOBALS['_BAZAR_']['url'];
$lien_mes_fiches = clone $GLOBALS['_BAZAR_']['url'];
$lien_visualiser_fiche = clone $GLOBALS['_BAZAR_']['url'];
$lien_duplication->addQueryString(BAZ_VARIABLE_ID_FICHE, $_GET[BAZ_VARIABLE_ID_FICHE]);
$lien_duplication->addQueryString(BAZ_VARIABLE_DUPLICATION, 1);
$lien_duplication->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_NOUVEAU);
$lien_duplication = $lien_duplication->getURL();
$lien_nouvelle_fiche->addQueryString(BAZ_VARIABLE_ACTION, BAZ_DEPOSER_ANNONCE);
$lien_nouvelle_fiche->addQueryString(BAZ_VARIABLE_CATEGORIE_NATURE, $GLOBALS['_BAZAR_']['categorie_nature']);
$lien_nouvelle_fiche = $lien_nouvelle_fiche->getURL();
$lien_mes_fiches->addQueryString(BAZ_VARIABLE_VOIR, BAZ_VOIR_MES_FICHES);
$lien_mes_fiches = $lien_mes_fiches->getURL();
$lien_visualiser_fiche->addQueryString(BAZ_VARIABLE_VOIR, BAZ_GERER_DROITS);
$lien_visualiser_fiche->addQueryString(BAZ_VARIABLE_ACTION, BAZ_VOIR_FICHE);
$lien_visualiser_fiche->addQueryString(BAZ_VARIABLE_ID_FICHE, $_GET[BAZ_VARIABLE_ID_FICHE]);
$lien_visualiser_fiche = $lien_visualiser_fiche->getUrl() ;
ob_start();
if (file_exists(BAZ_CHEMIN_SQUELETTE.'baz_post_validation.tpl.html')) {
include_once BAZ_CHEMIN_SQUELETTE.'baz_post_validation.tpl.html';
}
$res = ob_get_contents();
ob_end_clean();
return $res ;
}
 
/** baz_suppression() - Supprime une fiche
*
* @global L'identifiant de la fiche a supprimer
* @return void
*/
function baz_suppression() {
if ($GLOBALS['AUTH']->getAuth()) {
$valeurs=baz_valeurs_fiche($_GET['id_fiche']);
//suppression des wikinis associes
//génération du titre du wiki, sous la forme id-titre du projet
$titre=baz_titre_wiki($valeurs["bf_titre"]);
$requete = 'SELECT gewi_id_wikini FROM gen_wikini WHERE gewi_code_alpha_wikini = "'.$titre.'"';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if ($resultat->numRows()>0) {
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
$id_wikini=$ligne['gewi_id_wikini'];
}
include_once PAP_CHEMIN_RACINE.'api/sql/SQL_manipulation.fonct.php';
include_once PAP_CHEMIN_RACINE.'client/integrateur_wikini/configuration/adwi_configuration.inc.php' ;
include_once PAP_CHEMIN_RACINE.'client/integrateur_wikini/bibliotheque/adwi_wikini.fonct.php' ;
adwi_supprimer_wikini($id_wikini, $GLOBALS['_BAZAR_']['db']);
}
// suppression des valeurs des listes et des cases à cocher
$requete = 'DELETE FROM bazar_fiche_valeur_liste WHERE bfvl_ce_fiche='.$_GET['id_fiche'];
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
//suppression des urls associes
$requete = 'delete FROM bazar_url WHERE bu_ce_fiche = '.$_GET['id_fiche'];
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
return ('Echec de la requete<br />'.$resultat->getMessage().'<br />'.$resultat->getDebugInfo().'<br />'."\n") ;
}
//suppression des fichiers associes
$requete = 'SELECT bfj_id_fichier FROM bazar_fichier_joint WHERE bfj_ce_fiche = '.$_GET['id_fiche'];
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
return ('Echec de la requete<br />'.$resultat->getMessage().'<br />'.$resultat->getDebugInfo().'<br />'."\n") ;
}
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
baz_suppression_fichier($ligne['bfj_id_fichier']);
}
//suppression dans bazar_fiche
$requete = 'DELETE FROM bazar_fiche WHERE bf_id_fiche = '.$_GET['id_fiche'];
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ('Echec de la requete<br />'.$resultat->getMessage().'<br />'.$resultat->getDebugInfo().'<br />'."\n") ;
}
return ;
}
}
 
 
/** baz_suppression_url() - Supprimer un lien d'une fiche
*
* @global integer L'identifiant du lien
* @return void
*/
function baz_suppression_url($id_url) {
if ($GLOBALS['AUTH']->getAuth()) {
//suppression dans bazar_url
$requete = 'DELETE FROM bazar_url WHERE bu_id_url = '.$id_url;
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ('Echec de la requete<br />'.$resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
}
return;
}
}
 
 
/** baz_suppression_fichier() - Supprimer un fichier d'une fiche
*
* @global integer L'identifiant du fichier
* @return void
*/
function baz_suppression_fichier($id_fichier) {
if ($GLOBALS['AUTH']->getAuth()) {
//verification de l'utilisation du fichier joint pour une autre annonce
$requete = 'SELECT bfj_fichier FROM bazar_fichier_joint WHERE bfj_id_fichier='.$id_fichier;
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
$requete = 'SELECT bfj_fichier FROM bazar_fichier_joint WHERE bfj_fichier="'.$ligne['bfj_fichier'].'"';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
//si le fichier n'est que utilise dans cette fiche, on le supprime, on le laisse sinon
if ($resultat->numRows()==1) {
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
unlink(BAZ_CHEMIN_APPLI.'upload/'.$ligne['bfj_fichier']);
}
//suppression dans la table bazar_fichier
$requete = 'DELETE FROM bazar_fichier_joint WHERE bfj_id_fichier = '.$id_fichier;
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
return ('Echec de la requete<br />'.$resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
}
return;
}
}
 
 
/** baz_suppression_image() - Supprimer une image d'une fiche
*
* @global integer L'identifiant de la fiche
* @return void
*/
function baz_suppression_image($id_fiche) {
if ($GLOBALS['AUTH']->getAuth()) {
//verification de l'utilisation de l'image pour une autre annonce
$requete = 'SELECT bf_url_image FROM bazar_fiche WHERE bf_id_fiche='.$id_fiche;
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
$requete = 'SELECT bf_url_image FROM bazar_fiche WHERE bf_url_image="'.$ligne['bf_url_image'].'"';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
//si le fichier n'est que utilise dans cette fiche, on le supprime, on le laisse sinon
if ($resultat->numRows()==1) {
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
unlink(BAZ_CHEMIN_APPLI.'upload/'.$ligne['bf_url_image']);
}
//suppression dans la table bazar_fiche
$requete = 'UPDATE bazar_fiche SET bf_url_image=NULL WHERE bf_id_fiche = '.$id_fiche;
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ('Echec de la requete<br />'.$resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
}
return;
}
}
 
 
/** publier_fiche () - Publie ou non dans les fichiers XML la fiche bazar d'un utilisateur
*
* @global boolean Valide: oui ou non
* @return void
*/
function publier_fiche($valid) {
 
$utilisateur = new Administrateur_bazar($GLOBALS['AUTH']);
// sortie anticipée en cas d'accès non autorisé
// ceci limite l'accès au supers admins
// TODO: voir si l'on ne pourrait valider que les fiches
// des catégories dont la personne est admin, ce qui permettrait un accès plus fin
if(!$utilisateur->isSuperAdmin()) {
return;
}
 
if (isset($_GET['id_fiche'])) $GLOBALS['_BAZAR_']['id_fiche']=$_GET['id_fiche'];
if (isset($_GET['typeannonce'])) $typeannonce=$_GET['typeannonce'];
if(isset($_POST['date_validite']) && date('Y-m-d', strtotime($_POST['date_validite']))) {
$date_validite = '"'.date('Y-m-d', strtotime($_POST['date_validite'])).'"';
} else {
$date_validite = 'now()';
}
if ($valid==0) {
$requete = 'UPDATE bazar_fiche SET bf_statut_fiche=2 ';
if(isset($_POST['date_validite']) && date('Y-m-d', strtotime($_POST['date_validite']))) {
$requete .= ', bf_date_debut_validite_fiche='.$date_validite.' ';
}
$requete .= 'WHERE bf_id_fiche="'.$GLOBALS['_BAZAR_']['id_fiche'].'"' ;
}
else {
$requete .= 'UPDATE bazar_fiche SET bf_date_debut_validite_fiche='.$date_validite.' , bf_statut_fiche=1 WHERE bf_id_fiche="'.$GLOBALS['_BAZAR_']['id_fiche'].'"' ;
}
// ====================Mise a jour de la table bazar_fiche====================
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
unset ($resultat) ;
//TODO envoie mail annonceur
return;
}
 
 
/** baz_s_inscrire() affiche le formulaire qui permet de s'inscrire pour recevoir des annonces d'un type
*
* @return string le code HTML
*/
function baz_s_inscrire() {
$res= '<h2>'.BAZ_S_INSCRIRE_AUX_ANNONCES.'</h2>'."\n";
$res .= '<p id="laius_abonnement">'.BAZ_LAIUS_S_ABONNER.'</p>'."\n";
//requete pour obtenir l'id et le label des types d'annonces
$requete = 'SELECT bn_id_nature, bn_label_nature, bn_image_titre '.
'FROM bazar_nature WHERE 1';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
return ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
// Nettoyage de l url
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_VOIR);
$table = new HTML_Table(array ('class' => 'table_bazar'));
$table->addRow(array(BAZ_TYPE_ANNONCES, BAZ_RSS));
$table->setRowType(0, 'th');
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
$lien_RSS=$GLOBALS['_BAZAR_']['url'];
$lien_RSS->addQueryString(BAZ_VARIABLE_ACTION, BAZ_VOIR_FLUX_RSS);
$lien_RSS->addQueryString('annonce', $ligne[bn_id_nature]);
if (isset($ligne['bn_image_titre'])) {$titre='&nbsp;<img src="client/bazar/images/'.$ligne['bn_image_titre'].'" alt="'.$ligne['bn_label_nature'].'" />'."\n";}
else {$titre='<strong>&nbsp;'.$ligne['bn_label_nature'].'</strong>'."\n";}
 
$table->addRow(array($titre,
'<a href="'.$lien_RSS->getURL().'"><img src="client/bazar/images/BAZ_rss.png" alt="'.BAZ_RSS.'"></a>'));
$lien_RSS->removeQueryString('annonce');
}
$table->altRowAttributes(1, array('class' => 'ligne_impaire'), array('class' => 'ligne_paire'));
$table->updateColAttributes(0, array('class' => 'col1'));
$table->updateColAttributes(1, array('class' => 'col2'));
$res.=$table->toHTML() ;
 
// Nettoyage de l'url
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
$GLOBALS['_BAZAR_']['url']->removeQueryString('idtypeannonce');
return $res;
}
 
 
/** baz_valeurs_fiche() - Renvoie un tableau avec les valeurs par defaut du formulaire d'inscription
*
* @param integer Identifiant de la fiche
*
* @return array Valeurs enregistrees pour cette fiche
*/
function baz_valeurs_fiche($idfiche) {
$requete = 'SELECT * FROM bazar_fiche WHERE bf_id_fiche='.$idfiche;
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
}
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC) ;
$valeurs_fiche = array() ;
$tableau = baz_valeurs_template($GLOBALS['_BAZAR_']['template']);
for ($i=0; $i<count($tableau); $i++) {
if ($tableau[$i]['type']=='liste' || $tableau[$i]['type']=='checkbox') {
$requete = 'SELECT bfvl_valeur FROM bazar_fiche_valeur_liste WHERE bfvl_ce_fiche='.$idfiche.
' AND bfvl_ce_liste='.$tableau[$i]['nom_bdd'];
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError ($resultat)) {
die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
}
$nb=0;$val='';
while ($result = $resultat->fetchRow()) {
if ($nb>0) $val .= ', ';
$val .= $result[0];
$nb++;
}
$valeurs_fiche[$tableau[$i]['type'].$tableau[$i]['nom_bdd']] = $val;
}
elseif ($tableau[$i]['type']=='champs_cache' || $tableau[$i]['type']=='texte' || $tableau[$i]['type']=='textelong' || $tableau[$i]['type']=='listedatedeb' || $tableau[$i]['type']=='listedatefin') {
$valeurs_fiche[$tableau[$i]['nom_bdd']] = stripslashes($ligne[$tableau[$i]['nom_bdd']]);
} elseif ($tableau[$i]['type']=='carte_google') {
$valeurs_fiche['bf_latitude'] = $ligne['bf_latitude'];
$valeurs_fiche['bf_longitude'] = $ligne['bf_longitude'];
}
}
return $valeurs_fiche;
}
 
function baz_valeur_champs($nom_champs,$id_fiche) {
 
$requete = 'SELECT blv_label FROM bazar_fiche_valeur_liste, bazar_liste_valeurs WHERE bfvl_ce_fiche='.
$id_fiche.' AND bfvl_ce_liste='.$nom_champs.
' AND bfvl_valeur=blv_valeur AND blv_ce_liste='.$nom_champs.
' AND blv_ce_i18n="'.$GLOBALS['_BAZAR_']['langue'].'"';
 
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError ($resultat)) {
return ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
}
else {
$res = '';
while($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
if($ligne['blv_label'] != 'Autre') {
$res .= $ligne['blv_label'].', ';
}
}
$res = rtrim($res,', ');
 
return $res;
}
}
 
/** function baz_nextId () Renvoie le prochain identifiant numerique libre d'une table
*
* @param string Nom de la table
* @param string Nom du champs identifiant
* @param mixed Objet DB de PEAR pour la connexion a la base de donnees
*
* return integer Le prochain numero d'identifiant disponible
*/
function baz_nextId($table, $colonne_identifiant, $bdd) {
$requete = 'SELECT MAX('.$colonne_identifiant.') AS maxi FROM '.$table;
$resultat = $bdd->query($requete) ;
if (DB::isError($resultat)) {
die (__FILE__ . __LINE__ . $resultat->getMessage() . $requete);
return $bdd->raiseError($resultat) ;
}
if ($resultat->numRows() > 1) {
return $bdd->raiseError('<br />La table '.$table.' a un identifiant non unique<br />') ;
}
$ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT) ;
return $ligne->maxi + 1 ;
}
 
/** function baz_titre_wiki () Renvoie la chaine de caractere sous une forme compatible avec wikini
*
* @param string mot à transformer (enlever accents, espaces)
*
* return string mot transformé
*/
function baz_titre_wiki($nom) {
$titre=trim($nom);
for ($j = 0; $j < strlen ($titre); $j++) {
if (!preg_match ('/[a-zA-Z0-9]/', $titre[$j])) {
$titre[$j] = '_' ;
}
}
return $titre;
}
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
* Revision 1.74.2.12 2008-04-16 12:38:17 alexandre_tb
* verification des droits avant de permettre l ajout d une nouvelle fiche
*
* Revision 1.74.2.11 2008-03-17 11:03:02 jp_milcent
* Ajout de l'authentification nécessaire pour déposer des commentaires.
* Corrections sur la gestion des paramêtres dans les urls (compatibilité applette Identification et Moteur de Recherche).
*
* Revision 1.74.2.10 2008-02-01 17:20:18 florian
* suppression du lien annuler pour la sélection des fiches, pas de valeur par défaut pour la sélection, et sélectionner un type de fiche devient obligatoire.
*
* Revision 1.74.2.9 2008-02-01 16:23:29 florian
* ajout champs_mail, décommenter les traductions des javascripts
*
* Revision 1.74.2.8 2008-02-01 09:56:56 alexandre_tb
* reglage du pb de double saisie de fiche,
* ajout d un exit apres le header location
*
* Revision 1.74.2.7 2008-01-29 14:35:22 alexandre_tb
* suppression de l identification pour l abonnement au fluxRSS
*
* Revision 1.74.2.6 2008-01-29 09:55:07 alexandre_tb
* suppression de l identification pour l abonnement au fluxRSS
*
* Revision 1.74.2.5 2008-01-29 09:35:36 alexandre_tb
* remplacement des variables action par une constante
* Utilisation d un redirection pour eviter que les formulaires soient valides 2 fois
* simplification de la suppression d un lien associe a une liste
*
* Revision 1.74.2.4 2008-01-11 14:10:12 alexandre_tb
* Remplacement de la variable action ecrite en dur par la constante BAZ_VARIABLE_ACTION
*
* Revision 1.74.2.3 2007-12-14 09:55:05 alexandre_tb
* suppression de style dans le formulaire
*
* Revision 1.74.2.2 2007-12-06 15:36:07 alexandre_tb
* appel de la fonction GEN_AttributsBody dans le composant carte_google
*
* Revision 1.74.2.1 2007-12-04 09:00:08 alexandre_tb
* corrections importantes sur baz_s_inscrire, simplification de l'application qui ne fonctionnait pas.
*
* Revision 1.74 2007-10-25 09:41:31 alexandre_tb
* mise en place de variable de session pour eviter que les formulaires soit valider 2 fois, pour les url, fichiers et image
*
* Revision 1.73 2007-10-24 13:27:00 alexandre_tb
* bug : double saisie d url
* suppression de warning sur variable
*
* Revision 1.72 2007-10-22 10:09:21 florian
* correction template
*
* Revision 1.71 2007-10-22 09:18:39 alexandre_tb
* prise en compte de la langue dans les requetes sur bazar_nature
*
* Revision 1.70 2007-10-10 13:26:36 alexandre_tb
* utilisation de la classe Administrateur_bazar a la place de niveau_droit
* suppression de fonction niveau_droit
*
* Revision 1.69 2007-09-18 07:39:42 alexandre_tb
* correction d un bug lors d une insertion
*
* Revision 1.68 2007-08-27 12:31:31 alexandre_tb
* mise en place de modele
*
* Revision 1.67 2007-07-04 10:01:30 alexandre_tb
* mise en place de divers templates :
* - mail pour admin (sujet et corps)
* - modele carte_google
* ajout de lignes dans bazar_template
*
* Revision 1.66 2007-06-25 12:15:06 alexandre_tb
* merge from narmer
*
* Revision 1.65 2007-06-25 08:31:17 alexandre_tb
* utilisation de la bibliotheque generale api/formulaire/formulaire.fonct.inc.php a la place de bazar.fonct.formulaire.php
*
* Revision 1.64 2007-06-04 15:25:39 alexandre_tb
* ajout de la carto google
*
* Revision 1.63 2007/04/11 08:30:12 neiluj
* remise en état du CVS...
*
* Revision 1.57.2.12 2007/03/16 14:49:24 alexandre_tb
* si la date de debut d evenement est superieure a la date de fin alors on met
* la meme date dans les deux champs (coherence)
*
* Revision 1.57.2.11 2007/03/07 17:40:57 jp_milcent
* Ajout d'id sur les colonnes et gestion par les CSS des styles du tableau des abonnements.
*
* Revision 1.57.2.10 2007/03/07 17:20:19 jp_milcent
* Ajout du nettoyage systématique des URLs.
*
* Revision 1.57.2.9 2007/03/06 16:23:24 jp_milcent
* Nettoyage de l'url pour la gestion des droits.
*
* Revision 1.57.2.8 2007/03/05 14:33:44 jp_milcent
* Suppression de l'appel à Mes_Fiches dans la fonction baz_formulaire
*
* Revision 1.57.2.7 2007/03/05 10:28:03 alexandre_tb
* correction d un commentaire
*
* Revision 1.57.2.6 2007/02/15 13:42:16 jp_milcent
* Utilisation de IN à la place du = dans les requêtes traitant les catégories de fiches.
* Permet d'utiliser la syntaxe 1,2,3 dans la configuration de categorie_nature.
*
* Revision 1.57.2.5 2007/02/12 16:16:31 alexandre_tb
* suppression du style clear:both dans les attribut du formulaire d identification
*
* Revision 1.57.2.4 2007/02/01 16:19:30 alexandre_tb
* correction erreur de requete sur insertion bazar_fiche
*
* Revision 1.57.2.3 2007/02/01 16:11:05 alexandre_tb
* correction erreur de requete sur insertion bazar_fiche
*
* Revision 1.57.2.2 2007/01/22 16:05:39 alexandre_tb
* insertion de la date du jour dans bf_date_debut_validite_fiche quand il n'y a pas ce champs dans le formulaire (évite le 0000-00-00)
*
* Revision 1.57.2.1 2006/12/13 13:23:03 alexandre_tb
* Remplacement de l appel d une constante par un appel direct. -> warning
*
* Revision 1.58 2006/12/13 13:20:16 alexandre_tb
* Remplacement de l appel d une constante par un appel direct. -> warning
*
* Revision 1.57 2006/10/05 08:53:50 florian
* amelioration moteur de recherche, correction de bugs
*
* Revision 1.56 2006/09/28 15:41:36 alexandre_tb
* Le formulaire pour se logguer dans l'action saisir reste sur l'action saisir après
*
* Revision 1.55 2006/09/21 14:19:39 florian
* amélioration des fonctions liés au wikini
*
* Revision 1.54 2006/09/14 15:11:23 alexandre_tb
* suppression temporaire de la gestion des wikinis
*
* Revision 1.53 2006/07/25 13:24:44 florian
* correction bug image
*
* Revision 1.52 2006/07/25 13:05:00 alexandre_tb
* Remplacement d un die par un echo
*
* Revision 1.51 2006/07/18 14:17:32 alexandre_tb
* Ajout d'un formulaire d identification
*
* Revision 1.50 2006/06/21 08:37:59 alexandre_tb
* Correction de bug, d'un appel constant (....) qui ne fonctionnais plus.
*
* Revision 1.49 2006/06/02 09:29:07 florian
* debut d'integration de wikini
*
* Revision 1.48 2006/05/19 13:54:11 florian
* stabilisation du moteur de recherche, corrections bugs, lien recherche avancee
*
* Revision 1.47 2006/04/28 12:46:14 florian
* integration des liens vers annuaire
*
* Revision 1.46 2006/03/29 13:04:35 alexandre_tb
* utilisation de la classe Administrateur_bazar
*
* Revision 1.45 2006/03/24 09:28:02 alexandre_tb
* utilisation de la variable globale $GLOBALS['_BAZAR_']['categorie_nature']
*
* Revision 1.44 2006/03/14 17:10:21 florian
* ajout des fonctions de syndication, changement du moteur de recherche
*
* Revision 1.43 2006/03/02 20:36:52 florian
* les entrees du formulaire de saisir ne sont plus dans les constantes mias dans des tables qui gerent le multilinguisme.
*
* Revision 1.42 2006/03/01 16:23:22 florian
* modifs textes fr et correction bug "undefined index"
*
* Revision 1.41 2006/03/01 16:05:51 florian
* ajout des fichiers joints
*
* Revision 1.40 2006/02/06 09:33:00 alexandre_tb
* correction de bug
*
* Revision 1.39 2006/01/30 17:25:38 alexandre_tb
* correction de bugs
*
* Revision 1.38 2006/01/30 10:27:04 florian
* - ajout des entrées de formulaire fichier, url, et image
* - correction bug d'affichage du mode de saisie
*
* Revision 1.37 2006/01/24 14:11:11 alexandre_tb
* correction de bug sur l'ajout d'une image et d'un fichier
*
* Revision 1.36 2006/01/19 17:42:11 florian
* ajout des cases à cocher pré-cochées pour les maj
*
* Revision 1.35 2006/01/18 11:06:51 florian
* correction erreur saisie date
*
* Revision 1.34 2006/01/18 10:53:28 florian
* corrections bugs affichage fiche
*
* Revision 1.33 2006/01/18 10:07:34 florian
* recodage de l'insertion et de la maj des données relatives aux listes et checkbox dans des formulaires
*
* Revision 1.32 2006/01/18 10:03:36 florian
* recodage de l'insertion et de la maj des données relatives aux listes et checkbox dans des formulaires
*
* Revision 1.31 2006/01/17 10:07:08 alexandre_tb
* en cours
*
* Revision 1.30 2006/01/16 09:42:57 alexandre_tb
* en cours
*
* Revision 1.29 2006/01/13 14:12:51 florian
* utilisation des temlates dans la table bazar_nature
*
* Revision 1.28 2006/01/05 16:28:24 alexandre_tb
* prise en chage des checkbox, reste la mise à jour à gérer
*
* Revision 1.27 2006/01/04 15:30:56 alexandre_tb
* mise en forme du code
*
* Revision 1.26 2006/01/03 10:19:31 florian
* 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...
*
* Revision 1.25 2005/12/20 14:49:35 ddelon
* Fusion Head vers Livraison
*
* Revision 1.24 2005/12/16 15:44:40 alexandre_tb
* ajout de l'option restreindre dépôt
*
* Revision 1.23 2005/12/01 17:03:34 florian
* changement des chemins pour appli Pear
*
* Revision 1.22 2005/12/01 16:05:41 florian
* changement des chemins pour appli Pear
*
* Revision 1.21 2005/12/01 15:31:30 florian
* correction bug modifs et saisies
*
* Revision 1.20 2005/11/30 13:58:45 florian
* ajouts graphisme (logos, boutons), changement structure SQL bazar_fiche
*
* Revision 1.19 2005/11/24 16:17:13 florian
* corrections bugs, ajout des cases à cocher
*
* Revision 1.18 2005/11/18 16:03:23 florian
* correction bug html entites
*
* Revision 1.17 2005/11/17 18:48:02 florian
* corrections bugs + amélioration de l'application d'inscription
*
* Revision 1.16 2005/11/07 17:30:36 florian
* ajout controle sur les listes pour la saisie
*
* Revision 1.15 2005/11/07 17:05:45 florian
* amélioration validation conditions de saisie, ajout des règles spécifiques de saisie des formulaires
*
* Revision 1.14 2005/11/07 08:48:02 florian
* correction pb guillemets pour saisie et modif de fiche
*
* Revision 1.13 2005/10/21 16:15:04 florian
* mise a jour appropriation
*
* Revision 1.11 2005/10/12 17:20:33 ddelon
* Reorganisation calendrier + applette
*
* Revision 1.10 2005/10/12 15:14:06 florian
* amélioration de l'interface de bazar, de manière a simplifier les consultations, et à harmoniser par rapport aux Ressources
*
* Revision 1.9 2005/10/10 16:22:52 alexandre_tb
* Correction de bug. Lorsqu'on revient en arrière après avoir validé un formulaire.
*
* Revision 1.8 2005/09/30 13:50:07 alexandre_tb
* correction bug date parution ressource
*
* Revision 1.7 2005/09/30 13:15:58 ddelon
* compatibilité php5
*
* Revision 1.6 2005/09/30 13:00:05 ddelon
* Fiche bazar generique
*
* Revision 1.5 2005/09/30 12:22:54 florian
* Ajouts commentaires pour fiche, modifications graphiques, maj SQL
*
* Revision 1.3 2005/07/21 19:03:12 florian
* nouveautés bazar: templates fiches, correction de bugs, ...
*
* Revision 1.1.1.1 2005/02/17 18:05:11 florian
* Import initial de Bazar
*
* Revision 1.1.1.1 2005/02/17 11:09:50 florian
* Import initial
*
* Revision 1.1.1.1 2005/02/16 18:06:35 florian
* import de la nouvelle version
*
* Revision 1.10 2004/07/08 17:25:25 florian
* ajout commentaires + petits debuggages
*
* Revision 1.8 2004/07/07 14:30:19 florian
* débogage RSS
*
* Revision 1.7 2004/07/06 16:22:01 florian
* débogage modification + MAJ flux RSS
*
* Revision 1.6 2004/07/06 09:28:26 florian
* changement interface de modification
*
* Revision 1.5 2004/07/05 15:10:23 florian
* changement interface de saisie
*
* Revision 1.4 2004/07/02 14:51:14 florian
* ajouts divers pour faire fonctionner l'insertion de fiches
*
* Revision 1.3 2004/07/01 16:37:42 florian
* ajout de fonctions pour les templates
*
* Revision 1.2 2004/07/01 13:00:13 florian
* modif Florian
*
* Revision 1.1 2004/06/23 09:58:32 alex
* version initiale
*
* Revision 1.1 2004/06/18 09:00:37 alex
* version initiale
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
 
?>
/trunk/bibliotheque/bazar.fonct.formulaire.php
New file
0,0 → 1,566
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: bazar.fonct.formulaire.php,v 1.26 2007-06-04 15:24:31 alexandre_tb Exp $
/**
* Formulaire
*
* Les fonctions de mise en page des formulaire
*
*@package bazar
//Auteur original :
*@author Florian SCHMITT <florian@ecole-et-nature.org>
//Autres auteurs :
*@author Aleandre GRANIER <alexandre@tela-botanica.org>
*@copyright Tela-Botanica 2000-2004
*@version $Revision: 1.26 $ $Date: 2007-06-04 15:24:31 $
// +------------------------------------------------------------------------------------------------------+
*/
 
require_once 'bazar.fonct.formulaire.controles.php';
 
//-------------------FONCTIONS DE MISE EN PAGE DES FORMULAIRES
 
/** liste() - Ajoute un élément de type liste au formulaire
*
* @param mixed L'objet QuickForm du formulaire
* @param int identifiant de la liste sur bazar_liste
* @param string label à afficher dans le formulaire
* @param string première restriction de la taille des champs du formulaire
* @param string deuxième restriction de la taille des champs du formulaire
* @param string valeur par défaut du formulaire
* @param string table source pour les valeurs de la liste
* @param string ce champs est il obligatoire? (required)
* @param boolean sommes nous dans le moteur de recherche?
* @return void
*/
function liste(&$formtemplate, $id_liste , $label, $limite1, $limite2, $defaut, $source, $obligatoire, $dans_moteur_de_recherche=0) {
$requete = 'SELECT * FROM bazar_liste_valeurs WHERE blv_ce_liste='.$id_liste.' AND blv_ce_i18n="'.$GLOBALS['_BAZAR_']['langue'].'"';
$resultat = & $GLOBALS['_BAZAR_']['db'] -> query($requete) ;
if (DB::isError ($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
if ($dans_moteur_de_recherche==0) {
$select[0]=BAZ_CHOISIR;
}
else {
$select[0]=BAZ_INDIFFERENT;
}
while ($ligne = $resultat->fetchRow()) {
$select[$ligne[1]] = $ligne[2] ;
}
$option=array('style'=>'width: '.$limite1.'px;', 'id' => 'liste'.$id_liste);
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm/select.php';
$select= new HTML_QuickForm_select('liste'.$id_liste, $label, $select, $option);
$select->setSize($limite2);
$select->setMultiple(0);
$select->setSelected($defaut);
$formtemplate->addElement($select) ;
if (($dans_moteur_de_recherche==0) && isset($obligatoire) && ($obligatoire==1)) {
$formtemplate->addRule('liste'.$id_liste, BAZ_CHOISIR_OBLIGATOIRE.' '.$label , 'nonzero', '', 'client') ;
$formtemplate->addRule('liste'.$id_liste, $label.' obligatoire', 'required', '', 'client') ;}
}
 
 
/** checkbox() - Ajoute un élément de type checkbox au formulaire
*
* @param mixed L'objet QuickForm du formulaire
* @param int identifiant de la liste sur bazar_liste
* @param string label à afficher dans le formulaire
* @param string première restriction de la taille des champs du formulaire
* @param string deuxième restriction de la taille des champs du formulaire
* @param string valeur par défaut du formulaire
* @param string table source pour les valeurs de la liste
* @param string ce champs est il obligatoire? (required)
* @return void
*/
function checkbox(&$formtemplate, $id_liste , $label, $limite1, $limite2, $defaut, $source, $obligatoire, $dans_moteur_de_recherche=0) {
$requete = 'SELECT * FROM bazar_liste_valeurs WHERE blv_ce_liste='.$id_liste.' AND blv_ce_i18n="'.$GLOBALS['_BAZAR_']['langue'].'" ORDER BY blv_label';
$resultat = & $GLOBALS['_BAZAR_']['db'] -> query($requete) ;
if (DB::isError ($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm/checkbox.php' ;
$i=0;
if (isset($defaut)) $tab=split(', ', $defaut);
while ($ligne = $resultat->fetchRow()) {
if ($i==0) $labelchkbox=$label ; else $labelchkbox='&nbsp;';
$checkbox[$i]= & HTML_Quickform::createElement('checkbox', $ligne[1], $labelchkbox, $ligne[2],
array ('style'=>'display:inline;margin:2px;')) ;
foreach ($tab as $val) {
if ($ligne[1]==$val) $checkbox[$i]->setChecked(1);
}
$i++;
}
$squelette_checkbox =& $formtemplate->defaultRenderer();
$squelette_checkbox->setElementTemplate( '<tr><td colspan="2" style="text-align:left;">'."\n".'<fieldset class="bazar_fieldset">'."\n".'<legend>{label}'.
'<!-- BEGIN required --><span class="symbole_obligatoire">&nbsp;*</span><!-- END required -->'."\n".
'</legend>'."\n".'{element}'."\n".'</fieldset> '."\n".'</td></tr>'."\n", 'checkbox'.$id_liste);
$squelette_checkbox->setGroupElementTemplate( "\n".'<div class="bazar_checkbox">'."\n".'{element}'."\n".'</div>'."\n", 'checkbox'.$id_liste);
$formtemplate->addGroup($checkbox, 'checkbox'.$id_liste, $label, "\n");
if (($dans_moteur_de_recherche==0) && isset($obligatoire) && ($obligatoire==1)) {
$formtemplate->addGroupRule('checkbox'.$id_liste, $label.' obligatoire', 'required', null, 1, 'client');
}
}
 
 
/** listedatedeb() - Ajoute un élément de type date sous forme de liste au formulaire pour designer une date de début
*
* @param mixed L'objet QuickForm du formulaire
* @param string nom de la table dans la base de donnée
* @param string label à afficher dans le formulaire
* @param string première restriction de la taille des champs du formulaire
* @param string deuxième restriction de la taille des champs du formulaire
* @param string valeur par défaut du formulaire
* @param string table source pour les valeurs de la date
* @param string ce champs est il obligatoire? (required)
* @return void
*/
function listedatedeb(&$formtemplate, $nom_bdd , $label, $limite1, $limite2, $defaut, $source, $obligatoire, $dans_moteur_de_recherche=0) {
$optiondate = array('language' => BAZ_LANGUE_PAR_DEFAUT,
'minYear' => date('Y')-4,
'maxYear'=> (date('Y')+10),
'format' => 'd m Y',
'addEmptyOption' => BAZ_DATE_VIDE,
);
$formtemplate->addElement('date', $nom_bdd, $label, $optiondate) ;
//gestion des valeurs par défaut (date du jour)
if (isset($defaut) && $defaut!='') {
$tableau_date = explode ('-', $defaut);
$formtemplate->setDefaults(array($nom_bdd => array ('d'=> $tableau_date[2], 'm'=> $tableau_date[1], 'Y'=> $tableau_date[0])));
}
else {
$defauts=array($nom_bdd => array ('d'=>date('d'), 'm'=>date('m'), 'Y'=>date('Y')));
$formtemplate->setDefaults($defauts);
}
//gestion du champs obligatoire
if (($dans_moteur_de_recherche==0) && isset($obligatoire) && ($obligatoire==1)) {
$formtemplate->addRule($nom_bdd, $label.' obligatoire', 'required', '', 'client') ;
}
}
 
/** listedatefin() - Ajoute un élément de type date sous forme de liste au formulaire pour designer une date de fin
*
* @param mixed L'objet QuickForm du formulaire
* @param string nom de la table dans la base de donnée
* @param string label à afficher dans le formulaire
* @param string première restriction de la taille des champs du formulaire
* @param string deuxième restriction de la taille des champs du formulaire
* @param string valeur par défaut du formulaire
* @param string table source pour les valeurs de la date
* @param string ce champs est il obligatoire? (required)
* @return void
*/
function listedatefin(&$formtemplate, $nom_bdd , $label, $limite1, $limite2, $defaut, $source, $obligatoire, $dans_moteur_de_recherche=0) {
listedatedeb($formtemplate, $nom_bdd , $label, $limite1, $limite2, $defaut, $source, $obligatoire, $dans_moteur_de_recherche);
}
 
 
/** texte() - Ajoute un élément de type texte au formulaire
*
* @param mixed L'objet QuickForm du formulaire
* @param string nom de la table dans la base de donnée
* @param string label à afficher dans le formulaire
* @param string première restriction de la taille des champs du formulaire
* @param string deuxième restriction de la taille des champs du formulaire
* @param string valeur par défaut du formulaire
* @param string table source pour les valeurs du texte (inutile)
* @param string ce champs est il obligatoire? (required)
* @return void
*/
function texte(&$formtemplate, $nom_bdd , $label, $limite1, $limite2, $defaut, $source, $obligatoire, $dans_moteur_de_recherche=0) {
$option=array('size'=>$limite1,'maxlength'=>$limite2, 'id' => $nom_bdd);
$formtemplate->addElement('text', $nom_bdd, $label, $option) ;
//gestion des valeurs par défaut
$defauts=array($nom_bdd=>$defaut);
$formtemplate->setDefaults($defauts);
$formtemplate->applyFilter($nom_bdd, 'addslashes') ;
//gestion du champs obligatoire
if (($dans_moteur_de_recherche==0) && isset($obligatoire) && ($obligatoire==1)) {
$formtemplate->addRule($nom_bdd, $label.' obligatoire', 'required', '', 'client') ;
}
}
 
 
/** textelong() - Ajoute un élément de type textearea au formulaire
*
* @param mixed L'objet QuickForm du formulaire
* @param string nom de la table dans la base de donnée
* @param string label à afficher dans le formulaire
* @param string taille des colonnes de l'élément
* @param string taille des lignes de l'élément
* @param string valeur par défaut du formulaire
* @param string table source pour les valeurs du texte (inutile)
* @param string ce champs est il obligatoire? (required)
* @return void
*/
function textelong(&$formtemplate, $nom_bdd , $label, $limite1, $limite2, $defaut, $source, $obligatoire, $dans_moteur_de_recherche=0) {
$formtexte= new HTML_QuickForm_textarea($nom_bdd, $label, array('style'=>'white-space: normal;', 'id' => $nom_bdd));
$formtexte->setCols($limite1);
$formtexte->setRows($limite2);
$formtemplate->addElement($formtexte) ;
//gestion des valeurs par défaut
$defauts=array($nom_bdd=>$defaut);
$formtemplate->setDefaults($defauts);
$formtemplate->applyFilter($nom_bdd, 'addslashes') ;
//gestion du champs obligatoire
if (($dans_moteur_de_recherche==0) && isset($obligatoire) && ($obligatoire==1)) {
$formtemplate->addRule($nom_bdd, $label.' obligatoire', 'required', '', 'client') ;
}
}
 
/** url() - Ajoute un élément de type url internet au formulaire
*
* @param mixed L'objet QuickForm du formulaire
* @param string numero du champs input du formulaire (pour le différencier d'autres champs du meme type dans ce formulaire)
* @param string label à afficher dans le formulaire
* @param string taille des colonnes de l'élément
* @param string taille des lignes de l'élément
* @param string valeur par défaut du formulaire
* @param string table source pour les valeurs du texte (inutile)
* @param string ce champs est il obligatoire? (required)
* @return void
*/
function url(&$formtemplate, $nom_bdd , $label, $limite1, $limite2, $defaut, $source, $obligatoire, $dans_moteur_de_recherche=0) {
//recherche des URLs deja entrees dans la base
$html_url= '';
if (isset($GLOBALS['_BAZAR_']["id_fiche"])) {
$requete = 'SELECT bu_id_url, bu_url, bu_descriptif_url FROM bazar_url WHERE bu_ce_fiche='.$GLOBALS['_BAZAR_']["id_fiche"];
$resultat = & $GLOBALS['_BAZAR_']['db'] -> query($requete) ;
if (DB::isError ($resultat)) {
die ($GLOBALS['_BAZAR_']['db']->getMessage().$GLOBALS['_BAZAR_']['db']->getDebugInfo()) ;
}
if ($resultat->numRows()>0) {
$html_url= '<tr>'."\n".'<td colspan="2">'."\n".'<strong>'.BAZ_LISTE_URL.'</strong>'."\n";
$tableAttr = array("class" => "bazar_table") ;
$table = new HTML_Table($tableAttr) ;
$entete = array (BAZ_LIEN , BAZ_SUPPRIMER) ;
$table->addRow($entete) ;
$table->setRowType(0, "th") ;
$lien_supprimer=$GLOBALS['_BAZAR_']['url'];
$lien_supprimer->addQueryString('action', $_GET['action']);
$lien_supprimer->addQueryString('id_fiche', $GLOBALS['_BAZAR_']["id_fiche"]);
$lien_supprimer->addQueryString('typeannonce', $_REQUEST['typeannonce']);
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
$lien_supprimer->addQueryString('id_url', $ligne->bu_id_url);
$table->addRow (array(
'<a href="'.$ligne->bu_url.'" target="_blank"> '.$ligne->bu_descriptif_url.'</a>', // col 1 : le lien
'<a href="'.$lien_supprimer->getURL().'" onclick="javascript:return confirm(\''.BAZ_CONFIRMATION_SUPPRESSION_LIEN.'\');" >'.BAZ_SUPPRIMER.'</a>'."\n")) ; // col 2 : supprimer
$lien_supprimer->removeQueryString('id_url');
}
 
// Nettoyage de l'url
$lien_supprimer->removeQueryString('action');
$lien_supprimer->removeQueryString('id_fiche');
$lien_supprimer->removeQueryString('typeannonce');
$table->altRowAttributes(1, array("class" => "ligne_impaire"), array("class" => "ligne_paire"));
$table->updateColAttributes(1, array("align" => "center"));
$html_url.= $table->toHTML()."\n".'</td>'."\n".'</tr>'."\n" ;
}
}
$html ='<tr>'."\n".'<td colspan="2">'."\n".'<h4>'.$label.'</h4>'."\n".'</td>'."\n".'</tr>'."\n";
$formtemplate->addElement('html', $html) ;
if ($html_url!='') $formtemplate->addElement('html', $html_url) ;
$formtemplate->addElement('text', 'url_lien'.$nom_bdd, BAZ_URL_LIEN) ;
$formtemplate->addElement('text', 'url_texte'.$nom_bdd, BAZ_URL_TEXTE) ;
//gestion du champs obligatoire
if (($dans_moteur_de_recherche==0) && isset($obligatoire) && ($obligatoire==1)) {
$formtemplate->addRule('url_lien'.$nom_bdd, BAZ_URL_LIEN_REQUIS, 'required', '', 'client') ;
$formtemplate->addRule('url_texte'.$nom_bdd, BAZ_URL_TEXTE_REQUIS, 'required', '', 'client') ;
}
}
 
/** fichier() - Ajoute un élément de type fichier au formulaire
*
* @param mixed L'objet QuickForm du formulaire
* @param string numero du champs input du formulaire (pour le différencier d'autres champs du meme type dans ce formulaire)
* @param string label à afficher dans le formulaire
* @param string taille des colonnes de l'élément
* @param string taille des lignes de l'élément
* @param string valeur par défaut du formulaire
* @param string table source pour les valeurs du texte (inutile)
* @param string ce champs est il obligatoire? (required)
* @return void
*/
function fichier(&$formtemplate, $nom_bdd , $label, $limite1, $limite2, $defaut, $source, $obligatoire, $dans_moteur_de_recherche=0) {
//AJOUTER DES FICHIERS JOINTS
$html_fichier= '';
if (isset($GLOBALS['_BAZAR_']["id_fiche"])) {
$requete = 'SELECT * FROM bazar_fichier_joint WHERE bfj_ce_fiche='.$GLOBALS['_BAZAR_']["id_fiche"];
$resultat = & $GLOBALS['_BAZAR_']['db'] -> query($requete) ;
if (DB::isError ($resultat)) {
die ($GLOBALS['_BAZAR_']['db']->getMessage().$GLOBALS['_BAZAR_']['db']->getDebugInfo()) ;
}
if ($resultat->numRows()>0) {
$html_fichier = '<tr>'."\n".'<td colspan="2">'."\n".'<strong>'.BAZ_LISTE_FICHIERS_JOINTS.'</strong>'."\n";
$tableAttr = array("class" => "bazar_table") ;
$table = new HTML_Table($tableAttr) ;
$entete = array (BAZ_FICHIER , BAZ_SUPPRIMER) ;
$table->addRow($entete) ;
$table->setRowType(0, "th") ;
$lien_supprimer=$GLOBALS['_BAZAR_']['url'];
$lien_supprimer->addQueryString('action', $_GET['action']);
$lien_supprimer->addQueryString('id_fiche', $GLOBALS['_BAZAR_']["id_fiche"]);
$lien_supprimer->addQueryString('typeannonce', $_REQUEST['typeannonce']);
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
$lien_supprimer->addQueryString('id_fichier', $ligne->bfj_id_fichier);
$table->addRow(array('<a href="client/bazar/upload/'.$ligne->bfj_fichier.'"> '.$ligne->bfj_description.'</a>', // col 1 : le fichier et sa description
'<a href="'.$lien_supprimer->getURL().'" onclick="javascript:return confirm(\''.BAZ_CONFIRMATION_SUPPRESSION_FICHIER.'\');" >'.BAZ_SUPPRIMER.'</a>'."\n")) ; // col 2 : supprimer
$lien_supprimer->removeQueryString('id_fichier');
}
$table->altRowAttributes(1, array("class" => "ligne_impaire"), array("class" => "ligne_paire"));
$table->updateColAttributes(1, array("align" => "center"));
$html_fichier .= $table->toHTML()."\n".'</td>'."\n".'</tr>'."\n" ;
}
}
$html ='<tr>'."\n".'<td colspan="2">'."\n".'<h4>'.$label.'</h4>'."\n".'</td>'."\n".'</tr>'."\n";
$formtemplate->addElement('html', $html) ;
if ($html_fichier!='') $formtemplate->addElement('html', $html_fichier) ;
$formtemplate->addElement('text', 'texte_fichier'.$nom_bdd, BAZ_FICHIER_DESCRIPTION) ;
$formtemplate->addElement('file', 'fichier'.$nom_bdd, BAZ_FICHIER_JOINT) ;
$formtemplate->addRule('image', BAZ_IMAGE_VALIDE_REQUIS, '', '', 'client') ; //a completer pour checker l'image
$formtemplate->setMaxFileSize($limite1);
//gestion du champs obligatoire
if (($dans_moteur_de_recherche==0) && isset($obligatoire) && ($obligatoire==1)) {
$formtemplate->addRule('texte_fichier'.$nom_bdd, BAZ_FICHIER_LABEL_REQUIS, 'required', '', 'client') ;
$formtemplate->addRule('fichier'.$nom_bdd, BAZ_FICHIER_JOINT_REQUIS, 'required', '', 'client') ;
}
}
 
/** image() - Ajoute un élément de type image au formulaire
*
* @param mixed L'objet QuickForm du formulaire
* @param string numero du champs input du formulaire (pour le différencier d'autres champs du meme type dans ce formulaire)
* @param string label à afficher dans le formulaire
* @param string taille maximum du fichier colonnes de l'élément
* @param string taille des lignes de l'élément
* @param string valeur par défaut du formulaire
* @param string table source pour les valeurs du texte (inutile)
* @param string ce champs est il obligatoire? (required)
* @return void
*/
function image(&$formtemplate, $nom_bdd , $label, $limite1, $limite2, $defaut, $source, $obligatoire, $dans_moteur_de_recherche=0) {
//AJOUTER UNE IMAGE
$html_image= '';
if (isset($GLOBALS['_BAZAR_']["id_fiche"])) {
$requete = 'SELECT bf_url_image FROM bazar_fiche WHERE bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
$resultat = & $GLOBALS['_BAZAR_']['db'] -> query($requete) ;
if (DB::isError ($resultat)) {
die ($GLOBALS['_BAZAR_']['db']->getMessage().$GLOBALS['_BAZAR_']['db']->getDebugInfo()) ;
}
if ($resultat->numRows()>0) {
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
$image=$ligne->bf_url_image;
}
if ($image!=NULL) {
$lien_supprimer=$GLOBALS['_BAZAR_']['url'];
$lien_supprimer->addQueryString('action', $_GET['action']);
$lien_supprimer->addQueryString('id_fiche', $GLOBALS['_BAZAR_']["id_fiche"]);
$lien_supprimer->addQueryString('typeannonce', $_REQUEST['typeannonce']);
$lien_supprimer->addQueryString('image', 1);
$html_image = '<tr>'."\n".
'<td>'."\n".'<img src="client/bazar/upload/'.$image.'" alt="'.BAZ_TEXTE_IMG_ALTERNATIF.'" width="130" height="130" />'."\n".'</td>'."\n".
'<td>'."\n".'<a href="'.$lien_supprimer->getURL().'" onclick="javascript:return confirm(\''.BAZ_CONFIRMATION_SUPPRESSION_IMAGE.'\');" >'.BAZ_SUPPRIMER.'</a><br /><br />'."\n".
'<strong>'.BAZ_POUR_CHANGER_IMAGE.'</strong><br />'."\n".'</td>'."\n".'</tr>'."\n";
}
}
}
$html ='<tr>'."\n".'<td colspan="2">'."\n".'<h4>'.$label.'</h4>'."\n".'</td>'."\n".'</tr>'."\n";
$formtemplate->addElement('html', $html) ;
if ($html_image!='') $formtemplate->addElement('html', $html_image) ;
$formtemplate->addElement('file', 'image', BAZ_IMAGE) ;
//TODO: controler si c'est une image
$formtemplate->setMaxFileSize($limite1);
//gestion du champs obligatoire
if (($dans_moteur_de_recherche==0) && isset($obligatoire) && ($obligatoire==1)) {
$formtemplate->addRule('image', BAZ_IMAGE_VALIDE_REQUIS, 'required', '', 'client') ;
}
}
 
/** wikini() - Ajoute un wikini au formulaire
*
* @param mixed L'objet QuickForm du formulaire
* @param string numero du champs input du formulaire (pour le différencier d'autres champs du meme type dans ce formulaire)
* @param string label à afficher dans le formulaire
* @param string taille maximum du fichier colonnes de l'élément
* @param string taille des lignes de l'élément
* @param string valeur par défaut du formulaire
* @param string table source pour les valeurs du texte (inutile)
* @param string ce champs est il obligatoire? (required)
* @return void
*/
function wikini(&$formtemplate, $nom_bdd , $label, $limite1, $limite2, $defaut, $source, $obligatoire, $dans_moteur_de_recherche=0) {
return;
}
 
/** labelhtml() - Ajoute un élément de type textearea au formulaire
*
* @param mixed L'objet QuickForm du formulaire
* @param string nom de la table dans la base de donnée (pas utilisé)
* @param string label à afficher dans le formulaire
* @param string taille des colonnes de l'élément (pas utilisé)
* @param string taille des lignes de l'élément (pas utilisé)
* @param string valeur par défaut du formulaire (pas utilisé)
* @param string table source pour les valeurs du texte (pas utilisé)
* @param string ce champs est il obligatoire? (required) (pas utilisé)
* @return void
*/
function labelhtml(&$formtemplate, $nom_bdd , $label, $limite1, $limite2, $defaut, $source, $obligatoire, $dans_moteur_de_recherche=0) {
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm/html.php';
$formhtml= new HTML_QuickForm_html('<tr>'."\n".'<td colspan="2" style="text-align:left;">'."\n".$label."\n".'</td>'."\n".'</tr>'."\n");
$formtemplate->addElement($formhtml) ;
}
 
/** carte_google() - Ajoute un élément de carte google au formulaire
*
* @param mixed L'objet QuickForm du formulaire
* @param string l url vers la script google
* @param string label à afficher dans le formulaire
* @param string première restriction de la taille des champs du formulaire
* @param string deuxième restriction de la taille des champs du formulaire
* @param string valeur par défaut du formulaire
* @param string table source pour les valeurs de la liste
* @param string ce champs est il obligatoire? (required)
* @param boolean sommes nous dans le moteur de recherche?
* @return void
*/
function carte_google(&$formtemplate, $url_google_script , $label, $limite1, $limite2, $defaut, $source, $obligatoire, $dans_moteur_de_recherche=0) {
if (is_array ($defaut)) {
$formtemplate->setDefaults(array('latitude' => $defaut['latitude'], 'longitude' => $defaut['longitude']));
}
GEN_stockerFichierScript('googleMapScript', $url_google_script);
$formtemplate->addElement('button', 'chercher_sur_carte', 'Vérifier mon adresse avec la carte', array("onclick" => "showAddress();"));
$formtemplate->addElement('text', 'latitude', 'Latitude', array('id' => 'latitude', 'size' => 6, 'readonly' => 'readonly'));
$formtemplate->addElement('text', 'longitude', 'longitude', array('id' => 'longitude', 'size' => 6, 'readonly' => 'readonly'));
$formtemplate->addElement('html', '<tr><td colspan="2" ><div id="map" style="width: 600px; height: 450px"></div></td></tr>');
include_once BAZ_CHEMIN_APPLI.'bibliotheque/bazar.fonct.google.php';
GEN_stockerCodeScript($script);
}
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: bazar.fonct.formulaire.php,v $
* Revision 1.26 2007-06-04 15:24:31 alexandre_tb
* ajout du type carte_google
*
* Revision 1.25 2007/04/11 08:30:12 neiluj
* remise en état du CVS...
*
* Revision 1.22.2.3 2007/03/16 14:48:32 alexandre_tb
* on peut maintenant saisir une date par défaut
* et 0000-00-00 pour des champs vide
*
* Revision 1.22.2.2 2007/03/07 17:20:19 jp_milcent
* Ajout du nettoyage systématique des URLs.
*
* Revision 1.22.2.1 2007/01/17 16:01:37 alexandre_tb
* les dates ne s'affichent pas si elles sont vides.
* les champs dates propose 4 années avant l'année actuelle
*
* Revision 1.22 2006/06/02 09:29:07 florian
* debut d'integration de wikini
*
* Revision 1.21 2006/05/19 13:54:11 florian
* stabilisation du moteur de recherche, corrections bugs, lien recherche avancee
*
* Revision 1.20 2006/04/28 12:46:14 florian
* integration des liens vers annuaire
*
* Revision 1.19 2006/03/02 20:36:52 florian
* les entrees du formulaire de saisir ne sont plus dans les constantes mias dans des tables qui gerent le multilinguisme.
*
* Revision 1.18 2006/03/01 16:01:46 florian
* correction bug déclaration variable $html
*
* Revision 1.17 2006/01/30 10:27:03 florian
* - ajout des entrées de formulaire fichier, url, et image
* - correction bug d'affichage du mode de saisie
*
* Revision 1.16 2006/01/24 14:11:44 alexandre_tb
* ajout du paramètre emptyOptionValue dans les champs de date
*
* Revision 1.15 2006/01/23 16:57:03 alexandre_tb
* correction d'un notice
*
* Revision 1.14 2006/01/19 17:42:11 florian
* ajout des cases à cocher pré-cochées pour les maj
*
* Revision 1.13 2006/01/13 14:12:51 florian
* utilisation des temlates dans la table bazar_nature
*
* Revision 1.12 2006/01/05 16:28:24 alexandre_tb
* prise en chage des checkbox, reste la mise à jour à gérer
*
* Revision 1.11 2006/01/02 13:24:07 alexandre_tb
* correction de bug d'un mauvais retour en erreur
*
* Revision 1.10 2005/12/01 16:05:41 florian
* changement des chemins pour appli Pear
*
* Revision 1.9 2005/11/24 16:17:13 florian
* corrections bugs, ajout des cases à cocher
*
* Revision 1.8 2005/11/18 16:03:23 florian
* correction bug html entites
*
* Revision 1.7 2005/11/07 17:51:06 florian
* correction bug liste
*
* Revision 1.6 2005/11/07 17:30:36 florian
* ajout controle sur les listes pour la saisie
*
* Revision 1.5 2005/11/07 17:05:45 florian
* amélioration validation conditions de saisie, ajout des règles spécifiques de saisie des formulaires
*
* Revision 1.4 2005/10/25 13:53:02 alexandre_tb
* ajout d'un filtre dans les formulaire texte et textelong
*
* Revision 1.3 2005/07/21 19:03:12 florian
* nouveautés bazar: templates fiches, correction de bugs, ...
*
* Revision 1.1.1.1 2005/02/17 18:05:11 florian
* Import initial de Bazar
*
* Revision 1.1.1.1 2005/02/17 11:09:50 florian
* Import initial
*
* Revision 1.1.1.1 2005/02/16 18:06:35 florian
* import de la nouvelle version
*
* Revision 1.4 2004/07/08 11:17:59 alex
* ajout de commentaires et d'entete
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>
/trunk/bibliotheque/bazar.abonnement.inc.php
1,68 → 1,71
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id$
/**
* Fonctions d'abonnement a afficher dans la fiche du bottin
*
*
*@package inscription
//Auteur original :
*@author Florian Schmitt <florian@ecole-et-nature.org>
//Autres auteurs :
*
*@copyright Outils-Reseaux 2006-2010
*@version $Revision$ $Date$
*@version $Revision$ $Date$
// +------------------------------------------------------------------------------------------------------+
*/
 
// +------------------------------------------------------------------------------------------------------+
// | ENTETE du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
 
include_once PAP_CHEMIN_RACINE.'client/bazar/configuration/baz_config.inc.php' ;
include_once PAP_CHEMIN_RACINE.'client/bazar/bibliotheque/bazar.fonct.php' ;
 
// +------------------------------------------------------------------------------------------------------+
// | LISTE de FONCTIONS |
// +------------------------------------------------------------------------------------------------------+
$GLOBALS['id_user']=$id;
if (isset($_GET[BAZ_VARIABLE_ACTION]) && $_GET[BAZ_VARIABLE_ACTION]==BAZ_VOIR_FLUX_RSS) {
header('Content-type: text/xml; charset=ISO-8859-1');
include(PAP_CHEMIN_RACINE.'client/bazar/bazarRSS.php');exit(0);break;
} else {
$abonnement = baz_s_inscrire();
}
 
//-- Fin du code source ------------------------------------------------------------
/*
* $Log$
* Revision 1.2 2006-10-05 08:53:50 florian
* amelioration moteur de recherche, correction de bugs
*
* Revision 1.1 2006/04/28 12:46:14 florian
* integration des liens vers annuaire
*
*
*/
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id$
/**
* Fonctions d'abonnement a afficher dans la fiche du bottin
*
*
*@package inscription
//Auteur original :
*@author Florian Schmitt <florian@ecole-et-nature.org>
//Autres auteurs :
*
*@copyright Outils-Reseaux 2006-2010
*@version $Revision$ $Date$
*@version $Revision$ $Date$
// +------------------------------------------------------------------------------------------------------+
*/
 
// +------------------------------------------------------------------------------------------------------+
// | ENTETE du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
 
include_once PAP_CHEMIN_RACINE.'client/bazar/configuration/baz_config.inc.php' ;
include_once PAP_CHEMIN_RACINE.'client/bazar/bibliotheque/bazar.fonct.php' ;
 
// +------------------------------------------------------------------------------------------------------+
// | LISTE de FONCTIONS |
// +------------------------------------------------------------------------------------------------------+
$GLOBALS['id_user']=$id;
if (isset($_GET[BAZ_VARIABLE_ACTION]) && $_GET[BAZ_VARIABLE_ACTION]==BAZ_VOIR_FLUX_RSS) {
header('Content-type: text/xml; charset=ISO-8859-1');
include(PAP_CHEMIN_RACINE.'client/bazar/bazarRSS.php');exit(0);break;
} else {
$abonnement = baz_s_inscrire();
}
 
//-- Fin du code source ------------------------------------------------------------
/*
* $Log$
* Revision 1.3 2008-09-17 14:08:45 alexandre_tb
* merge depuis aha
*
* Revision 1.2 2006-10-05 08:53:50 florian
* amelioration moteur de recherche, correction de bugs
*
* Revision 1.1 2006/04/28 12:46:14 florian
* integration des liens vers annuaire
*
*
*/
?>
/trunk/bibliotheque/bazar.fonct.rss.php
706,8 → 706,6
if ($nbitem!='') {$requete .= ' LIMIT 0,'.$nbitem;}
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete . ' -- ' . __FILE__ . ':' . __LINE__) ;
 
//mail('aurelien@tela-botanica.org','requete',$requete);
 
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
789,7 → 787,7
$xml .= XML_Util::createStartElement ('description');
$xml .= "\r\n ";
if ($_GET[BAZ_VARIABLE_ACTION] != BAZ_VOIR_TOUTES_ANNONCES) {
$xml .= XML_Util::createCDataSection(transformerTxtPourRss(subtext($ligne['bf_description'])));
$xml .= XML_Util::createCDataSection(transformerTxtPourRss($ligne['bf_description']));
}
$xml .= "\r\n ";
$xml .= XML_Util::createEndElement ('description');
824,6 → 822,8
$xml .= XML_Util::createEndElement ('channel');
$xml .= "\r\n ";
$xml .= XML_Util::createEndElement('rss') ;
// Truc copiédepuis l'applette syndication de Papyrus qui semble empêcher les flux de foirer dans Foudroiseau
$xml = supprimerXmlDangereux($xml);
 
// Nettoyage de l'url
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
832,7 → 832,36
return $xml;
}
 
function supprimerXmlDangereux($xml)
{
$ret = "";
$encours;
if (empty($xml))
{
return $ret;
}
 
$lg = strlen($xml);
for ($i=0; $i < $lg; $i++)
{
$encours = ord($xml{$i});
if (($encours == 0x9) ||
($encours == 0xA) ||
($encours == 0xD) ||
(($encours >= 0x20) && ($encours <= 0xD7FF)) ||
(($encours >= 0xE000) && ($encours <= 0xFFFD)) ||
(($encours >= 0x10000) && ($encours <= 0x10FFFF)))
{
$ret .= chr($encours);
}
else
{
$ret .= " ";
}
}
return $ret;
}
 
/** baz_liste() Formate la liste de toutes les annonces actuelles
*
* @return string le code HTML a afficher
875,7 → 904,7
//Traduction de champs requis
$formtemplate->setRequiredNote(BAZ_CHAMPS_REQUIS) ;
$formtemplate->setJsWarnings(BAZ_ERREUR_SAISIE,BAZ_VEUILLEZ_CORRIGER);
GEN_stockerFichierScript('jquery', 'http://code.jquery.com/jquery-latest.js');
//GEN_stockerFichierScript('jquery', 'http://code.jquery.com/jquery-latest.js');
GEN_stockerFichierScript('jquery_date_picker', 'api/js/jquery/ui.datepicker.js');
GEN_stockerFichierScript('jquery_date_picker_fr', 'api/js/jquery/ui.datepicker-fr.js');
GEN_stockerStyleExterne( 'jquery_date_picker_style', 'api/js/jquery/ui.datepicker.css');
1412,6 → 1441,7
'\x1D' => '', // GS : Group Separator (séparateur de groupe)
'\x1E' => '', // RS : Record Separator (séparateur d'enregistrement)
'\x1F' => '', // US : Unit Separator (séparateur d'unité)
'\x92' => '', // Apostrophes de Windows qui puduk
'\x20' => ' '); // SP : Espace (Space en anglais)
$txtEnUtf8 = strtr($txtEnUtf8, $ascii_remplacements);
return $txtEnUtf8;
1690,4 → 1720,4
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>
?>
/trunk/bibliotheque/bazarTemplate.class.php
1,102 → 1,87
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | General Public License for more details. |
// | |
// | You should have received a copy of the GNU General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
 
// CVS : $Id: bazarTemplate.class.php,v 1.7 2008-10-29 15:44:02 alexandre_tb Exp $
 
/**
* Application projet
*
* La classe d acces aux templates du bazar
*
*@package bazar
//Auteur original :
*@author Alexandre Granier <alexandre@tela-botanica.org>
//Autres auteurs :
*@author Aucun
*@copyright Tela-Botanica 2000-2004
*@version $Revision: 1.7 $
// +------------------------------------------------------------------------------------------------------+
*/
 
// +------------------------------------------------------------------------------------------------------+
// | ENTETE du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
 
include_once PAP_CHEMIN_API_PEAR.'PEAR.php' ;
 
// +------------------------------------------------------------------------------------------------------+
// | CONSTANTE DES TEMPLATES |
// +------------------------------------------------------------------------------------------------------+
 
define ('BAZ_TEMPLATE_CONSULTER', 1); // Squelette de l onglet "consulter"
define ('BAZ_TEMPLATE_LISTE_DES_FICHES', 2); // Modele de la liste des fiches
 
define ('BAZ_TEMPLATE_MAIL_NOUVELLE_FICHE_SUJET', 3); // Modele du mail pour prevenir les admins d une nouvelle fiche (sujet)
define ('BAZ_TEMPLATE_MAIL_NOUVELLE_FICHE_CORPS', 4); // Modele du mail pour prevenir les admins d une nouvelle fiche (corps)
 
define ('BAZ_TEMPLATE_MESSAGE_LOGIN', 5); // Modele du message lorsque l utilisateur n est pas logue
 
define ('BAZ_TEMPLATE_ACCUEIL_CARTE_GOOGLE', 6); // Modele de la page d accueil de l appli bazar.carte_google.php
define ('BAZ_TEMPLATE_FORMULAIRE_ACCUEIL', 7); // Modele, de la page saisie formulaire ou l'on choisit le type de fiche a saisir
 
define ('BAZ_TEMPLATE_FORMULAIRE', 8); // Modele du formulaire (different de celui ci-dessus)
 
define ('BAZ_TEMPLATE_MAIL_MODIFIER_FICHE_SUJET', 9); // Modele du mail pour prevenir les admins d une modification de fiche (sujet)
define ('BAZ_TEMPLATE_MAIL_MODIFIER_FICHE_CORPS', 10); // Modele du mail pour prevenir les admins d une modification de fiche (corps)
 
class bazarTemplate extends PEAR {
 
 
var $_db ;
function bazarTemplate(&$objetDB) {
$this->_db = $objetDB ;
}
function getTemplate ($id_template, $lang='fr-FR', $categorie_nature = 'toutes') {
$requete = 'select bt_template from bazar_template where bt_id_template='.$id_template.
' and bt_id_i18n like "'.$lang.'%" ' ;
if($categorie_nature != 'toutes') {
$requete .= ' and bt_categorie_nature='.$categorie_nature ;
}
else
{
//si toutes les catégories natures sont affichées, on affiche par défaut le template du numéro 1
$requete .= ' and bt_categorie_nature=1' ;
}
$resultat = $this->_db->query($requete) ;
if (DB::isError($resultat)) {
return $this->raiseError ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
}
if ($resultat->numRows() == 0) {
return $this->raiseError ('Aucun template avec l\'identifiant: '.$id_template.
' et la langue: '.$lang.'<br />'.$requete) ;
}
$ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ;
 
return $ligne->bt_template ;
}
}
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | General Public License for more details. |
// | |
// | You should have received a copy of the GNU General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
 
// CVS : $Id: bazarTemplate.class.php,v 1.7 2008-10-29 15:44:02 alexandre_tb Exp $
 
/**
* Application projet
*
* La classe d acces aux templates du bazar
*
*@package bazar
//Auteur original :
*@author Alexandre Granier <alexandre@tela-botanica.org>
//Autres auteurs :
*@author Aucun
*@copyright Tela-Botanica 2000-2004
*@version $Revision: 1.7 $
// +------------------------------------------------------------------------------------------------------+
*/
 
// +------------------------------------------------------------------------------------------------------+
// | ENTETE du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
 
include_once PAP_CHEMIN_API_PEAR.'PEAR.php' ;
 
// +------------------------------------------------------------------------------------------------------+
// | CONSTANTE DES TEMPLATES |
// +------------------------------------------------------------------------------------------------------+
 
define ('BAZ_TEMPLATE_CONSULTER', 1); // Squelette de l onglet "consulter"
define ('BAZ_TEMPLATE_LISTE_DES_FICHES', 2); // Modele de la liste des fiches
 
define ('BAZ_TEMPLATE_MAIL_NOUVELLE_FICHE_SUJET', 3); // Modele du mail pour prevenir les admins d une nouvelle fiche (sujet)
define ('BAZ_TEMPLATE_MAIL_NOUVELLE_FICHE_CORPS', 4); // Modele du mail pour prevenir les admins d une nouvelle fiche (corps)
 
define ('BAZ_TEMPLATE_MESSAGE_LOGIN', 5); // Modele du message lorsque l utilisateur n est pas logue
 
define ('BAZ_TEMPLATE_ACCUEIL_CARTE_GOOGLE', 6); // Modele de la page d accueil de l appli bazar.carte_google.php
define ('BAZ_TEMPLATE_FORMULAIRE_ACCUEIL', 7); // Modele, de la page saisie formulaire ou l'on choisit le type de fiche a saisir
 
define ('BAZ_TEMPLATE_FORMULAIRE', 8); // Modele du formulaire (different de celui ci-dessus)
 
define ('BAZ_TEMPLATE_MAIL_MODIFIER_FICHE_SUJET', 9); // Modele du mail pour prevenir les admins d une modification de fiche (sujet)
define ('BAZ_TEMPLATE_MAIL_MODIFIER_FICHE_CORPS', 10); // Modele du mail pour prevenir les admins d une modification de fiche (corps)
 
class bazarTemplate extends PEAR {
 
 
var $_db ;
function bazarTemplate(&$objetDB) {
$this->_db = $objetDB ;
}
function getTemplate ($id_template, $lang='fr-FR', $categorie_nature = 'toutes') {
$requete = 'select bt_template from bazar_template where bt_id_template='.$id_template.
' and bt_id_i18n like "'.$lang.'%" ' ;
$resultat = $this->_db->query($requete) ;
if (DB::isError($resultat)) return $this->raiseError ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
if ($resultat->numRows() == 0) return $this->raiseError ('Aucun template avec l\'identifiant: '.$id_template.
' et la langue: '.$lang.'<br />'.$requete) ;
$ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ;
 
return $ligne->bt_template ;
}
}
?>