--- /Users/brent/Sites/iiwbeta/sites/default/modules/forward/forward.module copy	2006-11-07 10:15:14.000000000 -0800
+++ -	2006-11-07 12:35:16.000000000 -0800
@@ -112,8 +112,8 @@
     '#type' => 'select',
     '#title' => t('Form Type'),
     '#default_value' => variable_get('forward_form_type', "link"),
-    '#options' => array("link" => "link", "form" => "form"),
-    '#description' => t('Select link for a forward this page link or form to use a collapsible forwarding form.'),
+    '#options' => array("link" => "link", "form" => "form","none"=>"none"),
+	'#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(
     '#type' => 'select',
@@ -249,7 +249,7 @@
 /**
  * Form
  */
-function forward_form() {
+function forward_form($isablock) {
   if (!user_access('access forward')) {
     return drupal_access_denied();
   }
@@ -292,86 +292,155 @@
     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' => 50,
-      '#maxlength' => 256,
-      '#description' => NULL,
-      '#attributes' => NULL,
-      '#required' => TRUE,
-    );
-    $form['message']['yname'] = array(
-      '#type' => 'textfield',
-      '#title' => t('Your Name'),
-      '#default_value' => $user->name,
-      '#size' => 50,
-      '#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', ''),
-    );
-    $form['message'][] = array(
-      '#type' => 'submit',
-      '#value' => t('Send Message'),
-    );
-
-    $form['#method'] = 'post';
-    $output = drupal_get_form('forward_form', $form);
+	switch ( $isablock )
+	{
+		case 'yes':
+			$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' => 20,
+		      '#maxlength' => 256,
+		      '#description' => NULL,
+		      '#attributes' => NULL,
+		      '#required' => TRUE,
+		    );
+		    $form['message']['yname'] = array(
+		      '#type' => 'textfield',
+		      '#title' => t('Your Name'),
+		      '#default_value' => $user->name,
+		      '#size' => 20,
+		      '#maxlength' => 256,
+		      '#description' => NULL,
+		      '#attributes' => NULL,
+		      '#required' => TRUE,
+		    );
+		    $form['message']['recipients'] = array(
+		      '#type' => 'textfield',
+		      '#title' => t('Recipient Email'),
+		      '#default_value' => str_replace(', ', '\n', $recipients),
+		      '#size' => 20,
+			  '#description' => t('Separate multiple addresses with commas.'),
+		      '#attributes' => NULL,
+		      '#required' => TRUE,
+		    );
+		    $form['message']['mymessage'] = array(
+		      '#type' => 'textarea',
+		      '#title' => t('Your Personal Message'),
+		      '#default_value' => '',
+		      '#cols' => 20,
+		      '#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';
+		    $output = drupal_get_form('forward_form', $form);
+		break;
+		
+		
+				
+		default:
+			$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' => 50,
+		      '#maxlength' => 256,
+		      '#description' => 'NULL',
+		      '#attributes' => NULL,
+		      '#required' => TRUE,
+		    );
+		    $form['message']['yname'] = array(
+		      '#type' => 'textfield',
+		      '#title' => t('Your Name'),
+		      '#default_value' => $user->name,
+		      '#size' => 50,
+		      '#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', ''),
+		    );
+		    $form['message'][] = array(
+		      '#type' => 'submit',
+		      '#value' => t('Send Message'),
+		    );
+
+		    $form['#method'] = 'post';
+		    $output = drupal_get_form('forward_form', $form);
+		break;
+	}
+    
   }
   return $output;
 }
@@ -465,6 +534,7 @@
   }
 }
 
+
 function forward_form_validate($form_id, &$form) {
   ### Here the global variable where form values are stored is brought into the function
   ### for possible editing
@@ -700,62 +770,84 @@
 
 /**
  * Implementation of hook_block().
+ * Delta 0 is the Most Emailed Block
+ * Delta 1 is the Email This Page Block
  */
 function forward_block($op = 'list', $delta = 0, $edit = array()) {
-  switch ($op) {
-    case 'list':
-      $blocks[0]['info'] = t('Most Emailed');
-      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')
-      );
-	    $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);
-      return $output;
-    case 'save':
-      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;
-      }
-  }
+	if ( $op =='list' )
+	{
+		$blocks[0]['info'] = t('Most Emailed');
+		$blocks[1]["info"] = t('Email This Page');
+		return $blocks;
+
+	} else if ( $op =='configure' && $delta ==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')
+	      );
+		    $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);
+	      return $output;
+	
+	}
+	else if ( $op == 'save' && $delta == 0 )
+	{
+		variable_set('forward_block_type', $edit['forward_block_type']);
+		break;
+	}
+	else if ( $op =='view' )
+	{
+		# code...
+		$block = array ();
+		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:
+				$block['subject'] = 'Email This Page';
+				$block['content'] = forward_form($isablock='yes');
+				return $block;
+			break;
+		}
+	}
 }
 
 //  this function supports the dynamic footer generation
