diff options
author | Dries Buytaert <dries@buytaert.net> | 2003-09-20 21:28:52 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2003-09-20 21:28:52 +0000 |
commit | 2c5272578d4d362add1cf101f3148ff5e784ae2e (patch) | |
tree | 890b3f2c1a60e084e0f69d65e5e4c00b8956a6a2 /modules/poll.module | |
parent | 85eebfb5ed16a85bd40008e5f045a288bf25dee8 (diff) | |
download | brdo-2c5272578d4d362add1cf101f3148ff5e784ae2e.tar.gz brdo-2c5272578d4d362add1cf101f3148ff5e784ae2e.tar.bz2 |
- Updated the poll module to use the _validate hook. Fixes bug #2918 reported
by Jonathan.
Diffstat (limited to 'modules/poll.module')
-rw-r--r-- | modules/poll.module | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/modules/poll.module b/modules/poll.module index ab8fbe9ea..b93cdbb8d 100644 --- a/modules/poll.module +++ b/modules/poll.module @@ -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); -} - ?> |