From ab8dc68b7f8439814913f512d4b1794c80d1a408 Mon Sep 17 00:00:00 2001
From: Mirko Haaser <kontakt@mirko-haaser.de>
Date: Mon, 21 Mar 2011 08:36:15 +0100
Subject: [PATCH] Issue #992964 b< McGo: Adding additional information to status mail by exposing a site wide textarea in the module settings

---
 update_advanced.module       |   18 ++++++++++++++++++
 update_advanced.settings.inc |    8 ++++++++
 2 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/update_advanced.module b/update_advanced.module
index e1b0fe6..47d0b96 100644
--- a/update_advanced.module
+++ b/update_advanced.module
@@ -75,6 +75,24 @@ function update_advanced_update_status_alter(&$projects) {
 }
 
 /**
+ * Implements hook_mail_alter().
+ *
+ * This function will be used to alter the status mail of the drupal update
+ * status und add the configured token.
+ *
+ * @param $message
+ *   Reference to the message that is about to be altered.
+ */
+function update_advanced_mail_alter(&$message) {
+  if ($message['id'] == 'update_status_notify') {
+    $param_list = explode("\n", variable_get('update_advanced_additional_mailtext', ''));
+    foreach ($param_list as $param) {
+      array_push($message['body'], $param);
+    }
+  }
+}
+
+/**
  * Check if a project or a project's release has been set to be ignored.
  *
  * @param $project
diff --git a/update_advanced.settings.inc b/update_advanced.settings.inc
index 2c550b2..3d1cbf2 100644
--- a/update_advanced.settings.inc
+++ b/update_advanced.settings.inc
@@ -15,6 +15,13 @@ function _update_advanced_alter_settings(&$form, $form_state) {
     '#default_value' => variable_get('update_advanced_check_disabled', FALSE),
   );
 
+  $form['update_advanced_additional_mailtext'] = array(
+    '#type' => 'textarea',
+    '#title' => t('Additional text added to the status mail'),
+    '#default_value' => variable_get('update_advanced_additional_mailtext', ''),
+    '#description' => t('This text will be added to the status mail that you receive upon new available module versions. You could easily add information regarding your Drupal site. This might be interesting if you automatically process these mails by a issue tracking tool liken Open Atrium or Redmine for automatically assigning the created mail to a project.'),
+  );
+
   if ($available = update_get_available(TRUE)) {
     drupal_add_css(drupal_get_path('module', 'update_advanced') . '/update_advanced.css');
 
@@ -77,6 +84,7 @@ function _update_advanced_alter_settings(&$form, $form_state) {
 function theme_update_advanced_settings($form) {
   $output = '';
   $output .= drupal_render($form['update_notify_emails']);
+  $output .= drupal_render($form['update_advanced_additional_mailtext']);
   $output .= drupal_render($form['update_check_frequency']);
   $output .= drupal_render($form['update_notification_threshold']);
   $output .= drupal_render($form['update_advanced_check_disabled']);
-- 
1.7.3.2

