1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
$array_commentaire = array();
while ($tab_data_comment = $sql_data_comment->fetch())
{
$array_commentaire[$tab_data_comment['id']]['titre']= stripslashes(htmlspecialchars($tab_data_comment['titre']));
$array_commentaire[$tab_data_comment['id']]['contenu']= stripslashes($tab_data_comment['contenu']);
$array_commentaire[$tab_data_comment['id']]['pseudo']= stripslashes(htmlspecialchars($tab_data_comment['pseudo']));
$array_commentaire[$tab_data_comment['id']]['timestamp']= intval($tab_data_comment['timestamp']);
$array_commentaire[$tab_data_comment['id']]['type_comment']= intval($tab_data_comment['type_comment']);
$array_commentaire[$tab_data_comment['id']]['identifiant_comment']= intval($tab_data_comment['identifiant_comment']);
$array_commentaire[$tab_data_comment['id']]['message_cite']= intval($tab_data_comment['message_cite']);
$array_commentaire[$tab_data_comment['id']]['id_user']= intval($tab_data_comment['id_user']);
$array_commentaire[$tab_data_comment['id']]['type_balade']= intval($tab_data_comment['type_balade']);
$array_commentaire[$tab_data_comment['id']]['id']= intval($tab_data_comment['id']);
}
//debut fonction
function afficher_commentaire($identifiant_comment, $array_commentaire,$cite = false)
{
$contenu = $array_commentaire[$identifiant_comment]['contenu'];
$id_message_cite = $array_commentaire[$identifiant_comment]['message_cite'];
$type_comment = $array_commentaire[$identifiant_comment]['type_comment'];
$id_maj_supr_comment = $array_commentaire[$identifiant_comment]['identifiant_comment'];
$type_balade = $array_commentaire[$identifiant_comment]['type_balade'];
$id = $array_commentaire[$identifiant_comment]['id'];
$timestamp = $array_commentaire[$identifiant_comment]['timestamp'];
$pseudo = $array_commentaire[$identifiant_comment]['pseudo'];
echo '<div class="componentheading_categorie">';
echo stripslashes($array_commentaire[$identifiant_comment]['titre']);
echo' <span class="quote_droite">';
//si connecté
if (Fsb::$session->is_logged())
{
$id_user = $array_commentaire[$identifiant_comment]['id_user'];
//si c'est pas son message
if (Fsb::$session->id() != $id_user )
{
//il peut citer
if(!$cite)
{
//si il à déjà cité le message, on ne lui laisse pas quoter une seconde fois
$racine = $_SERVER['DOCUMENT_ROOT'];
include ($racine.'/inclusion/connect_pdo.php');
$sql_unique = $bdd->prepare('SELECT * from comment where message_cite IN(select id from comment) and message_cite = ?');
$sql_unique->execute(array($id));
$tab_unique = $sql_unique->fetch();
$message_unique = $tab_unique['message_cite'];
if($message_unique == $id_message_cite)
{
echo' <a href="/php/commentaires/moi/rediger_commentaire.php?type_comment='.$type_comment.'&identifiant_comment='.$id_maj_supr_comment.'&commentaire_cite='.$identifiant_comment.'';
if($type_balade == 0 OR $type_balade == 1)
{
echo'&type_balade='.$type_balade.'';
}
echo' " title="Citer le commentaire" target="_self"><img src="/php/commentaires/images/quote.gif" title="Citer le commentaire"></a>';
}
}
}
//c'est son message
if (Fsb::$session->id() == $id_user OR Fsb::$session->data['u_auth'] == 5 OR Fsb::$session->data['u_auth'] == 4 )
{
//rien dans les messages cités
if(!$cite)
{
//suppresion ok
echo' <a href="/php/commentaires/moi/liste_commentaire.php?type_comment='.$type_comment.'&identifiant_comment='.$id_maj_supr_comment.'';
if($type_balade == 0 OR $type_balade == 1)
{
echo'&type_balade='.$type_balade.'';
}
echo'&id_com_a_supprimer='.$identifiant_comment.'';
if(!empty($id_message_cite))
{
echo'&commentaire_cite='. $id_message_cite .'';
}
echo'" title="Supprimer le commentaire" target="_self" onclick="return confirm(\'Etes vous sur de vouloir supprimer ce commentaire ?\');"><img src="/php/commentaires/images/delete.gif" title="Supprimer le commentaire"></a>';
//editer le commentaire
echo' <a href="/php/commentaires/moi/rediger_commentaires.php?type_comment='.$type_comment.'&identifiant_comment='.$id_maj_supr_comment.'';
if($type_balade == 0 OR $type_balade == 1)
{
echo'&type_balade='.$type_balade.'';
}
//si modif, on passe l'id message qui à été cité si il y en a
if(!empty($id_message_cite))
{
echo'&commentaire_cite='. $id_message_cite .'';
}
echo'&id_message_a_editer='.$identifiant_comment.'" title="Editer le commentaire" target="_self"><img src="/php/commentaires/images/edit.gif" title="Editer le commentaire"></a>';
}
}
}
echo'</span>';
echo'</div>';
//recursive si c'est un message cité
if (!empty($id_message_cite))
{
echo'<blockquote class="cadre_forum">';
echo '<div class="citer">';
afficher_commentaire($id_message_cite, $array_commentaire, true);
echo '</div>';
echo'</blockquote><br />';
}
echo $contenu;
echo'<p class="spacer"></p>';
echo'<span class="poste_par">';
echo'Posté le '.date('d/m/Y à H\hi',$timestamp). ' par <strong>'.$pseudo.' </strong>';
echo'</span>';
}
//fin fonction
//on lance la fonction
foreach ($array_commentaire as $id => $value)
{
afficher_commentaire($id,$array_commentaire);
} |
Partager