From 0089961197a23cbbe2df4ea1111cce496893ddae Mon Sep 17 00:00:00 2001 From: Bogdanova Olga Date: Sat, 17 Apr 2021 14:14:32 +0300 Subject: [PATCH] Issues-578:The up/down vote buttons aren't clickable in guest mode --- Voting/class.voting.plugin.php | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/Voting/class.voting.plugin.php b/Voting/class.voting.plugin.php index a6236b0..daab2a0 100644 --- a/Voting/class.voting.plugin.php +++ b/Voting/class.voting.plugin.php @@ -38,7 +38,12 @@ public function addVotingBox($sender, $args) { $currentUserVote = $commentModel->GetUserScore($id, $session->UserID); } - echo generateVoterBox($id,$args['Type'], $pScore, $nScore, $currentUserVote ).''; + $control = generateVoterBox($id,$args['Type'], $pScore, $nScore, $currentUserVote ); + + if ($session->IsValid()) { + $control .=''; + } + echo $control; } @@ -366,13 +371,23 @@ function generateVoterBox($id, $VoteType, $pScore, $nScore, $currentUserVote) { } $result = ''; - $result .= Anchor(Wrap('', 'span', array('class' => 'icon ' . $cssClassVoteUp, 'rel' => 'nofollow')), $voteUpUrl, 'VoteUp'); + // The up/down vote buttons are clickable in guest mode + if(Gdn::session()->isValid()) { + $result .= Anchor(Wrap('', 'span', array('class' => 'icon ' . $cssClassVoteUp, 'rel' => 'nofollow')), $voteUpUrl, 'VoteUp'); + } else { + $result .= Wrap(Wrap('', 'span', array('class' => 'icon ' . $cssClassVoteUp, 'rel' => 'nofollow')), 'span', array('class' =>'VoteUp')); + } + $counts = formattedPScore($pScore); if(!StringIsNullOrEmpty($nScore) && $nScore != 0) { $counts .= '/' . formattedNScore($nScore); } $result .= Wrap($counts, 'span', array('class' => 'CountVoices')); - $result .= Anchor(Wrap('', 'span', array('class' => 'icon ' . $cssClassVoteDown, 'rel' => 'nofollow')), $voteDownUrl, 'VoteDown'); + if(Gdn::session()->isValid()) { + $result .= Anchor(Wrap('', 'span', array('class' => 'icon ' . $cssClassVoteDown, 'rel' => 'nofollow')), $voteDownUrl, 'VoteDown'); + } else { + $result .= Wrap(Wrap('', 'span', array('class' => 'icon ' . $cssClassVoteDown, 'rel' => 'nofollow')), 'span', array('class' =>'VoteDown')); + } $result .= ''; return $result;