Robust
Well-known member
I have this helper:
It's used like this I think:
Neither Vote or Unvote is shown. the getCurrentBestAnswerStatusOnPost basically does this:
What am I doing wrong?
Code:
<?php
class BestAnswer_Helper_VoteStatus
{
public static function checkVoteStatus($postId, $userId)
{
$baPostModel = self::_getBaPostModel();
$existingBestAnswer = $baPostModel->getCurrentBestAnswerStatusOnPost($postId, $userId);
return ($existingBestAnswer ? false : true);
}
/**
* @return BestAnswer_Model_Post
*/
protected function _getBaPostModel()
{
return $this->getModelFromCache('BestAnswer_Model_Post');
}
}
Code:
<xen:if is="<xen:if is="{xen:helper voteStatus, $post['post_id'], $visitor['user_id']}">{xen:phrase bestanswer_vote}<else>{xen:phrase bestanswer_unvote}</xen:if>
Neither Vote or Unvote is shown. the getCurrentBestAnswerStatusOnPost basically does this:
Code:
/**
* Gets a best answer content record for a user that has voted on a piece of content.
*
* @param integer $postId
* @param integer $userId
*
* @return array|false
*/
public function getCurrentBestAnswerStatusOnPost($postId, $userId)
{
return $this->_getDb()->fetchRow('
SELECT *
FROM ba_votes
WHERE post_id = ?
AND ba_user_id = ?
', array($postId, $userId));
}
What am I doing wrong?