summaryrefslogtreecommitdiff
path: root/modules/forum/forum.module
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2006-08-31 21:58:36 +0000
committerDries Buytaert <dries@buytaert.net>2006-08-31 21:58:36 +0000
commit49fa25fb7658ada5ee242853d3ed301d0a0b05a9 (patch)
tree12fb57e50398413cc420df5ed486b77b9c996aa2 /modules/forum/forum.module
parentc64db1da29a6b2067f09e66e5e85e8877b489cb0 (diff)
downloadbrdo-49fa25fb7658ada5ee242853d3ed301d0a0b05a9.tar.gz
brdo-49fa25fb7658ada5ee242853d3ed301d0a0b05a9.tar.bz2
- Rollback of patch #68418: clean up node submit hooks. Needs more thinkering.
Restores the old node API.
Diffstat (limited to 'modules/forum/forum.module')
-rw-r--r--modules/forum/forum.module80
1 files changed, 44 insertions, 36 deletions
diff --git a/modules/forum/forum.module b/modules/forum/forum.module
index 1ebc7175c..685c96a2f 100644
--- a/modules/forum/forum.module
+++ b/modules/forum/forum.module
@@ -231,31 +231,6 @@ function forum_form_alter($form_id, &$form) {
unset($form['nodes']['forum']);
}
}
-
- if ($form_id == 'node_delete_confirm' && $form['node']['#value']->type == 'forum') {
- $form['#submit']['forum_node_delete_confirm_submit'] = array();
- }
-}
-
-/**
- * Check in particular that only a "leaf" term in the associated taxonomy
- * vocabulary is selected, not a "container" term.
- */
-function forum_node_validate($form_id, $node) {
- $node = (object)$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))) {
- 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' => $term->name)));
- }
- }
- }
- }
}
/**
@@ -350,15 +325,16 @@ function forum_view(&$node, $teaser = FALSE, $page = FALSE) {
}
/**
- * An early submit handler of the forum_node_form. Runs before the node is saved.
+ * Implementation of hook_submit().
+ *
+ * Check in particular that only a "leaf" term in the associated taxonomy
+ * vocabulary is selected, not a "container" term.
*/
-function forum_node_submit_early($form_id, &$node) {
- $node = (object)$node;
-
+function forum_submit(&$node) {
// Make sure all fields are set properly:
$node->icon = $node->icon ? $node->icon : '';
- if (!empty($node->taxonomy)) {
+ if ($node->taxonomy) {
// Get the forum terms from the (cached) tree
$tree = taxonomy_get_tree(_forum_get_vid());
if ($tree) {
@@ -379,13 +355,35 @@ function forum_node_submit_early($form_id, &$node) {
}
}
}
+}
- $node = (array)$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) {
+ 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' => $term->name)));
+ }
+ }
+ }
+ }
}
-function forum_node_submit($form_id, $node) {
- $node = (object)$node;
- if ($node->is_new) {
+/**
+ * Implementation of hook_update().
+ */
+function forum_update($node) {
+ if ($node->revision) {
db_query("INSERT INTO {forum} (nid, vid, tid) VALUES (%d, %d, %d)", $node->nid, $node->vid, $node->tid);
}
else {
@@ -424,8 +422,18 @@ function forum_prepare(&$node) {
}
}
-function forum_node_delete_confirm_submit($form_id, $form_values) {
- db_query('DELETE FROM {forum} WHERE nid = %d', $form_values['node']->nid);
+/**
+ * Implementation of hook_insert().
+ */
+function forum_insert($node) {
+ db_query('INSERT INTO {forum} (nid, vid, tid) VALUES (%d, %d, %d)', $node->nid, $node->vid, $node->tid);
+}
+
+/**
+ * Implementation of hook_delete().
+ */
+function forum_delete(&$node) {
+ db_query('DELETE FROM {forum} WHERE nid = %d', $node->nid);
}
/**