#652372 by matason, ksenzee, naxoc, jpmckinney, sun: Don't allow users to add forum topics when no forums exist.
parent
28fb603ae3
commit
0ad37ad057
|
@ -58,6 +58,7 @@ function forum_enable() {
|
|||
'entity_type' => 'node',
|
||||
'label' => $vocabulary->name,
|
||||
'bundle' => 'forum',
|
||||
'required' => TRUE,
|
||||
'widget' => array(
|
||||
'type' => 'options_select',
|
||||
),
|
||||
|
|
|
@ -299,7 +299,13 @@ function forum_node_validate($node, $form) {
|
|||
if (!empty($node->taxonomy_forums[$langcode])) {
|
||||
// Extract the node's proper topic ID.
|
||||
$containers = variable_get('forum_containers', array());
|
||||
foreach ($node->taxonomy_forums[$langcode] as $item) {
|
||||
foreach ($node->taxonomy_forums[$langcode] as $delta => $item) {
|
||||
// If no term was selected (e.g. when no terms exist yet), remove the
|
||||
// item.
|
||||
if (empty($item['tid'])) {
|
||||
unset($node->taxonomy_forums[$langcode][$delta]);
|
||||
continue;
|
||||
}
|
||||
$term = taxonomy_term_load($item['tid']);
|
||||
$used = db_query_range('SELECT 1 FROM {taxonomy_term_data} WHERE tid = :tid AND vid = :vid',0 , 1, array(
|
||||
':tid' => $term->tid,
|
||||
|
|
|
@ -90,6 +90,17 @@ class ForumTestCase extends DrupalWebTestCase {
|
|||
$this->assertResponse(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Forum nodes should not be created without choosing forum from select list.
|
||||
*/
|
||||
function testAddOrphanTopic() {
|
||||
$this->drupalLogin($this->admin_user);
|
||||
$this->drupalPost('node/add/forum', array('title' => $this->randomName(10), 'body[' . LANGUAGE_NONE .'][0][value]' => $this->randomName(120)), t('Save'));
|
||||
|
||||
$nid_count = db_query('SELECT COUNT(nid) FROM {node}')->fetchField();
|
||||
$this->assertEqual(0, $nid_count, t('A forum node was not created.'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Run admin tests on the admin user.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue