Index: privatemsg.module =================================================================== RCS file: /cvs/drupal/contributions/modules/privatemsg/privatemsg.module,v retrieving revision 1.122 diff -u -p -r1.122 privatemsg.module --- privatemsg.module 12 Mar 2010 16:23:08 -0000 1.122 +++ privatemsg.module 15 Mar 2010 10:04:09 -0000 @@ -14,12 +14,23 @@ define('PRIVATEMSG_READ', 0); * Status constant for unread messages. */ define('PRIVATEMSG_UNREAD', 1); + /** * Show unlimited messages in a thread. */ define('PRIVATEMSG_UNLIMITED', 'unlimited'); /** + * Url constant for specifying url path prefix. + */ +define('PRIVATEMSG_URL_PREFIX', variable_get('privatemsg_url_prefix', 'messages') ); + +/** + * Integer constant for specifying argument count in url path prefix. + */ +define('PRIVATEMSG_URL_PREFIX_ARG_COUNT', substr_count(PRIVATEMSG_URL_PREFIX, '/') + 1 ); + +/** * Implements hook_perm(). */ function privatemsg_perm() { @@ -119,16 +130,19 @@ function _privatemsg_format_participants * Implements hook_menu(). */ function privatemsg_menu() { - $items['messages'] = array( + $url_prefix = variable_get('privatemsg_url_prefix', 'messages'); + $arg_count = substr_count($url_prefix, '/') + 1; + + $items[$url_prefix] = array( 'title' => 'Messages', 'title callback' => 'privatemsg_title_callback', 'page callback' => 'drupal_get_form', 'page arguments' => array('privatemsg_list', 'list'), 'file' => 'privatemsg.pages.inc', 'access callback' => 'privatemsg_user_access', - 'type' => MENU_NORMAL_ITEM, + 'type' => strpos($url_prefix, '%user') === FALSE ? MENU_NORMAL_ITEM : MENU_LOCAL_TASK, ); - $items['messages/list'] = array( + $items[$url_prefix . '/list'] = array( 'title' => 'Messages', 'page callback' => 'drupal_get_form', 'page arguments' => array('privatemsg_list', 'list'), @@ -137,16 +151,16 @@ function privatemsg_menu() { 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10, ); - $items['messages/view/%privatemsg_thread'] = array( + $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(2), + 'page arguments' => array($arg_count + 1), 'file' => 'privatemsg.pages.inc', 'access callback' => 'privatemsg_view_access', - 'access arguments' => array(2), + 'access arguments' => array($arg_count + 1), 'type' => MENU_LOCAL_TASK, 'weight' => -5, ); @@ -159,10 +173,10 @@ function privatemsg_menu() { 'access arguments' => array('delete privatemsg'), 'type' => MENU_CALLBACK, ); - $items['messages/new'] = array( + $items[$url_prefix . '/new'] = array( 'title' => 'Write new message', 'page callback' => 'drupal_get_form', - 'page arguments' => array('privatemsg_new', 2, 3, NULL), + 'page arguments' => array('privatemsg_new', $arg_count + 1, $arg_count + 2, NULL), 'file' => 'privatemsg.pages.inc', 'access callback' => 'privatemsg_user_access', 'access arguments' => array('write privatemsg'), @@ -219,6 +233,25 @@ function privatemsg_menu() { } /** + * Returns the current dynamic url prefix. + * + * Does replace %user with the uid. + * + * @param $uid + * Use this uid instead of global $user. + * + * @return + * The privatemsg url prefix for the current request. + */ + function privatemsg_get_dynamic_url_prefix($uid = NULL) { + global $user; + if (!$uid) { + $uid = $user->uid; + } + return str_replace('%user', $uid, variable_get('privatemsg_url_prefix', 'messages')); + } + +/** * Privatemsg wrapper for user_access. * * Never allows anonymous user access as that doesn't makes sense. @@ -241,7 +274,8 @@ function privatemsg_user_access($permiss return FALSE; } if (privatemsg_is_disabled($account) && ($permission == 'write privatemsg') ) { - if (arg(0) == 'messages' && variable_get('privatemsg_display_disabled_message', TRUE) && !$disabled_displayed) { + $arg = substr_count(variable_get('privatemsg_url_prefix', 'messages'), '/'); + if (arg($arg) == 'messages' && variable_get('privatemsg_display_disabled_message', TRUE) && !$disabled_displayed) { $disabled_displayed = TRUE; drupal_set_message(t('You have disabled Privatemsg and are not allowed to write messages. Go to your Account settings to enable it again.', array('@settings_url' => url('user/' . $account->uid . '/edit'))), 'warning'); } @@ -272,7 +306,8 @@ function privatemsg_view_access($thread) // Count all messages, if there return FALSE; } - if (privatemsg_user_access('read privatemsg') && arg(1) == 'view') { + $arg = substr_count(variable_get('privatemsg_url_prefix', 'messages'), '/') + 1; + if (privatemsg_user_access('read privatemsg') && arg($arg) == 'view') { return TRUE; } return FALSE; @@ -1002,7 +1037,7 @@ function privatemsg_user($op, &$edit, &$ if (variable_get('privatemsg_display_loginmessage', TRUE) && privatemsg_user_access()) { $count = privatemsg_unread_count(); if ($count) { - drupal_set_message(format_plural($count, 'You have 1 unread message.', 'You have @count unread messages', array('@messages' => url('messages')))); + drupal_set_message(format_plural($count, 'You have 1 unread message.', 'You have @count unread messages', array('@messages' => url(privatemsg_get_dynamic_url_prefix())))); } } break; @@ -1093,10 +1128,10 @@ function _privatemsg_block_menu() { $links = array(); if (privatemsg_user_access('write privatemsg')) { - $links[] = l(t('Write new message'), 'messages/new', array('attributes' => array('title' => t('Write new message')))); + $links[] = l(t('Write new message'), privatemsg_get_dynamic_url_prefix() . '/new', array('attributes' => array('title' => t('Write new message')))); } if (privatemsg_user_access('read privatemsg') || privatemsg_user_access('read all private messages') ) { - $links[] = l(privatemsg_title_callback(), 'messages'); + $links[] = l(privatemsg_title_callback(), privatemsg_get_dynamic_url_prefix()); } if ( count( $links ) ) { $block = array( @@ -1493,7 +1528,7 @@ function privatemsg_get_link($recipients if (empty($validated)) { return FALSE; } - $url = 'messages/new/'. implode(',', $validated); + $url = privatemsg_get_dynamic_url_prefix() . '/new/'. implode(',', $validated); if (!is_null($subject)) { $url .= '/'. $subject; } Index: privatemsg.pages.inc =================================================================== RCS file: /cvs/drupal/contributions/modules/privatemsg/privatemsg.pages.inc,v retrieving revision 1.1 diff -u -p -r1.1 privatemsg.pages.inc --- privatemsg.pages.inc 2 Dec 2009 20:03:59 -0000 1.1 +++ privatemsg.pages.inc 15 Mar 2010 10:04:09 -0000 @@ -115,7 +115,7 @@ function privatemsg_view($thread) { 'query' => array('start' => $thread['older_start']), 'title' => t('Display older messages'), ); - $older = l(t('<<'), 'messages/view/' . $thread['thread_id'], $options); + $older = l(t('<<'), privatemsg_get_dynamic_url_prefix() . '/view/' . $thread['thread_id'], $options); } $newer = ''; if (isset($thread['newer_start'])) { @@ -123,7 +123,7 @@ function privatemsg_view($thread) { 'query' => array('start' => $thread['newer_start']), 'title' => t('Display newer messages'), ); - $newer = l(t('>>'), 'messages/view/' . $thread['thread_id'], $options); + $newer = l(t('>>'), privatemsg_get_dynamic_url_prefix() . '/view/' . $thread['thread_id'], $options); } $substitutions = array('@from' => $thread['from'], '@to' => $thread['to'], '@total' => $thread['message_count'], '!previous_link' => $older, '!newer_link' => $newer); $title = t('!previous_link Displaying messages @from - @to of @total !newer_link', $substitutions); @@ -305,7 +305,7 @@ function privatemsg_new(&$form_state, $r '#value' => t('Send message'), '#weight' => 15, ); - $url = 'messages'; + $url = privatemsg_get_dynamic_url_prefix(); $title = t('Cancel'); if (isset($_REQUEST['destination'])) { $url = $_REQUEST['destination']; @@ -413,7 +413,7 @@ function privatemsg_delete($form_state, ); $form['delete_destination'] = array( '#type' => 'value', - '#value' => count($thread['messages']) > 1 ? 'messages/view/' . $message['thread_id'] : 'messages', + '#value' => count($thread['messages']) > 1 ? privatemsg_get_dynamic_url_prefix() . '/view/' . $message['thread_id'] : privatemsg_get_dynamic_url_prefix(), ); if (privatemsg_user_access('read all private messages')) { @@ -426,7 +426,7 @@ function privatemsg_delete($form_state, } return confirm_form($form, t('Are you sure you want to delete this message?'), - isset($_GET['destination']) ? $_GET['destination'] : 'messages/view/'. $message['thread_id'], + isset($_GET['destination']) ? $_GET['destination'] : privatemsg_get_dynamic_url_prefix() . '/view/'. $message['thread_id'], t('This action cannot be undone.'), t('Delete'), t('Cancel') Index: privatemsg.admin.inc =================================================================== RCS file: /cvs/drupal/contributions/modules/privatemsg/privatemsg.admin.inc,v retrieving revision 1.6 diff -u -p -r1.6 privatemsg.admin.inc --- privatemsg.admin.inc 12 Mar 2010 16:23:08 -0000 1.6 +++ privatemsg.admin.inc 15 Mar 2010 10:04:09 -0000 @@ -107,6 +107,13 @@ function privatemsg_admin_settings() { '#default_value' => variable_get('privatemsg_display_fields', array('participants')), ); + $form['privatemsg_url_prefix'] = array( + '#type' => 'textfield', + '#title' => t('URL Prefix'), + '#description' => t('Specify the url prefix to use for all privatemsg pages. Default is "messages". %user will be replaced with the current user id.'), + '#default_value' => variable_get('privatemsg_url_prefix', 'messages'), + ); + $amounts = drupal_map_assoc(array(5, 10, 20, 30, 50, 70, 90, 150, 200, 250, 300)); $form['privatemsg_listing']['privatemsg_view_max_amount'] = array( '#type' => 'select', @@ -179,10 +186,14 @@ function privatemsg_admin_settings() { ); drupal_add_js(drupal_get_path('module', 'privatemsg') .'/privatemsg-admin.js'); + $form = system_settings_form($form); $form['#submit'][] = 'privatemsg_admin_settings_submit'; - return system_settings_form($form); + return $form; } -function privatemsg_admin_settings_submit() { - drupal_rebuild_theme_registry(); +function privatemsg_admin_settings_submit($form, &$form_state) { + // Only rebuild menu if url prefix has changed + if ($form_state['values']['privatemsg_url_prefix'] != $form['privatemsg_url_prefix']['#default_value']) { + menu_rebuild(); + } } \ No newline at end of file Index: privatemsg.theme.inc =================================================================== RCS file: /cvs/drupal/contributions/modules/privatemsg/privatemsg.theme.inc,v retrieving revision 1.2 diff -u -p -r1.2 privatemsg.theme.inc --- privatemsg.theme.inc 30 Nov 2009 17:37:15 -0000 1.2 +++ privatemsg.theme.inc 15 Mar 2010 10:04:10 -0000 @@ -96,7 +96,7 @@ function phptemplate_privatemsg_list_fie $is_new = theme_mark(MARK_NEW); $options['fragment'] = 'new'; } - $field['data'] = l($thread['subject'], 'messages/view/' . $thread['thread_id'], $options) . $is_new; + $field['data'] = l($thread['subject'], privatemsg_get_dynamic_url_prefix() . '/view/' . $thread['thread_id'], $options) . $is_new; $field['class'] = 'privatemsg-list-subject'; return $field; } @@ -112,7 +112,7 @@ function phptemplate_privatemsg_list_fie $options = array(); if (!empty($thread['is_new']) && $thread['is_new'] < $thread['count']) { $options['fragment'] = 'new'; - $field['data'] .= '
' . l((format_plural($thread['is_new'], '(1 new)', '(@count new)')), 'messages/view/' . $thread['thread_id'], $options); + $field['data'] .= '
' . l((format_plural($thread['is_new'], '(1 new)', '(@count new)')), privatemsg_get_dynamic_url_prefix() . '/view/' . $thread['thread_id'], $options); } $field['class'] = 'privatemsg-list-count'; return $field; Index: pm_email_notify/pm_email_notify.module =================================================================== RCS file: /cvs/drupal/contributions/modules/privatemsg/pm_email_notify/pm_email_notify.module,v retrieving revision 1.6 diff -u -p -r1.6 pm_email_notify.module --- pm_email_notify/pm_email_notify.module 12 Mar 2010 16:16:39 -0000 1.6 +++ pm_email_notify/pm_email_notify.module 15 Mar 2010 10:04:10 -0000 @@ -92,7 +92,7 @@ function _pm_email_notify_token($recipie '!pm_body' => drupal_html_to_text(check_markup($message['body'], $message['format'], FALSE)), '!thread' => $message['thread_id'], '!user_uid' => $recipient->uid, - '!message' => url('messages/view/' . $message['thread_id'], array('absolute' => TRUE)), + '!message' => url(privatemsg_get_dynamic_url_prefix() . '/view/' . $message['thread_id'], array('absolute' => TRUE)), '!settings' => url('user/' . $recipient->uid . '/edit', array('absolute' => TRUE)), ); Index: privatemsg_filter/privatemsg_filter.module =================================================================== RCS file: /cvs/drupal/contributions/modules/privatemsg/privatemsg_filter/privatemsg_filter.module,v retrieving revision 1.3 diff -u -p -r1.3 privatemsg_filter.module --- privatemsg_filter/privatemsg_filter.module 2 Dec 2009 20:04:00 -0000 1.3 +++ privatemsg_filter/privatemsg_filter.module 15 Mar 2010 10:04:10 -0000 @@ -21,6 +21,8 @@ function privatemsg_filter_perm() { * Implements hook_menu(). */ function privatemsg_filter_menu() { + $url_prefix = variable_get('privatemsg_url_prefix', 'messages'); + $items['admin/settings/messages/filter'] = array( 'title' => 'Filter', 'description' => 'Configure filter settings.', @@ -75,7 +77,7 @@ function privatemsg_filter_menu() { 'access arguments' => array('administer privatemsg settings'), 'type' => MENU_CALLBACK, ); - $items['messages/inbox'] = array( + $items[$url_prefix. '/inbox'] = array( 'title' => 'Inbox', 'page callback' => 'drupal_get_form', 'page arguments' => array('privatemsg_list', 'inbox'), @@ -85,8 +87,8 @@ function privatemsg_filter_menu() { 'type' => variable_get('privatemsg_filter_default_list', 0) ? MENU_LOCAL_TASK : MENU_DEFAULT_LOCAL_TASK, 'weight' => -15, ); - $items['messages/sent'] = array( - 'title' => 'Sent messages', + $items[$url_prefix . '/sent'] = array( + 'title' => 'Sent Messages', 'page callback' => 'drupal_get_form', 'page arguments' => array('privatemsg_list', 'sent'), 'file' => 'privatemsg.pages.inc', @@ -117,13 +119,15 @@ function privatemsg_filter_menu() { * Implements hook_menu_alter(). */ function privatemsg_filter_menu_alter(&$items) { + $url_prefix = variable_get('privatemsg_url_prefix', 'messages'); + // Rename messages to "All messages". - $items['messages/list']['title'] = 'All messages'; + $items[$url_prefix . '/list']['title'] = 'All messages'; if (variable_get('privatemsg_filter_default_list', 0) == 0) { // Change default argument of /messages to inbox. and set the task to MENU_LOCAL_TASK. - $items['messages']['page arguments'] = array('privatemsg_list', 'inbox'); - $items['messages/list']['type'] = MENU_LOCAL_TASK; + $items[$url_prefix]['page arguments'] = array('privatemsg_list', 'inbox'); + $items[$url_prefix . '/list']['type'] = MENU_LOCAL_TASK; } } Index: pm_block_user/pm_block_user.module =================================================================== RCS file: /cvs/drupal/contributions/modules/privatemsg/pm_block_user/pm_block_user.module,v retrieving revision 1.5 diff -u -p -r1.5 pm_block_user.module --- pm_block_user/pm_block_user.module 18 Feb 2010 18:16:22 -0000 1.5 +++ pm_block_user/pm_block_user.module 15 Mar 2010 10:04:10 -0000 @@ -30,6 +30,7 @@ function pm_block_user_help($path) { * Implements hook_menu(). */ function pm_block_user_menu() { + $url_prefix = variable_get('privatemsg_url_prefix', 'messages'); $items['messages/block/%user'] = array( 'title' => 'Block user messages', 'page callback' => 'drupal_get_form', @@ -41,7 +42,7 @@ function pm_block_user_menu() { 'weight' => -10, ); - $items['messages/blocked'] = array( + $items[$url_prefix . '/blocked'] = array( 'title' => 'Blocked users', 'page callback' => 'drupal_get_form', 'page arguments' => array('pm_block_user_list'), @@ -215,10 +216,10 @@ function pm_block_user_privatemsg_messag if ($user->uid <> $author->uid) { if ($vars['message']['is_blocked']) { - $vars['message_actions']['unblock_author'] = array('title' => t('Unblock author'), 'href' => 'messages/block/'. $author->uid, 'query' => 'destination=messages/view/' . $thread_id); + $vars['message_actions']['unblock_author'] = array('title' => t('Unblock author'), 'href' => 'messages/block/'. $author->uid, 'query' => array('destination' => privatemsg_get_dynamic_url_prefix() . '/view/' . $thread_id)); } else { - $vars['message_actions']['block_author'] = array('title' => t('Block author'), 'href' => 'messages/block/'. $author->uid, 'query' => 'destination=messages/view/' . $thread_id); + $vars['message_actions']['block_author'] = array('title' => t('Block author'), 'href' => 'messages/block/'. $author->uid, 'query' => array('destination' => privatemsg_get_dynamic_url_prefix() . '/view/' . $thread_id)); } } } Index: pm_block_user/pm_block_user.pages.inc =================================================================== RCS file: /cvs/drupal/contributions/modules/privatemsg/pm_block_user/pm_block_user.pages.inc,v retrieving revision 1.2 diff -u -p -r1.2 pm_block_user.pages.inc --- pm_block_user/pm_block_user.pages.inc 17 Feb 2010 11:03:30 -0000 1.2 +++ pm_block_user/pm_block_user.pages.inc 15 Mar 2010 10:04:10 -0000 @@ -23,7 +23,7 @@ function pm_block_user_form($form_state, ); $form['destination'] = array( '#type' => 'value', - '#value' => isset($_GET['destination']) ? $_GET['destination'] : 'messages/', + '#value' => isset($_GET['destination']) ? $_GET['destination'] : privatemsg_get_dynamic_url_prefix(), ); if (db_result(db_query('SELECT COUNT(recipient) FROM {pm_block_user} WHERE author = %d AND recipient = %d', $author->uid, $user->uid))) { @@ -33,7 +33,7 @@ function pm_block_user_form($form_state, ); return confirm_form($form, t('You have previously blocked "@author" from sending you any more messages. Are you sure you want to unblock this user?', array('@author' => $author->name)), - isset($_GET['destination']) ? $_GET['destination'] : 'messages/', + isset($_GET['destination']) ? $_GET['destination'] : privatemsg_get_dynamic_url_prefix(), t('This action cannot be undone.'), t('Unblock @author', array('@author' => $author->name)), t('Cancel') @@ -46,7 +46,7 @@ function pm_block_user_form($form_state, ); return confirm_form($form, t('Are you sure you want to block "@author" from sending you any more messages?', array('@author' => $author->name)), - isset($_GET['destination']) ? $_GET['destination'] : 'messages/', + isset($_GET['destination']) ? $_GET['destination'] : privatemsg_get_dynamic_url_prefix(), '', t('Block @author', array('@author' => $author->name)), t('Cancel')