summaryrefslogtreecommitdiff
path: root/modules/forum
diff options
context:
space:
mode:
authorSteven Wittens <steven@10.no-reply.drupal.org>2005-11-12 02:54:13 +0000
committerSteven Wittens <steven@10.no-reply.drupal.org>2005-11-12 02:54:13 +0000
commit85492ae9a548f0bfb58b673ac555f73d4b7977ed (patch)
treee980f521b5a0d66f7eac6020902de1628dba6633 /modules/forum
parent76226df8672409b23856b8ade20d1d884d934af8 (diff)
downloadbrdo-85492ae9a548f0bfb58b673ac555f73d4b7977ed.tar.gz
brdo-85492ae9a548f0bfb58b673ac555f73d4b7977ed.tar.bz2
#36791: node_validate was called twice
Diffstat (limited to 'modules/forum')
-rw-r--r--modules/forum/forum.module41
1 files changed, 28 insertions, 13 deletions
diff --git a/modules/forum/forum.module b/modules/forum/forum.module
index 931033a98..726bbf938 100644
--- a/modules/forum/forum.module
+++ b/modules/forum/forum.module
@@ -506,30 +506,21 @@ function forum_view(&$node, $teaser = FALSE, $page = FALSE) {
}
/**
- * Implementation of hook_validate().
+ * Implementation of hook_execute().
*
* Check in particular that only a "leaf" term in the associated taxonomy
* vocabulary is selected, not a "container" term.
*/
-function forum_validate(&$node) {
+function forum_execute(&$node) {
// Make sure all fields are set properly:
$node->icon = $node->icon ? $node->icon : '';
- node_validate_title($node,t('You have to specify a subject.'));
-
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))) {
- if (in_array($term, $containers)) {
- $term = taxonomy_get_term($term);
- form_set_error('taxonomy', t('The item %forum is only a container for forums. Please select one of the forums below it.', array('%forum' => theme('placeholder', $term->name))));
- }
- else {
- $node->tid = $term;
- }
+ $node->tid = $term;
}
}
if ($node->tid && $node->shadow) {
@@ -543,6 +534,30 @@ function forum_validate(&$node) {
}
/**
+ * Implementation of hook_validate().
+ *
+ * Check in particular that only a "leaf" term in the associated taxonomy
+ * vocabulary is selected, not a "container" term.
+ */
+function forum_validate($node) {
+ node_validate_title($node,t('You have to specify a subject.'));
+
+ 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))) {
+ if (in_array($term, $containers)) {
+ $term = taxonomy_get_term($term);
+ form_set_error('taxonomy', t('The item %forum is only a container for forums. Please select one of the forums below it.', array('%forum' => theme('placeholder', $term->name))));
+ }
+ }
+ }
+ }
+}
+
+/**
* Implementation of hook_update().
*/
function forum_update($node) {
@@ -571,7 +586,7 @@ function forum_form(&$node) {
if ($node->nid) {
// if editing, give option to leave shadows
$shadow = (count(taxonomy_node_get_terms($node->nid)) > 1);
- $form['shadow'] = array('#type' => 'checkbox', 'title' => t('Leave shadow copy'), '#default_value' => $shadow, '#description' => t('If you move this topic, you can leave a link in the old forum to the new forum.'));
+ $form['shadow'] = array('#type' => 'checkbox', '#title' => t('Leave shadow copy'), '#default_value' => $shadow, '#description' => t('If you move this topic, you can leave a link in the old forum to the new forum.'));
}
$form['body'] = array('#type' => 'textarea', '#title' => t('Body'), '#default_value' => $node->body, '#required' => TRUE