poll_block

  1. drupal
    1. drupal6
Versionen
drupal6 poll_block($op = 'list', $delta = 0)

Implementation of hook_block().

Generates a block containing the latest poll.

Code

modules/poll/poll.module, line 130

<?php
function poll_block($op = 'list', $delta = 0) {
  if (user_access('access content')) {
    if ($op == 'list') {
      $blocks[0]['info'] = t('Most recent poll');
      return $blocks;
    }
    else if ($op == 'view') {
      // Retrieve the latest poll.
      $sql = db_rewrite_sql("SELECT MAX(n.created) FROM {node} n INNER JOIN {poll} p ON p.nid = n.nid WHERE n.status = 1 AND p.active = 1");
      $timestamp = db_result(db_query($sql));
      if ($timestamp) {
        $poll = node_load(array('type' => 'poll', 'created' => $timestamp, 'status' => 1));

        if ($poll->nid) {
          $poll = poll_view($poll, TRUE, FALSE, TRUE);
        }
      }
      $block['subject'] = t('Poll');
      $block['content'] = drupal_render($poll->content);
      return $block;
    }
  }
}
?>

Kommentare

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen