As it is, a user can send himself/herself a message. So far, that's not too bad.
The problem is, imo, when there's a link next to your post or comment to "write" to yourself.

There's only one line to change in the code :

/**
 * Implementation of hook_link().
 */
function privatemsg_link($type, $node = 0, $main = 0) {
  global $user;
  static $access = array();
  if (user_access('access private messages') && ($type == 'node' || $type == 'comment') && variable_get("privatemsg_link_$type", 0) && (isset($user->privatemsg_allow) ? $user->privatemsg_allow : 1)) {
    if (!isset($access[$node->uid])) {
      $author = user_load(array('uid' => $node->uid));
      $access[$node->uid] = user_access('access private messages', $author) && $author->uid && (isset($author->privatemsg_allow) ? $author->privatemsg_allow : 1);
    }
    // if ($access[$node->uid]) {
      if ($access[$node->uid] && ($node->uid != $user->uid)) {
      return array(l(t('write to author'), 'privatemsg/msgto/'. $node->uid));
    }
  }
} 

So you change this line :

if ($access[$node->uid]) {

To that line :

if (($node->uid != $user->uid) && $access[$node->uid]) {

Comments

mindless’s picture

Assigned: Unassigned » mindless
Status: Active » Fixed

fixed in DRUPAL-4-7 and DRUPAL-5 branches.

Anonymous’s picture

Status: Fixed » Closed (fixed)