From 576b3471f796ea59893d6bf79f396838232c02fd Mon Sep 17 00:00:00 2001 From: Julie Choquet <julie.choquet@ensiie.fr> Date: Mon, 9 May 2016 01:54:08 +0200 Subject: [PATCH] =?UTF-8?q?bouton=20like=20disabled=20si=20d=C3=A9j=C3=A0?= =?UTF-8?q?=20fait?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Timeline/TODO.txt | 4 ++-- Timeline/acceuil.php | 2 ++ Timeline/js/modal.js | 7 +++++++ Timeline/modal.php | 2 +- Timeline/script_modal.php | 10 +++++++++- 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/Timeline/TODO.txt b/Timeline/TODO.txt index d8cac19..b6da7c6 100755 --- a/Timeline/TODO.txt +++ b/Timeline/TODO.txt @@ -25,11 +25,11 @@ TO DO LATER : - ajout commentaire sur click photo - faire le bouton j'aime qui marche -- acceuil + - identification de personnes rajouter un bouton et que ça marche (mettre qu'on aurait aimer elastic search ect) -- oubli de marquer qui a posté à raj ? +- oubli de marquer qui a posté à raj ? - ajout concours admin, fin concours admin: Abandon -> probleme dans la table concours winner = identifiant photo LATER diff --git a/Timeline/acceuil.php b/Timeline/acceuil.php index 9f66647..74df3da 100755 --- a/Timeline/acceuil.php +++ b/Timeline/acceuil.php @@ -88,5 +88,7 @@ } ?> + + <?php include 'modal.php'; ?> <?php include 'footer.php'; ?> diff --git a/Timeline/js/modal.js b/Timeline/js/modal.js index 0ef4b10..e16d49b 100755 --- a/Timeline/js/modal.js +++ b/Timeline/js/modal.js @@ -56,6 +56,13 @@ $(document).ready(function (){ var like = resultObj[1][0]; $('.like').html(like); + var possible = resultObj[2][0]; + + if(possible == 1) + { + $("#like").attr("disabled", true); + } + } else { diff --git a/Timeline/modal.php b/Timeline/modal.php index 8881ff5..b5be550 100755 --- a/Timeline/modal.php +++ b/Timeline/modal.php @@ -63,7 +63,7 @@ echo '</div>'; echo '<div class="modal-footer">'; echo '<button class="btn btn-primary vote" data-toggle="tooltip" title="Vote pour la photo la plus trash">Trash<span class="badge trash">0</span></button>'; echo '<button class="btn btn-primary vote" data-toggle="tooltip" title="Vote pour la photo où ça pécho sec">Love<span class="badge love">0</span></button>'; -echo '<button class="btn btn-primary vote" data-toggle="tooltip" title="Photo de toute beauté">Like<span class="badge like">0</span></button>'; +echo '<button class="btn btn-primary vote" data-toggle="tooltip" title="Photo de toute beauté" id="like">Like<span class="badge like">0</span></button>'; echo '</div>'; echo '</div>'; diff --git a/Timeline/script_modal.php b/Timeline/script_modal.php index 5dd689e..b998b00 100755 --- a/Timeline/script_modal.php +++ b/Timeline/script_modal.php @@ -2,6 +2,8 @@ session_start(); + + $id = $_SESSION['login']; $idphoto = $_POST['idphoto']; $idsoiree = $_POST['idsoiree']; @@ -21,6 +23,11 @@ return $result; } + function dejaLike($db, $idphoto, $id) { + $stmt = $db->query("SELECT COUNT(*) FROM liker WHERE idutilisateur='$id' AND idphoto='$idphoto'"); + return $stmt->fetchColumn(); + } + try{ /* Connexion à la base de données avec PDO */ @@ -29,6 +36,7 @@ $commentaires = getComment($DB, $idphoto); $nblike = getLike($DB, $idphoto); + $likePossible = dejaLike($DB, $idphoto, $id); $DB = null; @@ -39,7 +47,7 @@ } - $array = array($commentaires, $nblike); + $array = array($commentaires, $nblike, $likePossible); echo json_encode($array); -- GitLab