--- emailpage.module_original	Mon May  8 22:54:37 2006
+++ emailpage.module	Tue May  9 01:10:42 2006
@@ -1,9 +1,11 @@
 <?php
 /* $Id: emailpage.module,v 1.8 2006/03/13 22:11:06 deekayen Exp $ */
 
-define('EMAILPAGE_SUBJECT_LINE', variable_get('emailpage_subject_line', t("thought you'd like to see this")));
+define('EMAILPAGE_SUBJECT_LINE', variable_get('emailpage_subject_line', t("%someone thought you'd like to see this")));
 define('EMAILPAGE_TITLE', t('Email this page to a friend'));
-define('EMAILPAGE_MESSAGE', variable_get('emailpage_message', t('%someone thought you would like this page')."\n"));
+define('EMAILPAGE_MESSAGE', variable_get('emailpage_message', t('%someone thought you would like this page. Click the link above to visit it!')."\n"));
+define('EMAILPAGE_SENDER_ADDY', variable_get('emailpage_sender_addy', "NoReply@".$host['host']));
+define('EMAILPAGE_SUCCESS_MSG', variable_get('emailpage_success_msg', t('Your message was sent to %recipient.')));
 
 function emailpage_help($section) {
   if ($section == 'admin/modules#description') {
@@ -73,9 +75,9 @@
   if(!$_COOKIE['referer']) {
     if($_GET['nid']) {
       if($_GET['cid']) {  // this takes care of links to specific comments
-        $nodelink = $base_url .'/'. url('node/'. $_GET['nid'] ."#comment-". $_GET['cid']);
+        $nodelink = $base_url . url('node/'. $_GET['nid'] ."#comment-". $_GET['cid']);
       } else {
-        $nodelink = $base_url .'/'. url('node/' .$_GET['nid']);
+        $nodelink = $base_url . url('node/' .$_GET['nid']);
       }
       // Set the refering page in a cookie
       // 5mins should be enuf for anyone to put in a valid email address ;-)
@@ -90,9 +92,9 @@
   //  we need to check if the form has been posted..
   if($_POST) {
     if(!user_validate_mail($_POST['edit']['emailpage_addy']) && $_POST['edit']['emailpage_sender'] && $_COOKIE['referer']) {  // all is well, so lets send it!
-      $headers = 'Reply-To: '. variable_get('emailpage_sender_addy', ''). "\r\nFrom: ". variable_get('emailpage_sender_addy', ''). "\r\n";
+      $headers = 'Reply-To: '. EMAILPAGE_SENDER_ADDY. "\r\nFrom: ". EMAILPAGE_SENDER_ADDY. "\r\n";
       $headers = "MIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8; format=flowed\nContent-transfer-encoding: 8Bit\n" . $headers;
-      mail($_POST['edit']['emailpage_addy'], $_POST['edit']['emailpage_sender'].' '. mime_header_encode(EMAILPAGE_SUBJECT_LINE), $_COOKIE['referer']. "\n\n". wordwrap(str_replace('%someone', $_POST['edit']['emailpage_sender'], EMAILPAGE_MESSAGE), 72), $headers);
+      mail($_POST['edit']['emailpage_addy'], mime_header_encode(str_replace('%someone', $_POST['edit']['emailpage_sender'], EMAILPAGE_SUBJECT_LINE)), $_COOKIE['referer']. "\n\n". wordwrap(str_replace('%someone', $_POST['edit']['emailpage_sender'], EMAILPAGE_MESSAGE), 72), $headers);
 
       // Delete the cookie
       // If we dont do this, sending other pages becomes messy.
@@ -101,7 +103,7 @@
       // Increase the emailpage_flood_control cookie (check settings)
       setcookie('emailpage_flood_count', $_COOKIE['emailpage_flood_count']+1, time()+7200, '/', '.'.$host['host']);
 
-      $content=variable_get('emailpage_success_msg', t('Success!'));
+      drupal_set_message(str_replace('%recipient',$_POST['edit']['emailpage_addy'], EMAILPAGE_SUCCESS_MSG));
       variable_set('emailpage_total', variable_get('emailpage_total', 0)+1);
     	drupal_goto();
       return;
@@ -133,7 +135,7 @@
       $form['#method'] = 'post';
       $form['#action'] = url('emailpage');
       $content .= '<h2>'. t('Example Email')."</h2>\n";
-      $content .= '<p><strong>'. t('Subject'). ': </strong>['. t('Your Name').'] '.EMAILPAGE_SUBJECT_LINE."</p>\n\n<p>".$nodelink."</p>\n\n<p>[".t('Your Name').'] '.nl2br(EMAILPAGE_MESSAGE).'</p>';
+      $content .= '<p><strong>'. t('Subject'). ': </strong> '.str_replace('%someone','['.t('Your Name').']', EMAILPAGE_SUBJECT_LINE)."</p>\n\n<p>".$nodelink."</p>\n\n<p>".nl2br(str_replace('%someone','['.t('Your Name').']',EMAILPAGE_MESSAGE)).'</p>';
       $form['emailpage_stuff'] = array('#type' => 'markup', '#value' => $content, '#weight' => -1);
       return drupal_get_form('emailpage', $form);
 
@@ -141,8 +143,8 @@
   }
 
   if(!$_POST) {
-    $content .= '<h2>'. t('Example  Email'). "</h2>\n";
-    $content .= '<p><strong>'. t('Subject'). ': </strong>['. t('Your Name'). '] '. EMAILPAGE_SUBJECT_LINE. "</p>\n\n<p>". $nodelink. "</p>\n\n<p>[". t('Your Name'). '] '. nl2br(EMAILPAGE_MESSAGE). '</p>';
+    $content .= '<h2>'. t('Example Email'). "</h2>\n";
+      $content .= '<p><strong>'. t('Subject'). ': </strong> '.str_replace('%someone','['.t('Your Name').']', EMAILPAGE_SUBJECT_LINE)."</p>\n\n<p>".$nodelink."</p>\n\n<p>".nl2br(str_replace('%someone','['.t('Your Name').']',EMAILPAGE_MESSAGE)).'</p>';
 
     $form['emailpage_stuff'] = array('#type' => 'markup', '#value' => $content);
     $form['emailpage_sender'] = array(
@@ -161,7 +163,7 @@
     );
     $form['emailpage_submit'] = array(
       '#type' => 'submit',
-      '#value' => 'Send it Now!',
+      '#value' => t('Send it Now!'),
     );
 
     return drupal_get_form('emailpage', $form);
@@ -182,7 +184,7 @@
   $form['emailpage'] = array(
       '#type' => 'fieldset',
       '#title' => t('Emailpage settings'),
-      '#tree' => TRUE,
+      '#tree' => FALSE,
     );
 
   $form['emailpage']['emailpage_stuff'] = array('#type' => 'markup', '#value' => $stuff);
@@ -217,18 +219,19 @@
   $form['emailpage']['emailpage_sender_addy'] = array(
     '#type' => 'textfield',
     '#title' => t('Sender Address'),
-    '#default_value' => variable_get('emailpage_sender_addy', "NoReply@".$host['host']),
+    '#default_value' => EMAILPAGE_SENDER_ADDY,
     '#size' => 30,
     '#maxlength' => 40,
     '#description' => t('The address to send FROM.'),
   );
+
   $form['emailpage']['emailpage_subject_line'] = array(
     '#type' => 'textfield',
     '#title' => t('Subject Line'),
     '#default_value' => EMAILPAGE_SUBJECT_LINE,
-    '#size' => 30,
-    '#maxlength' => 40,
-    '#description' => t('The subject line will start with the senders name as the first word, you can edit the rest of the line above.')
+    '#size' => 40,
+    '#maxlength' => 60,
+    '#description' => t("The string '%someone' is used as a placeholder for the sender's name in the subject. Example: <em>%someone thought you'd like to see this</em>")
   );
 
   $form['emailpage']['emailpage_message'] = array(
@@ -237,7 +240,16 @@
     '#default_value' => EMAILPAGE_MESSAGE,
     '#cols' => 40,
     '#rows' => 10,
-    '#description' => t('The senders name will appear as the first word followed by the text in the textarea above.')
+    '#description' => t("The string '%someone' is used as a placeholder for the sender's name in the message. Example: <em>%someone thought you would like this page. Click the link above to visit it!</em>")
+  );
+
+  $form['emailpage']['emailpage_success_msg'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Success Message'),
+    '#default_value' => EMAILPAGE_SUCCESS_MSG,
+    '#size' => 40,
+    '#maxlength' => 60,
+    '#description' => t("This text will be shown to the user when the message has been sent. The string '%recipient' can be used to include the recieving address, for example: <em>Your message was sent to %recipient.</em>")
   );
 
   $form['emailpage']['emailpage_flood_error_msg'] = array(
