function user_relationships_menu in User Relationships 5
Same name and namespace in other branches
- 5.2 user_relationships_hooks.inc \user_relationships_menu()
- 7 user_relationships.module \user_relationships_menu()
Menu
File
- ./
user_relationships_hooks.inc, line 37
Code
function user_relationships_menu($may_cache) {
$items = array();
if ($may_cache) {
$items[] = array(
'path' => 'admin/user/relationships',
'title' => t('Relationships'),
'description' => t('Create relationship types'),
'access' => user_access('administer user relationships'),
'callback' => 'user_relationships_types_list_page',
);
$items[] = array(
'path' => 'admin/user/relationships/list',
'title' => t('List'),
'callback' => 'user_relationships_types_list_page',
'access' => user_access('administer user relationships'),
'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items[] = array(
'path' => 'admin/user/relationships/add',
'title' => t('Add type'),
'callback' => 'drupal_get_form',
'callback arguments' => array(
'user_relationships_type_edit',
),
'access' => user_access('administer user relationships'),
'type' => MENU_LOCAL_TASK,
'weight' => 1,
);
$items[] = array(
'path' => 'admin/user/relationships/edit',
'title' => t('Edit type'),
'callback' => 'drupal_get_form',
'callback arguments' => array(
'user_relationships_type_edit',
),
'access' => user_access('administer user relationships'),
'type' => MENU_CALLBACK,
);
$items[] = array(
'path' => 'admin/user/relationships/delete',
'title' => t('Delete type'),
'callback' => 'drupal_get_form',
'callback arguments' => array(
'user_relationships_type_delete',
),
'access' => user_access('administer user relationships'),
'type' => MENU_CALLBACK,
);
$items[] = array(
'path' => 'admin/user/relationships/settings',
'title' => t('Settings'),
'callback' => 'drupal_get_form',
'callback arguments' => array(
'user_relationships_settings',
),
'access' => user_access('administer user relationships'),
'type' => MENU_LOCAL_TASK,
'weight' => 2,
);
$items[] = array(
'path' => 'relationship_types/autocomplete',
'title' => t('User Relationships Autocomplete'),
'callback' => '_user_relationships_autocomplete_types',
'access' => user_access('administer user relationships'),
'type' => MENU_CALLBACK,
);
}
else {
global $user;
$id = is_numeric(arg(1)) ? arg(1) : $user->uid;
$edit_access = $id == $user->uid && user_access('maintain relationships') || user_access('administer users');
$items[] = array(
'path' => 'relationships',
'title' => t('My relationships'),
'access' => $id && user_access('maintain relationships'),
'callback' => 'theme',
'callback arguments' => array(
'user_relationships_page',
),
);
$items[] = array(
'path' => "relationship/request",
'title' => t('Create a relationship'),
'access' => $edit_access,
'callback' => 'drupal_get_form',
'callback arguments' => array(
'user_relationships_request',
arg(2),
),
'type' => MENU_CALLBACK,
);
$items[] = array(
'path' => "relationship/{$id}/remove",
'title' => t('Remove relationship'),
'access' => $edit_access,
'callback' => 'drupal_get_form',
'callback arguments' => array(
'user_relationships_remove',
$id,
arg(3),
),
'type' => MENU_CALLBACK,
);
if (true || $approval_required && $edit_access) {
$items[] = array(
'path' => "relationships/{$id}/requests",
'title' => t('Pending requests'),
'access' => $edit_access,
'callback' => 'theme',
'type' => MENU_LOCAL_TASK,
'weight' => 0,
'callback arguments' => array(
'user_relationships_pending_requests_page',
$id,
),
);
}
// 'view only' tabs
$view_access = $id == $user->uid && user_access('maintain relationships') || user_access('view user relationships');
$items[] = array(
'path' => "relationships/{$id}",
'title' => t('Relationships'),
'access' => $view_access && $id,
);
$items[] = array(
'path' => "relationships/{$id}/list",
'title' => t('All'),
'access' => $view_access,
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -1,
'callback' => 'theme',
'callback arguments' => array(
'user_relationships_page',
$id,
),
);
// operations
// arg(3) should be one of "approve" "disapprove" or "cancel"
$items[] = array(
'path' => "relationships/{$id}/requested",
'title' => t('Approve Relationship'),
'access' => $edit_access,
'type' => MENU_CALLBACK,
'callback' => 'drupal_get_form',
'callback arguments' => array(
'user_relationships_pending_requested',
arg(3),
$id,
arg(4),
),
);
$relationships = user_relationships_relationship_types_load();
foreach ($relationships as $relationship) {
$items[] = array(
'path' => "relationships/{$id}/{$relationship->rtid}",
'title' => t($relationship->name),
'access' => $view_access,
'type' => MENU_LOCAL_TASK,
'callback' => 'theme',
'callback arguments' => array(
'user_relationships_page',
$id,
$relationship,
),
);
}
}
return $items;
}