Commit 2c527257 authored by Dries's avatar Dries

- Updated the poll module to use the _validate hook. Fixes bug #2918 reported

  by Jonathan.
parent 85eebfb5
......@@ -77,14 +77,8 @@ function poll_delete($node) {
db_query("DELETE FROM {poll_choices} WHERE nid = %d", $node->nid);
}
function poll_form(&$node, &$help, &$error) {
$admin = user_access("administer nodes");
$_duration = array(0 => t("Unlimited"), 86400 => format_interval(86400), 172800 => format_interval(172800), 345600 => format_interval(345600), 604800 => format_interval(604800), 1209600 => format_interval(1209600), 2419200 => format_interval(2419200), 4838400 => format_interval(4838400), 9676800 => format_interval(9676800), 31536000 => format_interval(31536000));
$_active = array(0 => t("Closed"), 1 => t("Active"));
$node->choices = $node->choices ? $node->choices : max(2, count($node->choice) ? count($node->choice) : 5);
function poll_validate(&$node) {
if (isset($node->title)) {
// Check for at least two options and validate amount of votes:
for ($i = 0; $i < $node->choices; $i++) {
......@@ -101,9 +95,21 @@ function poll_form(&$node, &$help, &$error) {
$error["choice][0"] = theme("theme_error", t("You must fill in at least two choices."));
}
}
else {
$help = variable_get("poll_help", "");
}
$node->teaser = poll_teaser($node);
return $error;
}
function poll_form(&$node, &$help, &$error) {
$admin = user_access("administer nodes");
$_duration = array(0 => t("Unlimited"), 86400 => format_interval(86400), 172800 => format_interval(172800), 345600 => format_interval(345600), 604800 => format_interval(604800), 1209600 => format_interval(1209600), 2419200 => format_interval(2419200), 4838400 => format_interval(4838400), 9676800 => format_interval(9676800), 31536000 => format_interval(31536000));
$_active = array(0 => t("Closed"), 1 => t("Active"));
$node->choices = $node->choices ? $node->choices : max(2, count($node->choice) ? count($node->choice) : 5);
$help = variable_get("poll_help", "");
if (function_exists("taxonomy_node_form")) {
$output = implode("", taxonomy_node_form("poll", $node));
......@@ -380,8 +386,4 @@ function poll_update($node) {
}
}
function poll_validate(&$node) {
$node->teaser = poll_teaser($node);
}
?>
......@@ -77,14 +77,8 @@ function poll_delete($node) {
db_query("DELETE FROM {poll_choices} WHERE nid = %d", $node->nid);
}
function poll_form(&$node, &$help, &$error) {
$admin = user_access("administer nodes");
$_duration = array(0 => t("Unlimited"), 86400 => format_interval(86400), 172800 => format_interval(172800), 345600 => format_interval(345600), 604800 => format_interval(604800), 1209600 => format_interval(1209600), 2419200 => format_interval(2419200), 4838400 => format_interval(4838400), 9676800 => format_interval(9676800), 31536000 => format_interval(31536000));
$_active = array(0 => t("Closed"), 1 => t("Active"));
$node->choices = $node->choices ? $node->choices : max(2, count($node->choice) ? count($node->choice) : 5);
function poll_validate(&$node) {
if (isset($node->title)) {
// Check for at least two options and validate amount of votes:
for ($i = 0; $i < $node->choices; $i++) {
......@@ -101,9 +95,21 @@ function poll_form(&$node, &$help, &$error) {
$error["choice][0"] = theme("theme_error", t("You must fill in at least two choices."));
}
}
else {
$help = variable_get("poll_help", "");
}
$node->teaser = poll_teaser($node);
return $error;
}
function poll_form(&$node, &$help, &$error) {
$admin = user_access("administer nodes");
$_duration = array(0 => t("Unlimited"), 86400 => format_interval(86400), 172800 => format_interval(172800), 345600 => format_interval(345600), 604800 => format_interval(604800), 1209600 => format_interval(1209600), 2419200 => format_interval(2419200), 4838400 => format_interval(4838400), 9676800 => format_interval(9676800), 31536000 => format_interval(31536000));
$_active = array(0 => t("Closed"), 1 => t("Active"));
$node->choices = $node->choices ? $node->choices : max(2, count($node->choice) ? count($node->choice) : 5);
$help = variable_get("poll_help", "");
if (function_exists("taxonomy_node_form")) {
$output = implode("", taxonomy_node_form("poll", $node));
......@@ -380,8 +386,4 @@ function poll_update($node) {
}
}
function poll_validate(&$node) {
$node->teaser = poll_teaser($node);
}
?>
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