Index: pmgrowl.css
===================================================================
RCS file: pmgrowl.css
diff -N pmgrowl.css
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ pmgrowl.css	20 Aug 2009 21:56:32 -0000
@@ -0,0 +1,5 @@
+/* $Id$ */
+.pmgrowl-body img {
+ float: left;
+ margin: 5px;
+}
Index: pmgrowl.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/pmgrowl/pmgrowl.module,v
retrieving revision 1.7
diff -u -8 -p -r1.7 pmgrowl.module
--- pmgrowl.module	17 Jun 2009 00:25:35 -0000	1.7
+++ pmgrowl.module	20 Aug 2009 21:56:32 -0000
@@ -7,16 +7,17 @@
  */
 
 /**
  * Implementation of hook_init().
  */
 function pmgrowl_init() {
   if (user_access('read privatemsg')) {
     // Add required files
+    drupal_add_css(drupal_get_path('module', 'pmgrowl') .'/pmgrowl.css');
     drupal_add_css(drupal_get_path('module', 'pmgrowl') .'/jgrowl/jquery.jgrowl.css');
     drupal_add_js(drupal_get_path('module', 'pmgrowl') .'/jgrowl/jquery.jgrowl_minimized.js', 'footer');
     drupal_add_js(drupal_get_path('module', 'pmgrowl') .'/pmgrowl.js', 'footer');
   
     // Pass in the interval for checking messages. Multiply by 1000 to move to milliseconds instead of seconds
     drupal_add_js(array('pmGrowlInterval' => variable_get('pmgrowl_interval', 30) * 1000), 'setting');
   }
 }
