Index: privatemsg.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/privatemsg/privatemsg.module,v
retrieving revision 1.107
diff -u -p -r1.107 privatemsg.module
--- privatemsg.module	2 Dec 2009 20:03:59 -0000	1.107
+++ privatemsg.module	3 Dec 2009 00:23:32 -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() {
@@ -118,16 +129,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'),
@@ -136,10 +150,10 @@ 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',
     'page callback'    => 'privatemsg_view',
-    'page arguments'   => array(2),
+    'page arguments'   => array($arg_count + 1),
     'file'             => 'privatemsg.pages.inc',
     'access callback'  => 'privatemsg_view_access',
     'type'             => MENU_LOCAL_TASK,
@@ -154,10 +168,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'),
@@ -214,6 +228,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.
@@ -250,7 +283,8 @@ function privatemsg_user_access($permiss
  * @ingroup api
  */
 function privatemsg_view_access() {
-  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;
@@ -896,7 +930,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(t('You have <a href="@messages">%unread</a>.', array('@messages' => url('messages'), '%unread' => format_plural($count, '1 unread message', '@count unread messages'))));
+          drupal_set_message(t('You have <a href="@messages">%unread</a>.', array('@messages' => url(privatemsg_get_dynamic_url_prefix()), '%unread' => format_plural($count, '1 unread message', '@count unread messages'))));
         }
       }
       break;
@@ -984,10 +1018,10 @@ function _privatemsg_block_menu() {
 
   $links = array();
   if (privatemsg_user_access('write privatemsg')) {
-    $links[] = l(t('Write new message'), 'messages/new');
+    $links[] = l(t('Write new message'), privatemsg_get_dynamic_url_prefix() . '/new');
   }
   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(
@@ -1381,7 +1415,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	3 Dec 2009 00:23:34 -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.1
diff -u -p -r1.1 privatemsg.admin.inc
--- privatemsg.admin.inc	2 Dec 2009 20:03:59 -0000	1.1
+++ privatemsg.admin.inc	3 Dec 2009 00:23:34 -0000
@@ -84,6 +84,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',
@@ -114,10 +121,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	3 Dec 2009 00:23:35 -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'] .= '<br />' . l((format_plural($thread['is_new'], '(1 new)', '(@count new)')), 'messages/view/' . $thread['thread_id'], $options);
+    $field['data'] .= '<br />' . 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_block_user/pm_block_user.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/privatemsg/pm_block_user/pm_block_user.module,v
retrieving revision 1.3
diff -u -p -r1.3 pm_block_user.module
--- pm_block_user/pm_block_user.module	2 Dec 2009 20:04:00 -0000	1.3
+++ pm_block_user/pm_block_user.module	3 Dec 2009 00:23:36 -0000
@@ -202,10 +202,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.1
diff -u -p -r1.1 pm_block_user.pages.inc
--- pm_block_user/pm_block_user.pages.inc	2 Dec 2009 20:04:00 -0000	1.1
+++ pm_block_user/pm_block_user.pages.inc	3 Dec 2009 00:23:36 -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')
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.3
diff -u -p -r1.3 pm_email_notify.module
--- pm_email_notify/pm_email_notify.module	2 Dec 2009 20:04:00 -0000	1.3
+++ pm_email_notify/pm_email_notify.module	3 Dec 2009 00:23:36 -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	3 Dec 2009 00:23:39 -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;
   }
 }
 
