You are here

function plus1_jquery_widget in Plus 1 6.2

Same name and namespace in other branches
  1. 6 plus1.module \plus1_jquery_widget()

Create voting widget to display on the webpage.

1 call to plus1_jquery_widget()
plus1_nodeapi in ./plus1.module
Implements hook_nodeapi().

File

./plus1.module, line 191
A simple +1 voting widget module.

Code

function plus1_jquery_widget($node, $teaser, $page) {

  // If voting is disabled on this node, just go away.
  if ($node->plus1_disable_vote) {
    return NULL;
  }
  $score = plus1_get_score($node->nid);
  global $user;

  // If user is not logged-in.
  if ($user->uid == 0) {
    $logged_in = FALSE;
    $is_author = FALSE;
  }
  else {
    $logged_in = TRUE;
    $is_author = $node->uid == $user->uid ? TRUE : FALSE;
  }
  $voted = plus1_get_votes($node->nid, $user->uid);

  // If a user wishes to, they may provide a different theme function
  // for each content type.
  return theme(array(
    $node->type . '_plus1_widget',
    'plus1_widget',
  ), $node, $score, $logged_in, $is_author, $voted, $teaser, $page);
}