diff --git contrib/uc_signup_cp/uc_signup_cp.info contrib/uc_signup_cp/uc_signup_cp.info new file mode 100644 index 0000000..96c76c3 --- /dev/null +++ contrib/uc_signup_cp/uc_signup_cp.info @@ -0,0 +1,7 @@ +; $Id$ +name=UC Signup Content Profile +description=Integrates Content Profile module with UC Signup +core=6.x +dependencies[] = uc_signup +dependencies[] = content_profile_registration +package=Signup \ No newline at end of file diff --git contrib/uc_signup_cp/uc_signup_cp.module contrib/uc_signup_cp/uc_signup_cp.module new file mode 100644 index 0000000..d84dadd --- /dev/null +++ contrib/uc_signup_cp/uc_signup_cp.module @@ -0,0 +1,66 @@ + $typename) { + $form_state = array(); + // Fake a node here so that content_profile doesn't redirect. + $form_state['node'] = array('nid' => FALSE); + content_profile_registration_add_profile_form($type, $form, $form_state); + } + if (empty($form['#field_info'])) { + return; + } + + $new_form = array(); + foreach ($form['#field_info'] as $field => $value) { + $new_form[$field] = $form[$field]; + } + + $extras = array( + '#field_info', '#pre_render', '#content_profile_weights', '#attributes', + ); + foreach ($extras as $key) { + $new_form[$key] = $form[$key]; + } + + return $new_form; +} + +/** + * Implementation of hook_form_alter(). + */ +function uc_signup_cp_form_alter(&$form, $form_state, $form_id) { + if ($form_id == 'uc_signup_attendees_form') { + foreach (element_children($form) as $key => $value) { + if (isset($form[$value]['profile']['#attributes']['enctype'])) { + // For filefields. + $form['#attributes']['enctype'] = $form[$value]['profile']['#attributes']['enctype']; + } + if (isset($form[$value]['profile']['#field_info'])) { + // CCK modules such as Option Widgets expect #field_info to be in the top level of the form. + $form['#field_info'] = $form[$value]['profile']['#field_info']; + } + } + } +} + +/** + * Implementation of hook_uc_signup_profile_values(). + */ +function uc_signup_cp_uc_signup_profile_values(&$form_state, $mail) { + $form = uc_signup_cp_profile_form(); + foreach ($form['#field_info'] as $name => $field) { + $form_state['values'][$name] = $_SESSION['uc_signup']['profile'][$name . '_' . $mail]; + } +} \ No newline at end of file diff --git contrib/uc_signup_profile/uc_signup_profile.info contrib/uc_signup_profile/uc_signup_profile.info new file mode 100644 index 0000000..f700b45 --- /dev/null +++ contrib/uc_signup_profile/uc_signup_profile.info @@ -0,0 +1,7 @@ +; $Id$ +name=UC Signup Profile +description=Integrates core Profile module with UC Signup +core=6.x +dependencies[] = uc_signup +dependencies[] = profile +package=Signup \ No newline at end of file diff --git contrib/uc_signup_profile/uc_signup_profile.install contrib/uc_signup_profile/uc_signup_profile.install new file mode 100644 index 0000000..5bf70ec --- /dev/null +++ contrib/uc_signup_profile/uc_signup_profile.install @@ -0,0 +1,26 @@ + l(t('set at least one profile field to appear on the registration form.'), 'admin/user/profile'))); + $requirements['uc_signup_profile']['severity'] = REQUIREMENT_WARNING; + } + else { + $requirements['uc_signup_profile']['description'] = t('You have at least one core profile field set to show up on the user registration form.'); + $requirements['uc_signup_profile']['severity'] = REQUIREMENT_OK; + } + } + return $requirements; +} + diff --git contrib/uc_signup_profile/uc_signup_profile.module contrib/uc_signup_profile/uc_signup_profile.module new file mode 100644 index 0000000..56dba65 --- /dev/null +++ contrib/uc_signup_profile/uc_signup_profile.module @@ -0,0 +1,34 @@ + $val) { + $new_form[$val] = $form[$val]; + } + return $new_form; +} + +/** + * Implementation of hook_uc_signup_profile_values(). + */ +function uc_signup_profile_uc_signup_profile_values(&$form_state, $mail) { + $profile_form = uc_signup_profile_form($form_state); + foreach ($profile_form as $key => $value) { + $form_state['values'][$key] = $_SESSION['uc_signup']['profile'][$key .'_'. $mail]; + } +} + + diff --git uc_signup.info uc_signup.info index c7fab89..d237b36 100644 --- uc_signup.info +++ uc_signup.info @@ -8,4 +8,3 @@ dependencies[] = uc_product dependencies[] = uc_payment dependencies[] = ca dependencies[] = date -dependencies[] = profile diff --git uc_signup.install uc_signup.install index c8dfff6..372b670 100644 --- uc_signup.install +++ uc_signup.install @@ -53,6 +53,30 @@ function uc_signup_uninstall() { } /** + * Implementation of hook_requirements(). + */ +function uc_signup_requirements($phase) { + $requirements = array(); + if ($phase == 'runtime') { + $requirements['uc_signup']['title'] = t('Signup Integration for Ubercart'); + + // Check to see if either uc_signup_profile or uc_signup_cp are enabled. + $profile = module_exists('uc_signup_profile'); + $cp = module_exists('content_profile'); + if (!$profile && !$cp) { + // Neither is enabled. + $requirements['uc_signup']['description'] = t('It is recommended that you enable either the core Profile module, or Content Profile for use with UC Signup.'); + $requirements['uc_signup']['severity'] = REQUIREMENT_WARNING; + } + else { + $requirements['uc_signup']['description'] = t('You have core profile or Content Profile module enabled.'); + $requirements['uc_signup']['severity'] = REQUIREMENT_OK; + } + } + return $requirements; +} + +/** * Ensure that uc_signup hooks are executed before payment modules. */ function uc_signup_update_6000() { @@ -100,4 +124,19 @@ function uc_signup_update_6001() { } return $ret; -} \ No newline at end of file +} + +/** + * Enable uc_signup_profile module (as, for existing installs, this is + * an assumed dependency). + */ +function uc_signup_update_6002() { + $ret = array(); + module_rebuild_cache(); + drupal_install_modules(array('uc_signup_profile')); + $ret[] = array( + 'success' => TRUE, + 'query' => t('Enabled the UC Signup Profile module, as this functionality has been split out from UC Signup.'), + ); + return $ret; +} diff --git uc_signup.module uc_signup.module index ed15f7c..3ac7ac7 100644 --- uc_signup.module +++ uc_signup.module @@ -62,42 +62,16 @@ function uc_signup_theme() { } /* - * Implementation of hook_requirements(). - */ - -function uc_signup_requirements($phase) { - if ($phase == 'runtime') { - $requirements['uc_signup']['title'] = t('Signup Integration for Ubercart'); - $profile_form = uc_signup_profile_form(); - if (empty($profile_form)) { - $requirements['uc_signup']['description'] = t('You have no core user - profile fields that are configured to show on the user registration form. - UC_Signup requires that you make at !action', - array('!action' => l(t('set at least one profile field to appear on the registration form.'), 'admin/user/profile'))); - $requirements['uc_signup']['severity'] = REQUIREMENT_WARNING; - } - else { - $requirements['uc_signup']['description'] = t('You have at least one core profile field set to show up on the user registration form.'); - $requirements['uc_signup']['severity'] = REQUIREMENT_OK; - } - } - return $requirements; -} - -/* * Get the profile fields required on user registration. */ function uc_signup_profile_form() { - include_once(drupal_get_path('module', 'user') .'/user.pages.inc'); - $form = profile_form_profile(array(), (object)array(), NULL, TRUE); - // $form now has a fieldset for each profile field category. - // We want an array of individual field elements from the first category. - $form = array_values($form); - $form = $form[0]; - foreach (element_children($form) as $key => $val) { - $new_form[$val] = $form[$val]; + // TODO Generalize this...perhaps a hook? + if (module_exists('uc_signup_profile')) { + return uc_signup_profile_profile_form(); + } + elseif (module_exists('uc_signup_cp')) { + return uc_signup_cp_profile_form(); } - return $new_form; } function uc_signup_attendees_form_validate($form, &$form_state) { @@ -265,7 +239,6 @@ function uc_signup_attendees_form_profiles(&$form_state, $events = array()) { } } - $profile_form = uc_signup_profile_form(); $mail = ''; foreach ($mails as $mail => $events) { $form[$mail] = array( @@ -662,11 +635,12 @@ function uc_signup_order($op, &$arg1, $arg2) { $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); - $profile_form = uc_signup_profile_form(); - foreach ($profile_form as $key => $value) { - $form_state['values'][$key] = $_SESSION['uc_signup']['profile'][$key .'_'. $mail]; + + foreach (module_implements('uc_signup_profile_values') as $module) { + $function = $module . '_uc_signup_profile_values'; + $function($form_state, $mail); } - + //We masquerade as user 1 in case there is captcha or other protection on the user_register form that could cause submission to fail. global $user; $temp_user = $user;