summaryrefslogtreecommitdiff
path: root/modules/poll/poll.module
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2003-07-10 17:46:44 +0000
committerDries Buytaert <dries@buytaert.net>2003-07-10 17:46:44 +0000
commit337b3c9de997f4fcb27467e3d80d0f43fda7783e (patch)
tree392e4a56fa1ac3d09e9cb78998f87ab438229926 /modules/poll/poll.module
parent1c2fc43b51455e4895455798919e4c77e2b1bf21 (diff)
downloadbrdo-337b3c9de997f4fcb27467e3d80d0f43fda7783e.tar.gz
brdo-337b3c9de997f4fcb27467e3d80d0f43fda7783e.tar.bz2
- Committed a slightly modified version of Slavica's table prefix patch.
Diffstat (limited to 'modules/poll/poll.module')
-rw-r--r--modules/poll/poll.module32
1 files changed, 16 insertions, 16 deletions
diff --git a/modules/poll/poll.module b/modules/poll/poll.module
index 0313b62c8..9df886bc8 100644
--- a/modules/poll/poll.module
+++ b/modules/poll/poll.module
@@ -49,7 +49,7 @@ function poll_block($op = "list", $delta = 0) {
return $blocks;
}
else {
- $timestamp = db_result(db_query("SELECT MAX(created) FROM node WHERE type = 'poll' AND status = '1' AND moderate = '0'"));
+ $timestamp = db_result(db_query("SELECT MAX(created) FROM {node} WHERE type = 'poll' AND status = '1' AND moderate = '0'"));
if ($timestamp) {
$poll = node_load(array("type" => "poll", "created" => $timestamp, "moderate" => "0", "status" => "1"));
if ($poll->nid) {
@@ -66,15 +66,15 @@ function poll_block($op = "list", $delta = 0) {
function poll_cron() {
// Close polls that have exceeded their allowed runtime
- $result = db_query("SELECT p.nid FROM poll p LEFT JOIN node n ON p.nid=n.nid WHERE (n.created + p.runtime) < '". time() ."' AND p.active = '1' AND p.runtime != '0'");
+ $result = db_query("SELECT p.nid FROM {poll} p LEFT JOIN {node} n ON p.nid=n.nid WHERE (n.created + p.runtime) < '". time() ."' AND p.active = '1' AND p.runtime != '0'");
while ($poll = db_fetch_object($result)) {
- db_query("UPDATE poll SET active='0' WHERE nid = %d", $poll->nid);
+ db_query("UPDATE {poll} SET active='0' WHERE nid = %d", $poll->nid);
}
}
function poll_delete($node) {
- db_query("DELETE FROM poll WHERE nid=%d", $node->nid);
- db_query("DELETE FROM poll_choices WHERE nid = %d", $node->nid);
+ db_query("DELETE FROM {poll} WHERE nid=%d", $node->nid);
+ db_query("DELETE FROM {poll_choices} WHERE nid = %d", $node->nid);
}
function poll_form(&$node, &$help, &$error) {
@@ -143,11 +143,11 @@ function poll_insert($node) {
$node->active = 1;
}
- db_query("INSERT INTO poll (nid, runtime, voters, active) VALUES (%d, %d, '', %d)", $node->nid, $node->runtime, $node->active);
+ db_query("INSERT INTO {poll} (nid, runtime, voters, active) VALUES (%d, %d, '', %d)", $node->nid, $node->runtime, $node->active);
for ($i = 0; $i < $node->choices; $i++) {
if ($node->choice[$i] != "") {
- db_query("INSERT INTO poll_choices (nid, chtext, chvotes, chorder) VALUES (%d, '%s', %d, %d)", $node->nid, $node->choice[$i], $node->chvotes[$i], $i);
+ db_query("INSERT INTO {poll_choices} (nid, chtext, chvotes, chorder) VALUES (%d, '%s', %d, %d)", $node->nid, $node->choice[$i], $node->chvotes[$i], $i);
}
}
}
@@ -199,9 +199,9 @@ function poll_link($type, $node = 0, $main) {
function poll_load($node) {
// Load the appropriate choices into the $node object
- $poll = db_fetch_object(db_query("SELECT runtime, voters, active FROM poll WHERE nid = %d", $node->nid));
+ $poll = db_fetch_object(db_query("SELECT runtime, voters, active FROM {poll} WHERE nid = %d", $node->nid));
- $result = db_query("SELECT chtext, chvotes, chorder FROM poll_choices WHERE nid=%d ORDER BY chorder", $node->nid);
+ $result = db_query("SELECT chtext, chvotes, chorder FROM {poll_choices} WHERE nid=%d ORDER BY chorder", $node->nid);
while ($choice = db_fetch_object($result)) {
$poll->choice[$choice->chorder] = $choice->chtext;
$poll->chvotes[$choice->chorder] = $choice->chvotes;
@@ -221,7 +221,7 @@ function poll_node($field) {
function poll_page() {
theme("header");
- $result = db_query("SELECT n.nid, n.title, p.active, SUM(c.chvotes) AS votes FROM node n LEFT JOIN poll p ON n.nid=p.nid LEFT JOIN poll_choices c ON n.nid=c.nid WHERE type = 'poll' AND status = '1' AND moderate = '0' GROUP BY n.nid, n.title, p.active, n.created ORDER BY n.created DESC");
+ $result = db_query("SELECT n.nid, n.title, p.active, SUM(c.chvotes) AS votes FROM {node} n LEFT JOIN {poll} p ON n.nid=p.nid LEFT JOIN {poll_choices} c ON n.nid=c.nid WHERE type = 'poll' AND status = '1' AND moderate = '0' GROUP BY n.nid, n.title, p.active, n.created ORDER BY n.created DESC");
$output = "<ul>";
while ($node = db_fetch_object($result)) {
$output .= "<li>".l($node->title, "node/view/$node->nid") ." - ". format_plural($node->votes, "1 vote", "%count votes") ." - ". ($node->active ? t("open") : t("closed")) ."</li>";
@@ -293,7 +293,7 @@ function poll_view_results(&$node, $main, $block, $links) {
if ($node->choice) {
foreach ($node->choice as $key => $value) {
if ($value != "") {
- $width = round($node->chvotes[$key] * 100 / $votesmax);
+ $width = round($node->chvotes[$key] * 100 / $votestotal);
$percentage = round($node->chvotes[$key] * 100 / max($votestotal, 1));
$output .= "<div class=\"text\">". filter($value) ."</div>";
$output .= "<div class=\"bar\">";
@@ -317,8 +317,8 @@ function poll_view_processvote(&$node) {
if (isset($pollvote[$node->nid]) && ($node->allowvotes == 1)) {
if (!empty($node->choice[$pollvote[$node->nid]])) {
$node->voters = $node->voters ? ($node->voters ." ". $node->polluserid) : $node->polluserid;
- db_query("UPDATE poll SET voters='%s' WHERE nid = %d", $node->voters, $node->nid);
- db_query("UPDATE poll_choices SET chvotes = chvotes + 1 WHERE nid = %d AND chorder = %d", $node->nid, $pollvote[$node->nid]);
+ db_query("UPDATE {poll} SET voters='%s' WHERE nid = %d", $node->voters, $node->nid);
+ db_query("UPDATE {poll_choices} SET chvotes = chvotes + 1 WHERE nid = %d AND chorder = %d", $node->nid, $pollvote[$node->nid]);
$node->allowvotes = 0;
$node->chvotes[$pollvote[$node->nid]]++;
}
@@ -366,16 +366,16 @@ function poll_view(&$node, $main = 0, $block = 0) {
}
function poll_update($node) {
- db_query("UPDATE poll SET runtime = %d, active = %d WHERE nid = %d", $node->runtime, $node->active, $node->nid);
+ db_query("UPDATE {poll} SET runtime = %d, active = %d WHERE nid = %d", $node->runtime, $node->active, $node->nid);
- db_query("DELETE FROM poll_choices WHERE nid = %d", $node->nid);
+ db_query("DELETE FROM {poll_choices} WHERE nid = %d", $node->nid);
for ($i = 0; $i < $node->choices; $i++) {
$choice->chtext = $node->choice[$i];
$choice->chvotes = (int)$node->chvotes[$i];
$choice->chorder = $i;
if ($choice->chtext != "") {
- db_query("INSERT INTO poll_choices (nid, chtext, chvotes, chorder) VALUES (%d, '%s', %d, %d)", $node->nid, $choice->chtext, $choice->chvotes, $choice->chorder);
+ db_query("INSERT INTO {poll_choices} (nid, chtext, chvotes, chorder) VALUES (%d, '%s', %d, %d)", $node->nid, $choice->chtext, $choice->chvotes, $choice->chorder);
}
}
}