summaryrefslogtreecommitdiff
path: root/modules/node
diff options
context:
space:
mode:
Diffstat (limited to 'modules/node')
-rw-r--r--modules/node/content_types.inc19
-rw-r--r--modules/node/node.api.php50
-rw-r--r--modules/node/node.module8
3 files changed, 50 insertions, 27 deletions
diff --git a/modules/node/content_types.inc b/modules/node/content_types.inc
index 0a0e0e692..207a3d864 100644
--- a/modules/node/content_types.inc
+++ b/modules/node/content_types.inc
@@ -349,10 +349,23 @@ function node_type_form_submit($form, &$form_state) {
}
/**
- * Implement hook_node_type().
+ * Implement hook_node_type_insert().
*/
-function node_node_type($op, $info) {
- if ($op != 'delete' && !empty($info->old_type) && $info->old_type != $info->type) {
+function node_node_type_insert($info) {
+ if (!empty($info->old_type) && $info->old_type != $info->type) {
+ $update_count = node_type_update_nodes($info->old_type, $info->type);
+
+ if ($update_count) {
+ drupal_set_message(format_plural($update_count, 'Changed the content type of 1 post from %old-type to %type.', 'Changed the content type of @count posts from %old-type to %type.', array('%old-type' => $info->old_type, '%type' => $info->type)));
+ }
+ }
+}
+
+/**
+ * Implement hook_node_type_update().
+ */
+function node_node_type_update($info) {
+ if (!empty($info->old_type) && $info->old_type != $info->type) {
$update_count = node_type_update_nodes($info->old_type, $info->type);
if ($update_count) {
diff --git a/modules/node/node.api.php b/modules/node/node.api.php
index 818528082..24ccf1ffa 100644
--- a/modules/node/node.api.php
+++ b/modules/node/node.api.php
@@ -626,35 +626,45 @@ function hook_ranking() {
/**
+ * Act on node type creation.
+ *
+ * This hook allows modules to take action when a node type is created.
+ *
+ * @param $info
+ * The node type object which is being created.
+ */
+function hook_node_type_insert($info) {
+}
+
+/**
* Act on node type changes.
*
* This hook allows modules to take action when a node type is modified.
*
- * @param $op
- * What is being done to $info. Possible values:
- * - "delete"
- * - "insert"
- * - "update"
* @param $info
- * The node type object on which $op is being performed.
- */
-function hook_node_type($op, $info) {
-
- switch ($op) {
- case 'delete':
- variable_del('comment_' . $info->type);
- break;
- case 'update':
- if (!empty($info->old_type) && $info->old_type != $info->type) {
- $setting = variable_get('comment_' . $info->old_type, COMMENT_NODE_OPEN);
- variable_del('comment_' . $info->old_type);
- variable_set('comment_' . $info->type, $setting);
- }
- break;
+ * The node type object which is being modified.
+ */
+function hook_node_type_update($info) {
+ if (!empty($info->old_type) && $info->old_type != $info->type) {
+ $setting = variable_get('comment_' . $info->old_type, COMMENT_NODE_OPEN);
+ variable_del('comment_' . $info->old_type);
+ variable_set('comment_' . $info->type, $setting);
}
}
/**
+ * Act on node type deletion.
+ *
+ * This hook allows modules to take action when a node type is deleted.
+ *
+ * @param $info
+ * The node type object which is being deleted.
+ */
+function hook_node_type_delete($info) {
+ variable_del('comment_' . $info->type);
+}
+
+/**
* Define access restrictions.
*
* This hook allows node modules to limit access to the node types they
diff --git a/modules/node/node.module b/modules/node/node.module
index b66b423f0..40023b9af 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -431,7 +431,7 @@ function node_type_save($info) {
field_attach_rename_bundle($type->old_type, $type->type);
}
node_configure_fields($type);
- module_invoke_all('node_type', 'update', $type);
+ module_invoke_all('node_type_update', $type);
return SAVED_UPDATED;
}
else {
@@ -442,7 +442,7 @@ function node_type_save($info) {
field_attach_create_bundle($type->type);
node_configure_fields($type);
- module_invoke_all('node_type', 'insert', $type);
+ module_invoke_all('node_type_insert', $type);
return SAVED_NEW;
}
}
@@ -517,7 +517,7 @@ function node_type_delete($type) {
db_delete('node_type')
->condition('type', $type)
->execute();
- module_invoke_all('node_type', 'delete', $info);
+ module_invoke_all('node_type_delete', $info);
}
/**
@@ -2614,7 +2614,7 @@ function node_access_needs_rebuild($rebuild = NULL) {
* large number of nodes).
* hook_update_N and any form submit handler are safe contexts to use the
* 'batch mode'. Less decidable cases (such as calls from hook_user,
- * hook_taxonomy, hook_node_type...) might consider using the non-batch mode.
+ * hook_taxonomy, etc...) might consider using the non-batch mode.
*/
function node_access_rebuild($batch_mode = FALSE) {
db_delete('node_access')->execute();