Index: forward.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/forward/forward.install,v
retrieving revision 1.1
diff -u -r1.1 forward.install
--- forward.install	11 Jul 2006 19:31:49 -0000	1.1
+++ forward.install	28 Dec 2006 19:32:20 -0000
@@ -31,3 +31,7 @@
     drupal_set_message(t('Table installation for the Forward module was unsuccessful. The tables may need to be installed by hand. See forward.install file for a list of the installation queries.'), 'error');
   }
 }
+
+function forward_uninstall() {
+  db_query('DROP TABLE {forward_log}');
+}
Index: forward.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/forward/forward.module,v
retrieving revision 1.29
diff -u -r1.29 forward.module
--- forward.module	25 Jul 2006 15:55:54 -0000	1.29
+++ forward.module	30 Dec 2006 20:22:28 -0000
@@ -25,9 +25,6 @@
 }
 
 function forward_help($section) {
-  if ($section == "admin/modules#description") {
-    return t("Enables users to forward pages to friends.");
-  }
 }
 
 /**
@@ -35,43 +32,59 @@
  */
 function forward_menu($may_cache) {
   $items = array();
-  $items[] = array(
-    'path'     => 'forward',
-    'title'    => t('forward this page'),
-    'callback' => 'forward_form',
-    'callback arguments' => array(arg(1),arg(2)),
-    'access'   => (user_access('access content')),
-    'type'     => MENU_CALLBACK
-  );
-  $items[] = array(
-    'path'     => 'epostcard',
-    'title'    => t('Send an e-Postcard'),
-    'callback' => 'forward_form',
-    'callback arguments' => array(),
-    'access'   => (user_access('access content')),
-    'type'     => MENU_CALLBACK
-  );
-  $items[] = array(
-    'path'     => 'admin/forward',
-    'title'    => t('forward tracking'),
-    'callback' => 'forward_tracking',
-    'callback arguments' => array(),
-    'access'   => (user_access('administer forward')),
-  );
+  if($may_cache) {
+    $items[] = array(
+      'path'     => 'epostcard',
+      'title'    => t('Send an e-Postcard'),
+      'callback' => 'drupal_get_form',
+      'callback arguments' => array('forward_form'),
+      'access'   => (user_access('access content')),
+      'type'     => MENU_CALLBACK
+    );
+    $items[] = array(
+      'path'     => 'admin/forward',
+      'description'  => 'Track the forward module',
+      'title'    => t('Forward tracking'),
+      'callback' => 'forward_tracking',
+      'access'   => (user_access('administer forward')),
+    );
+    // 5.x admin menu
+    $items[] = array(
+      'path'    => 'admin/settings/forward',
+      'title'    => t('Forward'),
+      'callback'  => 'drupal_get_form',
+      'callback arguments'  => array('forward_admin_settings'),
+      'access'  => user_access('administer forward'),
+      'type'    => MENU_NORMAL_ITEM
+    );
+  }
+  else {
+    $items[] = array(
+      'path'     => 'forward',
+      'title'    => t('Forward this page'),
+      'callback' => 'drupal_get_form',
+      'callback arguments' => array('forward_form', arg(1)),
+      'access'   => (user_access('access content')),
+      'type'     => MENU_CALLBACK
+    );
+    $items[] = array(
+      'path'     => 'forward/emailref',
+      'title'    => t('Track email clickthrus'),
+      'callback' => 'forward_tracker',
+      'callback arguments' => array(arg(2)),
+      'access'   => (user_access('access content')),
+      'type'     => MENU_CALLBACK
+    );
+  };
   return $items;
 }
 
 /**
  * Administration Page
  */
