You are here

function plus1_jquery_widget in Plus 1 6

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

Create voting widget to display on the webpage.

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

File

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

Code

function plus1_jquery_widget($nid, $teaser) {

  // Load the JavaScript and CSS files.
  drupal_add_js(drupal_get_path('module', 'plus1') . '/jquery.plus1.js');
  drupal_add_css(drupal_get_path('module', 'plus1') . '/plus1.css');
  $score = plus1_get_score($nid);
  global $user;

  // If user is not logged-in.
  if ($user->uid == 0) {
    $logged_in = FALSE;
  }
  else {
    $logged_in = TRUE;
    $is_author = db_result(db_query('SELECT uid FROM {node} WHERE nid = %d AND uid = %d', $nid, $user->uid));
    $voted = plus1_get_vote($nid, $user->uid);
  }
  return theme('plus1_widget', $nid, $score, $logged_in, $is_author, $voted, $teaser);
}