function privatemsg_menu in Privatemsg 6.2
Same name and namespace in other branches
- 5.3 privatemsg.module \privatemsg_menu()
- 5 privatemsg.module \privatemsg_menu()
- 6 privatemsg.module \privatemsg_menu()
- 7.2 privatemsg.module \privatemsg_menu()
- 7 privatemsg.module \privatemsg_menu()
Implements hook_menu().
File
- ./
privatemsg.module, line 141 - Allows users to send private messages to other users.
Code
function privatemsg_menu() {
$url_prefix = variable_get('privatemsg_url_prefix', 'messages');
// Find how many arguments are in the prefix.
$url_prefix_arg_count = substr_count($url_prefix, '/') + 1;
// Find at which position a %user token is if it exists.
$url_prefix_user_arg_position = array_search('%user', explode('/', $url_prefix));
$items[$url_prefix] = array(
'title' => 'Messages',
'title callback' => 'privatemsg_title_callback',
'title arguments' => array(
$url_prefix_user_arg_position,
),
'page callback' => 'privatemsg_list_page',
'page arguments' => array(
'list',
$url_prefix_user_arg_position,
),
'file' => 'privatemsg.pages.inc',
'access callback' => 'privatemsg_menu_access',
'type' => $url_prefix_user_arg_position === FALSE ? MENU_NORMAL_ITEM : MENU_LOCAL_TASK,
);
$items[$url_prefix . '/list'] = array(
'title' => 'Messages',
'page callback' => 'privatemsg_list_page',
'page arguments' => array(
'list',
$url_prefix_user_arg_position,
),
'file' => 'privatemsg.pages.inc',
'access callback' => 'privatemsg_menu_access',
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -10,
);
$items[$url_prefix . '/view/%privatemsg_thread'] = array(
'title' => 'Read message',
// Set the third argument to TRUE so that we can show access denied instead
// of not found.
'load arguments' => array(
NULL,
NULL,
TRUE,
),
'page callback' => 'privatemsg_view',
'page arguments' => array(
$url_prefix_arg_count + 1,
),
'file' => 'privatemsg.pages.inc',
'access callback' => 'privatemsg_view_access',
'access arguments' => array(
$url_prefix_arg_count + 1,
),
'type' => MENU_LOCAL_TASK,
'weight' => -5,
);
$items['messages/delete/%privatemsg_thread/%privatemsg_message'] = array(
'title' => 'Delete message',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'privatemsg_delete',
2,
3,
),
'file' => 'privatemsg.pages.inc',
'access callback' => 'privatemsg_menu_access',
'access arguments' => array(
'delete privatemsg',
),
'type' => MENU_CALLBACK,
);
$items[$url_prefix . '/new'] = array(
'title' => 'Write new message',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'privatemsg_new',
$url_prefix_arg_count + 1,
$url_prefix_arg_count + 2,
NULL,
),
'file' => 'privatemsg.pages.inc',
'access callback' => 'privatemsg_menu_access',
'access arguments' => array(
'write privatemsg',
TRUE,
),
'type' => MENU_LOCAL_TASK,
'weight' => -3,
);
// Auto-completes available user names & removes duplicates.
$items['messages/autocomplete'] = array(
'page callback' => 'privatemsg_autocomplete',
'file' => 'privatemsg.pages.inc',
'access callback' => 'privatemsg_menu_access',
'access arguments' => array(
'write privatemsg',
),
'type' => MENU_CALLBACK,
'weight' => -10,
);
$items['admin/settings/messages'] = array(
'title' => 'Private messages',
'description' => 'Configure private messaging settings.',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'privatemsg_admin_settings',
),
'file' => 'privatemsg.admin.inc',
'access arguments' => array(
'administer privatemsg settings',
),
'type' => MENU_NORMAL_ITEM,
);
$items['admin/settings/messages/default'] = array(
'title' => 'Private messages',
'description' => 'Configure private messaging settings.',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'privatemsg_admin_settings',
),
'file' => 'privatemsg.admin.inc',
'access arguments' => array(
'administer privatemsg settings',
),
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -10,
);
if (module_exists('devel_generate')) {
$items['admin/generate/privatemsg'] = array(
'title' => 'Generate private messages',
'description' => 'Generate a given number of private messages. Optionally delete current private messages.',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'privatemsg_devel_generate_form',
),
'access arguments' => array(
'administer privatemsg settings',
),
'file' => 'privatemsg.devel_generate.inc',
);
}
$items['messages/undo/action'] = array(
'title' => 'Private messages',
'description' => 'Undo last thread action',
'page callback' => 'privatemsg_undo_action',
'file' => 'privatemsg.pages.inc',
'access callback' => 'privatemsg_menu_access',
'type' => MENU_CALLBACK,
);
if ($url_prefix_user_arg_position === FALSE) {
$items['user/%user/messages'] = array(
'title' => 'Messages',
'page callback' => 'privatemsg_list_page',
'page arguments' => array(
'list',
1,
),
'file' => 'privatemsg.pages.inc',
'access callback' => 'privatemsg_menu_access',
'access arguments' => array(
'read all private messages',
),
'type' => MENU_LOCAL_TASK,
);
}
return $items;
}