-function forward_settings() {
+function forward_admin_settings() {
   global $base_url;
 
-  // Permission Check
-  if (!user_access('administer forward')) {
-    return drupal_access_denied();
-  }
-
   $host=parse_url($base_url);
 
   // Administrative Options
@@ -169,34 +182,34 @@
   $form['forward_default_values']['forward_emailsubject'] = array(
     '#type' => 'textfield',
     '#title' => t('Forward Message Subject'),
-    '#default_value' => variable_get('forward_emailsubject', t('%name has forwarded a page to you from %site')),
+    '#default_value' => variable_get('forward_emailsubject', t('!name has forwarded a page to you from !site')),
     '#size' => 40,
     '#maxlength' => 256,
-    '#description' => t('Email subject line.  The sender\'s name will appear in place of %name in the subject.  The web site name will be inserted in place of %site'),
+    '#description' => t('Email subject line.  The sender\'s name will appear in place of !name in the subject.  The web site name will be inserted in place of !site.'),
   );
   $form['forward_default_values']['forward_emailmessage'] = array(
     '#type' => 'textarea',
     '#title' => t('Forward Message Body'),
-    '#default_value' => variable_get('forward_emailmessage', t('%name thought you would like to see this page from the %site web site.')),
+    '#default_value' => variable_get('forward_emailmessage', t('!name thought you would like to see this page from the !site web site.')),
     '#cols' => 40,
     '#rows' => 10,
-    '#description' => t('Email message body.  The sender\'s name will appear in place of %name in the message body.  The web site name will be inserted in place of %site  The sender will be able to add their own message after this.'),
+    '#description' => t('Email message body.  The sender\'s name will appear in place of !name in the message body.  The web site name will be inserted in place of !site.  The sender will be able to add their own message after this.'),
   );
   $form['forward_default_values']['forward_postcardsubject'] = array(
     '#type' => 'textfield',
     '#title' => t('e-Postcard Message Subject'),
-    '#default_value' => variable_get('forward_postcardsubject', t('%name has sent you an e-postcard from %site')),
+    '#default_value' => variable_get('forward_postcardsubject', t('!name has sent you an e-postcard from !site')),
     '#size' => 40,
     '#maxlength' => 256,
-    '#description' => t('Postcard subject line.  The sender\'s name will appear in place of %name in the subject.  The web site name will be inserted in place of %site'),
+    '#description' => t('Postcard subject line.  The sender\'s name will appear in place of !name in the subject.  The web site name will be inserted in place of !site.'),
   );
   $form['forward_default_values']['forward_postcardmessage'] = array(
     '#type' => 'textarea',
     '#title' => t('e-Postcard Message Body'),
-    '#default_value' => variable_get('forward_postcardmessage', t('%name has sent you an e-postcard from the %site web site.  Please take a moment to visit our web site.')),
+    '#default_value' => variable_get('forward_postcardmessage', t('!name has sent you an e-postcard from the !site web site.  Please take a moment to visit our web site.')),
     '#cols' => 40,
     '#rows' => 10,
-    '#description' => t('Postcard message body.  The sender\'s name will appear in place of %name in the message body.  The web site name will be inserted in place of %site  The sender will be able to add their own message after this.'),
+    '#description' => t('Postcard message body.  The sender\'s name will appear in place of !name in the message body.  The web site name will be inserted in place of !site.  The sender will be able to add their own message after this.'),
   );
   $form['forward_default_values']['forward_ad_footer'] = array(
     '#type' => 'textarea',
@@ -220,7 +233,7 @@
     'comment' => t('Latest Comments'),
     'popular' => t('Most Popular Content'),
     'none' => t('None')
-    );
+  );
   $form['forward_default_values']['forward_dynamic_block'] = array(
     '#type' => 'radios',
     '#title' => t('Dynamic Block'),
@@ -230,128 +243,116 @@
     '#required' => TRUE,
     '#attributes' => NULL,
   );
-  return $form;
+  return system_settings_form($form);
 }
 
 /**
- * Form
+ * Email Tracker
  */
