You are here

function revision_deletion_menu in Revision Deletion 5

Same name and namespace in other branches
  1. 6 revision_deletion.module \revision_deletion_menu()
  2. 7 revision_deletion.module \revision_deletion_menu()

Implementation of hook_menu().

File

./revision_deletion.module, line 38
Node Revision Deletion, written by Greg Holsclaw

Code

function revision_deletion_menu($may_cache) {
  $items = array();
  if ($may_cache) {
    $items[] = array(
      'path' => 'admin/content/revision_deletion',
      'title' => t('Revision deletion'),
      'callback' => 'revision_deletion_settings_page',
      'title' => t('Revisions to Mass Delete'),
      'access' => user_access('mass delete revisions'),
      'type' => MENU_NORMAL_ITEM,
      'description' => t('Configure or manually run the revision deletion module'),
    );
    $items[] = array(
      'path' => 'admin/content/revision_deletion/list',
      'callback' => 'drupal_get_form',
      'callback arguments' => 'revision_deletion_auto_form',
      'title' => t('List'),
      'access' => user_access('mass delete revisions'),
      'type' => MENU_DEFAULT_LOCAL_TASK,
    );
    $items[] = array(
      'path' => 'admin/content/revision_deletion/settings',
      'title' => t('Settings'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'revision_deletion_settings',
      ),
      'access' => user_access('administer site configuration'),
      'type' => MENU_LOCAL_TASK,
      'description' => t('Configure settings for the revision deletion module'),
    );
    $items[] = array(
      'path' => 'admin/content/revision_deletion/node',
      'callback' => 'revision_deletion_list',
      'access' => user_access('mass delete revisions'),
      'type' => MENU_CALLBACK,
    );
  }
  else {
    drupal_add_css(drupal_get_path('module', 'revision_deletion') . '/revision_deletion.css');

    // Are we taking over the node revisions page?
    if (variable_get('revision_delete_list_takeover', 0)) {
      if (arg(0) == 'node' && is_numeric(arg(1))) {
        $node = node_load(arg(1));
        if ($node->nid) {
          $revisions_access = (user_access('view revisions') || user_access('administer nodes' || user_access('mass delete revisions'))) && node_access('view', $node) && db_result(db_query('SELECT COUNT(vid) FROM {node_revisions} WHERE nid = %d', arg(1))) > 1;
          $items[] = array(
            'path' => 'node/' . arg(1) . '/revisions',
            'title' => t('Revisions'),
            //            'callback' => 'node_revisions',
            'callback' => 'revision_deletion_list',
            'callback arguments' => array(
              $node->nid,
            ),
            'access' => $revisions_access,
            'weight' => 2,
            'type' => MENU_LOCAL_TASK,
          );
        }
      }
    }
  }
  return $items;
}