Commit ea5e9704 authored by Steven Wittens's avatar Steven Wittens
Browse files

- #14767: Do not display poll block when no polls are active

- Change double to single quotes.
parent e6b14d26
......@@ -51,7 +51,7 @@ function poll_block($op = 'list', $delta = 0) {
}
else if ($op == 'view') {
// Retrieve the latest poll.
$sql = db_rewrite_sql("SELECT MAX(n.created) FROM {node} n WHERE n.type = 'poll' AND n.status = 1 AND n.moderate = 0");
$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 AND n.moderate = 0");
$timestamp = db_result(db_query($sql));
if ($timestamp) {
$poll = node_load(array('type' => 'poll', 'created' => $timestamp, 'moderate' => 0, 'status' => 1));
......@@ -74,7 +74,7 @@ function poll_block($op = 'list', $delta = 0) {
* Closes polls that have exceeded their allowed runtime.
*/
function poll_cron() {
$result = db_query("SELECT p.nid FROM {poll} p INNER 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 INNER 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);
}
......
......@@ -51,7 +51,7 @@ function poll_block($op = 'list', $delta = 0) {
}
else if ($op == 'view') {
// Retrieve the latest poll.
$sql = db_rewrite_sql("SELECT MAX(n.created) FROM {node} n WHERE n.type = 'poll' AND n.status = 1 AND n.moderate = 0");
$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 AND n.moderate = 0");
$timestamp = db_result(db_query($sql));
if ($timestamp) {
$poll = node_load(array('type' => 'poll', 'created' => $timestamp, 'moderate' => 0, 'status' => 1));
......@@ -74,7 +74,7 @@ function poll_block($op = 'list', $delta = 0) {
* Closes polls that have exceeded their allowed runtime.
*/
function poll_cron() {
$result = db_query("SELECT p.nid FROM {poll} p INNER 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 INNER 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);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment