You are here

function profile2_menu in Profile 2 7.2

Same name and namespace in other branches
  1. 7 profile2.module \profile2_menu()

Implements hook_menu().

File

./profile2.module, line 117
Support for configurable user profiles.

Code

function profile2_menu() {
  $items = array();

  // Define page which provides form to generate profiles using
  // Devel generate module.
  if (module_exists('devel_generate')) {
    $items['admin/config/development/generate/profile2'] = array(
      'title' => 'Generate profiles',
      'description' => 'Generate a given number of profiles for users. Optionally override current user profiles.',
      'access arguments' => array(
        'administer profiles',
      ),
      'page callback' => 'drupal_get_form',
      'page arguments' => array(
        'profile2_generate_form',
      ),
      'file' => 'profile2.devel.inc',
    );
  }
  $items['user/%profile2_by_uid/%/delete'] = array(
    'title' => 'Delete',
    'description' => 'Delete Profile of User.',
    'type' => MENU_NORMAL_ITEM,
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'profile2_delete_confirm_form',
      1,
    ),
    'load arguments' => array(
      2,
    ),
    'access callback' => 'profile2_access',
    'access arguments' => array(
      'delete',
      1,
    ),
    'file' => 'profile2.delete.inc',
  );
  foreach (profile2_get_types() as $type_name => $type) {
    if (empty($type->data['use_page'])) {

      // Menu items for revisions in tab mode.
      if (module_exists('profile2_diff')) {
        $page_callback = 'profile2_diff_diffs_overview_user';
        $path = drupal_get_path('module', 'profile2_diff');
        $file = 'profile2_diff.pages.inc';
      }
      else {
        $page_callback = 'profile2_revisions_view_for_user';
        $path = NULL;
        $file = 'profile2.revisions.inc';
      }
      $items['user/%user/revisions/' . $type_name] = array(
        'page callback' => $page_callback,
        'page arguments' => array(
          $type_name,
          1,
        ),
        'access callback' => '_profile2_revision_tab_access',
        'access arguments' => array(
          $type_name,
          1,
          array(
            'view own profile revisions',
            'view any profile revisions',
          ),
        ),
        'title callback' => 'check_plain',
        'title arguments' => array(
          $type
            ->getTranslation('label'),
        ),
        'type' => MENU_LOCAL_TASK,
        'file path' => $path,
        'file' => $file,
      );
      $items['user/%user/revisions/' . $type_name . '/view'] = array(
        'title' => 'View revision',
        'page callback' => 'profile2_tab_revision_view',
        'page arguments' => array(
          $type_name,
          1,
          5,
        ),
        'access callback' => '_profile2_revision_tab_access',
        'access arguments' => array(
          $type_name,
          1,
          array(
            'view own profile revisions',
            'view any profile revisions',
          ),
        ),
        'type' => MENU_LOCAL_TASK,
        'file' => 'profile2.revisions.inc',
      );
      $items['user/%user/revisions/' . $type_name . '/%/revert'] = array(
        'title' => 'Revert to earlier revision',
        'page callback' => 'profile2_tab_get_revision_revert',
        'page arguments' => array(
          $type_name,
          1,
          4,
        ),
        'access callback' => '_profile2_revision_tab_access',
        'access arguments' => array(
          $type_name,
          1,
          array(
            'revert own profile revisions',
            'revert any profile revisions',
          ),
        ),
        'type' => MENU_CALLBACK,
        'file' => 'profile2.revisions.inc',
      );
      $items['user/%user/revisions/' . $type_name . '/%/delete'] = array(
        'title' => 'Delete earlier revision',
        'page callback' => 'profile2_tab_get_revision_delete',
        'page arguments' => array(
          $type_name,
          1,
          4,
        ),
        'access callback' => '_profile2_revision_tab_access',
        'access arguments' => array(
          $type_name,
          1,
          array(
            'delete own profile revisions',
            'delete any profile revisions',
          ),
        ),
        'type' => MENU_CALLBACK,
        'file' => 'profile2.revisions.inc',
      );
    }
  }
  return $items;
}