function revisioning_node_insert in Revisioning 8
Same name and namespace in other branches
- 7 revisioning.module \revisioning_node_insert()
Implements hook_node_insert().
New node.
File
- ./
revisioning.module, line 693 - Allows content to be updated and reviewed before submitting it for publication, while the current live revision remains unchanged and publicly visible until the changes have been reviewed and found fit for publication by a moderator.
Code
function revisioning_node_insert($node) {
revisioning_update_taxonomy_index($node, variable_get('revisioning_in_views_show_unpublished_content_terms', TRUE));
if (!empty($node->revision_moderation)) {
revisioning_set_status_message($node->status ? t('Initial revision created and published.') : t('Initial draft created, pending publication.'));
}
// Add revision usage records to files to prevent them being deleted.
$fields = field_info_instances('node', $node->type);
foreach ($fields as $field_name => $value) {
$field_info = field_info_field($field_name);
if ($field_info['type'] == 'file') {
$file_fields[$field_name] = $value;
}
}
if (!empty($file_fields)) {
foreach ($file_fields as $file_field) {
$files = field_get_items('node', $node, $file_field['field_name'], $node->language);
foreach ($files as $single_file) {
$file = (object) $single_file;
file_usage_add($file, 'revisioning', 'revision', $node->vid);
}
}
}
}