diff --git a/module/blog/blog.php b/module/blog/blog.php index 9ac4b2d3..ca32737f 100644 --- a/module/blog/blog.php +++ b/module/blog/blog.php @@ -179,7 +179,7 @@ class blog extends common { $comment['approval'] = array_key_exists('approval', $comment) === false ? true : $comment['approval'] ; if ( $this->getData(['module', $this->getUrl(0), $this->getUrl(2),'commentApproved']) === true) { $buttonApproval = template::button('blogCommentApproved' . $commentIds[$i], [ - 'class' => $comment['approval'] === true ? 'blogCommentReject buttonGreen' : 'blogCommentApproved buttonRed' , + 'class' => $comment['approval'] === true ? 'blogCommentRejected buttonGreen' : 'blogCommentApproved buttonRed' , 'href' => helper::baseUrl() . $this->getUrl(0) . '/commentApprove/' . $this->getUrl(2) . '/' . $commentIds[$i] . '/' . $_SESSION['csrf'] , 'value' => $comment['approval'] === true ? 'A' : 'R' ]); @@ -279,19 +279,20 @@ class blog extends common { } // Inversion du statut else { + $approved = !$this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'comment', $this->getUrl(3), 'approval']) ; $this->setData(['module', $this->getUrl(0), $this->getUrl(2), 'comment', $this->getUrl(3), [ 'author' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'comment', $this->getUrl(3), 'author']), 'content' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'comment', $this->getUrl(3), 'content']), 'createdOn' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'comment', $this->getUrl(3), 'createdOn']), 'userId' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'comment', $this->getUrl(3), 'userId']), - 'approval' => !$this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'comment', $this->getUrl(3), 'approval']) + 'approval' => $approved ]]); // Valeurs en sortie $this->addOutput([ 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/comment/'.$this->getUrl(2), - 'notification' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'comment', $this->getUrl(3), 'approval']) === true ? 'Commentaire rejeté' : 'Commentaire approuvé', - 'state' => !$this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'comment', $this->getUrl(3), 'approval']) + 'notification' => $approved ? 'Commentaire approuvé' : 'Commentaire rejeté', + 'state' => $approved ]); } } diff --git a/module/blog/view/comment/comment.js.php b/module/blog/view/comment/comment.js.php index e79aae5b..fc6f7aaa 100644 --- a/module/blog/view/comment/comment.js.php +++ b/module/blog/view/comment/comment.js.php @@ -25,7 +25,7 @@ $(".blogCommentDelete").on("click", function() { /** * Confirmation d'approbation */ -$(".blogCommentApprove").on("click", function() { +$(".blogCommentApproved").on("click", function() { var _this = $(this); var nom = "getData(['module', $this->getUrl(0), $this->getUrl(2), 'title' ]); ?>"; return core.confirm("Approuver le commentaire de l'article " + nom + " ?", function() { @@ -36,7 +36,7 @@ $(".blogCommentApprove").on("click", function() { /** * Confirmation de rejet */ -$(".blogCommentReject").on("click", function() { +$(".blogCommentRejected").on("click", function() { var _this = $(this); var nom = "getData(['module', $this->getUrl(0), $this->getUrl(2), 'title' ]); ?>"; return core.confirm("Rejeter le commentaire de l'article " + nom + " ?", function() {