--- privatemsg.module	2008-08-26 09:09:16.000000000 -0700
+++ privatemsg.module	2008-09-01 19:57:00.000000000 -0700
@@ -27,14 +27,14 @@ function privatemsg_menu() {
   $items['messages'] = array(
     'title' => t('Private messages'),
     'page callback' => 'privatemsg_list',
-    'access arguments' => array('read privatemsg'),
+    'access callback' => '_privatemsg_access',
     'type' => MENU_NORMAL_ITEM,
   );
   //list all messages this user received
   $items['messages/inbox'] = array(
     'title' => t('Inbox'),
     'page callback' => 'privatemsg_list',
-    'access arguments' => array('read privatemsg'),
+    'access callback' => '_privatemsg_access',
     'type' => MENU_DEFAULT_LOCAL_TASK,
     'weight'  => -10,
   );
@@ -50,7 +50,7 @@ function privatemsg_menu() {
   $items['messages/sent'] = array(
     'title' => t('Sent messages'),
     'page callback' => 'privatemsg_list',
-    'access arguments' => array('read privatemsg'),
+    'access callback' => '_privatemsg_access',
     'type' => MENU_LOCAL_TASK,
     'weight'  => -5,
   );
@@ -86,6 +86,25 @@ function privatemsg_menu() {
     'type' => MENU_CALLBACK,
     'weight' => -10,
   );  
+  // Read all access via user account page.
+  $items['user/%/messages'] = array(
+    'title' => 'Messages',
+    'page callback' => 'privatemsg_list',
+    'access callback' => '_privatemsg_access',
+    'type' => MENU_LOCAL_TASK,
+  );
+  $items['user/%/messages/inbox'] = array(
+    'title' => 'Inbox',
+    'page callback' => 'privatemsg_list',
+    'access callback' => '_privatemsg_access',
+    'type' => MENU_DEFAULT_LOCAL_TASK,
+  );
+  $items['user/%/messages/sent'] = array(
+    'title' => 'Sent messages',
+    'page callback' => 'privatemsg_list',
+    'access callback' => '_privatemsg_access',
+    'type' => MENU_LOCAL_TASK,
+  );
   //Admin pages
   $items['admin/settings/messages'] = array(
     'title'               => t('Private messages'),
@@ -211,31 +230,19 @@ function privatemsg_preprocess_privatems
  */
 function privatemsg_list($uid = NULL) {
   global $user;
-  disallow_anon_access();
   
-  if (!$uid) {    
-    // default behavior: we are trying to view our own private message if no uid is passed
+  if (arg(0) == 'user' && is_numeric(arg(1))) {
+    $uid = arg(1);
+    $account = user_load(array('uid' => $uid));
+    $box = arg(3);
+  }
+  else {
     $account = $user;
-  } 
-  else {  //here it means we are viewing either our own or some one else's messages
-    if ($uid && $uid == $user->uid) { //viewing our own messagess
-      $account = $user;
-    }
-    else if ($uid && $uid != $user->uid && user_access('read all private messages') ) {
-      $account = user_load(array('uid' => $uid));
-    }
-    else {  //we tried viewing some one else's messages but didnt have sufficient rights
-      drupal_set_message("You do not have sufficient rights to view someone else's messages", WATCHDOG_WARNING);
-      $account = $user;
-    }
-  }//end access permissions
-  /**
-   * By This point we have figured out for which user we are listing messages
-   * now it is safe to use $account->uid in listing query
-   */
+    $box = arg(1);
+  }
   
 //  drupal_set_message('<pre>'. print_r($uid, 1) .'</pre>');
-  switch (arg(1)) {
+  switch ($box) {
    case 'sent':
      $query = _privatemsg_assemble_query('privatemsg_list_sent', $account);
      break;
@@ -762,6 +769,23 @@ function disallow_anon_access() {
     exit;
   }
 }
+
+function _privatemsg_access () {
+  global $user;
+  if (!$user->uid) { // Disallow anonymous access, regardless of permissions
+    return FALSE;
+  }
+  elseif (arg(0) == 'user' && is_numeric(arg(1))) {
+    if (!user_access('read all private messages')) {
+      return FALSE;
+    }
+  }
+  elseif (!user_access('read privatemsg')) {
+    return FALSE;
+  }
+  return TRUE;
+}
+
 function privatemsg_user($op, &$edit, &$account, $category = NULL) {
   switch ($op) {
     case 'view':
