summaryrefslogtreecommitdiff
path: root/modules/taxonomy/taxonomy.module
diff options
context:
space:
mode:
authorNeil Drumm <drumm@3064.no-reply.drupal.org>2006-10-31 17:01:04 +0000
committerNeil Drumm <drumm@3064.no-reply.drupal.org>2006-10-31 17:01:04 +0000
commit4573af1f55ce509ed3fe41f2fefe0826d41017ab (patch)
treebde8194188dc141364df371c7021e0cc76187bf7 /modules/taxonomy/taxonomy.module
parent12df72255cc05ef53fa546e1877275d2accac919 (diff)
downloadbrdo-4573af1f55ce509ed3fe41f2fefe0826d41017ab.tar.gz
brdo-4573af1f55ce509ed3fe41f2fefe0826d41017ab.tar.bz2
#80257 by Jaza. Add a hook for content type changes and use it for keeping vocabulary associations.
Diffstat (limited to 'modules/taxonomy/taxonomy.module')
-rw-r--r--modules/taxonomy/taxonomy.module18
1 files changed, 18 insertions, 0 deletions
diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module
index c1c4372cd..40fde59c7 100644
--- a/modules/taxonomy/taxonomy.module
+++ b/modules/taxonomy/taxonomy.module
@@ -814,6 +814,24 @@ function taxonomy_node_delete($nid) {
}
/**
+ * Implementation of hook_node_type().
+ */
+function taxonomy_node_type($op, $info) {
+ if ($op == 'update' && !empty($info->old_type) && $info->type != $info->old_type) {
+ if (db_num_rows(db_query("SELECT * from {vocabulary_node_types} WHERE type = '%s'", $info->old_type))) {
+ db_query("UPDATE {vocabulary_node_types} SET type = '%s' WHERE type = '%s'", $info->type, $info->old_type);
+ $num_updated = db_affected_rows();
+
+ if ($num_updated) {
+ $substr_pre = 'Changed the content type association of ';
+ $substr_post = strtr(' from %old-type to %type.', array('%old-type' => theme('placeholder', $info->old_type), '%type' => theme('placeholder', $info->type)));
+ drupal_set_message(format_plural($num_updated, $substr_pre .'1 vocabulary'. $substr_post, $substr_pre .'@count vocabularies'. $substr_post));
+ }
+ }
+ }
+}
+
+/**
* Find all term objects related to a given term ID.
*/
function taxonomy_get_related($tid, $key = 'tid') {