X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=fs_selfservice%2Fdrupal%2Fsignup.inc;h=b3e54f0343681ec51b86492c65b7f1abafa4919f;hp=13ed37999105b39340d52ad0e3814ad3293020fe;hb=0fb307c305e4bc2c9c27dc25a3308beae3a4d33c;hpb=3706609762d9cec964f337e74829031b895ddbac diff --git a/fs_selfservice/drupal/signup.inc b/fs_selfservice/drupal/signup.inc index 13ed37999..b3e54f034 100644 --- a/fs_selfservice/drupal/signup.inc +++ b/fs_selfservice/drupal/signup.inc @@ -7,30 +7,34 @@ function dkpr($var) { /* "debug kpr": Krumo-print $var if debugging is on */ static $debug; if(empty($debug)) $debug = variable_get('freeside_debug',''); - if($debug) kpr($var); + if($debug) { + kpr($var); + } } -function signup_info($packet) { +function signup_info($keys) { /* local cache, because transporting the entire signup_info through XML-RPC is incredibly slow. If you change the config, you can flush the local cache with the "Clear cached data" button on the Drupal "Performance" menu. */ - if(1) { // change to 0 to disable local cache - $cid = 'FS_signup'.serialize($packet); - $info = cache_get($cid); - if($info) { - return($info->data); - } - else { - $freeside = new FreesideSelfService(); - $info = $freeside->signup_info($packet); - cache_set($cid, $info, 'cache', CACHE_TEMPORARY); - return($info); - } + $cid = 'FS_signup_info'; + $info = cache_get($cid); + if($info) { + return($info->data); } else { - $freeside = new FreesideSelfService(); - return $freeside->signup_info($packet); + $packet = array( + 'agentnum' => variable_get('freeside_agentnum',''), + 'promo_code' => '', + 'reg_code' => '', + 'keys' => $keys, + ); + + $freeside = new FreesideSelfService(); + $freeside->clear_signup_cache(); + $info = $freeside->signup_info($packet); + cache_set($cid, $info, 'cache', CACHE_TEMPORARY); + return($info); } } @@ -44,6 +48,7 @@ function subextract($array, $key) { } function freeside_signup_form($form_state) { + dkpr($form_state); $agentnum = variable_get('freeside_agentnum',''); if( !$agentnum || !(variable_get('freeside_hostname','')) ) { @@ -52,12 +57,18 @@ function freeside_signup_form($form_state) { } $freeside = new FreesideSelfService(); - $packet = array( - 'agentnum' => $agentnum, - 'promo_code' => '', - 'reg_code' => '', + $keys = array( + // all the signup_info that we need + 'part_referral', + 'refnum', + 'emailinvoiceonly', + 'payby', + 'payby_longname', + 'part_pkg', + 'default_pkgpart', + 'signup_service', ); - $signup_info = signup_info($packet); + $signup_info = signup_info($keys); dkpr($signup_info); $form = array(); @@ -239,18 +250,28 @@ function freeside_signup_form($form_state) { '#value' => $pkgs[0]['pkgpart'], ) ), - 'username'=> array( - '#type' => 'textfield', - '#title' => t('Username'), - '#size' => 20, - '#required'=>1, - ), - 'password'=> array( - '#type' => 'password_confirm', - '#size' => 20, - '#required'=>1, - ), ); + + switch($signup_info['signup_service']) { + case 'svc_acct': + $form['package'] += array( + 'username'=> array( + '#type' => 'textfield', + '#title' => t('Username'), + '#size' => 20, + '#required'=>1, + ), + 'password'=> array( + '#type' => 'password_confirm', + '#size' => 20, + '#required'=>1, + '#process'=> array('freeside_expand_password_confirm'), + ) + ); + break; + case 'svc_pbx': + break; // nothing yet implemented + } $form['package']['pkgpart']['#default_value'] = $signup_info['default_pkgpart']; $form['submit'] = array( @@ -260,6 +281,14 @@ function freeside_signup_form($form_state) { return $form; } +/* workaround for silly Drupal behavior */ +function freeside_expand_password_confirm($element) { + $element = expand_password_confirm($element); + $element['pass1']['#attributes']['value'] = $element['#value']['pass1']; + $element['pass2']['#attributes']['value'] = $element['#value']['pass2']; + return $element; +} + function freeside_signup_form_submit($form, &$form_state) { $freeside = new FreesideSelfService(); $values = $form_state['values']; @@ -278,6 +307,7 @@ function freeside_signup_form_submit($form, &$form_state) { 'night', 'fax', 'payby', + 'refnum', 'invoicing_list', 'pkgpart', 'username' @@ -306,12 +336,18 @@ function freeside_signup_form_submit($form, &$form_state) { dkpr($response); error_log("[new_customer] received response from Freeside: $response"); $error = $response['error']; + if ( $error ) { drupal_set_message(t("Signup error: $error"), 'error'); $form_state['redirect'] = FALSE; } else { drupal_set_message(t("Signup successful!"),'status'); + $form_state['redirect'] = array( + variable_get('freeside_redirect_after_signup','/'), + //query string would go here + //'custnum='.$response['custnum'].'&svcnum='.$response['svcnum'], + ); } }