commit 805e1a384c280a0ce43e31d27554ad742ca36f21
Author: Brückner Tamás <tamas.bruckner@integralvision.hu>
Date:   Mon Sep 14 16:44:49 2015 +0200

    Default.

diff --git a/rules_mail_edit.module b/rules_mail_edit.module
index b418031..da16a17 100644
--- a/rules_mail_edit.module
+++ b/rules_mail_edit.module
@@ -6,7 +6,7 @@
  */
 
 // Don't change these. Changing these will create new mail_edit templates.
-define("RULES_MAIL_EDIT_MAIL_RULE_KEY", 'rules_mail_edit_action_mail_');
+define("RULES_MAIL_EDIT_MAIL_RULE_KEY", 'rules_mail_edit_action_mail_single_');
 define("RULES_MAIL_EDIT_MAIL_ROLE_RULE_KEY", 'rules_mail_edit_action_mail_to_users_of_role_');
 
 /**
@@ -29,8 +29,16 @@ function rules_mailkeys() {
     $iterator = $rule->elements();
     foreach ($iterator as $k => $child) {
       $plugin_name = $child->getPluginName();
+
+
       if (isset($key_prefix[$plugin_name])) {
-        $mailkeys[$key_prefix[$plugin_name] . $key . '_' . $child->elementId()] = $rule->label;
+        $label = $rule->label;
+        if (!empty($child->settings['name'])) {
+          $label .= ' - ' . $child->settings['name'];
+        }
+
+        $mailkeys[$key_prefix[$plugin_name] . $key . '_' . $child->elementId()] = $label;
+
       }
     }
   }
@@ -45,6 +53,46 @@ function rules_mail_edit_text($mailkey, $language) {
   $message['subject'] = t('subject');
   $message['body']    = t('body');
 
+  $prefix = substr($mailkey, 0, strlen(RULES_MAIL_EDIT_MAIL_RULE_KEY));
+  if ($prefix == RULES_MAIL_EDIT_MAIL_RULE_KEY) {
+    $matches = array();
+    if (preg_match('/^(.*)_([0-9]+)$/', substr($mailkey, strlen(RULES_MAIL_EDIT_MAIL_RULE_KEY)), $matches)) {
+      $name = $matches[1];
+      $id = $matches[2];
+
+      $rule = rules_element_load($id, $name);
+
+      if (isset($rule->settings['subject'])) {
+        $message['subject'] = $rule->settings['subject'];
+      }
+
+      if (isset($rule->settings['message'])) {
+        $message['body'] = $rule->settings['message'];
+      }
+    }
+  }
+
+  $prefix = substr($mailkey, 0, strlen(RULES_MAIL_EDIT_MAIL_ROLE_RULE_KEY));
+  if ($prefix == RULES_MAIL_EDIT_MAIL_ROLE_RULE_KEY) {
+    $matches = array();
+    if (preg_match('/^(.*)_([0-9]+)$/', substr($mailkey, strlen(RULES_MAIL_EDIT_MAIL_ROLE_RULE_KEY)), $matches)) {
+      $name = $matches[1];
+      $id = $matches[2];
+
+      $rule = rules_element_load($id, $name);
+
+      if (isset($rule->settings['subject'])) {
+        $message['subject'] = $rule->settings['subject'];
+      }
+
+      if (isset($rule->settings['message'])) {
+        $message['body'] = $rule->settings['message'];
+      }
+    }
+  }
+
+
+
   return $message;
 }
 
diff --git a/rules_mail_edit.rules.inc b/rules_mail_edit.rules.inc
index 8507d14..bde5982 100644
--- a/rules_mail_edit.rules.inc
+++ b/rules_mail_edit.rules.inc
@@ -22,6 +22,11 @@ function rules_mail_edit_rules_action_info() {
       'label' => t('Send mail using mail edit templates'),
       'group' => t('System'),
       'parameter' => array(
+        'name' => array(
+          'type' => 'text',
+          'label' => t('Name'),
+          'description' => t('Give a human readable name for this mail sending.'),
+        ),
         'to' => array(
           'type' => 'text',
           'label' => t('To'),
@@ -60,6 +65,11 @@ function rules_mail_edit_rules_action_info() {
       'label' => t('Send mail to all users of a role using mail edit templates'),
       'group' => t('System'),
       'parameter' => array(
+        'name' => array(
+          'type' => 'text',
+          'label' => t('Name'),
+          'description' => t('Give a human readable name for this mail sending.'),
+        ),
         'roles' => array(
           'type' => 'list<integer>',
           'label' => t('Roles'),
