Index: privatemsg.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/privatemsg/privatemsg.module,v
retrieving revision 1.70.2.30.2.91.2.69
diff -u -p -r1.70.2.30.2.91.2.69 privatemsg.module
--- privatemsg.module	4 Oct 2009 22:48:42 -0000	1.70.2.30.2.91.2.69
+++ privatemsg.module	6 Oct 2009 12:16:09 -0000
@@ -411,6 +411,46 @@ function private_message_settings() {
   );
 
   $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 link on profile pages.'),
+    '#description' => t('If this setting is enabled, a link to send a private message will be displayed.'),
+    '#default_value' => variable_get('privatemsg_display_profile_links', 1),
+  );
+  $form['links']['privatemsg_display_own_links'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Display link for current user.'),
+    '#description' => t('If enabled, a link to send a private message is displayed if the recipient is the current user.'),
+    '#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 link on the selected content types'),
+    '#description' => t('Select which content types should display a link to send a private message to the author. By default, the link is not displayed below teasers.'),
+    '#default_value' => variable_get('privatemsg_link_node_types', array()),
+    '#options' => $node_types,
+  );
+  $form['links']['privatemsg_display_on_teaser'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Display link on teasers of the 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.'),
+    '#description' => t('Also display a link to send a private message to the authors of the comments of the selected content types.'),
+    '#default_value' => variable_get('privatemsg_display_on_comments', 0),
+  );
   return system_settings_form($form);
 }
 
@@ -1147,7 +1187,7 @@ function privatemsg_user($op, &$edit, &$
 
   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())),
@@ -1615,6 +1655,9 @@ function privatemsg_get_link($recipients
 
   $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;
     }
@@ -2134,3 +2177,36 @@ function privatemsg_privatemsg_thread_op
   }
   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
Index: privatemsg.install
===================================================================
RCS file: /cvs/drupal/contributions/modules/privatemsg/privatemsg.install,v
retrieving revision 1.5.2.4.2.11.2.11
diff -u -p -r1.5.2.4.2.11.2.11 privatemsg.install
--- privatemsg.install	7 Jul 2009 23:31:43 -0000	1.5.2.4.2.11.2.11
+++ privatemsg.install	6 Oct 2009 12:16:10 -0000
@@ -109,6 +109,11 @@ function privatemsg_uninstall() {
   variable_del('privatemsg_per_page');
   variable_del('privatemsg_display_loginmessage');
   variable_del('privatemsg_display_fields');
+  variable_del('privatemsg_display_profile_links');
+  variable_del('privatemsg_display_own_links');
+  variable_del('privatemsg_link_node_types');
+  variable_del('privatemsg_display_on_teaser');
+  variable_del('privatemsg_display_on_comments');
   drupal_uninstall_schema('privatemsg');
 }
 
