Esempio n. 1
0
 /**
  * Display links to vote a comment as HELPFUL if user is logged
  *
  * @param string to display before link
  * @param string to display after link
  * @param string glue between url params
  * @param boolean save context?
  * @param boolean true if create AJAX button
  * @param array Params
  */
 function vote_helpful($before = '', $after = '', $glue = '&', $save_context = true, $ajax_button = false, $params = array())
 {
     $params = array_merge(array('helpful_text' => T_('Is this comment helpful?'), 'title_yes' => T_('Mark this comment as helpful!'), 'title_yes_voted' => T_('You think this comment is helpful'), 'title_no' => T_('Mark this comment as not helpful!'), 'title_no_voted' => T_('You think this comment is not helpful'), 'title_empty' => T_('No votes on helpfulness yet.'), 'class' => ''), $params);
     global $current_User;
     $comment_Item =& $this->get_Item();
     $comment_Item->load_Blog();
     if (!is_logged_in(false) || !$comment_Item->Blog->get_setting('allow_rating_comment_helpfulness')) {
         // If User is not logged OR Users cannot vote
         return false;
     }
     echo $before;
     $class = '';
     if (!empty($params['class'])) {
         $class = ' class="' . $params['class'] . '"';
     }
     echo '<span id="vote_helpful_' . $this->ID . '"' . $class . '> &nbsp; ';
     if ($current_User->ID == $this->author_user_ID) {
         // Display only vote summary for users on their own comments
         $params['result_title_undecided'] = T_('Helpfulness:');
         $params['after_result'] = '.';
         $result_summary = $this->get_vote_summary('helpful', $params);
         echo !empty($result_summary) ? $result_summary : $params['title_empty'];
     } else {
         // Display form to vote
         $vote_result = $this->get_vote_helpful_disabled();
         if (!$vote_result['is_voted']) {
             // Current user didn't vote on this comment
             $title_text = $params['helpful_text'];
         } else {
             // Display vote summary if user already voted on this comment
             $title_text = $this->get_vote_summary('helpful', $params);
         }
         display_voting_form(array('vote_type' => 'comment', 'vote_ID' => $this->ID, 'display_noopinion' => false, 'display_inappropriate' => false, 'display_spam' => false, 'title_text' => $title_text . ' ', 'title_like' => $params['title_yes'], 'title_like_voted' => $params['title_yes_voted'], 'title_dontlike' => $params['title_no'], 'title_dontlike_voted' => $params['title_no_voted']));
     }
     echo '</span>';
     echo $after;
 }
Esempio n. 2
0
     if (empty($vote_action) || in_array($vote_action, array('like', 'noopinion', 'dontlike'))) {
         // Display a voting form if no action
         // or Refresh a voting form only for these actions (in order to disable icons)
         if (!empty($blog_ID)) {
             // If blog is defined we should check if we can display info about number of votes
             $BlogCache =& get_BlogCache();
             if (($Blog =& $BlogCache->get_by_ID($blog_ID, false, false)) && ($blog_skin_ID = $Blog->get_skin_ID())) {
                 $LinkOwner =& $Link->get_LinkOwner();
                 $SkinCache =& get_SkinCache();
                 if (($Skin =& $SkinCache->get_by_ID($blog_skin_ID, false, false)) && $Skin->get_setting('colorbox_vote_' . $LinkOwner->get('name') . '_numbers')) {
                     // Display number of votes for current link type if it is enabled by blog skin
                     $voting_form_params['display_numbers'] = true;
                 }
             }
         }
         display_voting_form($voting_form_params);
     }
     break;
 case 'comment':
     // Vote on comments
     $comment_ID = (int) $vote_ID;
     if (empty($comment_ID)) {
         // No comment ID
         break 2;
     }
     $CommentCache =& get_CommentCache();
     $Comment = $CommentCache->get_by_ID($comment_ID, false);
     if (!$Comment) {
         // Incorrect comment ID
         break 2;
     }