0 && $allow_avis==0) { $log_ok=1; $allow_avis=1; $allow_avis_ajout=false ; } // pour template des avis require_once($base_path.'/includes/templates/avis.tpl.php'); print $popup_header; if ($opac_avis_allow && !$allow_avis) die($popup_footer); print $avis_tpl_header ; switch($todo) { case 'save': if (!$allow_avis_ajout || !$noticeid) die(); if (!$note) $note="NULL"; $masque="@<[\/\!]*?[^<>]*?>@si"; $commentaire = preg_replace($masque,'',$commentaire); if($charset != "utf-8") $commentaire=cp1252Toiso88591($commentaire); $sql="insert into avis (num_empr,num_notice,note,sujet,commentaire) values ('$id_empr','$noticeid','$note','$sujet','$commentaire')"; if (mysql_query($sql, $dbh)) { print $avis_tpl_post_add; } else { print $avis_tpl_post_add_pb; } break; case 'add' : if (!$allow_avis_ajout) die(); //ajout d'un avis echo $avis_tpl_form; break; default: case 'liste' : if ($log_ok && $allow_avis && $allow_avis_ajout) echo "

".$msg[avis_lien_ajout]."

"; //affichage de la liste des avis //moyenne des notes $sql="select avg(note) as m from avis where valide=1 and num_notice='".$noticeid."' group by num_notice"; $r = mysql_query($sql, $dbh); $loc = mysql_fetch_object($r); $moyenne=number_format($loc->m,1, ',', ''); $c_notice = new notice_affichage($noticeid,""); $etoiles_moyenne = $c_notice->stars(); //liste des témoignages $requete="select note,sujet,commentaire,DATE_FORMAT(dateajout,'".$msg['format_date']."') as ladate,empr_login,empr_nom, empr_prenom from avis left join empr on id_empr=num_empr where valide=1 and num_notice='".$noticeid."' order by dateajout desc"; $r = mysql_query($requete, $dbh); if (mysql_numrows($r)){ echo "
".$msg['avis_titre_tous'].": ".$msg['avis_note'].": $moyenne
$etoiles_moyenne
 
"; $cpt_star = 4; while ($loc = mysql_fetch_object($r)) { $etoiles=""; for ($i = 1; $i <= $loc->note; $i++) { $etoiles.=""; } for ( $j = round($loc->note);$j <= $cpt_star ; $j++) { $etoiles .= ""; } echo "
$loc->sujet, ".$loc->ladate ; if ($opac_avis_show_writer==1 && $loc->empr_nom) echo " ".$msg['avis_de']." $loc->empr_prenom $loc->empr_nom "; if ($opac_avis_show_writer==2 && $loc->empr_login) echo " ".$msg['avis_de']." $loc->empr_login "; echo "
$etoiles
"; if($charset != "utf-8") $loc->commentaire=cp1252Toiso88591($loc->commentaire); echo "
".do_bbcode($loc->commentaire)."
"; } } else { echo "


".$msg['avis_aucun']."
"; } break; } if (!$log_ok && $opac_avis_allow==2) { $lvl='avis_'.$todo; print do_formulaire_connexion(); } //Enregistrement du log global $pmb_logs_activate; if($pmb_logs_activate){ global $log; $log->add_log('num_session',session_id()); $log->save(); } print $popup_footer; /* Fermeture de la connexion */ mysql_close($dbh);