Subversion Repositories Applications.bazar

Compare Revisions

Ignore whitespace Rev 6 → Rev 7

/trunk/bibliotheque/bazar.fonct.php
19,7 → 19,7
// | 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.3 2005-07-21 19:03:12 florian Exp $
// CVS : $Id: bazar.fonct.php,v 1.4 2005-09-28 16:06:03 florian Exp $
/**
*
* Fonctions du module bazar
30,7 → 30,7
*@author Florian Schmitt <florian@ecole-et-nature.org>
//Autres auteurs :
*@copyright Tela-Botanica 2000-2004
*@version $Revision: 1.3 $ $Date: 2005-07-21 19:03:12 $
*@version $Revision: 1.4 $ $Date: 2005-09-28 16:06:03 $
// +------------------------------------------------------------------------------------------------------+
*/
 
82,7 → 82,7
// 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
$res= '<h2>'.BAZ_ANNONCES_A_ADMINISTRER.'</h2>';
$requete = 'SELECT * FROM bazar_fiche, bazar_nature WHERE bf_statut_fiche=0 AND bn_id_nature=bf_ce_nature ORDER BY bf_date_maj_fiche DESC' ;
$requete = 'SELECT * FROM bazar_fiche, bazar_nature WHERE bf_statut_fiche=0 AND bn_id_nature=bf_ce_nature AND bn_ce_id_menu='.$GLOBALS['_GEN_commun']['info_menu']->gm_id_menu.' 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()) ;
158,7 → 158,7
$res= '<h2>'.BAZ_VOS_ANNONCES.'</h2>'."\n";
// requête pour voir si l'utilisateur a des fiches à son nom, classées 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 ORDER BY bf_date_maj_fiche DESC,bf_ce_nature ASC';
' AND bn_id_nature=bf_ce_nature AND bn_ce_id_menu='.$GLOBALS['_GEN_commun']['info_menu']->gm_id_menu.' 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()) ;
496,7 → 496,7
$res = '';
//requete pour obtenir le nom et la description des types d'annonce
$requete = "SELECT bn_id_nature, bn_label_nature, bn_description, bn_condition FROM bazar_nature ORDER BY bn_label_nature ASC";
$requete = "SELECT bn_id_nature, bn_label_nature, bn_description, bn_condition FROM bazar_nature WHERE bn_ce_id_menu=".$_REQUEST['menu']." ORDER BY bn_label_nature ASC";
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
506,19 → 506,22
while ($ligne = $resultat->fetchRow (DB_FETCHMODE_ASSOC)) {
$droitspers=niveau_droit($ligne["bn_id_nature"],$GLOBALS["id_user"]);
if (($droitspers=='redacteur') or ($droitspers=='administrateur') or ($droitspers=='superadministrateur')) {
$radio[] = &HTML_QuickForm::createElement('radio', 'typeannonce', '', '<b>'.$ligne['bn_label_nature'].
':</b><br />'.$ligne['bn_description'].'<br />', $ligne['bn_label_nature'], array("id" => "select"));
$formtemplate->addElement('radio', 'typeannonce', '', '<strong>'.$ligne['bn_label_nature'].
':</strong><br />'.$ligne['bn_description'], $ligne['bn_label_nature'], array("id" => 'select'.$ligne['bn_id_nature'], "style" => 'float:left;'));
}
}
$formtemplate->addGroup($radio, null, null, '');
$squelette =& $formtemplate->defaultRenderer();
$squelette->setFormTemplate("\n".'<div id="choix"><form {attributes}>'."\n".'{content}'."\n".'</form></div>'."\n");
$squelette->setElementTemplate( '<div style="clear:both;">'."\n".'{element}'."\n".'</div>'."\n");
//Mettre les annonces en choix par défaut
$formtemplate->setdefaults(array('typeannonce'=>'Annonces'));
//Bouton de validation du formulaire
$bouton[] = &HTML_QuickForm::createElement('submit', 'valider', BAZ_VALIDER);
$formtemplate->addGroup($bouton, null, null, '');
$formtemplate->addGroup($bouton, null, null, '&nbsp;');
//Affichage à l'écran
$res.= $formtemplate->toHTML() ;
651,7 → 654,7
$res.= '<a href='.$lien_passer_superadmin->getURL().'>'.BAZ_PASSER_SUPERADMINISTRATEUR.'</a><br />'."\n";
//on cherche les différentes rubriques d'annonces
$requete = 'SELECT bn_id_nature, bn_label_nature FROM bazar_nature';
$requete = 'SELECT bn_id_nature, bn_label_nature FROM bazar_nature WHERE bn_ce_id_menu='.$GLOBALS['_GEN_commun']['info_menu']->gm_id_menu;
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
1044,7 → 1047,7
//requete pour obtenir l'id et le label des types d'annonces
$requete = 'SELECT bn_id_nature, bn_label_nature '.
'FROM bazar_nature ';
'FROM bazar_nature WHERE bn_ce_id_menu='.$GLOBALS['_GEN_commun']['info_menu']->gm_id_menu;
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
1146,8 → 1149,8
//requete pour obtenir l'id et le label des types d'annonces
$requete = 'SELECT bn_label_nature '.
'FROM bazar_nature '.
'ORDER BY bn_label_nature ASC';
'FROM bazar_nature WHERE bn_ce_id_menu='.$GLOBALS['_GEN_commun']['info_menu']->gm_id_menu.
' ORDER BY bn_label_nature ASC';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
1326,6 → 1329,9
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
* 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
*
/trunk/bibliotheque/bazar.fonct.rss.php
44,28 → 44,35
* @return string HTML
*/
function baz_voir_fiche($danslappli, $idfiche='') {
$res = '';
if (isset($_GET['id_fiche'])) $GLOBALS['_BAZAR_']['id_fiche']=$_GET['id_fiche'];
if ($idfiche!='') $GLOBALS['_BAZAR_']['id_fiche']=$idfiche;
//on cherche le type d'annonce
$requete = 'SELECT bn_label_nature FROM bazar_fiche, bazar_nature WHERE bn_id_nature=bf_ce_nature AND bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
//on met à jour le nb de visites pour la fiche
$requete = 'UPDATE bazar_fiche SET bf_nb_consultations=bf_nb_consultations+1 WHERE bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
//on cherche le type d'annonce, l'annonceur et les stats
$requete = 'SELECT bn_label_nature, bn_commentaire, bn_appropriation, bf_ce_utilisateur,bf_nb_consultations FROM bazar_fiche, bazar_nature WHERE bn_id_nature=bf_ce_nature AND bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
$GLOBALS['_BAZAR_']['typeannonce']=$ligne['bn_label_nature'];
$GLOBALS['_BAZAR_']['commentaire']=$ligne['bn_commentaire'];
$GLOBALS['_BAZAR_']['appropriation']=$ligne['bn_appropriation'];
$GLOBALS['_BAZAR_']['annonceur']=$ligne['bf_ce_utilisateur'];
$GLOBALS['_BAZAR_']['nb_consultations']=$ligne['bf_nb_consultations'];
}
$res = '<div id="BAZ_cadre_fiche">'."\n";
$res .= '<div id="BAZ_cadre_fiche_haut">'."\n";
$res = '<div class="BAZ_cadre_fiche">'."\n";
$res .= '<div class="BAZ_cadre_fiche_haut">'."\n";
$res .= '&nbsp;</div>'."\n";
$res .= '<div id="BAZ_cadre_fiche_corps">'."\n";
$res .= '<div class="BAZ_cadre_fiche_corps">'."\n";
//si le template existe, on génère le template
if ((file_exists(BAZ_CHEMIN_APPLI.'templates/'.$GLOBALS['_BAZAR_']['typeannonce'].'-fiche.php'))) {
include_once(BAZ_CHEMIN_APPLI.'templates/'.$GLOBALS['_BAZAR_']['typeannonce'].'-fiche.php');
$res .=genere_fiche($GLOBALS['_BAZAR_']['id_fiche'],$danslappli);
$res .=genere_fiche($GLOBALS['_BAZAR_']['id_fiche']);
}
//on affiche ligne par ligne sinon
else {
76,10 → 83,17
}
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC) ;
if (isset($ligne['bf_url_image'])) $res .= '<img src="'.'http://'.$_SERVER['HTTP_HOST'].'/client/bazar/images/'.$ligne['bf_url_image'].'" border=0 alt="'.BAZ_TEXTE_IMG_ALTERNATIF.'" align="left" style="padding:0 10px 5px 0;" />'."\n";
$res .= '<h2>'.$ligne['bf_titre'].'</h2>'."\n" ;
if (isset($ligne['bf_description'])) $res .= '<br />'.$ligne['bf_description'].'<br /><br />'."\n";
if (isset($ligne['bf_url_image'])) {
$res .= '<div id="fiche_image">'."\n";
$res .= '<img src="'.'http://'.$_SERVER['HTTP_HOST'].'/client/bazar/images/'.$ligne['bf_url_image'].'" border=0 alt="'.BAZ_TEXTE_IMG_ALTERNATIF.'" />'."\n";
$res .= '</div>'."\n";
$res .= '<div id="fiche_titre_image">'.$ligne['bf_titre'];
}
else {
$res .= '<div id="fiche_titre">'.$ligne['bf_titre'];
}
$res .= '</div>'."\n";
$res .= '<div id="BAZ_description">'.$ligne['bf_description'].'</div>'."\n";
$tableau=baz_valeurs_template($GLOBALS['_BAZAR_']['typeannonce'].'.tpl');
for ($i=0; $i<count($tableau); $i++) {
if (isset($ligne[$tableau[$i]['nom_bdd']])) {
92,67 → 106,142
die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
}
while ($tab = $resultat->fetchRow()) {
$val=encoderChaine($tab[1]);
$val=$tab[1];
}
}
else {
$val=encoderChaine($ligne[$tableau[$i]['nom_bdd']]);
$val=$ligne[$tableau[$i]['nom_bdd']];
}
if (($tableau[$i]['nom_bdd']!='bf_titre')and($tableau[$i]['nom_bdd']!='bf_description')) {
if ($val!='') $res .= '<br /><strong>'.constant($tableau[$i]['label']).':</strong> '.$val.'<br />'."\n";
if ($val!='') {
$res .= '<span class="rubrique">'.constant($tableau[$i]['label']).':</span>'."\n";
$res .= '<span class="description"> '.$val.'</span>'."\n".'<br />'."\n";
}
}
}
}
//afficher les liens pour l'annonce
$requete = 'SELECT 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 ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
//afficher les liens pour l'annonce
$requete = 'SELECT 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 ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
if ($resultat->numRows()>0) {
$res .= '<span class="rubrique">'.BAZ_LIEN_INTERNET.':</span>'."\n";
$res .= '<span class="description">'."\n";
$res .= '<ul>'."\n";
while ($ligne1 = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
$res .= '<li><a href="'.$ligne1['bu_url'].'" target="_blank">'.$ligne1['bu_descriptif_url'].'</a></li>'."\n";
}
if ($resultat->numRows()>0) {
$res .= '<br /><strong>'.BAZ_LIEN_INTERNET.':</strong>'."\n";
$res .= '<ul>'."\n";
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
$res .= '<li><a href="'.$ligne['bu_url'].'" target="_blank">'.$ligne['bu_descriptif_url'].'</a></li>'."\n";
$res .= '</ul></span>'."\n";
}
//afficher les fichiers pour l'annonce
$requete = 'SELECT bfj_description, bfj_fichier FROM bazar_fichier_joint WHERE bfj_ce_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
if ($resultat->numRows()>0) {
$res .= '<span class="rubrique">'.BAZ_LISTE_FICHIERS_JOINTS.':</span>'."\n";
$res .= '<span class="description">'."\n";
$res .= '<ul>'."\n";
while ($ligne2 = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
$res .= '<li><a href="http://'.$_SERVER['HTTP_HOST'].'/client/bazar/upload/'.$ligne2['bfj_fichier'].'">'.$ligne2['bfj_description'].'</a></li>'."\n";
}
$res .= '</ul></span>'."\n";
}
$res .= '<div id="bulle_haut">&nbsp;</div>'."\n";
$res .= '<div id="bulle_corps">'."\n";
//affichage du rédacteur de la fiche
$requete = 'SELECT '.BAZ_CHAMPS_NOM.', '.BAZ_CHAMPS_PRENOM.', '.BAZ_CHAMPS_EMAIL.' FROM '.BAZ_ANNUAIRE.' WHERE '.BAZ_CHAMPS_ID.'='.$GLOBALS['_BAZAR_']['annonceur'];
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
while ($redacteur = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
$res .= BAZ_FICHE_ECRITE.'<a href="mailto:'.$redacteur[BAZ_CHAMPS_EMAIL].'">'.$redacteur[BAZ_CHAMPS_PRENOM].' '.$redacteur[BAZ_CHAMPS_NOM].'</a><br />'."\n";
}
$res .= BAZ_NB_VUS.'<strong>'.$GLOBALS['_BAZAR_']['nb_consultations'].'</strong>'.BAZ_FOIS.'<br />'."\n";
$res .= '</div>'."\n";
$res .= '<div id="bulle_bas">&nbsp;</div>'."\n";
$res .= '<div id="BAZ_bas_page">';
//informations complémentaires (id fiche, état publication,... )
if ($danslappli==1) {
$res .= '<span class="rubrique">'.BAZ_NUM_FICHE.':</span> '.$GLOBALS['_BAZAR_']['id_fiche'].'<br />'."\n";
$res .= '<span class="rubrique">'.BAZ_NATURE.':</span> '.$GLOBALS['_BAZAR_']['typeannonce'].'<br />'."\n";
if ($ligne['bf_statut_fiche']==1) {
$res .= '<span class="rubrique">'.BAZ_PUBLIEE.':</span> '.BAZ_OUI.'<br />'."\n";
}
else {
$res .= '<span class="rubrique">'.BAZ_PUBLIEE.':</span> '.BAZ_NON.'<br />'."\n";
}
$res .= '<span class="rubrique">'.BAZ_DATE_CREATION.':</span> '.strftime('%d.%m.%Y &agrave; %H:%M',strtotime($ligne['bf_date_creation_fiche'])).'<br />'."\n";
$res .= '<span class="rubrique">'.BAZ_DATE_MAJ.':</span> '.strftime('%d.%m.%Y &agrave; %H:%M',strtotime($ligne['bf_date_maj_fiche']));
//pour les identifiés seulement, administrateurs de la rubrique ou superadmins
if ($GLOBALS['AUTH']->getAuth()) {
$est_admin=0;
$requete='SELECT bn_id_nature FROM bazar_nature WHERE bn_label_nature="'.$GLOBALS['_BAZAR_']['typeannonce'].'"';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
$res .= '</ul>'."\n";
$result = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
if ((niveau_droit($result['bn_id_nature'],$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID)))=='administrateur') {
$est_admin=1;
}
if (($est_admin)or(niveau_droit($id_nature_offre='0',$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID))=='superadministrateur')or($GLOBALS['_BAZAR_']['annonceur']==$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID))) {
$lien_modifier=$GLOBALS['_BAZAR_']['url'];
$lien_modifier->addQueryString('action', BAZ_ACTION_MODIFIER);
$lien_modifier->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
$lien_modifier->addQueryString('typeannonce', $GLOBALS['_BAZAR_']['typeannonce']);
$res .= '&nbsp;<a href="'.$lien_modifier->getURL().'">'.BAZ_MODIFIER_LA_FICHE.'</a>'."\n";
}
}
//afficher les fichiers pour l'annonce
$requete = 'SELECT bfj_description, bfj_fichier FROM bazar_fichier_joint WHERE bfj_ce_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
}
$res .= '</div>'."\n";
$res .= '</div>'."\n";
$res .= '<div class="BAZ_cadre_fiche_bas">&nbsp;</div>'."\n";
$res .= '</div>'."\n";
//on ajoute les commentaires, s'il le faut
if ($GLOBALS['_BAZAR_']['commentaire']==1) {
$res .= '<div class="BAZ_cadre_fiche">'."\n";
$res .= '<div class="BAZ_cadre_fiche_haut">&nbsp;</div>'."\n";
$res .= '<div class="BAZ_cadre_fiche_corps">'."\n";
$res .= '<h3>'.BAZ_LES_COMMENTAIRES.'</h3>'."\n";
$requete = 'SELECT * FROM bazar_commentaires WHERE bc_ce_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'].' ORDER BY bc_date ASC';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
if (DB::isError ($resultat)) {
die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
}
if ($resultat->numRows()>0) {
$res .= '<br /><strong>'.BAZ_LISTE_FICHIERS_JOINTS.':</strong>'."\n";
$res .= '<ul>'."\n";
$res .= 'Il y a '.$resultat->numRows();
if ($resultat->numRows()==1) $res .= 'commentaire : '.'<br />'."\n";
else $res .= 'commentaires : '.'<br />'."\n";
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
$res .= '<li><a href="http://'.$_SERVER['HTTP_HOST'].'/client/bazar/upload/'.$ligne['bfj_fichier'].'">'.$ligne['bfj_description'].'</a></li>'."\n";
$res .= 'essai'."\n";
}
$res .= '</ul>'."\n";
}
else $res .= BAZ_PAS_DE_COMMENTAIRES.'<br />'."\n";
$res .= '</div>'."\n";
$res .= '<div class="BAZ_cadre_fiche_bas">&nbsp;</div>'."\n";
$res .= '</div>'."\n";
}
//on ajoute les appropriations, s'il le faut
if ($GLOBALS['_BAZAR_']['appropriation']==1) {
$res .= '<div class="BAZ_cadre_fiche">'."\n";
$res .= '<div class="BAZ_cadre_fiche_haut">&nbsp;</div>'."\n";
$res .= '<div class="BAZ_cadre_fiche_corps">'."\n";
//informations complémentaires (id fiche, état publication,... )
if ($danslappli==1) {
$res .= '<br /><br /><strong>'.BAZ_NUM_FICHE.':</strong> '.$GLOBALS['_BAZAR_']['id_fiche'];
$res .= '<br /><strong>'.BAZ_NATURE.':</strong> '.$GLOBALS['_BAZAR_']['typeannonce'];
if ($ligne['bf_statut_fiche']==1) {
$res .= '<br /><strong>'.BAZ_PUBLIEE.':</strong> '.BAZ_OUI;
}
else {
$res .= '<br /><strong>'.BAZ_PUBLIEE.':</strong> '.BAZ_NON;
}
$res .= '<br /><strong>'.BAZ_DATE_CREATION.':</strong> '.$ligne['bf_date_creation_fiche'];
$res .= '<br /><strong>'.BAZ_DATE_MAJ.':</strong> '.$ligne['bf_date_maj_fiche'];
$res .='<ul><li><a href="Javascript:history.go(-1)">'.BAZ_RETOUR.'</a></li></ul>'."\n";
}
$res .= '</div>'."\n";
$res .= '<div class="BAZ_cadre_fiche_bas">&nbsp;</div>'."\n";
$res .= '</div>'."\n";
}
$res .= '</div>'."\n";
$res .= '<div id="BAZ_cadre_fiche_bas">'."\n";
$res .= '&nbsp;</div>'."\n";
$res .= '</div>'."\n";
return $res ;
}