/* "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);
}
}
}
function freeside_signup_form($form_state) {
+ dkpr($form_state);
$agentnum = variable_get('freeside_agentnum','');
if( !$agentnum || !(variable_get('freeside_hostname','')) ) {
}
$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();
'#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(
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'];
'night',
'fax',
'payby',
+ 'refnum',
'invoicing_list',
'pkgpart',
'username'
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'],
+ );
}
}