View source
<?php
require_once dirname(__FILE__) . '/revision_deletion.helpers.inc';
function revision_deletion_menu() {
$items = array();
$items['admin/config/content/revision_deletion'] = array(
'title' => 'Revision Deletion',
'description' => 'Configure or manually run the revision deletion module.',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'revision_deletion_admin_overview',
),
'file' => 'revision_deletion.admin.inc',
'access arguments' => array(
'administer revision_deletion',
),
'type' => MENU_NORMAL_ITEM,
);
$items['admin/config/content/revision_deletion/list'] = array(
'title' => 'List',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'revision_deletion_admin_overview',
),
'file' => 'revision_deletion.admin.inc',
'access arguments' => array(
'administer revision_deletion',
),
'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items['admin/config/content/revision_deletion/settings'] = array(
'title' => 'Settings',
'description' => 'Configure settings for the revision deletion module',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'revision_deletion_settings_form',
),
'file' => 'revision_deletion.admin.inc',
'access arguments' => array(
'administer revision_deletion',
),
'type' => MENU_LOCAL_TASK,
);
$items['admin/config/content/revision_deletion/node/%node'] = array(
'page callback' => 'revision_deletion_node',
'page arguments' => array(
5,
),
'access arguments' => array(
'administer revision_deletion',
),
'file' => 'revision_deletion.admin.inc',
'type' => MENU_CALLBACK,
);
return $items;
}
function revision_deletion_menu_alter(&$items) {
if (variable_get('revision_deletion_list_override')) {
$items['node/%node/revisions']['page callback'] = 'revision_deletion_node';
$items['node/%node/revisions']['file'] = 'revision_deletion.module';
$items['node/%node/revisions']['access_callback'] = '_revision_deletion_access';
$items['node/%node/revisions']['module'] = 'revision_deletion';
}
}
function revision_deletion_permission() {
return array(
'administer revision_deletion' => array(
'title' => t('Administer Revision Deletion'),
'description' => t('Allow access to configure the module settings.'),
),
);
}
function revision_deletion_help($path, $arg) {
switch ($path) {
case 'admin/help#revision_deletion':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('This module will greatly speed up the task of deleting old revisions of nodes. The database clutter and space can be quickly reclaimed as this module, on cron runs, will delete aged revisions (never the current revision) of nodes older than a set period of time.') . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Configuring content types') . '</dt>';
$output .= '<dd>' . t('To configure the module visit the <a href="@config-page">Revision Deletion Settings</a> page, possible settings include node type, the age of node revision before being deleted, along with a cron frequency setting. For this you need the <em>Administer Revision Deletion</em> permission.', array(
'@config-page' => url('admin/config/content/revision_deletion/settings'),
)) . '</dd>';
$output .= '<dt>' . t('Deleting revisions') . '</dt>';
$output .= '<dd>' . t('Deletions will occurs on cron run or can be manually run at <a href="@list-page">Revision Deletion</a> page where a review screen will display all the node revisions that meet the settings criteria.', array(
'@list-page' => url('admin/config/content/revision_deletion'),
)) . '</dd>';
$output .= '</dl>';
$output .= '</dl>';
return $output;
case 'admin/config/content/revision_deletion/settings':
return '<p>' . t('These settings control which revisions may be deleted, how often, and from which types of content.') . '</p>';
}
}
function _revision_deletion_access($node, $op = 'delete') {
return _node_revision_access($node, $op) || user_access('administer revision_deletion');
}
function revision_deletion_cron() {
$last_update = variable_get('revision_deletion_cron');
$frequency = variable_get('revision_deletion_frequency');
$difference = $frequency == 0 ? 0 : time() - $frequency;
if ($difference > $last_update) {
$revisions = _revision_deletion_get_list();
foreach ($revisions as $revision) {
if ($revision->select) {
_revision_deletion_delete_revision($revision->vid);
}
}
variable_set('revision_deletion_cron', time());
}
}