Index: revision_deletion.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/revision_deletion/revision_deletion.module,v retrieving revision 1.2.2.7 diff -u -r1.2.2.7 revision_deletion.module --- revision_deletion.module 2 Jan 2009 05:00:13 -0000 1.2.2.7 +++ revision_deletion.module 12 Aug 2009 21:48:49 -0000 @@ -6,7 +6,7 @@ * Node Revision Deletion, written by Greg Holsclaw */ -define('REV_DEL_PERM', 'mass delete revisions'); +define('REV_DEL_PERM', 'mass delete revisions'); /** * Implementation of hook_perm(). @@ -22,12 +22,19 @@ switch ($section) { case 'admin/help#revision_deletion': return 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. Options include frequency of the cron deletion job, and the age of revisions before being deleted. Cron.php must be run to execute.'); + case 'admin/modules#description': - return t('Delete old revision of nodes quickly'); + return t('Delete old revisions of nodes quickly.'); + + case 'admin/content/revision_deletion': + case 'admin/content/revision_deletion/list': + return t('Using revisions is a good way to improve the integrity of your node content; however it may result in a significant increase in your database size. This page lists the nodes that currently have revisions and allows you to delete them according to your settings.'); + + case 'admin/content/revision_deletion/settings': + return t('These settings control which revisions may be deleted, how often, and from which types of content.'); } } - /** * Implementation of hook_menu(). */ @@ -37,72 +44,92 @@ if ($may_cache) { $items[] = array( 'path' => 'admin/content/revision_deletion', - 'callback' => 'revision_deletion_page', + 'title' => t('Revision deletion'), + 'callback' => 'revision_deletion_settings_page', 'title' => t('Revisions to Mass Delete'), 'access' => user_access(REV_DEL_PERM), - 'type' => MENU_NORMAL_ITEM - ); + 'type' => MENU_NORMAL_ITEM, + 'description' => t('Configure or manually run the revision deletion module'), + ); + + $items[] = array( + 'path' => 'admin/content/revision_deletion/list', + 'callback' => 'revision_deletion_page', + 'title' => t('List'), + 'access' => user_access(REV_DEL_PERM), + 'type' => MENU_DEFAULT_LOCAL_TASK, + ); + $items[] = array( 'path' => 'admin/content/revision_deletion/settings', - 'title' => t('Revision deletion'), + 'title' => t('Settings'), 'callback arguments' => array('revision_deletion_settings'), 'callback' => 'drupal_get_form', 'access' => user_access('administer site configuration'), - 'type' => MENU_NORMAL_ITEM, + 'type' => MENU_LOCAL_TASK, 'description' => t('Configure settings for the revision deletion module'), - ); + ); } return $items; } function revision_deletion_settings() { - $frequency = drupal_map_assoc(array(86400, 604800, 1209600, 2419200, 4838400), 'format_interval'); - $age = drupal_map_assoc(array(60, 3600, 86400, 604800, 2419200, 4838400, 9676800, 15724800, 31449600), 'format_interval'); + drupal_add_css(drupal_get_path('module', 'revision_deletion') .'/revision_deletion.css'); + $frequency = array(0 => 'Manual'); + $frequency += drupal_map_assoc(array(86400, 604800, 1209600, 2419200, 4838400), 'format_interval'); + $age = drupal_map_assoc(array(900, 1800, 3600, 86400, 604800, 2419200, 4838400, 9676800, 15724800, 31449600), 'format_interval'); $form['rev_del'] = array( '#type' => 'fieldset', - '#title' => t('Revision Mass Deletion Settings') - ); - - //Set revision frequency interval + '#title' => t('Revision Mass Deletion Settings'), + ); + + // Set revision frequency interval. $form['rev_del']['revision_delete_freq'] = array( - '#type' => 'select', - '#title' => t('Cron Settings'), - '#default_value' => variable_get('revision_delete_freq', 604800), + '#type' => 'radios', + '#title' => t('Cron interval'), + '#default_value' => variable_get('revision_delete_freq', 0), '#options' => $frequency, - '#description' => t('Frequency of the mass revision delete cron jobs.') - ); - - //Set revision age for deletion + '#size' => 6, + '#description' => t('Frequency of the scheduled mass revision deleton.'), + '#prefix' => '
', + ); + + // Set revision age for deletion. $form['rev_del']['revision_delete_age'] = array( - '#type' => 'select', - '#title' => t('Revision Age Setting'), + '#type' => 'radios', + '#title' => t('Revision Age'), '#default_value' => variable_get('revision_delete_age', 2419200), '#options' => $age, - '#description' => t('Age in days of revisions that should be deleted.') - ); - - //Set node types to be deleted + '#description' => t('Age of revisions that should be deleted.'), + '#prefix' => '', + ); + + // Set node types to be deleted. $form['rev_del']['revision_delete'] = array( - '#type' => 'select', - '#title' => t('Select node types for revision deletion. Multiple select enabled.'), + '#type' => 'checkboxes', + '#title' => t('Node types'), '#default_value' => variable_get('revision_delete', array()), - '#multiple' => true, - '#required' => true, - '#options' => node_get_types('names') - ); - + '#multiple' => TRUE, + '#required' => TRUE, + '#options' => node_get_types('names'), + '#description' => t('Select which node types are subject to revision deletion. Multiple types may be selected.'), + '#prefix' => '', + ); + return system_settings_form($form); } - /** * Implementation of hook_cron(). */ function revision_deletion_cron() { $last_update = variable_get('revision_delete_cron', 0); - $rev_del_freq = variable_get('revision_delete_freq', 604800); - $diff = time() - $rev_del_freq; + $rev_del_freq = variable_get('revision_delete_freq', 0); + $diff = $rev_del_freq == 0 ? 0 : time() - $rev_del_freq; if ($diff > $last_update) { $result = revision_deletion_data(); @@ -115,45 +142,51 @@ } } +function revision_deletion_settings_page() { + return revision_deletion_page(); +} + function revision_deletion_page() { $result = revision_deletion_data(); - $output = ''; if (!$result) { - $output .= 'Revision Deletion settings has not been configured.'. t('Click the node ID to view the node; click the revision ID to view the revision.') .'
'; + $output .= ''. t('There are no revisions to delete at this time.') .'
'; + } + + return $output .'