From 71c1162465322f055204e3d40d75f696c26b3784 Mon Sep 17 00:00:00 2001
From: Steven Wittens <steven@10.no-reply.drupal.org>
Date: Wed, 23 May 2001 12:19:35 +0000
Subject: [PATCH] Fixed the poll block being messed up a lot. Stupid objects
 and arrays mixup :P

Please update drop.org as soon as possible, coz my crappy poll.mod is making drupal look bad :(
---
 modules/poll.module      | 10 +++++-----
 modules/poll/poll.module | 10 +++++-----
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/modules/poll.module b/modules/poll.module
index e299cc2c7f63..533a9b5e7d52 100644
--- a/modules/poll.module
+++ b/modules/poll.module
@@ -25,7 +25,7 @@ function poll_cron() {
 }
 
 function poll_get_choices_array($poll) {
-  if (!$poll[choice]) {
+  if (!is_array($poll[choice])) {
     $result = db_query("SELECT * FROM poll_choices WHERE nid='" . $poll[nid] . "'");
     if ($result) {
       while ($choices = db_fetch_array($result)) {
@@ -44,7 +44,7 @@ function poll_get_choices_array($poll) {
 }
 
 function poll_get_choices_obj($poll) {
-  if (!$poll->choice) {
+  if (!is_array($poll->choice)) {
     $result = db_query("SELECT * FROM poll_choices WHERE nid='" . $poll->nid . "'");
     if ($result) {
       while ($choices = db_fetch_array($result)) {
@@ -99,7 +99,7 @@ function poll_view($node, $main = 0, $block = 0) {
         $result = db_query("UPDATE poll_choices SET chvotes=chvotes+1 WHERE nid='" . $node->nid . "' && chid='" . check_input($chid) . "'");
         if (($result) && ($user)) {
           $new = node_get_array(array("nid" => $node->nid));
-          $new[voters] = field_set($node->voters, $user->userid,1);
+          $new[voters] = field_set($node->voters, $user->userid, 1);
           node_save($new, array(voters));
           $node = node_get_object(array("nid" => $node->nid));
         }
@@ -229,8 +229,8 @@ function poll_save($edit) {
 
 function poll_block() {
   $result = _node_get(array("type" => "poll"));
-  while ($poll = db_fetch_array($result)) {
-    if ($poll[active]) {
+  while ($poll = db_fetch_object($result)) {
+    if ($poll->active) {
       $poll = poll_view($poll, 0, 1);
       $output = "<b>" . $poll[title] . "</b><br>" . $poll[content];
       break;
diff --git a/modules/poll/poll.module b/modules/poll/poll.module
index e299cc2c7f63..533a9b5e7d52 100644
--- a/modules/poll/poll.module
+++ b/modules/poll/poll.module
@@ -25,7 +25,7 @@ function poll_cron() {
 }
 
 function poll_get_choices_array($poll) {
-  if (!$poll[choice]) {
+  if (!is_array($poll[choice])) {
     $result = db_query("SELECT * FROM poll_choices WHERE nid='" . $poll[nid] . "'");
     if ($result) {
       while ($choices = db_fetch_array($result)) {
@@ -44,7 +44,7 @@ function poll_get_choices_array($poll) {
 }
 
 function poll_get_choices_obj($poll) {
-  if (!$poll->choice) {
+  if (!is_array($poll->choice)) {
     $result = db_query("SELECT * FROM poll_choices WHERE nid='" . $poll->nid . "'");
     if ($result) {
       while ($choices = db_fetch_array($result)) {
@@ -99,7 +99,7 @@ function poll_view($node, $main = 0, $block = 0) {
         $result = db_query("UPDATE poll_choices SET chvotes=chvotes+1 WHERE nid='" . $node->nid . "' && chid='" . check_input($chid) . "'");
         if (($result) && ($user)) {
           $new = node_get_array(array("nid" => $node->nid));
-          $new[voters] = field_set($node->voters, $user->userid,1);
+          $new[voters] = field_set($node->voters, $user->userid, 1);
           node_save($new, array(voters));
           $node = node_get_object(array("nid" => $node->nid));
         }
@@ -229,8 +229,8 @@ function poll_save($edit) {
 
 function poll_block() {
   $result = _node_get(array("type" => "poll"));
-  while ($poll = db_fetch_array($result)) {
-    if ($poll[active]) {
+  while ($poll = db_fetch_object($result)) {
+    if ($poll->active) {
       $poll = poll_view($poll, 0, 1);
       $output = "<b>" . $poll[title] . "</b><br>" . $poll[content];
       break;
-- 
GitLab