function user_menu in Drupal 4
Same name and namespace in other branches
- 5 modules/user/user.module \user_menu()
- 6 modules/user/user.module \user_menu()
- 7 modules/user/user.module \user_menu()
Implementation of hook_menu().
File
- modules/
user.module, line 713 - Enables the user registration and login system.
Code
function user_menu($may_cache) {
global $user;
$items = array();
$admin_access = user_access('administer users');
$access_access = user_access('administer access control');
$view_access = user_access('access user profiles');
if ($may_cache) {
$items[] = array(
'path' => 'user',
'title' => t('user account'),
'callback' => 'user_login',
'access' => TRUE,
'type' => MENU_CALLBACK,
);
$items[] = array(
'path' => 'user/autocomplete',
'title' => t('user autocomplete'),
'callback' => 'user_autocomplete',
'access' => $view_access,
'type' => MENU_CALLBACK,
);
// Registration and login pages.
$items[] = array(
'path' => 'user/login',
'title' => t('log in'),
'callback' => 'user_login',
'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items[] = array(
'path' => 'user/register',
'title' => t('register'),
'callback' => 'user_register',
'access' => $user->uid == 0 && variable_get('user_register', 1),
'type' => MENU_LOCAL_TASK,
);
$items[] = array(
'path' => 'user/password',
'title' => t('request new password'),
'callback' => 'user_pass',
'access' => $user->uid == 0,
'type' => MENU_LOCAL_TASK,
);
$items[] = array(
'path' => 'user/reset',
'title' => t('reset password'),
'callback' => 'user_pass_reset',
'access' => TRUE,
'type' => MENU_CALLBACK,
);
$items[] = array(
'path' => 'user/help',
'title' => t('help'),
'callback' => 'user_help_page',
'type' => MENU_CALLBACK,
);
// Admin user pages
$items[] = array(
'path' => 'admin/user',
'title' => t('users'),
'callback' => 'user_admin',
'access' => $admin_access,
);
$items[] = array(
'path' => 'admin/user/list',
'title' => t('list'),
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -10,
);
$items[] = array(
'path' => 'admin/user/create',
'title' => t('add user'),
'callback' => 'user_admin',
'access' => $admin_access,
'type' => MENU_LOCAL_TASK,
);
$items[] = array(
'path' => 'admin/settings/user',
'title' => t('users'),
'callback' => 'user_configure',
);
// Admin access pages
$items[] = array(
'path' => 'admin/access',
'title' => t('access control'),
'callback' => 'user_admin_perm',
'access' => $access_access,
);
$items[] = array(
'path' => 'admin/access/permissions',
'title' => t('permissions'),
'callback' => 'user_admin_perm',
'access' => $access_access,
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -10,
);
$items[] = array(
'path' => 'admin/access/roles',
'title' => t('roles'),
'callback' => 'user_admin_role',
'access' => $access_access,
'type' => MENU_LOCAL_TASK,
);
$items[] = array(
'path' => 'admin/access/roles/edit',
'title' => t('edit role'),
'callback' => 'user_admin_role',
'access' => $access_access,
'type' => MENU_CALLBACK,
);
$items[] = array(
'path' => 'admin/access/rules',
'title' => t('access rules'),
'callback' => 'user_admin_access',
'access' => $access_access,
'type' => MENU_LOCAL_TASK,
'weight' => 10,
);
$items[] = array(
'path' => 'admin/access/rules/list',
'title' => t('list'),
'access' => $access_access,
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -10,
);
$items[] = array(
'path' => 'admin/access/rules/add',
'title' => t('add rule'),
'callback' => 'user_admin_access_add',
'access' => $access_access,
'type' => MENU_LOCAL_TASK,
);
$items[] = array(
'path' => 'admin/access/rules/check',
'title' => t('check rules'),
'callback' => 'user_admin_access_check',
'access' => $access_access,
'type' => MENU_LOCAL_TASK,
);
$items[] = array(
'path' => 'admin/access/rules/edit',
'title' => t('edit rule'),
'callback' => 'user_admin_access_edit',
'access' => $access_access,
'type' => MENU_CALLBACK,
);
$items[] = array(
'path' => 'admin/access/rules/delete',
'title' => t('delete rule'),
'callback' => 'user_admin_access_delete',
'access' => $access_access,
'type' => MENU_CALLBACK,
);
if (module_exist('search')) {
$items[] = array(
'path' => 'admin/user/search',
'title' => t('search'),
'callback' => 'user_admin',
'access' => $admin_access,
'type' => MENU_LOCAL_TASK,
);
}
// Your personal page
if ($user->uid) {
$items[] = array(
'path' => 'user/' . $user->uid,
'title' => t('my account'),
'callback' => 'user_view',
'callback arguments' => array(
arg(1),
),
'access' => TRUE,
'type' => MENU_DYNAMIC_ITEM,
);
}
$items[] = array(
'path' => 'logout',
'title' => t('log out'),
'access' => $user->uid != 0,
'callback' => 'user_logout',
'weight' => 10,
);
}
else {
if (arg(0) == 'user' && is_numeric(arg(1)) && arg(1) > 0) {
$account = user_load(array(
'uid' => arg(1),
));
if ($user !== FALSE) {
// Always let a user view their own account
$view_access |= $user->uid == arg(1);
// Only admins can view blocked accounts
$view_access &= $account->status || $admin_access;
$items[] = array(
'path' => 'user/' . arg(1),
'title' => t('user'),
'type' => MENU_CALLBACK,
'callback' => 'user_view',
'callback arguments' => array(
arg(1),
),
'access' => $view_access,
);
$items[] = array(
'path' => 'user/' . arg(1) . '/view',
'title' => t('view'),
'access' => $view_access,
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -10,
);
$items[] = array(
'path' => 'user/' . arg(1) . '/edit',
'title' => t('edit'),
'callback' => 'user_edit',
'access' => $admin_access || $user->uid == arg(1),
'type' => MENU_LOCAL_TASK,
);
$items[] = array(
'path' => 'user/' . arg(1) . '/delete',
'title' => t('delete'),
'callback' => 'user_edit',
'access' => $admin_access,
'type' => MENU_CALLBACK,
);
if (arg(2) == 'edit') {
if (($categories = _user_categories($account)) && count($categories) > 1) {
foreach ($categories as $key => $category) {
$items[] = array(
'path' => 'user/' . arg(1) . '/edit/' . $category['name'],
'title' => $category['title'],
'type' => $category['name'] == 'account' ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK,
'weight' => $category['weight'],
'access' => $admin_access || $user->uid == arg(1),
);
}
}
}
}
}
}
return $items;
}