Index: contact.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/contact/contact.module,v
retrieving revision 1.111
diff -u -r1.111 contact.module
--- modules/contact/contact.module	9 Oct 2008 15:15:51 -0000	1.111
+++ modules/contact/contact.module	7 Feb 2009 12:40:09 -0000
@@ -199,3 +199,36 @@
       break;
   }
 }
+
+/**
+ * Implementation of hook_theme().
+ */
+function contact_theme() {
+  return array(
+    'contact_link' => array(
+      'arguments' => array('account' => NULL, 'text' => NULL, 'display' => NULL),
+      ));
+}
+
+/**
+ * A themed link to the user contact page.
+ * 
+ * @param $account: The user account.
+ * @param $text: The text to use in the link.
+ * @param $display: The type of link display desired, text or icon image.
+ */
+function theme_contact_link($account, $text = 'contact', $display = 'icon') {
+  global $user;
+  
+  // Does this account use a contact page?
+  if (!_contact_user_tab_access($account)) {
+    return;
+  }
+  // Build the correct link.
+  if ($display == 'icon') {
+    return l(theme('image', 'misc/forum-new.png'), 'user/'. $account->uid .'/contact', array('html' => TRUE, 'attributes' => array('title' => t('Contact %user', array('%user' => $account->name)))));
+  }
+  else {
+    return l(t($text), 'user/'. $account->uid .'/contact', array('attributes' => array('title' => t('Contact %user', array('%user' => $account->name)))));
+  }
+}
