--- uc_signup.module.old	2010-07-04 00:02:37.000000000 -0400
+++ uc_signup.module	2010-08-03 10:29:32.000000000 -0400
@@ -101,6 +101,10 @@ function uc_signup_attendees_form_valida
           if (!isset($prev_mails[$key])) {
             $prev_mails[$key] = array();
           }
+          if (!variable_get('uc_signup_require_emails', 1) && empty($mail) && $num) {
+            $mail = str_replace("@", "+$num@", $prev_mails[$key][0]);
+            form_set_value(array('#parents' => array($key, $num)) , $mail, $form_state);
+          }
           if (in_array($mail, $prev_mails[$key])) {
             form_set_error("$key][$num", t("Please enter a unique email address for each event's attendees."));
           }
@@ -162,7 +166,7 @@ function uc_signup_attendees_form_emails
         '#type' => 'textfield',
         '#title' => t('Email Address of Attendee #%count', array('%count' => $num + 1)),
         '#default_value' => $default,
-        '#required' => TRUE,
+        '#required' => variable_get('uc_signup_require_emails', 1) ? TRUE : ($num ? FALSE : TRUE),
       );
       $num ++;
     }
@@ -260,10 +264,24 @@ function uc_signup_attendees_form_profil
 
   $profile_form = uc_signup_profile_form();
   $mail = '';
+  $registrant = '';
   foreach ($mails as $mail => $events) {
+    $legend = check_plain($mail);
+    if (!variable_get('uc_signup_require_emails', 1)) {
+      if (empty($registrant)) {
+        $registrant = $mail;
+      }
+      else {
+        $check_mail = preg_replace('/(.*)\+\d@(.*)/', '$1@$2', $mail);
+        $guest_num = preg_replace('/(.*)\+(\d)@(.*)/', '$2', $mail);
+        if ($check_mail == $registrant) {
+          $legend = t('Guest !num', array('!num' => $guest_num));
+        }
+      }
+    }
     $form[$mail] = array(
       '#type' => 'fieldset',
-      '#title' => check_plain($mail),
+      '#title' => $legend,
       '#collapsible' => TRUE,
       '#collapsed' => FALSE,
     );
@@ -599,10 +617,23 @@ function uc_signup_attendees_pane($op, $
             $mails[$mail][] = $nid;
           }
         }
-      
+        $registrant = ''; 
         foreach ($mails as $mail => $events) {
+          $legend = $mail;
+          if (!variable_get('uc_signup_require_emails', 1)) {
+            if (empty($registrant)) {
+              $registrant = $mail;
+            }
+            else {
+              $check_mail = preg_replace('/(.*)\+\d@(.*)/', '$1@$2', $mail);
+              $guest_num = preg_replace('/(.*)\+(\d)@(.*)/', '$2', $mail);
+              if ($check_mail == $registrant) {
+                $legend = t('Guest !num', array('!num' => $guest_num));
+              }
+            }
+          }
           $output .= "<div>";
-          $output .= $mail;
+          $output .= $legend;
           $output .= theme('uc_signup_user_events', $events, $nodes);
           $output .= "</div>";
         }
@@ -653,6 +684,7 @@ function uc_signup_order($op, &$arg1, $a
             if (empty($account->uid)) {
               $form_state['values']['mail'] = $mail;
               $form_state['values']['name'] = uc_store_email_to_username($mail);
+              $form_state['values']['name'] = str_replace('+', '', $form_state['values']['name']);
               $form_state['values']['op'] = t('Create new account');
               $form_state['values']['pass'] =  user_password(8);
               $form_state['values']['notify'] = (bool)variable_get('uc_signup_account_notify', 1);
@@ -792,6 +824,16 @@ function uc_signup_settings_form() {
     '#description' => t("When enabled account activation emails will be sent when uc_signup automatically creates accounts."),
     '#default_value' => variable_get('uc_signup_account_notify', 1),
   );
+  $form['uc_signup_require_emails'] = array(
+    '#type' => 'radios',
+    '#title' => t('Require email address for all guest attendees'),
+    '#description' => t('If enabled, user will be required to enter email address for all attendees. If not, only the registering user will need to enter an email address.'),
+    '#options' => array(
+      1 => t('Yes'),
+      0 => t('No'),
+    ),
+    '#default_value' => variable_get('uc_signup_require_emails', 1),
+  );
   return system_settings_form($form);
 }
 
