--- uc_signup.module.old	2010-06-02 15:15:43.000000000 +0000
+++ uc_signup.module	2010-06-02 16:48:17.000000000 +0000
@@ -69,6 +69,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."));
           }
@@ -125,7 +129,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 ++;
     }
@@ -224,10 +228,24 @@ function uc_signup_attendees_form_profil
   include_once(drupal_get_path('module', 'user') .'/user.pages.inc');
   $profile_form = array_values(module_invoke('profile', 'user', 'register', array(), (object)array()));
   $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,
     );
@@ -531,10 +549,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>";
         }
@@ -585,6 +616,7 @@ function uc_signup_order($op, &$arg1, $a
             if (empty($account->uid)) {
               $form_state['values']['mail'] = $mail;
               $namenew = preg_replace('/@.*$/', '', $mail);
+              $namenew = str_replace('+', '', $namenew);
               // From the email registration module:
               if (db_result(db_query("SELECT count(*) FROM {users} WHERE LOWER(name) = LOWER('%s')", $namenew)) > 0) {
                  // Find the next number available to append to the name
@@ -679,6 +711,16 @@ function uc_signup_settings_form() {
   '#description' => t("The signup/add to cart button will be disabled and display this text when signups are closed for a node. This text will be displayed when capacity is reached for an event."),
   '#default_value' => variable_get('uc_signup_signups_closed_text', t("Signups are closed for this event.")),
   );
+  $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);
 }
 
