--- forward.module (saved version)
+++ (current document)
@@ -104,13 +104,13 @@
     '#title' => t('Show link on main page'),
     '#return_value' => 1,
     '#default_value' => variable_get('forward_show_on_main', FALSE),
-    '#description' => t('If checked, the link will appear on your home page'),
+    '#description' => t('If checked, the link will appear on your home page. If Form Type is block_link or block_form, this does not matter.'),
   );
   $form['forward_options']['forward_form_type'] = array(
     '#type' => 'select',
     '#title' => t('Form Type'),
     '#default_value' => variable_get('forward_form_type', "link"),
-    '#options' => array("link" => "link", "form" => "form"),
+    '#options' => array("link" => "link", "form" => "form", "block_link" => "block_link", "block_form" => "block_form"),
     '#description' => t('Select link for a forward this page link or form to use a collapsible forwarding form.'),
   );
   $form['forward_options']['forward_flood_control'] = array(
@@ -349,7 +349,7 @@
 }
 
 /**
- * Generate nodeapi integration, foward signup
+ * Generate nodeapi integration, forward signup
  */
 function forward_nodeapi(&$node, $op, $arg = 0){
   if (variable_get('forward_form_type', 'link') == "form" && !$node->in_preview && variable_get('forward_display_'. $node->type, '1') == 1){
@@ -426,11 +426,90 @@
     '#type' => 'hidden',
     '#value' => $node->nid,
   );
+	$form['message']['forward_footer'] = array(
+    '#type' => 'hidden',
+    '#value' => variable_get('forward_footer', ''),
+  );
+  $form['message']['submit'] = array(
+    '#type' => 'submit',
+    '#value' => t('Send Message'),
+  );
+
+  $form['#method'] = 'post';
+  return $form;
+}
+
+function forward_form_block_body() {
+  global $user;
+  $form['message']['yemail'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Your Email'),
+    '#default_value' => $user->mail,
+    '#size' => 58,
+    '#maxlength' => 256,
+    '#description' => NULL,
+    '#attributes' => NULL,
+    '#required' => TRUE,
+  );
+  $form['message']['yname'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Your Name'),
+    '#default_value' => $user->name,
+    '#size' => 58,
+    '#maxlength' => 256,
+    '#description' => NULL,
+    '#attributes' => NULL,
+    '#required' => TRUE,
+  );
+  $form['message']['recipients'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Send To'),
+    '#default_value' => str_replace('\n', ', ', $recipients),
+    '#size' => 58,
+    '#description' => t('Enter multiple addresses by separateing them with commas.'),
+    '#attributes' => NULL,
+    '#required' => TRUE,
+  );
+  $form['message']['subject'] = array(
+    '#type' => 'item',
+    '#title' => t('Message Subject'),
+    '#value' => t(variable_get('forward_'.$emailtype.'subject', '!name has sent you a message from !site'), array('!name' => t('(Your Name)'), '!site' => variable_get('site_name', 'drupal'))),
+    '#description' => '',
+  );
+  $form['message']['body'] = array(
+    '#type' => 'item',
+    '#title' => t('Message Body'),
+    '#value' => t(variable_get('forward_'.$emailtype.'message', '!name thought you would like to see the !site web site.'), array('!name' => t('(Your Name)'), '!site' => variable_get('site_name', 'drupal'))),
+    '#description' => '',
+  );
+  $form['message']['message'] = array(
+    '#type' => 'textarea',
+    '#title' => t('Your Personal Message'),
+    '#default_value' => '',
+    '#cols' => 50,
+    '#rows' => 10,
+    '#description' => '',
+    '#attributes' => NULL,
+    '#required' => TRUE,
+  );
+	if (is_numeric(arg(1))) {
+		$node= node_load(arg(1));
+	  $form['message']['nid'] = array(
+	    '#type' => 'hidden',
+	    '#value' => $node->nid,
+	  );
+	}
+	$form['#validate'] = array(
+		'forward_form_validate' => array()
+	);
+	$form['#submit'] = array(
+		'forward_form_submit' => array()
+	);
   $form['message']['forward_footer'] = array(
     '#type' => 'hidden',
     '#value' => variable_get('forward_footer', ''),
   );
-  $form['message'][] = array(
+  $form['message']['submit'] = array(
     '#type' => 'submit',
     '#value' => t('Send Message'),
   );
@@ -499,6 +578,7 @@
 function forward_form_submit($form_id, $edit) {
   // Prepare the sender:
   $from = $edit['mail'];
+
   // Compose the body:
 ### Note how the form values are accessed the same way they were accessed in the validate
 ### function
@@ -578,6 +658,7 @@
 
   drupal_set_message(variable_get('forward_thankyou', t('Thank you for your help in spreading the word about').' '.variable_get('site_name', 'drupal').'. '.t('We appreciate your help.')), 'status');
   return $returnurl;
+  
 }
 
 function forward_mail($mail, $subject, $message, $from, $headers) {
@@ -605,10 +686,12 @@
     if ($forward_link_type) {
       if ($type == 'comment') {
         $forward_link_type = 'comment';
-      }
-      else {$forward_link_type = $node->type;}
-    }
-    else $forward_link_type = 'page';
+      } else {
+				$forward_link_type = $node->type;
+	  	}
+    } else {
+	  	$forward_link_type = 'page';
+		}
 
     // Work out if this is a node page.  We don't want to go adding
     // links anywhere but on the front page or on nodes.  Without 
@@ -693,47 +776,93 @@
   switch ($op) {
     case 'list':
       $blocks[0]['info'] = t('Most Emailed');
+	  	$blocks[1]['info'] = t('Forward');
       return $blocks;
     case 'configure':
-      $block_options = array (
-        'today' => t('Most Emailed Today'),
-        'week' => t('Most Emailed This Week'),
-        'allTime' => t('Most Emailed of All Time'),
-        'recent' => t('Most Recently Emailed')
-      );
-      $output = drupal_get_form('forward_block_formbody', $block_options);
-      return $output;
+	  switch ($delta) {
+	    case '0':
+		  $block_options = array (
+	        'today' => t('Most Emailed Today'),
+	        'week' => t('Most Emailed This Week'),
+	        'allTime' => t('Most Emailed of All Time'),
+	        'recent' => t('Most Recently Emailed')
+	      );
+	      $output = drupal_get_form('forward_block_formbody', $block_options);
+	      return $output;
+	  }
     case 'save':
-      variable_set('forward_block_type', $edit['forward_block_type']);
-      break;
+	  switch ($delta) {
+		case '0':
+		  variable_set('forward_block_type', $edit['forward_block_type']);
+	      break;
+	  }
     case 'view':
-      if (user_access('access content')) {
-        switch (variable_get('forward_block_type','allTime')) {
-          case 'today':
-            $pastday = time()-(24 * 60 * 60);
-            $query='SELECT n.nid, n.title, count(*) FROM {forward_log} s LEFT JOIN {node} n ON s.nid = n.nid WHERE s.type="sent" AND timestamp > '.$pastday.' GROUP BY n.nid DESC';
-            $block['subject'] = t("Today's Most Emailed");
-            $block['content'] = node_title_list(db_query_range($query, 0, 5));
-            break;
-          case 'week':
-            $pastweek = time()-(7 * 24 * 60 * 60);
-            $query='SELECT n.nid, n.title, count(*) FROM {forward_log} s LEFT JOIN {node} n ON s.nid = n.nid WHERE s.type="sent" AND timestamp > '.$pastweek.' GROUP BY n.nid DESC';
-            $block['subject'] = t("This Week's Most Emailed");
-            $block['content'] = node_title_list(db_query_range($query, 0, 5));
-            break;
-          case 'allTime':
-            $query='SELECT n.nid, n.title, count(*) FROM {forward_log} s LEFT JOIN {node} n ON s.nid = n.nid WHERE s.type="sent" GROUP BY n.nid DESC';
-            $block['subject'] = t("Most Emailed");
-            $block['content'] = node_title_list(db_query_range($query, 0, 5));
-            break;
-          case 'recent':
-            $query="SELECT DISTINCT n.nid, n.title FROM {node} n LEFT JOIN {forward_log} s ON s.nid = n.nid WHERE s.timestamp <> '0' AND s.type='SENT' AND n.status = 1 ORDER BY s.timestamp DESC";
-            $block['subject'] = t("Most Recently Emailed");
-            $block['content'] = node_title_list(db_query_range($query, 0, 5));
-            break;
-        }
-        return $block;
-      }
+	  switch ($delta) {
+		case '0':
+		  if (user_access('access content')) {
+	        switch (variable_get('forward_block_type','allTime')) {
+	          case 'today':
+	            $pastday = time()-(24 * 60 * 60);
+	            $query='SELECT n.nid, n.title, count(*) FROM {forward_log} s LEFT JOIN {node} n ON s.nid = n.nid WHERE s.type="sent" AND timestamp > '.$pastday.' GROUP BY n.nid DESC';
+	            $block['subject'] = t("Today's Most Emailed");
+	            $block['content'] = node_title_list(db_query_range($query, 0, 5));
+	            break;
+	          case 'week':
+	            $pastweek = time()-(7 * 24 * 60 * 60);
+	            $query='SELECT n.nid, n.title, count(*) FROM {forward_log} s LEFT JOIN {node} n ON s.nid = n.nid WHERE s.type="sent" AND timestamp > '.$pastweek.' GROUP BY n.nid DESC';
+	            $block['subject'] = t("This Week's Most Emailed");
+	            $block['content'] = node_title_list(db_query_range($query, 0, 5));
+	            break;
+	          case 'allTime':
+	            $query='SELECT n.nid, n.title, count(*) FROM {forward_log} s LEFT JOIN {node} n ON s.nid = n.nid WHERE s.type="sent" GROUP BY n.nid DESC';
+	            $block['subject'] = t("Most Emailed");
+	            $block['content'] = node_title_list(db_query_range($query, 0, 5));
+	            break;
+	          case 'recent':
+	            $query="SELECT DISTINCT n.nid, n.title FROM {node} n LEFT JOIN {forward_log} s ON s.nid = n.nid WHERE s.timestamp <> '0' AND s.type='SENT' AND n.status = 1 ORDER BY s.timestamp DESC";
+	            $block['subject'] = t("Most Recently Emailed");
+	            $block['content'] = node_title_list(db_query_range($query, 0, 5));
+	            break;
+	        }
+	        return $block;
+	      }
+		break;
+		case '1':
+		  if (user_access('access forward') && variable_get('forward_form_type', 'link') == "block_link" && !$node->in_preview) {
+			$forward_link_type = variable_get('forward_link_type', 0);
+			if ($forward_link_type) {
+			  if ($type == 'comment') {
+			    $forward_link_type = 'comment';
+			  }
+			  else {
+				$forward_link_type = $node->type;}
+			  }
+			  else {
+				$forward_link_type = 'page';
+			  }
+
+			  // Work out if this is a node page.  We don't want to go adding
+			  // links anywhere but on the front page or on nodes.  Without 
+			  // this logic, pages such as /event end up with an "email this page" link
+			  // that does not actually email that page.
+			  $path = drupal_get_normal_path($_GET['q']);
+			  list($node_url, $nid) = array_values(explode('/', $path));
+
+			  if ($node_url == 'node' && (!$main || variable_get('forward_show_on_main', 0)) && $nid != NULL) {
+			    $link = l(t('Email this !type', array('!type' => $forward_link_type)), 'forward/'.$nid, array('title' => t('Forward this page to a friend'), 'class' => 'forward-page'));
+			    $block['subject'] = t("Forward");
+			    $block['content'] = $link;
+			}
+			return $block;
+		  }
+		  if (user_access('access forward') && variable_get('forward_form_type', 'link') == "block_form" && !$node->in_preview) {
+				$output = drupal_get_form('forward_form_block_body');
+				$block['subject'] = t("Forward");
+				$block['content'] = $output;
+			return $block;
+		  }
+		break;
+	  }
   }
 }
 