-function forward_form() {
-  if (!user_access('access forward')) {
-    return drupal_access_denied();
+function forward_tracker($nid) {
+  db_query("INSERT INTO {forward_log} (nid, type, timestamp) VALUES ('%d', '%s', %d)", $nid, "REF", time());
+  if ($nid == 'postcard'){
+    drupal_goto(drupal_get_path_alias(''));
+  }
+  else {
+    drupal_goto(drupal_get_path_alias('node/'.$nid));
   }
+}
 
-  $nid = arg(1);
+/**
+ * Form
+ */
+function forward_form($nid) {
   global $base_url, $user;
-  $host=parse_url($base_url);
 
-  if (arg(2) == 'email_ref'){
-    db_query("INSERT INTO {forward_log} (nid, type, timestamp) VALUES ('%d', '%s', %d)", $nid, "REF", time());
-    if (arg(1) == 'postcard'){
-      drupal_goto(drupal_get_path_alias(''));
-    }
-    else {
-      drupal_goto(drupal_get_path_alias('node/'.$nid));
-    }
-  }
+  $form = array();
 
-  if (!flood_is_allowed('forward', variable_get('forward_flood_control', 10))) {
-    $output = t(variable_get('forward_flood_error', 'You can\'t send more than %number messages per hour. Please try again later.'), array('%number' => variable_get('forward_flood_control', 10)));
+  if ($nid != '') {
+    $emailtype = 'email';
   }
   else {
-    $form = array();
-    $url    = $base_url.'/node/'.$nid;
-    $output = variable_get('forward_instructions', '<p>'.t('Thank you for your interest in spreading the word on').' '.variable_get('site_name', 'drupal').'.</p><p>'.t('NOTE: We only request your email address so that the person you are recommending the page to knows that you wanted them to see it, and that it is not junk mail. We do not capture any email address.').'</p>');
-
-
-    if ($nid != '') {
-      $emailtype = 'email';
-    }
-    else {
-      $emailtype = 'postcard';
-    }
-
-    $form['message'] = array(
-      '#type' => 'fieldset',
-      '#title' => t('Message to Send'),
-      '#description' => '',
-    );
-    $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' => 'textarea',
-      '#title' => t('Send To'),
-      '#default_value' => str_replace(', ', '\n', $recipients),
-      '#cols' => 50,
-      '#rows' => 5,
-      '#description' => t('Enter multiple addresses on separate lines or separate them with commas.'),
-      '#attributes' => NULL,
-      '#required' => TRUE,
-    );
-    if ($emailtype == 'email') {
-      $form['message'][] = array(
-        '#type' => 'item',
-        '#title' => t('Page Being Sent'),
-        '#value' => $base_url.'/'.drupal_get_path_alias('node/'.$nid.''),
-      );
-    }
-    $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,
-    );
-    $form['message']['nid'] = array(
-      '#type' => 'hidden',
-      '#value' => $nid,
-    );
-    $form['message']['forward_footer'] = array(
-      '#type' => 'hidden',
-      '#value' => variable_get('forward_footer', ''),
-    );
+    $emailtype = 'postcard';
+  }
+  
+  $form['message'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Message to Send'),
+    '#description' => '',
+  );
+  $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' => 'textarea',
+    '#title' => t('Send To'),
+    '#default_value' => str_replace(', ', '\n', $recipients),
+    '#cols' => 50,
+    '#rows' => 5,
+    '#description' => t('Enter multiple addresses on separate lines or separate them with commas.'),
+    '#attributes' => NULL,
+    '#required' => TRUE,
+  );
+  if ($emailtype == 'email') {
     $form['message'][] = array(
-      '#type' => 'submit',
-      '#value' => t('Send Message'),
+      '#type' => 'item',
+      '#title' => t('Page Being Sent'),
+      '#value' => $base_url.'/'.drupal_get_path_alias('node/'.$nid.''),
     );
-
-    $form['#method'] = 'post';
-    $output = drupal_get_form('forward_form', $form);
   }
-  return $output;
+  $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,
+  );
+  $form['message']['nid'] = array(
+    '#type' => 'hidden',
+    '#value' => $nid,
+  );
+  $form['message']['forward_footer'] = array(
+    '#type' => 'hidden',
+    '#value' => variable_get('forward_footer', ''),
+  );
+  $form['message'][] = array(
+    '#type' => 'submit',
+    '#value' => t('Send Message'),
+  );
+
+  $form['#method'] = 'post';
+  return $form;
 }
 
 /**
@@ -361,104 +362,107 @@
   if (variable_get('forward_form_type', 'link') == "form" && !$node->in_preview && variable_get('forward_display_'. $node->type, '0') == 1){
     switch ($op) {
       case 'view':
-        global $user;
-        $form['message'] = array(
-          '#type' => 'fieldset',
-          '#title' => t('Forward this page to a friend'),
-          '#description' => '',
-          '#collapsed' => TRUE,
-          '#collapsible' => TRUE,
-        );
-        $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' => 'textarea',
-          '#title' => t('Send To'),
-          '#default_value' => str_replace(', ', '\n', $recipients),
-          '#cols' => 50,
-          '#rows' => 5,
-          '#description' => t('Enter multiple addresses on separate lines or separate 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,
-        );
-        $form['message']['nid'] = array(
-          '#type' => 'hidden',
-          '#value' => $node->nid,
-        );
-        $form['message']['forward_footer'] = array(
-          '#type' => 'hidden',
-          '#value' => variable_get('forward_footer', ''),
-        );
-        $form['message'][] = array(
-          '#type' => 'submit',
-          '#value' => t('Send Message'),
-        );
-
-        $form['#method'] = 'post';
-        $output = drupal_get_form('forward_form', $form);
-
-        $node->body .= $output;
-      break;
+        $output = drupal_get_form('forward_nodeapi_formbody');
+        $node->content['body']['#value'] .= $output;
+        break;
     }
   }
 }
 
+function forward_nodeapi_formbody() {
+  global $user;
+  $form['message'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Forward this page to a friend'),
+    '#description' => '',
+    '#collapsed' => TRUE,
+    '#collapsible' => TRUE,
+  );
+  $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' => 'textarea',
+    '#title' => t('Send To'),
+    '#default_value' => str_replace(', ', '\n', $recipients),
+    '#cols' => 50,
+    '#rows' => 5,
+    '#description' => t('Enter multiple addresses on separate lines or separate 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,
+  );
+  $form['message']['nid'] = array(
+    '#type' => 'hidden',
+    '#value' => $node->nid,
+  );
+  $form['message']['forward_footer'] = array(
+    '#type' => 'hidden',
+    '#value' => variable_get('forward_footer', ''),
+  );
+  $form['message'][] = array(
+    '#type' => 'submit',
+    '#value' => t('Send Message'),
+  );
+
+  $form['#method'] = 'post';
+  return $form;
+}
+
 function forward_form_validate($form_id, &$form) {
-  ### Here the global variable where form values are stored is brought into the function
-  ### for possible editing
+### Here the global variable where form values are stored is brought into the function
+### for possible editing
   global $form_values;
-  ### To check values, simply access them w/ the same name with which they were declared
+### To check values, simply access them w/ the same name with which they were declared
   if (!user_access('administer forward')) {
     if (!flood_is_allowed('forward', variable_get('forward_flood_control', 10))) {
       form_set_error(NULL,variable_get('forward_flood_error', t('You can\'t send more than %number messages per hour. Please try again later.', array('%number' => variable_get('forward_flood_control', 10)))));
     }
   }
 
-  $yname      = $_POST['edit']['yname'];
-  $yemail     = $_POST['edit']['yemail'];
-  $recipients = $_POST['edit']['recipients'];
-  $message    = $_POST['edit']['message'];
-  $nid        = $_POST['edit']['nid'];
+  $yname      = $form['edit']['yname'];
+  $yemail     = $form['edit']['yemail'];
+  $recipients = $form['edit']['recipients'];
+  $message    = $form['edit']['message'];
+  $nid        = $form['edit']['nid'];
   $url        = $base_url.'/node/'.$nid;
 
   // normalize address entries
@@ -504,19 +508,19 @@
   // 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
+### Note how the form values are accessed the same way they were accessed in the validate
+### function
 
   //If selected assemble dynamic footer block.
   switch (variable_get('forward_dynamic_block','')) {
     case 'node':
-  	  $dynamic_content = '<h3>'.t('Recent blog posts').'</h3>';
-  	  $query = "SELECT n.nid, n.title FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.created DESC";
-  	  $dynamic_content .= forward_top5_list($query, $base_url,'blog');
-  	  break;
+      $dynamic_content = '<h3>'.t('Recent blog posts').'</h3>';
+      $query = "SELECT n.nid, n.title FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.created DESC";
+      $dynamic_content .= forward_top5_list($query, $base_url,'blog');
+      break;
     case 'user':
-      $dynamic_content = '<h3>'.t('Who\'s new').'</h3>';
-	    $query = 'SELECT u.uid, u.name FROM {users} u WHERE status != 0 ORDER BY uid DESC';
+      $dynamic_content = '<h3>'.t("Who's new").'</h3>';
+      $query = 'SELECT u.uid, u.name FROM {users} u WHERE status != 0 ORDER BY uid DESC';
       $dynamic_content .= forward_top5_list($query, $base_url,'user');
       break;
     case 'comment':
@@ -548,20 +552,20 @@
     $returnurl = drupal_get_path_alias('node/'.$nid);
   }
   $vars = array(
-	  'forward_header_image' => variable_get('forward_header_image', ''),
-	  'site_name' => variable_get('site_name', 'Drupal'),
-	  'yemail' => $edit['yemail'],
-	  'forward_message' => t(variable_get('forward_'.$emailtype.'message', '%name thought you would like to see the %site web site.'), array('%name' => l($edit['yname'], 'mailto:'.$edit['yemail'],NULL,NULL,NULL,TRUE), '%site' => variable_get('site_name', 'drupal'))),
-	  'message' => $edit['message'],
-	  'base_url' => $base_url,
-	  'content' => $content,
-	  'dynamic_content' => $dynamic_content,
-	  'forward_ad_footer' => variable_get('forward_ad_footer', ''),
-	  'forward_footer' => variable_get('forward_footer', '')
+    'forward_header_image' => variable_get('forward_header_image', ''),
+    'site_name' => variable_get('site_name', 'Drupal'),
+    'yemail' => $edit['yemail'],
+    'forward_message' => t(variable_get('forward_'.$emailtype.'message', '!name thought you would like to see the !site web site.'), array('!name' => l($edit['yname'], 'mailto:'.$edit['yemail'],NULL,NULL,NULL,TRUE), '!site' => variable_get('site_name', 'drupal'))),
+    'message' => $edit['message'],
+    'base_url' => $base_url,
+    'content' => $content,
+    'dynamic_content' => $dynamic_content,
+    'forward_ad_footer' => variable_get('forward_ad_footer', ''),
+    'forward_footer' => variable_get('forward_footer', '')
   );
 
   $body = theme('forward_'.$emailtype, $vars);
-  $subject = t(variable_get('forward_'.$emailtype.'subject', '%name has sent you a message from %site'), array('%name' => $edit['yname'], '%site' => variable_get('site_name', 'drupal')));
+  $subject = t(variable_get('forward_'.$emailtype.'subject', '!name has sent you a message from !site'), array('!name' => $edit['yname'], '!site' => variable_get('site_name', 'drupal')));
 
   $headers = "From: ".$edit['yemail']."\n";
   $headers .= "MIME-Version: 1.0\n";
@@ -581,13 +585,13 @@
   flood_register_event('forward');
 
   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');
-	drupal_goto($returnurl);
+  drupal_goto($returnurl);
 }
 
 function forward_mail($mail, $subject, $message, $header) {
   if (variable_get('smtp_library', '') && file_exists(variable_get('smtp_library', ''))) {
     include_once './' . variable_get('smtp_library', '');
-    return user_mail_wrapper($mail, $subject, $message, $header);
+    return drupal_mail_wrapper($forward-mail, $mail, $subject, $message, $header);
   }
   else {
     return mail($mail, $subject, $message, $header);
@@ -601,8 +605,8 @@
   if (user_access('access forward') && (variable_get('forward_form_type', 'link') == "link") && variable_get('forward_display_'. $node->type, '1')){
     $links=array();
     if (($type == 'system')) {
-    // URL, page title, func called for page content, arg, 1 = don't disp menu
-      menu('forward', t('email this page'), 'forward_page', 1, 1);
+      // URL, page title, func called for page content, arg, 1 = don't disp menu
+      menu('forward', t('Email this page'), 'forward_page', 1, 1);
     }
 
     // This var is set in the settings section under the admin/modules/forward section
@@ -611,48 +615,31 @@
     if ($forward_link_type) {
       if ($type == 'comment') {
         $forward_link_type = 'comment';
-        $links['forward_page'] = array(
-          '#title' => t("email this %type", array('%type' => $forward_link_type)),
-          '#href' => 'forward/'.$node->nid.'&cid='.$node->cid,
-          '#attributes' => array('title' => t('Forward this page to a friend'), 'class' => 'forward-page')
-        );
       }
-      $forward_link_type = $node->type;
+      else {$forward_link_type = $node->type;}
     }
     else $forward_link_type = 'page';
 
-    if ($main) {  // not on an index page
-      if (variable_get('forward_show_on_main', 0)) {
-        $links['forward_epostcard'] = array(
-          '#title' => t("email this %type", array('%type' => $forward_link_type)),
-          '#href' => 'epostcard',
-          '#attributes' => array('title' => t('Send an E-Postcard'), 'class' => 'forward-page')
-        );
-      }
-    }
-    else { // not on a main page
-      $links['forward_page'] = array(
-        '#title' => t("email this %type", array('%type' => $forward_link_type)),
-        '#href' => 'forward/'.$node->nid,
-        '#attributes' => array('title' => t('Forward this page to a friend'), 'class' => 'forward-page')
-      );
+    if (!$main || variable_get('forward_show_on_main', 0)) {
+      $links['forward_links'] = array(
+        'title'      => t('Email this !type', array('!type' => $forward_link_type)),
+        'href'       => "forward/$node->nid",
+        'attributes' => array('title' => t('Forward this page to a friend'), 'class' => 'forward-page'));
+      return $links;
     }
   }
-  return $links;
 }
 
 function forward_form_alter($form_id, &$form){
-  if (isset($form['type'])) {
-    // Add the node-type settings option to activate the email this page link
-    if ($form['type']['#value'] .'_node_settings' == $form_id) {
-      $form['workflow']['forward_display_'. $form['type']['#value']] = array(
-        '#type' => 'checkbox',
-        '#title' => t('Show forwarding link/form'),
-        '#return_value' => 1,
-        '#default_value' => variable_get('forward_display_'. $form['type']['#value'], '1'),
-        '#description' => t('Displays the form/link to allow visitors to forward the page to a friend. Further configuration is available on the %settings.', array('%settings' => l(t('settings page'), 'admin/settings/forward' ))),
-      );
-    }
+  // Add the node-type settings option to activate the email this page link
+  if ('node_type_form' == $form_id) {
+    $form['workflow']['forward_display_'. $form['type']['#value']] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Show forwarding link/form'),
+      '#return_value' => 1,
+      '#default_value' => variable_get('forward_display_'. $form['type']['#value'], '1'),
+      '#description' => t('Displays the form/link to allow visitors to forward the page to a friend. Further configuration is available on the !settings.', array('!settings' => l(t('settings page'), 'admin/settings/forward' ))),
+    );
   }
 }
 
@@ -675,7 +662,8 @@
         array('data' => format_date($log->timestamp, 'small'), 'nowrap' => 'nowrap'),
         $log->type,
         l($_path, $_path),
-        l(_forward_column_width($log->title), $_path));
+        l(_forward_column_width($log->title), $_path)
+			);
     }
     if ($pager = theme('pager', NULL, 30, 0)) {
       $rows[] = array(array('data' => $pager, 'colspan' => '4'));
@@ -707,16 +695,7 @@
         'allTime' => t('Most Emailed of All Time'),
         'recent' => t('Most Recently Emailed')
       );
-	    $form['forward_block_type'] = array(
-        '#type' => 'radios',
-        '#title' => t('Block Type'),
-        '#default_value' => variable_get('forward_block_type', " "),
-        '#options' => $block_options,
-        '#description' => t('Choose the block type'),
-        '#required' => NULL,
-        '#attributes' => TRUE,
-      );
-      $output = drupal_get_form('forward_block', $form);
+      $output = drupal_get_form('forward_block_formbody', $block_options);
       return $output;
     case 'save':
       variable_set('forward_block_type', $edit['forward_block_type']);
@@ -726,25 +705,25 @@
         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));
+            $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));
+            $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));
+            $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));
+            $block['subject'] = t("Most Recently Emailed");
+            $block['content'] = node_title_list(db_query_range($query, 0, 5));
             break;
         }
         return $block;
@@ -752,17 +731,30 @@
   }
 }
 
+function forward_block_formbody($block_options) {
+  $form['forward_block_type'] = array(
+    '#type' => 'radios',
+    '#title' => t('Block Type'),
+    '#default_value' => variable_get('forward_block_type', " "),
+    '#options' => $block_options,
+    '#description' => t('Choose the block type'),
+    '#required' => NULL,
+    '#attributes' => TRUE,
+  );
+  return $form;
+}
+
 //  this function supports the dynamic footer generation
 function forward_top5_list($query, $base_url, $type) {
   $items = '<ol>';
   $result = db_query_range($query, 0, 5);
   while ($lineitem = db_fetch_array($result)) {
-   if ($type == 'user'){
-       $items .= '<li>'.l(next($lineitem),'/user/'.current($lineitem)).'</li>';
+    if ($type == 'user'){
+      $items .= '<li>'.l(next($lineitem),'/user/'.current($lineitem)).'</li>';
     } elseif ($type == 'comment'){
-       $items .= '<li>'.l(next($lineitem),'/node/'.current($lineitem).'#comment-'.next($lineitem)).'</li>';
+      $items .= '<li>'.l(next($lineitem),'/node/'.current($lineitem).'#comment-'.next($lineitem)).'</li>';
     } else {
-       $items .= '<li>'.l(next($lineitem),'/node/'.current($lineitem)).'</li>';
+      $items .= '<li>'.l(next($lineitem),'/node/'.current($lineitem)).'</li>';
     }
   }
   return $items.'</ol>';
Index: forward.theme
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/forward/forward.theme,v
retrieving revision 1.4
diff -u -r1.4 forward.theme
--- forward.theme	31 May 2006 19:54:22 -0000	1.4
+++ forward.theme	29 Dec 2006 12:03:54 -0000
@@ -14,15 +14,15 @@
  */
 function theme_forward_email($vars) {
 
-	$style = "<style>
+  $style = "<style>
       <!--
-      	html, body {margin:0; padding:0; background-color:#fff;}
-      	#container {margin:0 auto; width:670px; font:normal 10pt arial,helvetica,sans-serif;}
+        html, body {margin:0; padding:0; background-color:#fff;}
+        #container {margin:0 auto; width:670px; font:normal 10pt arial,helvetica,sans-serif;}
         #header {width:670px; margin:0; text-align:center;}
-      	#body {width:630px; margin:0; padding:5px 20px; text-align:left; background-color:#fff;}
-      	#footer {width:670px; height:35px; margin:0; padding:5px 0 0 0; font-size:9pt; text-align:center; color:#fff;}
+        #body {width:630px; margin:0; padding:5px 20px; text-align:left; background-color:#fff;}
+        #footer {width:670px; height:35px; margin:0; padding:5px 0 0 0; font-size:9pt; text-align:center; color:#fff;}
         .ad_footer, .message, .article  {font-size:10pt; padding:0;}
-      	.frm_title, .frm_txt {font-size:12pt;}
+        .frm_title, .frm_txt {font-size:12pt;}
         .frm_txt {padding-bottom:15px;}
         .links {font-size:10pt; font-style:italic;}
         .article_title {font-size:12pt;}
@@ -45,13 +45,13 @@
         <div class="frm_title">'.t('Message from Sender').':</div>
         <div class="frm_txt"><p><b>'.$vars['message'].'</b></p></div>';}
         $output .= '
-        <div><b>'.l($vars['content']->title, 'forward/'.$vars['content']->nid.'/email_ref',NULL,NULL,NULL,TRUE).'</b>';
+        <div><b>'.l($vars['content']->title, 'forward/emailref/'.$vars['content']->nid,NULL,NULL,NULL,TRUE).'</b>';
         if (theme_get_setting('toggle_node_info_'.$vars['content']->type)) { $output .= '
         <br /><i>'.t('by %author', array('%author' => $vars['content']->name)).'</i>';}
         $output .= '
         </div>
         <div class="article">'.$vars['content']->teaser.'</div>
-        <div class="links">'.l(t('Click here to read more on our site'), 'forward/'.$vars['content']->nid.'/email_ref',NULL,NULL,NULL,TRUE).'</div>
+        <div class="links">'.l(t('Click here to read more on our site'), 'forward/emailref/'.$vars['content']->nid,NULL,NULL,NULL,TRUE).'</div>
         <div class="dyn_content"><br />'.$vars['dynamic_content'].'</div>
         <div class="ad_footer"><br />'.$vars['forward_ad_footer'].'<br></div>
       </div>
@@ -71,15 +71,15 @@
  */
 function theme_forward_postcard($vars) {
 
-	$style = "<style>
-      <!--
-      	html, body {margin:0; padding:0; background-color:#fff;}
-      	#container {margin:0 auto; width:670px; font:normal 10pt arial,helvetica,sans-serif;}
+  $style = "<style>
+     <!--
+        html, body {margin:0; padding:0; background-color:#fff;}
+        #container {margin:0 auto; width:670px; font:normal 10pt arial,helvetica,sans-serif;}
         #header {width:670px; margin:0; text-align:center;}
-      	#body {width:630px; margin:0; padding:5px 20px; text-align:left; background-color:#fff;}
-      	#footer {width:670px; height:35px; margin:0; padding:5px 0 0 0; font-size:9pt; text-align:center; color:#fff;}
+        #body {width:630px; margin:0; padding:5px 20px; text-align:left; background-color:#fff;}
+        #footer {width:670px; height:35px; margin:0; padding:5px 0 0 0; font-size:9pt; text-align:center; color:#fff;}
         .ad_footer, .message, .article  {font-size:10pt; padding:0;}
-      	.frm_title, .frm_txt {font-size:12pt;}
+        .frm_title, .frm_txt {font-size:12pt;}
         .frm_txt {padding-bottom:15px;}
         .links {font-size:10pt; font-style:italic;}
         .article_title {font-size:12pt;}
@@ -102,7 +102,7 @@
         <div class="frm_title">'.t('Message from Sender').':</div>
         <div class="frm_txt">'.$vars['message'].'</div>';}
         $output .= '
-        <div class="links">'.l(t('Click here to visit our site'), 'forward/'.$vars['nid'].'/email_ref',NULL,NULL,NULL,TRUE).'</div>
+        <div class="links">'.l(t('Click here to visit our site'), 'forward/emailref/'.$vars['nid'],NULL,NULL,NULL,TRUE).'</div>
         <div class="dyn_content"><br />'.$vars['dynamic_content'].'</div>
         <div class="ad_footer"><br />'.$vars['forward_ad_footer'].'<br></div>
       </div>
