Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
project
drupal
Commits
d058394c
Commit
d058394c
authored
Mar 05, 2010
by
Dries
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Patch
#652176
by bleen18, David_Rothstein, JacobSingh: fixed 'Forums' term defaulting to 'None'.
parent
76a4f8fe
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
24 deletions
+12
-24
modules/forum/forum.module
modules/forum/forum.module
+7
-12
modules/forum/forum.test
modules/forum/forum.test
+5
-12
No files found.
modules/forum/forum.module
View file @
d058394c
...
...
@@ -255,18 +255,6 @@ function forum_node_view($node, $view_mode) {
}
}
/**
* Implements hook_node_prepare().
*/
function
forum_node_prepare
(
$node
)
{
if
(
_forum_node_check_node_type
(
$node
))
{
if
(
empty
(
$node
->
nid
))
{
// New topic
$node
->
taxonomy_forums
[
0
][
'tid'
]
=
arg
(
3
);
}
}
}
/**
* Implements hook_node_validate().
*
...
...
@@ -578,6 +566,13 @@ function forum_form_alter(&$form, $form_state, $form_id) {
// Make the vocabulary required for 'real' forum-nodes.
$form
[
'taxonomy_forums'
][
$langcode
][
'#required'
]
=
TRUE
;
$form
[
'taxonomy_forums'
][
$langcode
][
'#multiple'
]
=
FALSE
;
if
(
empty
(
$form
[
'taxonomy_forums'
][
$langcode
][
'#default_value'
]))
{
// If there is no default forum already selected, try to get the forum
// ID from the URL (e.g., if we are on a page like node/add/forum/3, we
// expect "3" to be the ID of the forum that was requested).
$requested_forum_id
=
arg
(
3
);
$form
[
'taxonomy_forums'
][
$langcode
][
'#default_value'
]
=
is_numeric
(
$requested_forum_id
)
?
$requested_forum_id
:
NULL
;
}
}
}
...
...
modules/forum/forum.test
View file @
d058394c
...
...
@@ -261,23 +261,15 @@ class ForumTestCase extends DrupalWebTestCase {
$title
=
$this
->
randomName
(
20
);
$body
=
$this
->
randomName
(
200
);
// Without this being set, post variable equals the first non-blank in
// select items list.
$tid
=
$forum
[
'tid'
];
$langcode
=
LANGUAGE_NONE
;
$edit
=
array
(
"title"
=>
$title
,
"body[
$langcode
][0][value]"
=>
$body
,
"taxonomy_forums[
$langcode
]"
=>
$tid
,
);
// TODO The taxonomy select value is set by drupal code when the tid is part
// of the url. However, unless a tid is passed in the edit array, when
// drupalPost() runs, the select value is not preserved. Instead, the post
// variables seem to pick up the first non-blank value in the select list.
// Create forum topic.
$this
->
drupalPost
(
'node/add/forum/'
,
$edit
,
t
(
'Save'
));
// Create the forum topic, preselecting the forum ID via a URL parameter.
$this
->
drupalPost
(
'node/add/forum/'
.
$forum
[
'tid'
],
$edit
,
t
(
'Save'
));
$type
=
t
(
'Forum topic'
);
if
(
$container
)
{
$this
->
assertNoRaw
(
t
(
'@type %title has been created.'
,
array
(
'@type'
=>
$type
,
'%title'
=>
$title
)),
t
(
'Forum topic was not created'
));
...
...
@@ -289,9 +281,10 @@ class ForumTestCase extends DrupalWebTestCase {
$this
->
assertNoRaw
(
t
(
'The item %title is a forum container, not a forum.'
,
array
(
'%title'
=>
$forum
[
'name'
])),
t
(
'No error message was shown'
));
}
// Retrieve node object.
// Retrieve node object
, ensure that the topic was created and in the proper forum
.
$node
=
$this
->
drupalGetNodeByTitle
(
$title
);
$this
->
assertTrue
(
$node
!=
NULL
,
t
(
'Node @title was loaded'
,
array
(
'@title'
=>
$title
)));
$this
->
assertEqual
(
$node
->
taxonomy_forums
[
LANGUAGE_NONE
][
0
][
'tid'
],
$forum
[
'tid'
],
'Saved forum topic was in the expected forum'
);
// View forum topic.
$this
->
drupalGet
(
'node/'
.
$node
->
nid
);
...
...
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