@@ -43,16 +44,46 @@ function pmgrowl_menu() {
       'page callback' => 'pmgrowl_close',
       'access callback' => TRUE,
       'type' => MENU_CALLBACK,
       );
   return $items;
 }
 
 /**
+ * Implementation of hook_theme()
+ */
+function pmgrowl_theme($existing, $type, $theme, $path) {
+  return array(
+    'pmgrowl_alert_individual_body' => array(
+      'arguments' => array(
+        'msg' => NULL,
+        'author' => NULL,
+      ),
+    ),
+    'pmgrowl_alert_individual_subject' => array(
+      'arguments' => array(
+        'msg' => NULL,
+        'author' => NULL,
+      ),
+    ),
+    'pmgrowl_alert_new_msg_body' => array(
+      'arguments' => array(
+        'msg' => NULL,
+      ),
+    ),
+    'pmgrowl_alert_new_msg_subject' => array(
+      'arguments' => array(
+        'msg' => NULL,
+      ),
+    ),
+  );
+}
+
+/**
  * Callback function to store a user's request to close a message alert
  */
 function pmgrowl_close() {
   global $user;
 
   if(variable_get('pmgrowl_operating_mode', 0) == 0) {
     // build a record to write to the database to signify this message has been closed by the user
     $table = 'pmgrowl_close';
@@ -87,23 +118,25 @@ function pmgrowl_json() {
   $result = db_query($query, $user->uid, $user->uid);
 
   $data = array();
 
   // for every message that comes back
   while ($row = db_fetch_object($result)) {
     // check the operating mode, and return a message accordingly
     if(variable_get('pmgrowl_operating_mode', 0) == 0) {
-        $row->body = check_markup(truncate_utf8($row->body, 400, FALSE, TRUE));
-        $row->body .= '<p>'. l(t('Open & Reply'), 'messages/view/'. $row->thread_id);
-        $row->body .= ' | '. l(t('View All'), 'messages') .'</p>';
-        $data[] = $row;
+      $author = user_load($row->author);
+      $message = new StdClass();
+      $message->mid = $row->mid;
+      $message->body = theme('pmgrowl_alert_individual_body', $row, $author);
+      $message->subject = theme('pmgrowl_alert_individual_subject', $row, $author);
+      $data[] = $message;
     } else {
-      $message['subject'] = 'You have Mail!';
-      $message['body'] = 'You have '. l(t('unread messages'), 'messages');
+      $message['subject'] = theme('pmgrowl_alert_new_msg_subject', $row);
+      $message['body'] = theme('pmgrowl_alert_new_msg_body', $row);
       $data[0] = $message;
 
       // now mark all of these messages as closed so that there isn't a popup on subsequent messages
       if (variable_get('pmgrowl_persistence', 0) == 0) {
         $table = 'pmgrowl_close';
         $record = new stdClass();
         $record->mid = $row->mid;
         $record->uid = $row->uid;
@@ -138,21 +171,92 @@ function pmgrowl_admin_settings() {
       );
   $form['pmgrowl_persistence'] = array(
       '#type' => 'radios',
       '#default_value' => variable_get('pmgrowl_persistence', 0),
       '#options' => array(t('One time'), t('Close manually')),
       '#title' => t('Message persistence'),
       '#description' => t('<em>This setting only applies to Operating mode "New Message alert".</em> If you choose "One time", then the message will appear only once. "Close manually" means that the message will continue to appear every time a page is loaded until the user closes it themselves.'),
       );
+  $form['pmgrowl_show_picture'] = array(
+      '#type' => 'radios',
+      '#default_value' => variable_get('pmgrowl_show_picture', 1),
+      '#options' => array(t("Don't Display"), t('Display')),
+      '#title' => t('Display User Picture'),
+      '#description' => t("This setting lets you choose whether or not you'd like to display the author's picture in the notification message."),
+      );
+  if (module_exists('imagecache')) {
+    $presets = imagecache_presets();
+    foreach ($presets as $preset) {
+      $options[$preset['presetname']] = $preset['presetname'];
+    }
+    if (! empty($options)) {
+      $form['pmgrowl_imagecache_size'] = array(
+          '#type' => 'select',
+          '#default_value' => variable_get('pmgrowl_imagecache_size', ''),
+          '#options' => $options,
+          '#title' => t('Imagecache size'),
+          '#description' => t('This setting allows you to pick which imagecache size should be used for the user picture in the notification. This setting only applies if you have chosen to display the user picture.'),
+          );
+    }
+  }
 
   return system_settings_form($form);
 }
 
 /**
  * Validate the pmgrowl settings configuration form.
  */
 function pmgrowl_admin_settings_validate($form, $form_state) {
   $interval = $form_state['values']['pmgrowl_interval'];
   if (!is_numeric($interval)) {
     form_set_error('pmgrowl_interval', t('Please enter a number.'));
   }
 }
+
+/**
+ * This function themes out the individual message alert body
+ */
+function theme_pmgrowl_alert_individual_body($msg, $author) {
+  $body = '';
+  $body .= '<div class="pmgrowl-body">';
+  if (variable_get('pmgrowl_show_picture', 1) && $author->picture) {
+    if (module_exists('imagecache') && variable_get('pmgrowl_imagecache_size', '')) {
+      $body .= theme('imagecache', variable_get('pmgrowl_imagecache_size', ''), $author->picture);
+    }
+    else {
+      $body .= theme('user_picture', $author);
+    }
+  }
+  $body .= check_markup(truncate_utf8($msg->body, 200, FALSE, TRUE));
+  $body .= '<p>'. l(t('Open & Reply'), 'messages/view/'. $msg->thread_id) . ' | '. l(t('View All'), 'messages') .'</p>';
+  $body .= '</div>';
+  return $body;
+}
+
+/**
+ * This function themes out the individual message alert subject
+ */
+function theme_pmgrowl_alert_individual_subject($msg, $author) {
+  $output = '';
+  $output .= '<div class="pmgrowl-subject">';
+  $output .= t('New message from @user', array('@user' => $author->name));
+  $output .= '</div>';
+  return $output;
+}
+
+/**
+ * This function themes out the new message alert subject
+ */
+function theme_pmgrowl_alert_new_msg_body($msg) {
+  $output = '';
+  $output .= t('You have Mail!');
+  return $output;
+}
+
+/**
+ * This function themes out the new message alert subject
+ */
+function theme_pmgrowl_alert_new_msg_subject($msg) {
+  $output = '';
+  $output .= t('You have !msgs', array('!msgs' => l(t('unread messages'), 'messages')));
+  return $output;
+}
