You are here

function fivestar_block in Fivestar 6.2

Same name and namespace in other branches
  1. 5 fivestar.module \fivestar_block()
  2. 6 fivestar.module \fivestar_block()

File

./fivestar.module, line 563
A simple n-star voting widget, usable in other forms.

Code

function fivestar_block($op = 'list', $delta = 0, $edit = array()) {
  switch ($op) {
    case 'list':
      $blocks[0]['info'] = t('Fivestar: Rate this node');
      return $blocks;
    case 'view':
      if (user_access('access content') && user_access('rate content')) {
        if (arg(0) == 'node' && is_numeric(arg(1)) && (arg(2) == '' || arg(2) == 'view')) {
          $node = node_load(arg(1));
          $block = array();
          foreach (fivestar_get_tags() as $tag) {
            if (fivestar_validate_target('node', $node->nid, $tag)) {
              if (!$block) {
                $block['subject'] = t('Rate This');
                $block['content'] = '';
              }
              $block['content'] .= fivestar_widget_form($node, $tag);
            }
          }
          return $block;
        }
      }
      break;
  }
}