Index: uc_signup.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/uc_signup/uc_signup.module,v retrieving revision 1.30 diff -u -p -r1.30 uc_signup.module --- uc_signup.module 8 Aug 2009 16:36:35 -0000 1.30 +++ uc_signup.module 12 Aug 2009 15:25:34 -0000 @@ -18,13 +18,22 @@ function uc_signup_menu() { 'page arguments' => array('uc_signup_settings_form'), 'title' => 'Ubercart Signup settings', ); - $items['uc_signup/attendees'] = array( + $items['uc_signup/attendees/emails'] = array( 'access arguments' => array('view own orders'), 'page callback' => 'drupal_get_form', - 'page arguments' => array('uc_signup_attendees_form'), - 'title' => 'Attendee Information', + 'page arguments' => array('uc_signup_attendees_form', 2), + 'title' => 'Attendee E-mail Addresses', 'type' => MENU_CALLBACK, ); + + $items['uc_signup/attendees/profiles'] = array( + 'access arguments' => array('view own orders'), + 'page callback' => 'drupal_get_form', + 'page arguments' => array('uc_signup_attendees_form', 2), + 'title' => 'Attendee Contact Information', + 'type' => MENU_CALLBACK, + ); + return $items; } @@ -43,13 +52,6 @@ function uc_signup_theme() { } function uc_signup_attendees_form_validate($form, &$form_state) { - if ($form_state['clicked_button']['#value'] == t('Previous step')) { - switch ($form_state['storage']['step']) { - case 'profiles': - $form_state['storage']['step'] = 'emails'; - } - } - if ($form_state['storage']['step'] == 'emails') { foreach ($form_state['values'] as $key => $value) { if (is_numeric($key)) { @@ -116,17 +118,10 @@ function uc_signup_attendees_form_emails '#type' => 'submit', '#value' => t('Next step'), ); - drupal_set_title(t("Attendee Email addresses")); + return $form; } function uc_signup_attendees_form_submit($form, &$form_state) { - if ($form_state['clicked_button']['#value'] == t('Previous step')) { - switch ($form_state['storage']['step']) { - case 'profiles': - $form_state['storage']['step'] = 'emails'; - return $form; - } - } foreach ($form_state['values'] as $key => $value) { if (is_numeric($key)) { @@ -143,10 +138,11 @@ function uc_signup_attendees_form_submit } if ($form_state['storage']['step'] == 'emails') { - $form_state['storage']['step'] = 'profiles'; + unset($form_state['storage']); + $form_state['redirect'] = 'uc_signup/attendees/profiles'; } } -function uc_signup_attendees_form(&$form_state = NULL) { +function uc_signup_attendees_form(&$form_state = NULL, $menu_path = NULL) { // We have to disable page chaching so that this form works properly for anonymous users. $_SERVER['REQUEST_METHOD'] = 'post'; $GLOBALS['config']['cache'] = FALSE; @@ -169,13 +165,12 @@ function uc_signup_attendees_form(&$form $form_state['storage']['uc_signup'] = $_SESSION['uc_signup']; } - if (!empty($form_state['storage']['step'])) { - // The form step has been set in the submission hanlder. The user may have pressed the 'previous' button. - $function = 'uc_signup_attendees_form_'. $form_state['storage']['step']; - return $function($form_state, $events); + //At this point, if the user requested the emails form, present it. + if (!empty($menu_path) && $menu_path == 'emails') { + return uc_signup_attendees_form_emails($form_state, $events); } - // Yes, there are signup enabled nodes in the cart. - // Is there a full list of emails attending each event? + + // Is there a full list of emails for attendees attending each event that matches the event's quantity in the cart? $emails_needed = 0; foreach ($events as $event) { $nid = $event['nid']; @@ -183,16 +178,14 @@ function uc_signup_attendees_form(&$form $emails_needed ++; } } - // If so, proceed to the user acount submission page - // If not, present the email address fields + + // If not, redirect to the email address form. if ($emails_needed > 0) { - return uc_signup_attendees_form_emails($form_state, $events); - } - else { - return uc_signup_attendees_form_profiles($form_state); + drupal_goto('uc_signup/attendees/emails'); } - return $form; + //Otherwise, the user is requesting the profiles form. + return uc_signup_attendees_form_profiles($form_state, $events); } function uc_signup_attendees_form_profiles(&$form_state, $events = array()) { @@ -256,17 +249,16 @@ function uc_signup_attendees_form_profil ); } } - // TODO: get these in the right order. + + $form['back'] = array( + '#type' => 'markup', + '#value' => l(t("Previous step"), 'uc_signup/attendees/emails'), + ); $form['submit'] = array( '#type' => 'submit', '#value' => t('Next step'), ); - $form['back'] = array( - '#type' => 'button', - '#value' => t("Previous step"), - ); - drupal_set_title(t('Attendee Contact Information')); return $form; } @@ -336,7 +328,6 @@ function uc_signup_form_alter(&$form, &$ } } - function uc_signup_cart_view_form_submit($form, &$form_state) { if (!empty($form_state['values']['items'])) { foreach ($form_state['values']['items'] as $item) { @@ -515,7 +506,7 @@ function uc_signup_attendees_pane($op, $ $signups = TRUE; } if ($signups && (empty($_SESSION['uc_signup']['nids'][$product->nid]) || count($_SESSION['uc_signup']['nids'][$product->nid]) < $product->qty)) { - drupal_goto('uc_signup/attendees'); + drupal_goto('uc_signup/attendees/emails'); } } $mails = array(); @@ -537,7 +528,7 @@ function uc_signup_attendees_pane($op, $ $output .= theme('uc_signup_user_events', $events, $nodes); $output .= ""; } - $output .= l(t('Edit signup information'), 'uc_signup/attendees', array('attributes' => array('class' => 'uc_signup_edit_info'))); + $output .= l(t('Edit signup information'), 'uc_signup/attendees/emails', array('attributes' => array('class' => 'uc_signup_edit_info'))); $pane['uc_signup'] = array( '#value' => $output, '#weight' => variable_get('uc_pane_cart_field_cart_weight', 2),