node_revision_generate.batch.inc in Node Revision Delete 7.3
Batch API callbacks for node_revision_generate module.
File
modules/node_revision_generate/node_revision_generate.batch.incView source
<?php
/**
* @file
* Batch API callbacks for node_revision_generate module.
*/
/**
* Batch operation to create a single revision.
*
* @param int $nid
* The node id.
* @param int $timestamp
* The timestamp.
* @param array $context
* The context.
*/
function node_revision_generate_create_operation($nid, $timestamp, array &$context) {
// Load the node to generate revision.
$node_entity = node_load($nid);
$node_entity->revision = TRUE;
$node_entity->log = 'Revision generated by Node Revision Generate module.';
// Set the timestamp for the revision, to actually be set in
// node_revision_generate_node_presave().
$node_entity->node_revision_generate = TRUE;
$node_entity->next_revision = $timestamp;
node_save($node_entity);
}
/**
* Batch Finished.
*
* @param bool $success
* If the batch finish well or not.
* @param array $results
* The batch results.
* @param array $operations
* The batch operations.
*/
function node_revision_generate_create_finished($success, array $results, array $operations) {
if ($success) {
drupal_set_message(t('Revisions generated for the selected content types.'), 'status', FALSE);
drupal_set_message(t('Revisions were generated up to the current date, no revisions were generated with a date in the future. So, depending on this maybe we will not generate the number of revisions you expect.'), 'warning', FALSE);
}
else {
$error_operation = reset($operations);
drupal_set_message(t('An error occurred while processing @operation with arguments: @args', array(
'@operation' => $error_operation[0],
'@args' => print_r($error_operation[0], TRUE),
)));
}
}
Functions
Name | Description |
---|---|
node_revision_generate_create_finished | Batch Finished. |
node_revision_generate_create_operation | Batch operation to create a single revision. |