diff U3 citizenspeak.lib.php citizenspeak.lib.php
--- citizenspeak.lib.php	Sat Nov 12 19:37:20 2005
+++ citizenspeak.lib.php	Thu Nov 02 18:03:29 2006
@@ -30,39 +30,32 @@
   return preg_split('/[\s,]+/', $emails);
 }
 
-function _citizenspeak_validate_participation($edit) {
-  $errors = false;
-  if ($edit['name'] == "") {
+function citizenspeak_send_petition_validate($form_id, $edit) {
+  if ($edit['name'] == '') {
     form_set_error('name', t('You must enter your name'));
-    $errors = true;
   }
   
   if (!valid_email_address($edit['email'])) {
     form_set_error('email', t('You must provide a valid email address'));
-    $errors = true;
   }
 
-  if ($edit['address'] == "") {
-    form_set_error('name', t('You must enter your address'));
-    $errors = true;
-  }  
-
-  if ($edit['city'] == "") {
-    form_set_error('city', t('You must enter your city'));
-    $errors = true;
-  }
+  if (variable_get('citizenspeak_require_address', 1)) {
+    if ($edit['address'] == '') {
+      form_set_error('name', t('You must enter your address'));
+    }  
 
-  if ($edit['state'] == "") {
-    form_set_error('state', t('You must enter your state'));
-    $errors = true;
-  }
+    if ($edit['city'] == '') {
+      form_set_error('city', t('You must enter your city'));
+    }
 
-  if (!_citizenspeak_valid_zipcode($edit['zip'])) {
-    form_set_error('zip', t('You must provide a 5 digit ZIP code'));
-    $errors = true;
+    if ($edit['state'] == '') {
+      form_set_error('state', t('You must enter your state'));
+    }
+
+    if (!_citizenspeak_valid_zipcode($edit['zip'])) {
+      form_set_error('zip', t('You must provide a 5 digit ZIP code'));
+    }
   }
-  
-  return !$errors;
 }
 
 function _citizenspeak_valid_zipcode($zip) {
@@ -89,4 +82,4 @@
     }
   }
 }
-?>
\ No newline at end of file
+?>
diff U3 citizenspeak.module citizenspeak.module
--- citizenspeak.module	Sun Mar 19 02:08:04 2006
+++ citizenspeak.module	Thu Nov 02 18:03:29 2006
@@ -11,11 +11,11 @@
  * @todo Create CiviCRM integration
  */
 
-require_once(dirname(__FILE__) . '/citizenspeak.node.php');
-require_once(dirname(__FILE__) . '/citizenspeak.theme.php');
-require_once(dirname(__FILE__) . '/citizenspeak.lib.php');
-require_once(dirname(__FILE__) . '/citizenspeak.reports.php');
-require_once(dirname(__FILE__) . '/citizenspeak.user.php');
+require_once(drupal_get_path('module', 'citizenspeak') .'/citizenspeak.node.php');
+require_once(drupal_get_path('module', 'citizenspeak') .'/citizenspeak.theme.php');
+require_once(drupal_get_path('module', 'citizenspeak') .'/citizenspeak.lib.php');
+require_once(drupal_get_path('module', 'citizenspeak') .'/citizenspeak.reports.php');
+require_once(drupal_get_path('module', 'citizenspeak') .'/citizenspeak.user.php');
 
 /**
  * Implementation of hook_help().
@@ -43,7 +43,6 @@
  * Creates:
  * A menu item to add a campaign at node/add/citizenspeak
  * A local task for citizenspeak_report() at node/###/report
- * A menu callback for citizenspeak_send() at node/###/send
  * A menu callback for citizenspeak_thank_you() at node/###/thank_you
  */
 function citizenspeak_menu($may_cache) {
@@ -58,10 +57,13 @@
       'access' => user_access('access content'),
       'callback' => 'citizenspeak_page', 
       'type' => MENU_SUGGESTED_ITEM);
+    /* $items[] = array('path' => 'admin/settings/citizenspeak', 
+      'title' => t('CitizenSpeak'),
+      'callback' => 'citizenspeak_configure'); */
   } 
   else {
     if (arg(0) == 'node' && is_numeric(arg(1))) {
-      $node = node_load(array('nid' => arg(1)));
+      $node = node_load(arg(1));
       if ($node->type == 'citizenspeak') {
         global $user;
       
@@ -73,13 +75,6 @@
           'weight' => 3,
           'type' => MENU_LOCAL_TASK);
         
-        $items[] = array('path' => 'node/'.arg(1).'/send', 
-          'title' => t('send citizenspeak response'),
-          'callback' => 'citizenspeak_send',
-          'callback arguments' => arg(1),
-          'access' => user_access('participate in campaigns'),
-          'type' => MENU_CALLBACK);
-        
         $items[] = array('path' => 'node/'.arg(1).'/thank_you', 
           'title' => t('thank you'),
           'callback' => 'citizenspeak_thank_you',
@@ -102,24 +97,8 @@
   return array('create campaigns', 'edit own campaigns', 'participate in campaigns', 'collect contact information', 'customize thank you page', 'administer citizenspeak');
 } // function citizenspeak_perm
 
-/**
- * Implementation of hook_link().
- */
-function citizenspeak_link($type, $node = 0, $main) {
-  $links = array();
-
-  if ($type == 'node' && $node->type == 'citizenspeak') {
-    // Don't display a redundant edit link if they are node administrators.
-    if (citizenspeak_access('update', $node) && !user_access('administer nodes')) {
-      $links[] = l(t('edit this citizenspeak campaign'), "node/$node->nid/edit");
-    }
-  }
-
-  return $links;
-} // function citizenspeak_link
-
 define("CITIZENSPEAK_DEFAULT_REMINDER_SUBJECT", t('Reminder about your campaign'));
-define("CITIZENSPEAK_DEFAULT_REMINDER_TEMPLATE", t('Your campaign "%title" has received %count responses.  You can download reports about your campaign at %url'));
+define("CITIZENSPEAK_DEFAULT_REMINDER_TEMPLATE", t('Your campaign "%title" has received %count responses.  You can download reports about your campaign at %url.'));
 
 /**
  * Implementation of hook_settings().
@@ -128,24 +107,79 @@
  * @return settings HTML or deny access
  */
 function citizenspeak_settings() {
-  $output = '';
+  $form['citizenspeak_debug'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Turn on debugging?'),
+    '#return_value' => 1,
+    '#default_value' => variable_get('citizenspeak_debug', 0),
+    '#description' => t('When debugging is on, campaign messages will be displayed on the screen instead of emailed to the recipient.'),
+  );
   
-  $output .= form_checkbox(t('Turn on debugging?'), 'citizenspeak_debug', 1, variable_get('citizenspeak_debug', 0), t('When debugging is on, campaign messages will be displayed on the screen instead of emailed to the recipient.'));
+  $form['citizenspeak_signature'] = array(
+    '#type' => 'textarea',
+    '#title' => t('Email Signature'),
+    '#default_value' => variable_get('citizenspeak_signature', ""),
+    '#cols' => 60,
+    '#rows' => 6,
+    '#description' => t('If set, "-- " and this message will be added to the end of every campaign message sent.  These variables will be replaced with information about the campaign: %title, %url, %nid'),
+  );
+
+  $form['citizenspeak_show_to'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Show recipient?'),
+    '#return_value' => 1,
+    '#default_value' => variable_get('citizenspeak_show_to', 1),
+    '#description' => t('Should the campaign display where it will be sent?'),
+  );
   
-  $output .= form_textarea(t('Email Signature'), 'citizenspeak_signature', variable_get('citizenspeak_signature', ""), 60, 6, t('If set, "-- " and this message will be added to the end of every campaign message sent.  These variables will be replaced with information about the campaign: %title, %url, %nid'));
+  $form['citizenspeak_signature'] = array(
+    '#type' => 'textarea',
+    '#title' => t('Email Signature'),
+    '#default_value' => variable_get('citizenspeak_signature', ""),
+    '#cols' => 60,
+    '#rows' => 6,
+    '#description' => t('If set, "-- " and this message will be added to the end of every campaign message sent.  These variables will be replaced with information about the campaign: %title, %url, %nid.'),
+  );
 
-  $output .= form_checkbox(t('Show recipient?'), 'citizenspeak_show_to', 1, variable_get('citizenspeak_show_to', 1), t('Should the campaign display where it will be sent?'));
-  
   // Reminder email settings
-  $reminders = form_checkbox(t('Remind user to download report after 15 participants'), 'citizenspeak_remind_15', 1, variable_get('citizenspeak_remind_15', 0));
-  $reminders .= form_checkbox(t('Remind user to download report after 50 participants'), 'citizenspeak_remind_50', 1, variable_get('citizenspeak_remind_50', 0));
-  $reminders .= form_checkbox(t('Remind user to download report after 100 participants'), 'citizenspeak_remind_100', 1, variable_get('citizenspeak_remind_100', 0));
-  $reminders .= form_textfield(t('Reminder email subject'), 'citizenspeak_reminder_subject', variable_get('citizenspeak_reminder_subject', CITIZENSPEAK_DEFAULT_REMINDER_SUBJECT), '', '');
-  $reminders .= form_textarea(t('Reminder email template'), 'citizenspeak_reminder_template', variable_get('citizenspeak_reminder_template', CITIZENSPEAK_DEFAULT_REMINDER_TEMPLATE), 60, 6, t('These variables will be replaced with information about the campaign: %title, %count, %url'));
+  $form['reminder'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Reminder Emails'),
+    '#description' => t('Campaign creators can be sent emails to remind them to download their reports.'),
+  );
+  $form['reminder']['citizenspeak_remind_15'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Remind user to download report after 15 participants'),
+    '#return_value' => 1,
+    '#default_value' => variable_get('citizenspeak_remind_15', 0),
+  );
+  $form['reminder']['citizenspeak_remind_50'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Remind user to download report after 50 participants'),
+    '#return_value' => 1,
+    '#default_value' => variable_get('citizenspeak_remind_50', 0),
+  );
+  $form['reminder']['citizenspeak_remind_100'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Remind user to download report after 100 participants'),
+    '#return_value' => 1,
+    '#default_value' => variable_get('citizenspeak_remind_100', 0),
+  );
+  $form['reminder']['citizenspeak_reminder_subject'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Reminder email subject'),
+    '#default_value' => variable_get('citizenspeak_reminder_subject', CITIZENSPEAK_DEFAULT_REMINDER_SUBJECT),
+  );
+  $form['reminder']['citizenspeak_reminder_template'] = array(
+    '#type' => 'textarea',
+    '#title' => t('Reminder email template'),
+    '#default_value' => variable_get('citizenspeak_reminder_template', CITIZENSPEAK_DEFAULT_REMINDER_TEMPLATE),
+    '#cols' => 60,
+    '#rows' => 6,
+    '#description' => t('These variables will be replaced with information about the campaign: %title, %count, %url.'),
+  );
   
-  $output .= form_group(t("Reminder Emails"), $reminders, t("Campaign creators can be sent emails to remind them to download their reports."));
-  
-  return $output;
+  return $form;
 } // function citizenspeak_settings
 
 /**
@@ -204,20 +238,13 @@
  * @param $nid
  *   Node ID of the campaign
  */
-function citizenspeak_send($nid) {
-  $edit = $_POST['edit'];
-  
-  // Validate form
-  if (!_citizenspeak_validate_participation($edit)) {
-    drupal_goto('node/'.$nid);
-  }
-      
+function citizenspeak_send_petition_submit($form_id, $edit) {
   // Log response
   $id = db_next_id('citizenspeak_participants');
-  db_query("INSERT INTO {citizenspeak_participants} (nid, id, name, organization, email, address, city, state, zip, phone, fax, personal_statement, sent_at) VALUES (%d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%05d', '%s', '%s', '%s', NOW())", $nid, $id, $edit['name'], $edit['organization'], $edit['email'], $edit['address'], $edit['city'], $edit['state'], $edit['zip'], $edit['phone'], $edit['fax'], $edit['personal_statement']); 
+  db_query("INSERT INTO {citizenspeak_participants} (nid, id, name, organization, email, address, city, state, zip, phone, fax, personal_statement, sent_at) VALUES (%d, %d, '%s', '%s', '%s', '%s', '%s', '%s', %d, '%s', '%s', '%s', NOW())", $edit['nid'], $id, $edit['name'], $edit['organization'], $edit['email'], $edit['address'], $edit['city'], $edit['state'], $edit['zip'], $edit['phone'], $edit['fax'], $edit['personal_statement']); 
 
   // Make email content
-  $node = node_load(array("nid" => $nid));
+  $node = node_load($edit['nid']);
   $participant = db_fetch_object(db_query("SELECT * FROM {citizenspeak_participants} WHERE id = %d", $id));
   $message = theme("citizenspeak_message", $node, $participant);
   $headers = theme("citizenspeak_message_headers", $node, $participant);
@@ -232,10 +259,10 @@
   if (!variable_get('citizenspeak_debug', 0)) {
     mail($node->email_recipients, $node->title, $message, $headers);
     // Redirect to thank you page
-    drupal_goto("node/". $nid."/thank_you");
+    drupal_goto("node/". $edit['nid'] ."/thank_you");
   }
   else {
-    echo theme('page', theme('citizenspeak_debug_page', $node, $message, $headers));
+    return theme('citizenspeak_debug_page', $node, $message, $headers);
   }
 }
 
@@ -246,7 +273,7 @@
  *   Node ID of the campaign
  */
 function citizenspeak_thank_you($nid) {
-    $node = node_load(array("nid" => $nid));
+    $node = node_load($nid);
     $owner = user_load(array("uid" => $node->uid));
     if ($owner->use_redirect) {
       header("Location: ". $node->redirect_url);
@@ -266,10 +293,10 @@
   $output = '';
   if (db_num_rows($result)) {
     while ($node = db_fetch_object($result)) { 
-      $output .= node_view(node_load(array('nid' => $node->nid)), 1); 
+      $output .= node_view(node_load($node->nid), 1); 
     } 
     $output .= theme('pager', NULL, variable_get('default_nodes_main', 10));
   }
   print theme('page', $output);
 }
-?>
\ No newline at end of file
+?>
diff U3 citizenspeak.node.php citizenspeak.node.php
--- citizenspeak.node.php	Wed Aug 30 10:10:58 2006
+++ citizenspeak.node.php	Thu Nov 02 18:09:53 2006
@@ -44,24 +44,42 @@
 /**
  * Implementation of hook_form().
  */
-function citizenspeak_form(&$node, &$error) {
-  $output = '';
-  
-  // In order to be able to attach taxonomy terms to this node, we need
-  // to display the appropriate form elements.
-  if (function_exists('taxonomy_node_form')) {
-    $output .= implode('', taxonomy_node_form('citizenspeak', $node));
-  }
+function citizenspeak_form($node) {
+  $form = array();
+  $form['title'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Title'),
+    '#default_value' => $node->title,
+    '#size' => 60,
+    '#maxlength' => 128,
+    '#required' => TRUE,
+ );
+
+ // Now we define the form elements specific to our node type. 
+ $form['email_message'] = array(
+   '#type' => 'textarea',
+   '#title' => t('Email Message'),
+   '#default_value' => $node->email_message,
+   '#cols' => 60,
+   '#rows' => 20,
+   '#description' => t('Note: This text will be followed by the participant\'s contact information.'),
+   '#required' => TRUE,
+  );
+  $form['email_recipients'] = array(
+    '#type' => 'textarea',
+    '#title' => t('Send Message To'),
+    '#default_value' => $node->email_recipients,
+    '#cols' => 60,
+    '#rows' => 6,
+    '#description' => t('Use a comma or space to separate addresses. Make sure the above email addresses are valid to avoid campaign suspension.'),
+    '#required' => TRUE,
+  );
+  $form['campaign_format'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Put personal statements at top of letter'),
+  );
 
-  // Now we define the form elements specific to our node type. 
-  $email_group = '';
-  $email_group .= form_textarea(t('Email Message'), 'email_message', $node->email_message, 60, 20, t("Note: This text will be followed by the participant's contact information."), array(), true);
-  $email_group .= form_textarea(t('Send Message To'), 'email_recipients', $node->email_recipients, 60, 6, t("Use a comma or space to separate addresses.  Make sure the above email addresses are valid to avoid campaign suspension."), array(), true);
-  $email_group .= form_checkbox(t('Put personal statements at top of letter'), 'campaign_format', 1, $node->campaign_format);
-  
-  $output .= form_group(t('Campaign Information'), $email_group);
-    
-  return $output;
+  return $form;
 } // function citizenspeak_form
 
 /**
@@ -80,13 +98,14 @@
 } // function citizenspeak_load
 
 /**
- * Implementation of hook_node_name().
- *
- * @return name of the module
+ * Implementation of hook_node_info().
  */
-function citizenspeak_node_name($node) {
-  return t('citizenspeak');
-} // function citizenspeak_node_name
+function citizenspeak_node_info() {
+  return array('citizenspeak' => array(
+      'name' => t('CitizenSpeak campaign'),
+      'base' => 'citizenspeak'
+  ));
+}
 
 /**
  * Implementation of hook_update().
@@ -140,11 +159,98 @@
  * necessary so it can be properly presented by theme('node', $node).
  */
 function citizenspeak_view(&$node, $teaser = false, $page = false) {
-  if ($_POST['op'] == 'send') {
-    _citizenspeak_validate_participation($_POST['edit']);
+  $node->body .= theme('citizenspeak_message_preview', $node);
+  if (user_access('participate in campaigns')) {
+    $node->body .= _citizenspeak_participate_display($node);
   }
-  $node->body .= theme('citizenspeak_participate_display', $node);
   $node->teaser .= $node->email_message;
 } // function citizenspeak_view
 
-?>
\ No newline at end of file
+/**
+ * Display the form to participate in a campaign
+ *
+ * @param $node 
+ *   A CitizenSpeak campaign node
+ */
+function _citizenspeak_participate_display($node) {
+  $form = array();
+
+  $form['name'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Name'),
+    '#required' => TRUE,
+  );
+  $form['organization'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Organization'),
+    '#required' => FALSE,
+  );
+  $form['email'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Email'),
+    '#required' => TRUE,
+  );
+  $form['address'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Address'),
+    '#required' => variable_get('citizenspeak_require_address', 1),
+  );
+  $form['city'] = array(
+    '#type' => 'textfield',
+    '#title' => t('City'),
+    '#required' => variable_get('citizenspeak_require_address', 1),
+  );
+  
+  $state_array = array('', 'Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorado', 'Connecticut', 'Delaware', 'District of Columbia', 'Florida', 'Georgia', 'Hawaii', 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota', 'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire', 'New Jersey', 'New Mexico', 'New York', 'North Carolina', 'North Dakota', 'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode Island', 'South Carolina', 'South Dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington', 'West Virginia', 'Wisconsin', 'Wyoming');
+  $form['state'] = array(
+    '#type' => 'select',
+    '#title' => t('State'),
+    '#options' => drupal_map_assoc($state_array),
+    '#extra' => 0,
+    '#multiple' => FALSE,
+    '#required' => variable_get('citizenspeak_require_address', 1),
+  );
+
+  $form['zip'] = array(
+    '#type' => 'textfield',
+    '#title' => t('ZIP code'),
+    '#size' => 5,
+    '#maxlength' => 5,
+    '#required' => variable_get('citizenspeak_require_address', 1),
+  );
+  $form['phone'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Phone'),
+    '#required' => FALSE,
+  );
+  $form['fax'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Fax'),
+    '#required' => FALSE,
+  );
+  $form['personal_statement'] = array(
+    '#type' => 'textarea',
+    '#title' => t('Personal statement'),
+    '#cols' => 60,
+    '#rows' => 20,
+    '#description' => t('This will be included in the email sent.'),
+  );
+
+  $form['nid'] = array(
+    '#type' => 'value',
+    '#value' => $node->nid,
+  );
+  $form['send'] = array(
+    '#type' => 'submit',
+    '#value' => t('Send'),
+  );
+  
+  if (!$node->nid) {
+    // Disable the form if the node hasn't been saved.
+    array_walk($form, create_function('&$value, $key', '$value["#attributes"] = array("disabled" => "disabled");'));
+  }
+
+  return drupal_get_form('citizenspeak_send_petition', $form);  
+} // function _citizenspeak_form_display
+
+?>
diff U3 citizenspeak.reports.php citizenspeak.reports.php
--- citizenspeak.reports.php	Thu Nov 10 22:44:50 2005
+++ citizenspeak.reports.php	Thu Nov 02 18:03:29 2006
@@ -13,11 +13,9 @@
  *   A node ID
  */
 function citizenspeak_report($nid) {
-  $edit = $_GET['edit'];
-  $op = (isset($_GET['op']))?$_GET['op']:t('view');
   $params = array('nid' => $nid);
-  $node = node_load($params);
-  if ($op == t('view')) {
+  $node = node_load($nid);
+  if (!isset($_GET['format'])) {
     $params = array_merge($params, 
       db_fetch_array(db_query("SELECT COUNT(*) AS total_emails, MAX(sent_at) AS last_email FROM {citizenspeak_participants} WHERE nid = %d", $nid)));
 
@@ -25,33 +23,33 @@
     $output = theme('citizenspeak_statistics_page', $params);
     echo theme('page', $output);
   } 
-  elseif ($op == t('download')) {
-      $participants = array();
-      $participants_result = db_query("SELECT * FROM {citizenspeak_participants} WHERE nid = %d", $nid);
-      while ($row = db_fetch_array($participants_result)) {
-        $participants[] = $row;
-      }
-      
-      switch($edit['format']) {
-        case "dbimport":
-          $report_theme = 'citizenspeak_report_dbimport';
-          $content_type = 'text/tab-separated-values';
-          $ext          = 'tab';
-          break;
-        
-        case "excel":
-          $report_theme = 'citizenspeak_report_excel';
-          $content_type = 'application/msexcel';
-          $ext          = 'xls';
-          break;
-        
-        case "text":
-        default:
-          $report_theme = 'citizenspeak_report_text';
-          $content_type = 'text/plain';
-          $ext          = 'txt';
-          break;
-      }
+  else {
+    $participants = array();
+    $participants_result = db_query("SELECT * FROM {citizenspeak_participants} WHERE nid = %d", $nid);
+    while ($row = db_fetch_array($participants_result)) {
+      $participants[] = $row;
+    }
+
+    switch($_GET['format']) {
+      case "dbimport":
+        $report_theme = 'citizenspeak_report_dbimport';
+        $content_type = 'text/tab-separated-values';
+        $ext          = 'tab';
+        break;
+
+      case "excel":
+        $report_theme = 'citizenspeak_report_excel';
+        $content_type = 'application/msexcel';
+        $ext          = 'xls';
+        break;
+
+      case "text":
+      default:
+        $report_theme = 'citizenspeak_report_text';
+        $content_type = 'text/plain';
+        $ext          = 'txt';
+        break;
+    }
 
     header("Content-Type: $content_type; name=report.$ext");
     header("Content-Disposition: attachment; filename=report.$ext");
@@ -133,4 +131,4 @@
 
   return $output;
 }
-?>
\ No newline at end of file
+?>
diff U3 citizenspeak.theme.php citizenspeak.theme.php
--- citizenspeak.theme.php	Sun Mar 19 02:08:04 2006
+++ citizenspeak.theme.php	Thu Nov 02 18:03:29 2006
@@ -98,7 +98,7 @@
   drupal_set_title(t('Thank You'));
 
   $output = '<div id="citizenspeak_thank_you">';
-  $output .= t('<p>Thank you for supporting our campaign.  Your email is currently being sent to the individuals identified by %name. You can also be of great help to the campaign simply by passing the word along. All it takes is a brief letter to your e-mail circle.</p>', array("%name" => format_name($user)));
+  $output .= t('<p>Thank you for supporting our campaign.  Your email is currently being sent to the individuals identified by %name. You can also be of great help to the campaign simply by passing the word along. All it takes is a brief letter to your e-mail circle.</p>', array("%name" => theme('username', $user)));
   
   // Add action list
   $tell_a_friend_text = t("Dear Friend,
@@ -134,7 +134,7 @@
     $output .= t('<p>If you have any questions, feel free to contact <a href="mailto:%email">%email</a>.</p>', array("%email" => $user->feedback_email));
   }
 
-  $output .= t('<p>Sincerely,<br /><strong>%name</strong></p>', array("%name" => format_name($user)));
+  $output .= t('<p>Sincerely,<br /><strong>%name</strong></p>', array("%name" => theme('username', $user)));
   $output .= '</div>';
   return $output;
 }
@@ -161,13 +161,11 @@
   $output .= t("<p>Download reports with all your campaign participants’ contact information, including name, organization, address, email address and personal statement.  With campaign reports you can:<ul><li>Expand your list of supporters</li><li>Let supporters know they’re not alone.</li><li>Identify compelling personal statements.</li></ul>Please respect your campaign participants’ privacy by getting consent before making public their contact information and statements.</p>");
   $output .= t("<p>To download a report, choose a file format and click \"download\"</p>");
 
-  $download_fields .= form_select(t('File format'), 'format', null, array("text" => t("text file"), "excel" => t("excel file"), "dbimport" => t("db import file")));
-  $download_fields .= form_submit(t("download"), 'op');
-  // If clean URLs aren't enabled, include the path
-  if (!variable_get('clean_url', 0)) {
-    $download_fields .= '<input type="hidden" name="q" value="node/'. arg(1) .'/report" />';
-  }
-  $output .= form($download_fields, 'get');
+  $output .= theme('links', array(
+      l(t('text file'), 'node/'. arg(1) .'/report', array(), 'format=text'),
+      l(t('Excel file'), 'node/'. arg(1) .'/report', array(), 'format=excel'),
+      l(t('dbimport'), 'node/'. arg(1) .'/report', array(), 'format=dbimport'),
+  ));
 
   $output .= t('<h2>ZIP Code Summary</h2>');
   $output .= theme_table(array(t('ZIP Code'), t('Emails')), $params['zips']);
@@ -250,7 +248,6 @@
  *   Additional headers, from theme_citizenspeak_message_headers()
  */
 function theme_citizenspeak_debug_page($node, $message, $headers) {
-  drupal_set_title(t('Debugging Mode'));
   $output = t('<p>Message not sent because the system is in debugging mode.  Use <a href="%settings_url">the CitizenSpeak settings</a> to turn of debugging mode.  The email that would have been sent is below.</p>', array("%settings_url" => url("admin/settings/citizenspeak")));
   $output .= '<pre>';
   $output .= htmlentities("{$headers}\n");
@@ -259,6 +256,6 @@
   $output .= htmlentities("\n{$message}\n");
   $output .= '</pre>';
   $output .= l(t('Continue to Thank You page'), "node/". $node->nid."/thank_you");
-  return $output;  
+  drupal_set_message($output);
 } 
 ?>
diff U3 citizenspeak.user.php citizenspeak.user.php
--- citizenspeak.user.php	Fri Nov 04 16:36:56 2005
+++ citizenspeak.user.php	Thu Nov 02 18:03:29 2006
@@ -26,7 +26,7 @@
   // TODO: make weight customizable in admin interface
   
   if (user_access('customize thank you page', $user)) {
-    return array(array('name' => 'citizenspeak_thank_you', 'title' => t('Customize Thank You Page'), 'weight' => 0));
+    return array(array('name' => 'citizenspeak_thank_you', 'title' => t('campaign thank you pages'), 'weight' => 0));
   }
 }
 
@@ -66,32 +66,143 @@
 
 function citizenspeak_user_form(&$edit, &$user, $category = false) {
   if ($category == "citizenspeak_thank_you" && user_access('customize thank you page', $user)) {
-    $thank_group = $customize_desc = '';
+    $form = array();
     
-    $option_desc = form_textfield('Email To', 'volunteer_email', $user->volunteer_email, 25, 255);
-    $customize_desc .= form_checkbox(t('Volunteer Signup'), 'request_volunteers', 1, $user->request_volunteers, $option_desc);
+    $form['use_redirect_false']['use_redirect'] = array(
+      '#name' => 'edit[use_redirect]',
+      '#type' => 'radio',
+      '#title' => t('Customize standard page'),
+      '#return_value' => 0,
+      '#default_value' => $user->use_redirect,
+    );
+    $form['use_redirect_false'][] = array(
+      '#type' => 'markup',
+      '#value' => '<div style="margin-left: 2em">',
+    );
+
+    $form['use_redirect_false']['request_volunteers'] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Volunteer signup'),
+      '#return_value' => 1,
+      '#default_value' => $user->request_volunteers,
+    );
+    $form['use_redirect_false']['volunteer_email'] = array(
+      '#type' => 'textfield',
+      '#title' => t('Email to'),
+      '#default_value' => $user->volunteer_email,
+      '#size' => 25,
+      '#maxlength' => 255,
+      '#prefix' => '<div style="margin-left: 2em">',
+      '#suffix' => '</div>',
+    );
+
+    $form['use_redirect_false']['request_donations'] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Donation link'),
+      '#return_value' => 1,
+      '#default_value' => $user->request_donations,
+    );
+    $form['use_redirect_false']['donation_paypal_id'] = array(
+      '#type' => 'textfield',
+      '#title' => t('PayPal ID'),
+      '#default_value' => $user->donation_paypal_id,
+      '#size' => 25,
+      '#maxlength' => 255,
+      '#prefix' => '<div style="margin-left: 2em">',
+      '#suffix' => '</div>',
+    );
+
+    $form['use_redirect_false']['request_memberships'] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Membership link'),
+      '#return_value' => 1,
+      '#default_value' => $user->request_memberships,
+    );
+    $form['use_redirect_false']['membership_paypal_id'] = array(
+      '#type' => 'textfield',
+      '#title' => t('PayPal ID'),
+      '#default_value' => $user->membership_paypal_id,
+      '#size' => 25,
+      '#maxlength' => 255,
+      '#prefix' => '<div style="margin-left: 2em">',
+      '#suffix' => '</div>',
+    );
+    $form['use_redirect_false']['membership_paypal_amount'] = array(
+      '#type' => 'textfield',
+      '#title' => t('Dues (USD)'),
+      '#default_value' => $user->membership_paypal_amount,
+      '#size' => 6,
+      '#maxlength' => 10,
+      '#description' => t('(yearly)'),
+      '#prefix' => '<div style="margin-left: 2em">',
+      '#suffix' => '</div>',
+    );
+
+    $form['use_redirect_false']['include_additional_text'] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Additional text'),
+      '#return_value' => 1,
+      '#default_value' => $user->include_additional_text,
+    );
+    $form['use_redirect_false']['additional_text_language'] = array(
+      '#type' => 'select',
+      '#title' => '',
+      '#default_value' => $user->additional_text_language,
+      '#options' => drupal_map_assoc(array(t('English'), t('Spanish'))),
+      '#prefix' => '<div style="margin-left: 2em">',
+      '#suffix' => '</div>',
+    );
+    $form['use_redirect_false']['additional_text'] = array(
+      '#type' => 'textarea',
+      '#title' => '',
+      '#default_value' => $user->additional_text,
+      '#cols' => 60,
+      '#rows' => 6,
+      '#prefix' => '<div style="margin-left: 2em">',
+      '#suffix' => '</div>',
+    );
+
+    $form['use_redirect_false']['request_feedback'] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Feedback'),
+      '#return_value' => 1,
+      '#default_value' => $user->request_feedback,
+    );
+    $form['use_redirect_false']['feedback_email'] = array(
+      '#type' => 'textfield',
+      '#title' => t('Email to'),
+      '#default_value' => $user->feedback_email,
+      '#size' => 25,
+      '#maxlength' => 255,
+      '#prefix' => '<div style="margin-left: 2em">',
+      '#suffix' => '</div>',
+    );
+
+    $form['use_redirect_false'][] = array(
+      '#type' => 'markup',
+      '#value' => '</div>',
+    );
+
+
+    $form['use_redirect_true']['use_redirect'] = array(
+      '#name' => 'edit[use_redirect]',
+      '#type' => 'radio',
+      '#title' => t('Use your page'),
+      '#return_value' => 1,
+      '#default_value' => $user->use_redirect,
+    );
+
+    $form['use_redirect_true']['redirect_url'] = array(
+      '#type' => 'textfield',
+      '#default_value' => $user->redirect_url,
+      '#size' => 25,
+      '#maxlength' => 255,
+      '#description' => t('Your full web address'),
+      '#prefix' => '<div style="margin-left: 2em">',
+      '#suffix' => '</div>',
+    );
 
-    $option_desc = form_textfield('PayPal ID', 'donation_paypal_id', $user->donation_paypal_id, 25, 255);
-    $customize_desc .= form_checkbox(t('Donation Link'), 'request_donations', 1, $user->request_donations, $option_desc);
-  
-    $option_desc = form_textfield('PayPal ID', 'membership_paypal_id', $user->membership_paypal_id, 25, 255);
-    $option_desc .= form_textfield('Dues: $', 'membership_paypal_amount', $user->membership_paypal_amount, 6, 10, t('(yearly)')); 
-    $customize_desc .= form_checkbox(t('Membership Link'), 'request_memberships', 1, $user->request_memberships, $option_desc);
-  
-    $option_desc = form_select('', 'additional_text_language', $user->additional_text_language, drupal_map_assoc(array('English', 'Spanish')));
-    $option_desc .= form_textarea('', 'additional_text', $user->additional_text, 60, 6);  
-    $customize_desc .= form_checkbox(t('Additional Text'), 'include_additional_text', 1, $user->include_additional_text, $option_desc);
-  
-    $option_desc = form_textfield('Email To', 'feedback_email', $user->feedback_email, 25, 255);
-    $customize_desc .= form_checkbox(t('Feedback'), 'request_feedback', 1, $user->request_feedback, $option_desc);
-  
-    
-    $thank_group .= form_radio(t('Customize Standard Page:'), 'use_redirect', 0, !$user->use_redirect, $customize_desc, NULL, true);
-
-    $redirect_desc = form_textfield('', 'redirect_url', $user->redirect_url, 25, 255, t('Your full web address'));
-    $thank_group .= form_radio(t('Use Your Page:'), 'use_redirect', 1, $user->use_redirect, $redirect_desc, NULL, true);
-    
-    return array(array('title' => t('Thank You Page'), 'data' => $thank_group, 'weight' => 0));
+    return $form;
   } 
 }
 
@@ -127,7 +238,8 @@
 
 function citizenspeak_user_update(&$edit, &$user, $category = false) {
   if ($category == "citizenspeak_thank_you" && user_access('customize thank you page', $user)) {
-    db_query("UPDATE {citizenspeak_thankyou_options} SET use_redirect = %d, redirect_url = '%s', request_volunteers = %d, volunteer_email = '%s', request_donations = %d, donation_paypal_id = '%s', request_memberships = %d, membership_paypal_id = '%s', membership_paypal_amount = %.2f, include_additional_text = %d, additional_text_language = '%s', additional_text = '%s', request_feedback = %d, feedback_email = '%s' WHERE uid = %d", $edit['use_redirect'],  $edit['redirect_url'],  $edit['request_volunteers'],  $edit['volunteer_email'],  $edit['request_donations'],  $edit['donation_paypal_id'],  $edit['request_memberships'],  $edit['membership_paypal_id'],  $edit['membership_paypal_amount'],  $edit['include_additional_text'],  $edit['additional_text_language'],  $edit['additional_text'],  $edit['request_feedback'],  $edit['feedback_email'],  $user->uid);
+    db_query('DELETE FROM {citizenspeak_thankyou_options} WHERE uid = %d', $user->uid);
+    db_query("INSERT INTO {citizenspeak_thankyou_options} (use_redirect, redirect_url, request_volunteers, volunteer_email, request_donations, donation_paypal_id, request_memberships, membership_paypal_id, membership_paypal_amount, include_additional_text, additional_text_language, additional_text, request_feedback, feedback_email, uid) VALUES (%d, '%s', %d, '%s', %d, '%s', %d, '%s', %f, %d, '%s', '%s', %d, '%s', %d)", $edit['use_redirect'], $edit['redirect_url'], $edit['request_volunteers'], $edit['volunteer_email'], $edit['request_donations'], $edit['donation_paypal_id'], $edit['request_memberships'], $edit['membership_paypal_id'], $edit['membership_paypal_amount'], $edit['include_additional_text'], $edit['additional_text_language'], $edit['additional_text'], $edit['request_feedback'], $edit['feedback_email'], $user->uid);
   }
 }
 
@@ -165,4 +277,4 @@
       form_set_error('redirect_url', 'You must provide a valid web address');
     }
   }
-}
\ No newline at end of file
+}
