You are here

function user_relationships_ui_menu in User Relationships 6

Same name and namespace in other branches
  1. 5.3 user_relationships_ui/user_relationships_ui.hooks.inc \user_relationships_ui_menu()
  2. 7 user_relationships_ui/user_relationships_ui.module \user_relationships_ui_menu()

Implementation of hook_menu().

File

user_relationships_ui/user_relationships_ui.module, line 437
UI components of user_relationships @author Jeff Smick (creator) @author Alex Karshakevich (maintainer) http://drupal.org/user/183217 @author Darren Ferguson (contributor) http://drupal.org/user/70179

Code

function user_relationships_ui_menu() {
  include_once drupal_get_path('module', 'user_relationships_api') . '/user_relationships_api.module';
  $items = array();
  $items['admin/user/relationships'] = array(
    'title' => 'Relationships',
    'description' => 'Create relationship types',
    'access callback' => 'user_access',
    'access arguments' => array(
      'administer user relationships',
    ),
    'page callback' => 'user_relationships_ui_types_list_page',
    'file' => 'user_relationships_ui.pages.inc',
  );
  $items['admin/user/relationships/list'] = array(
    'title' => 'List',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'page callback' => 'user_relationships_ui_types_list_page',
    'access callback' => 'user_access',
    'access arguments' => array(
      'administer user relationships',
    ),
    'file' => 'user_relationships_ui.pages.inc',
  );
  $items['admin/user/relationships/add'] = array(
    'title' => 'Add type',
    'type' => MENU_LOCAL_TASK,
    'weight' => 1,
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'user_relationships_ui_type_edit',
    ),
    'access callback' => 'user_access',
    'access arguments' => array(
      'administer user relationships',
    ),
    'file' => 'user_relationships_ui.admin.inc',
  );
  $items['admin/user/relationships/%user_relationships_type/edit'] = array(
    'title' => 'Edit type',
    'type' => MENU_CALLBACK,
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'user_relationships_ui_type_edit',
      3,
    ),
    'access callback' => 'user_access',
    'access arguments' => array(
      'administer user relationships',
    ),
    'file' => 'user_relationships_ui.admin.inc',
  );
  $items['admin/user/relationships/%user_relationships_type/delete'] = array(
    'title' => 'Delete type',
    'type' => MENU_CALLBACK,
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'user_relationships_ui_type_delete',
      3,
    ),
    'access callback' => 'user_access',
    'access arguments' => array(
      'administer user relationships',
    ),
    'file' => 'user_relationships_ui.admin.inc',
  );
  $items['admin/user/relationships/settings'] = array(
    'title' => 'Settings',
    'type' => MENU_LOCAL_TASK,
    'weight' => 2,
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'user_relationships_ui_settings',
    ),
    'access callback' => 'user_access',
    'access arguments' => array(
      'administer user relationships',
    ),
    'file' => 'user_relationships_ui.admin.inc',
  );
  $items['relationship_types/autocomplete'] = array(
    'title' => 'User Relationships Autocomplete',
    'type' => MENU_CALLBACK,
    'page callback' => '_user_relationships_ui_autocomplete_types',
    'access callback' => 'user_access',
    'access arguments' => array(
      'administer user relationships',
    ),
  );

  //TODO: Issue #735862, see node/109153 rethink how to handle relationships/*
  $items['relationships'] = array(
    'title' => 'My relationships',
    'type' => MENU_NORMAL_ITEM,
    'access callback' => 'user_relationships_ui_check_access',
    'access arguments' => array(
      'view',
    ),
    'page callback' => 'user_relationships_page',
    'file' => 'user_relationships_ui.pages.inc',
  );
  $items['relationships/list'] = array(
    'title' => 'All',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => -10,
    'access callback' => 'user_relationships_ui_check_access',
    'access arguments' => array(
      'view',
    ),
  );
  $items['relationships/requests'] = array(
    'title' => 'Pending',
    'access callback' => 'user_relationships_ui_check_access',
    'access arguments' => array(
      'edit',
    ),
    'type' => MENU_NORMAL_ITEM | MENU_LOCAL_TASK,
    'weight' => -9,
    'page callback' => 'user_relationships_pending_requests_page',
    'file' => 'user_relationships_ui.pages.inc',
  );
  foreach (user_relationships_types_load() as $rtid => $relationship) {
    $items["relationships/{$rtid}"] = array(
      'title' => $relationship->plural_name ? $relationship->plural_name : $relationship->name,
      'type' => MENU_NORMAL_ITEM | MENU_LOCAL_TASK,
      'access callback' => 'user_relationships_ui_check_access',
      'access arguments' => array(
        'edit',
      ),
      'page callback' => 'user_relationships_page',
      'page arguments' => array(
        NULL,
        1,
      ),
      'file' => 'user_relationships_ui.pages.inc',
    );
  }
  $items['relationships/%user_relationships/remove'] = array(
    'title' => 'Remove relationship',
    'type' => MENU_CALLBACK,
    'access callback' => 'user_relationships_ui_check_access',
    'access arguments' => array(
      'edit',
    ),
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'user_relationships_ui_remove',
      1,
    ),
    'file' => 'user_relationships_ui.forms.inc',
  );
  $items['relationship/%user/request'] = array(
    'title' => 'Create a relationship',
    'type' => MENU_CALLBACK,
    'access callback' => 'user_relationships_ui_check_access',
    'access arguments' => array(
      'edit',
    ),
    'page callback' => 'user_relationships_ui_request_ajax',
    'page arguments' => array(
      1,
    ),
    'file' => 'user_relationships_ui.forms.inc',
  );
  $items['user/%user/relationships'] = array(
    'title' => 'Relationships',
    'access callback' => 'user_relationships_ui_check_access',
    'access arguments' => array(
      array(
        'admin',
        'user',
      ),
      1,
    ),
    'page callback' => 'user_relationships_page',
    'page arguments' => array(
      1,
    ),
    'file' => 'user_relationships_ui.pages.inc',
  );
  $items['user/%user/relationships/list'] = array(
    'title' => 'All',
    'type' => MENU_NORMAL_ITEM | MENU_DEFAULT_LOCAL_TASK,
    'weight' => -10,
    'access callback' => 'user_relationships_ui_check_access',
    'access arguments' => array(
      array(
        'admin',
        'user',
      ),
      1,
    ),
  );
  $items['user/%user/relationships/requests'] = array(
    'title' => 'Pending',
    'type' => MENU_NORMAL_ITEM | MENU_LOCAL_TASK,
    'weight' => -9,
    'access callback' => 'user_relationships_ui_check_access',
    'access arguments' => array(
      array(
        'admin',
        'user',
      ),
      1,
    ),
    'page callback' => 'user_relationships_pending_requests_page',
    'page arguments' => array(
      1,
    ),
    'file' => 'user_relationships_ui.pages.inc',
  );
  foreach (user_relationships_types_load() as $rtid => $relationship) {
    $items["user/%user/relationships/{$rtid}"] = array(
      'title' => $relationship->plural_name ? $relationship->plural_name : $relationship->name,
      'type' => MENU_NORMAL_ITEM | MENU_LOCAL_TASK,
      'access callback' => 'user_relationships_ui_check_access',
      'access arguments' => array(
        array(
          'admin',
          'user',
        ),
        1,
      ),
      'page callback' => 'user_relationships_page',
      'page arguments' => array(
        1,
        3,
      ),
      'file' => 'user_relationships_ui.pages.inc',
    );
  }
  foreach (array(
    'approve',
    'disapprove',
    'cancel',
  ) as $action) {
    $items["user/%user/relationships/requested/%user_relationships/{$action}"] = array(
      'title' => 'Approve Relationship',
      'type' => MENU_CALLBACK,
      'access callback' => 'user_relationships_ui_check_access',
      'access arguments' => array(
        array(
          'admin',
          'user',
        ),
        1,
      ),
      'page callback' => 'user_relationships_ui_pending_requested_ajax',
      'page arguments' => array(
        $action,
        1,
        4,
      ),
      'file' => 'user_relationships_ui.forms.inc',
    );
  }
  $items['user/%user/relationships/%user_relationships/remove'] = array(
    'title' => 'Remove relationship',
    'type' => MENU_CALLBACK,
    'access callback' => 'user_relationships_ui_check_access',
    'access arguments' => array(
      array(
        'admin',
        'user',
      ),
      1,
    ),
    'page callback' => 'user_relationships_ui_remove_ajax',
    'page arguments' => array(
      1,
      3,
    ),
    'file' => 'user_relationships_ui.forms.inc',
  );
  return $items;
}