You are here

function revisioning_menu in Revisioning 7

Same name and namespace in other branches
  1. 8 revisioning.module \revisioning_menu()
  2. 6.4 revisioning.module \revisioning_menu()
  3. 6 revisioning.module \revisioning_menu()
  4. 6.3 revisioning.module \revisioning_menu()

Implements hook_menu().

Define new menu items. Existing menu items are modified through hook_menu_alter().

File

./revisioning.module, line 138
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_menu() {
  $items = array();

  // Start with the Revisioning config menu item, put under Content Authoring.
  $items['admin/config/content/revisioning'] = array(
    'title' => 'Revisioning',
    'description' => 'Configure how content view and edit links behave. Customise revision summary listing.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'revisioning_admin_configure',
    ),
    'access arguments' => array(
      'administer site configuration',
    ),
    'file' => 'revisioning.admin.inc',
  );

  // Plain link, not a tab, to allow users to unpublish a node.
  $items['node/%node/unpublish-current'] = array(
    // 'title' => t(Unpublish current revision'),
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'revisioning_unpublish_confirm',
      1,
    ),
    'access callback' => '_revisioning_access_node_revision',
    'access arguments' => array(
      'unpublish current revision',
      1,
    ),
    'type' => MENU_CALLBACK,
  );

  // Revision tab local subtasks (i.e. secondary tabs), up to 8 of them:
  // list, view, edit, publish, unpublish, revert, delete and compare.
  // All revision operations 'node/%node/revisions/%vid/<op>' are defined as
  // local subtasks (subtabs) secondary to the primary 'node/%node/revisions'
  // local task (primary tab).
  //
  // Subtab to the Revisions primary tab to allow going back to the revisions
  // list without clicking the primary tab for a second time, which also works.
  $items['node/%node/revisions/list'] = array(
    'title' => 'List all revisions',
    'access callback' => '_revisioning_access_node_revision',
    'access arguments' => array(
      'view revision list',
      1,
    ),
    'type' => MENU_LOCAL_TASK,
    'weight' => -20,
  );
  $items['node/%node/revisions/delete-archived'] = array(
    'title' => 'Delete archived revisions',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'revisioning_delete_archived_confirm',
      1,
    ),
    'access callback' => '_revisioning_access_node_revision',
    'access arguments' => array(
      'delete archived revisions',
      1,
    ),
    'type' => MENU_CALLBACK,
  );

  // View revision local subtask.
  // Note the use of %vid as opposed to %. This allows us to manipulate the
  // second argument in the path through vid_to_arg().
  $items['node/%node/revisions/%vid/view'] = array(
    'title' => 'View',
    'load arguments' => array(
      3,
    ),
    'page callback' => '_revisioning_view_revision',
    'page arguments' => array(
      1,
    ),
    'access callback' => '_revisioning_access_node_revision',
    'access arguments' => array(
      'view revisions',
      1,
    ),
    'type' => MENU_LOCAL_TASK,
    'weight' => -10,
  );

  // Edit revision local subtask.
  $items['node/%node/revisions/%vid/edit'] = array(
    'title' => 'Edit',
    'load arguments' => array(
      3,
    ),
    'page callback' => '_revisioning_edit_revision',
    'page arguments' => array(
      1,
    ),
    'access callback' => '_revisioning_access_node_revision',
    'access arguments' => array(
      'edit revisions',
      1,
    ),
    'file' => 'node.pages.inc',
    'file path' => drupal_get_path('module', 'node'),
    'type' => MENU_LOCAL_TASK,
    'weight' => -7,
  );

  // Publish revision local subtask.
  // As the menu is content type unaware, a further check on
  // node->revision_moderation must be made to determine whether it is
  // appropriate to show this tab.
  // This is done in _revisioning_access_node_revision.
  $items['node/%node/revisions/%vid/publish'] = array(
    'title' => 'Publish',
    'load arguments' => array(
      3,
    ),
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'revisioning_publish_confirm',
      1,
    ),
    'access callback' => '_revisioning_access_node_revision',
    'access arguments' => array(
      'publish revisions',
      1,
    ),
    'type' => MENU_LOCAL_TASK,
    'weight' => -4,
  );

  // Unpublish node local subtask.
  // As the menu is content type unaware, a further check on
  // node->revision_moderation must be made to determine whether it is
  // appropriate to show this tab.
  // This is done in _revisioning_access_node_revision.
  $items['node/%node/revisions/%vid/unpublish'] = array(
    'title' => 'Unpublish',
    'load arguments' => array(
      3,
    ),
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'revisioning_unpublish_confirm',
      1,
    ),
    'access callback' => '_revisioning_access_node_revision',
    'access arguments' => array(
      'unpublish current revision',
      1,
    ),
    'type' => MENU_LOCAL_TASK,
    'weight' => -3,
  );

  // Revert to revision local subtask.
  $items['node/%node/revisions/%vid/revert'] = array(
    'title' => 'Revert to this',
    'load arguments' => array(
      3,
    ),
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'node_revision_revert_confirm',
      1,
    ),
    'access callback' => '_revisioning_access_node_revision',
    'access arguments' => array(
      'revert revisions',
      1,
    ),
    'file' => 'node.pages.inc',
    'file path' => drupal_get_path('module', 'node'),
    'type' => MENU_LOCAL_TASK,
    'weight' => -2,
  );

  // Delete revision local subtask.
  $items['node/%node/revisions/%vid/delete'] = array(
    'title' => 'Delete',
    'load arguments' => array(
      3,
    ),
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'node_revision_delete_confirm',
      1,
    ),
    'access callback' => '_revisioning_access_node_revision',
    'access arguments' => array(
      'delete revisions',
      1,
    ),
    'file' => 'node.pages.inc',
    'file path' => drupal_get_path('module', 'node'),
    'type' => MENU_LOCAL_TASK,
    'weight' => 10,
  );

  // If Diff module is enabled, provide a "Compare to current" local subtask.
  if (module_exists('diff')) {
    $items['node/%node/revisions/%vid/compare'] = array(
      'title' => 'Compare to current',
      'load arguments' => array(
        3,
      ),
      'page callback' => '_revisioning_compare_to_current_revision',
      'page arguments' => array(
        1,
      ),
      'access callback' => '_revisioning_access_node_revision',
      'access arguments' => array(
        'compare to current',
        1,
      ),
      'type' => MENU_LOCAL_TASK,
      'weight' => 0,
    );
  }
  return $items;
}