From 14b84fa2997b5e27046a70ac307a4241d724e466 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Thu, 12 Feb 2004 19:04:20 +0000 Subject: - Fixed bug #5831: added validation for posting to forum containers. Patch by UnConeD. --- modules/forum/forum.module | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'modules/forum/forum.module') diff --git a/modules/forum/forum.module b/modules/forum/forum.module index 7437346c0..890b8ef40 100644 --- a/modules/forum/forum.module +++ b/modules/forum/forum.module @@ -197,12 +197,20 @@ function forum_validate(&$node) { if ($node->taxonomy) { // Extract the node's proper topic ID. $vocabulary = variable_get('forum_nav_vocabulary', ''); + $containers = variable_get('forum_containers', array()); foreach ($node->taxonomy as $term) { if (db_result(db_query('SELECT COUNT(*) FROM {term_data} WHERE tid = %d AND vid = %d', $term, $vocabulary))) { - $node->tid = $term; + if (in_array($term, $containers)) { + $term = taxonomy_get_term($term); + $error['taxonomy'] = theme('error', t('The item \'%forum\' is only a container for forums. Please select one of the forums below it.', array('%forum' => $term->name))); + } + else { + $node->tid = $term; + } } } } + return $error; } function forum_form(&$node, &$error) { @@ -211,7 +219,7 @@ function forum_form(&$node, &$error) { $node->taxonomy[] = arg(3); } - $output = implode('', taxonomy_node_form('forum', $node)); + $output = implode('', taxonomy_node_form('forum', $node, $error)); if ($node->nid) { // if editing, give option to leave shadows -- cgit v1.2.3