? .cvsignore
? cvs-release-notes.php
? jgrowl
? pmgrowl_1.patch
? use_theme_functions.patch
Index: pmgrowl.css
===================================================================
RCS file: pmgrowl.css
diff -N pmgrowl.css
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ pmgrowl.css	6 Jan 2011 17:04:48 -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.9.2.1
diff -u -p -r1.9.2.1 pmgrowl.module
--- pmgrowl.module	19 Jul 2010 11:17:47 -0000	1.9.2.1
+++ pmgrowl.module	6 Jan 2011 17:04:48 -0000
@@ -11,7 +11,8 @@
  */
 function pmgrowl_init() {
   if (user_access('read privatemsg')) {
-    // Add required files
+    // 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', 'module', 'footer');
     drupal_add_js(drupal_get_path('module', 'pmgrowl') .'/pmgrowl.js', 'module', 'footer');
@@ -48,6 +49,26 @@ function pmgrowl_menu() {
 }
 
 /**
+ * Implementation of hook_theme()
+ */
+function pmgrowl_theme($existing, $type, $theme, $path) {
+  return array(
+    'pmgrowl_alert_individual_body' => array(
+      'arguments' => array('message' => NULL),
+    ),
+    'pmgrowl_alert_individual_subject' => array(
+      'arguments' => array('message' => NULL),
+    ),
+    'pmgrowl_alert_new_msg_body' => array(
+      'arguments' => array('unread' => NULL),
+    ),
+    'pmgrowl_alert_new_msg_subject' => array(
+      'arguments' => array('unread' => NULL),
+    ),
+  );
+}
+
+/**
  * Callback function to store a user's request to close a message alert
  */
 function pmgrowl_close() {
@@ -107,11 +128,7 @@ function pmgrowl_sql_unclosed(&$fragment
   $fragments['primary_table'] = '{pm_index} pmi';
 
   // Add all necessary fields.
-  $fragments['select']['thread_id'] = 'pmi.thread_id';
   $fragments['select']['mid'] = 'pmi.mid';
-  $fragments['select']['subject'] = 'pm.subject';
-  $fragments['select']['body'] = 'pm.body';
-  $fragments['select']['format'] = 'pm.format';
 
   // Add join to {pm_message}
   $fragments['inner_join']['pm_message'] = 'INNER JOIN {pm_message} pm ON (pmi.mid = pm.mid)';
@@ -147,24 +164,27 @@ function pmgrowl_json() {
     $query = _privatemsg_assemble_query(array('unclosed', 'pmgrowl'), $user);
     $result = db_query($query['query']);
     $data = array();
-
+    $mids = array();
     while ($row = db_fetch_object($result)) {
-      $row->body = check_markup(truncate_utf8($row->body, 400, FALSE, TRUE), $row->format, FALSE);
-      $row->body .= '<p>' . l(t('Open & Reply'), 'messages/view/' . $row->thread_id, array('fragment' => 'privatemsg-mid-' . $row->mid));
-      $row->body .= ' | ' . l(t('View All'), 'messages') .'</p>';
-      $data[] = $row;
+      $mids[] = $row->mid;
+    }
+    foreach (privatemsg_message_load_multiple($mids) as $message) {
+      $data[] = array(
+        'mid' => $message['mid'],
+        'subject' => theme('pmgrowl_alert_individual_subject', $message),
+        'body' => theme('pmgrowl_alert_individual_body', $message),
+      );
 
       // If auto-close is enabled, mark messages as closed.
       if (variable_get('pmgrowl_persistence', 0) == 0) {
-        pmgrowl_close_message($user->uid, $row->mid);
+        pmgrowl_close_message($user->uid, $message['mid']);
       }
     }
   }
   else {
     if ($unread = privatemsg_unread_count()) {
-      $message['subject'] = t('You have mail!');
-      $message['body'] = '<p>' . t('You have received a !received_messages_link!', array('!received_messages_link' => l(t('new message'), 'messages'))) . '</p>';
-      $message['body'] .= '<p>' . t('You have @unread_message_count @unread_messages.', array('@unread_message_count' => $unread, '@unread_messages' => format_plural($unread, 'unread message', 'unread messages'))) . '</p>';
+      $message['subject'] = theme('pmgrowl_alert_new_msg_subject', $unread);
+      $message['body'] = theme('pmgrowl_alert_new_msg_body', $unread);
       $data[0] = $message;
 
       // If auto-close is enabled, mark all messages as closed.
@@ -206,6 +226,28 @@ function pmgrowl_admin_settings() {
     '#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' => 'checkbox',
+    '#default_value' => variable_get('pmgrowl_show_picture', 1),
+    '#title' => t('Display author picture'),
+    '#description' => t("If checked, the author profile picture is displayed in growl notifications."),
+  );
+
+  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);
 }
 
@@ -218,3 +260,48 @@ function pmgrowl_admin_settings_validate
     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($message) {
+  $body = '<div class="pmgrowl-body">';
+  if (variable_get('pmgrowl_show_picture', 1) && $message['author']->picture) {
+    if (module_exists('imagecache') && variable_get('pmgrowl_imagecache_size', '')) {
+      $body .= theme('imagecache', variable_get('pmgrowl_imagecache_size', ''), $message['author']->picture);
+    }
+    else {
+      $body .= theme('user_picture', $message['author']);
+    }
+  }
+  $body .= check_markup(truncate_utf8($message['body'], 400, FALSE, TRUE), $message['format'], FALSE);
+  $body .= '<p>'. l(t('Open & Reply'), 'messages/view/'. $message['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($message) {
+  $output = '<div class="pmgrowl-subject">';
+  $output .= t('New message from !user', array('!user' => theme('username', $message['author'])));
+  $output .= '</div>';
+  return $output;
+}
+
+/**
+ * This function themes out the new message alert subject
+ */
+function theme_pmgrowl_alert_new_msg_subject($unread) {
+  return t('You have mail!');
+}
+
+/**
+ * This function themes out the new message alert body
+ */
+function theme_pmgrowl_alert_new_msg_body($unread) {
+  $output = '<p>' . t('You have received a !received_messages_link!', array('!received_messages_link' => l(t('new message'), 'messages'))) . '</p>';
+  $output .= '<p>' . t('You have @unread_message_count @unread_messages.', array('@unread_message_count' => $unread, '@unread_messages' => format_plural($unread, 'unread message', 'unread messages'))) . '</p>';
+  return $output;
+}
