Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
524 views
in Plugins by
edited by
When someone clicks 'show X previous comments', the voting arrows to vote on comments disappear. Did someone find a fix for this yet?
Q2A version: 1.6.2

1 Answer

+2 votes
by

I found a stupid solution to this problem (it's not optimal). Replace the redefinition of c_item_main in qa-comment-voting-layer.php with this code : 

 

function c_item_main($c_item)
{
 
global $topage;
 
 
$this->logged_in_userid = qa_get_logged_in_userid();
if(qa_opt('voting_on_cs')) {
$this->comment_votes = $this->logged_in_userid?qa_db_read_all_assoc(qa_db_query_sub('SELECT ^uservotes.vote AS vote, ^uservotes.postid AS postid  FROM ^posts,^uservotes WHERE ^uservotes.vote<>0 AND ^uservotes.userid=# AND ^uservotes.postid=^posts.postid AND ^posts.type=$',$this->logged_in_userid, 'C')):null;
}
 
if(qa_opt('voting_on_cs') && is_array($this->comment_votes) && isset($c_item['content']) && !isset($c_item['url']) && !strpos($c_item['content'],'question-closed-message')) {
$vote=0;
$flag=0;
foreach($this->comment_votes as $vote) {
if($vote['postid'] == $c_item['raw']['postid']) {
$vote = (int)$vote['vote'];
break;
}
}
$netvotes = ($c_item['raw']['netvotes']!=0?$c_item['raw']['netvotes']:'');
 
if(qa_permit_check('permit_vote_c')) {
$this->output('<table class="comment-votable-container"><tr><td class="comment-vote-container">');
switch($vote) {
case 1:
$up = 0;
$up_type = '-selected';
$down_type = false;
break;
case -1:
$down = 0;
$down_type = '-selected';
$up_type = false;
break;
default:
$up = 1;
$down = -1;
$up_type = '';
$down_type = '';
break;
}
 
if(!qa_opt('voting_down_cs') && $vote != -1) $down_type = false;
 
// don't allow for own user
 
if($c_item['raw']['userid'] != qa_get_logged_in_userid())
$this->output(($up_type!==false?'<div class="comment-vote-item'.$up_type.'" name="vote_'.$c_item['raw']['postid'].'_'.$up.'_c'.$c_item['raw']['postid'].'_1" onclick="ajaxCommentVote(this);" title="'.qa_lang_html('main/vote'.($up == 0?'d':'').'_up_popup').'">▲</div>':'').($netvotes?'<div id="voting_'.$c_item['raw']['postid'].'">'.$netvotes.'</div>':'').($down_type!==false?'<div class="comment-vote-item'.$down_type.'" onclick="ajaxCommentVote(this);" name="vote_'.$c_item['raw']['postid'].'_'.$down.'_c'.$c_item['raw']['postid'].'_-1" title="'.qa_lang_html('main/vote'.($down == 0?'d':'').'_down_popup').'">▼</div>':''));
else if ($netvotes) {
$this->output('<div id="voting_'.$c_item['raw']['postid'].'">'.$netvotes.'</div>');
 
}
$this->output('</td><td>');
qa_html_theme_base::c_item_main($c_item);
$this->output('</td></tr></table>');
}
else if ($netvotes){
$this->output('<table class="comment-votable-container"><tr><td class="comment-vote-container"><div id="voting_'.$c_item['raw']['postid'].'">'.$netvotes.'</div></td><td>');
qa_html_theme_base::c_item_main($c_item);
$this->output('</td></tr></table>');
}
else qa_html_theme_base::c_item_main($c_item);
}
else qa_html_theme_base::c_item_main($c_item);
}
 
// db variable
 
var $logged_in_userid;
 
var $comment_votes;
 
// worker
 
function ajaxCommentVote($vote, $postid) {
global $topage,$qa_cookieid;
 
$post=qa_db_select_with_pending(qa_db_full_post_selectspec($this->logged_in_userid, $postid));
$voteerror = $this->comment_vote_error_html($post, $this->logged_in_userid, $topage);
if ($voteerror===false) {
$this->comment_vote_set($post, $this->logged_in_userid, qa_get_logged_in_handle(), $qa_cookieid, $vote);
 
$comment = qa_db_single_select(qa_db_full_post_selectspec(null, $postid));
 
$votes = $comment['netvotes'];
 
$up_text = qa_lang_html('main/vote'.($vote == 1?'d':'').'_up_popup');
$down_text = qa_lang_html('main/vote'.($vote == -1?'d':'').'_down_popup');
 
echo '{"status":"1","data":"'.$votes.'","up":"'.$up_text.'","down":"'.$down_text.'"}';
} else {
echo '{"status":"0","data":"'.$voteerror.'"}';
}
 
}
 
...