summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerhard Killesreiter <killes_www_drop_org@227.no-reply.drupal.org>2006-03-23 21:46:35 +0000
committerGerhard Killesreiter <killes_www_drop_org@227.no-reply.drupal.org>2006-03-23 21:46:35 +0000
commitd11c07502de0861fcc06d908fd7811ceccedeec4 (patch)
tree97300de2841fb850184089320c3f7567ece5c18f
parent667298972f2d0aea58239593010e73c15afd9d65 (diff)
downloadbrdo-d11c07502de0861fcc06d908fd7811ceccedeec4.tar.gz
brdo-d11c07502de0861fcc06d908fd7811ceccedeec4.tar.bz2
#54910, Forum and taxonomy term delete work only superficially, patch by Zen
-rw-r--r--modules/forum.module32
-rw-r--r--modules/forum/forum.module32
-rw-r--r--modules/taxonomy.module5
-rw-r--r--modules/taxonomy/taxonomy.module5
4 files changed, 50 insertions, 24 deletions
diff --git a/modules/forum.module b/modules/forum.module
index a79234c0a..6b0038427 100644
--- a/modules/forum.module
+++ b/modules/forum.module
@@ -148,16 +148,27 @@ function forum_nodeapi(&$node, $op, $teaser, $page) {
/**
* Implementation of hook_taxonomy().
*/
-function forum_taxonomy($op, $type, $object = NULL) {
- if ($op == 'delete' && $type == 'term' && $object->vid == _forum_get_vid()) {
- $results = db_query('SELECT f.nid FROM {forum} f WHERE f.tid = %d', $object->tid);
- while ($node = db_fetch_object($results)) {
- node_delete($node->nid);
+function forum_taxonomy($op, $type, $term = NULL) {
+ if ($op == 'delete' && $term->vid == _forum_get_vid()) {
+ switch ($type) {
+ case 'term':
+ $results = db_query('SELECT f.nid FROM {forum} f WHERE f.tid = %d', $term->tid);
+ while ($node = db_fetch_object($results)) {
+ // node_delete will also remove any association with non-forum vocabularies.
+ node_delete($node->nid);
+ }
+
+ // For containers, remove the tid from the forum_containers variable.
+ $containers = variable_get('forum_containers', array());
+ if ($key = array_search($term->tid, $containers)) {
+ unset($containers[$key]);
+ }
+ variable_set('forum_containers', $containers);
+ break;
+ case 'vocabulary':
+ variable_del('forum_nav_vocabulary');
}
}
- elseif ($op == 'delete' && $type == 'vocabulary' && $object->vid == _forum_get_vid()) {
- variable_del('forum_nav_vocabulary');
- }
}
/**
@@ -517,7 +528,7 @@ function _forum_confirm_delete($tid) {
$form['tid'] = array('#type' => 'value', '#value' => $tid);
$form['name'] = array('#type' => 'value', '#value' => $term->name);
- return confirm_form('forum_confirm_delete', $form, t('Are you sure you want to delete the forum %name?', array('%name' => theme('placeholder', $term->name))), 'admin/forums', t('Deleting a forum or container will delete all sub-forums as well. This action cannot be undone.'), t('Delete'), t('Cancel'));
+ return confirm_form('forum_confirm_delete', $form, t('Are you sure you want to delete the forum %name?', array('%name' => theme('placeholder', $term->name))), 'admin/forums', t('Deleting a forum or container will delete all sub-forums and associated posts as well. This action cannot be undone.'), t('Delete'), t('Cancel'));
}
/**
@@ -525,7 +536,8 @@ function _forum_confirm_delete($tid) {
*/
function forum_confirm_delete_submit($form_id, $form_values) {
taxonomy_del_term($form_values['tid']);
- drupal_set_message(t('The forum %term has been deleted.', array('%term' => theme('placeholder', $form_values['name']))));
+ drupal_set_message(t('The forum %term and all sub-forums and associated posts have been deleted.', array('%term' => theme('placeholder', $form_values['name']))));
+ watchdog('content', t('forum: deleted %term and all its sub-forums and associated posts.', array('%term' => theme('placeholder', $form_values['name']))));
return 'admin/forum';
}
diff --git a/modules/forum/forum.module b/modules/forum/forum.module
index a79234c0a..6b0038427 100644
--- a/modules/forum/forum.module
+++ b/modules/forum/forum.module
@@ -148,16 +148,27 @@ function forum_nodeapi(&$node, $op, $teaser, $page) {
/**
* Implementation of hook_taxonomy().
*/
-function forum_taxonomy($op, $type, $object = NULL) {
- if ($op == 'delete' && $type == 'term' && $object->vid == _forum_get_vid()) {
- $results = db_query('SELECT f.nid FROM {forum} f WHERE f.tid = %d', $object->tid);
- while ($node = db_fetch_object($results)) {
- node_delete($node->nid);
+function forum_taxonomy($op, $type, $term = NULL) {
+ if ($op == 'delete' && $term->vid == _forum_get_vid()) {
+ switch ($type) {
+ case 'term':
+ $results = db_query('SELECT f.nid FROM {forum} f WHERE f.tid = %d', $term->tid);
+ while ($node = db_fetch_object($results)) {
+ // node_delete will also remove any association with non-forum vocabularies.
+ node_delete($node->nid);
+ }
+
+ // For containers, remove the tid from the forum_containers variable.
+ $containers = variable_get('forum_containers', array());
+ if ($key = array_search($term->tid, $containers)) {
+ unset($containers[$key]);
+ }
+ variable_set('forum_containers', $containers);
+ break;
+ case 'vocabulary':
+ variable_del('forum_nav_vocabulary');
}
}
- elseif ($op == 'delete' && $type == 'vocabulary' && $object->vid == _forum_get_vid()) {
- variable_del('forum_nav_vocabulary');
- }
}
/**
@@ -517,7 +528,7 @@ function _forum_confirm_delete($tid) {
$form['tid'] = array('#type' => 'value', '#value' => $tid);
$form['name'] = array('#type' => 'value', '#value' => $term->name);
- return confirm_form('forum_confirm_delete', $form, t('Are you sure you want to delete the forum %name?', array('%name' => theme('placeholder', $term->name))), 'admin/forums', t('Deleting a forum or container will delete all sub-forums as well. This action cannot be undone.'), t('Delete'), t('Cancel'));
+ return confirm_form('forum_confirm_delete', $form, t('Are you sure you want to delete the forum %name?', array('%name' => theme('placeholder', $term->name))), 'admin/forums', t('Deleting a forum or container will delete all sub-forums and associated posts as well. This action cannot be undone.'), t('Delete'), t('Cancel'));
}
/**
@@ -525,7 +536,8 @@ function _forum_confirm_delete($tid) {
*/
function forum_confirm_delete_submit($form_id, $form_values) {
taxonomy_del_term($form_values['tid']);
- drupal_set_message(t('The forum %term has been deleted.', array('%term' => theme('placeholder', $form_values['name']))));
+ drupal_set_message(t('The forum %term and all sub-forums and associated posts have been deleted.', array('%term' => theme('placeholder', $form_values['name']))));
+ watchdog('content', t('forum: deleted %term and all its sub-forums and associated posts.', array('%term' => theme('placeholder', $form_values['name']))));
return 'admin/forum';
}
diff --git a/modules/taxonomy.module b/modules/taxonomy.module
index eee09173a..457875fa8 100644
--- a/modules/taxonomy.module
+++ b/modules/taxonomy.module
@@ -485,7 +485,7 @@ function taxonomy_del_term($tid) {
}
}
- $term = (array) taxonomy_get_term($tid);
+ $term = taxonomy_get_term($tid);
db_query('DELETE FROM {term_data} WHERE tid = %d', $tid);
db_query('DELETE FROM {term_hierarchy} WHERE tid = %d', $tid);
@@ -494,13 +494,14 @@ function taxonomy_del_term($tid) {
db_query('DELETE FROM {term_node} WHERE tid = %d', $tid);
module_invoke_all('taxonomy', 'delete', 'term', $term);
- return SAVED_DELETED;
}
$tids = $orphans;
}
cache_clear_all();
+
+ return SAVED_DELETED;
}
function _taxonomy_confirm_del_term($tid) {
diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module
index eee09173a..457875fa8 100644
--- a/modules/taxonomy/taxonomy.module
+++ b/modules/taxonomy/taxonomy.module
@@ -485,7 +485,7 @@ function taxonomy_del_term($tid) {
}
}
- $term = (array) taxonomy_get_term($tid);
+ $term = taxonomy_get_term($tid);
db_query('DELETE FROM {term_data} WHERE tid = %d', $tid);
db_query('DELETE FROM {term_hierarchy} WHERE tid = %d', $tid);
@@ -494,13 +494,14 @@ function taxonomy_del_term($tid) {
db_query('DELETE FROM {term_node} WHERE tid = %d', $tid);
module_invoke_all('taxonomy', 'delete', 'term', $term);
- return SAVED_DELETED;
}
$tids = $orphans;
}
cache_clear_all();
+
+ return SAVED_DELETED;
}
function _taxonomy_confirm_del_term($tid) {