Index: privatemsg.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/privatemsg/privatemsg.module,v
retrieving revision 1.70.2.30.2.91.2.53
diff -u -r1.70.2.30.2.91.2.53 privatemsg.module
--- privatemsg.module	8 Jun 2009 14:27:53 -0000	1.70.2.30.2.91.2.53
+++ privatemsg.module	12 Jun 2009 21:01:50 -0000
@@ -361,6 +361,42 @@
   );
 
   $form['#submit'][] = 'private_message_settings_submit';
+
+  $form['links'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('"Send private message" link settings'),
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
+  );
+
+  $form['links']['privatemsg_display_profile_links'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Display "Send private message" links on profile pages'),
+    '#default_value' => variable_get('privatemsg_display_profile_links', 1),
+  );
+  $form['links']['privatemsg_display_own_links'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Display "Send private message" links to self.'),
+    '#default_value' => variable_get('privatemsg_display_own_links', 1),
+  );
+
+  $node_types = node_get_types('names');
+  $form['links']['privatemsg_link_node_types'] = array(
+    '#type' => 'checkboxes',
+    '#title' => t('Display "Send private message to author" links on the selected content types'),
+    '#default_value' => variable_get('privatemsg_link_node_types', array()),
+    '#options' => $node_types,
+  );
+  $form['links']['privatemsg_display_on_teaser'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Display links on teasers of selected content types.'),
+    '#default_value' => variable_get('privatemsg_display_on_teaser', 1),
+  );
+  $form['links']['privatemsg_display_on_comments'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Display links on comments of selected content types.'),
+    '#default_value' => variable_get('privatemsg_display_on_comments', 0),
+  );
   return system_settings_form($form);
 }
 
@@ -986,7 +1022,7 @@
 
   switch ($op) {
     case 'view':
-      if ($url = privatemsg_get_link(array($account))) {
+      if ($url = privatemsg_get_link(array($account)) && variable_get('privatemsg_display_profile_links', 1)) {
         $account->content['privatemsg_send_new_message'] = array(
           '#type'   => 'markup',
           '#value'  => l(t('Send this user a message'), $url, array('query' => drupal_get_destination())),
@@ -1382,6 +1418,9 @@
 
   $validated = array();
   foreach ($recipients as $recipient) {
+    if (!variable_get('privatemsg_display_own_links', 1) && $recipient->uid == $account->uid) {
+      continue;
+    }
     if (!privatemsg_user_access('read privatemsg', $recipient)) {
       continue;
     }
@@ -1858,3 +1897,36 @@
   );
   return $operations;
 }
+
+function privatemsg_link($type, $object, $teaser = FALSE) {
+  global $user;
+  static $nodes = array();
+  $links = array();
+
+  if (!isset($nodes[$object->uid])) {
+    if ($type == 'node') {
+      $nodes[$object->nid] = $object;
+    }
+    elseif ($type == 'comment') {
+      $nodes[$object->nid] = node_load($object->nid);
+    }
+  }
+  
+  $types = array_filter(variable_get('privatemsg_link_node_types', array()));
+  $url = privatemsg_get_link(user_load($object->uid));
+  if ($type == 'node' && in_array($object->type, $types) && !empty($url) && ($teaser == FALSE || variable_get('privatemsg_display_on_teaser', 1))) {
+    $links['privatemsg_link'] = array(
+      'title' => t('Send private message to author'),
+      'href' => $url . '/' . t('Message regarding @node', array( '@node' => $object->title)),
+      'query' => drupal_get_destination(),
+    );
+  }
+  if ($type == 'comment' && in_array($nodes[$object->nid]->type, $types) && !empty($url) && variable_get('privatemsg_display_on_comments', 0)) {
+    $links['privatemsg_link'] = array(
+      'title' => t('Send private message'),
+      'href' => $url . '/' . t('Message regarding @comment', array( '@comment' => $object->subject)),
+      'query' => drupal_get_destination(),
+    );
+  }
+  return $links;
+}
\ No newline at end of file

