poll_load

  1. drupal
    1. drupal6
    2. drupal7
Versionen
drupal6 poll_load($node)
drupal7 poll_load($nodes)

Implementation of hook_load().

Code

modules/poll/poll.module, line 389

<?php
function poll_load($node) {
  global $user;

  $poll = db_fetch_object(db_query("SELECT runtime, active FROM {poll} WHERE nid = %d", $node->nid));

  // Load the appropriate choices into the $poll object.
  $result = db_query("SELECT chtext, chvotes, chorder FROM {poll_choices} WHERE nid = %d ORDER BY chorder", $node->nid);
  while ($choice = db_fetch_array($result)) {
    $poll->choice[$choice['chorder']] = $choice;
  }

  // Determine whether or not this user is allowed to vote.
  $poll->allowvotes = FALSE;
  if (user_access('vote on polls') && $poll->active) {
    if ($user->uid) {
      $result = db_fetch_object(db_query('SELECT chorder FROM {poll_votes} WHERE nid = %d AND uid = %d', $node->nid, $user->uid));
    }
    else {
      $result = db_fetch_object(db_query("SELECT chorder FROM {poll_votes} WHERE nid = %d AND hostname = '%s'", $node->nid, ip_address()));
    }
    if (isset($result->chorder)) {
      $poll->vote = $result->chorder;
    }
    else {
      $poll->vote = -1;
      $poll->allowvotes = TRUE;
    }
  }
  return $poll;
}
?>

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