Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
project
drupal
Commits
2c527257
Commit
2c527257
authored
Sep 20, 2003
by
Dries
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Updated the poll module to use the _validate hook. Fixes bug
#2918
reported
by Jonathan.
parent
85eebfb5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
28 deletions
+32
-28
modules/poll.module
modules/poll.module
+16
-14
modules/poll/poll.module
modules/poll/poll.module
+16
-14
No files found.
modules/poll.module
View file @
2c527257
...
...
@@ -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
);
}
?>
modules/poll/poll.module
View file @
2c527257
...
...
@@ -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
);
}
?>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment