[freeside-commits] freeside/fs_selfservice/drupal admin.inc, 1.1, 1.2 signup.inc, 1.1, 1.2
Mark Wells
mark at wavetail.420.am
Tue Sep 28 16:12:54 PDT 2010
Update of /home/cvs/cvsroot/freeside/fs_selfservice/drupal
In directory wavetail.420.am:/tmp/cvs-serv14687/fs_selfservice/drupal
Modified Files:
admin.inc signup.inc
Log Message:
assorted drupal self-service fixes, RT#9380
Index: signup.inc
===================================================================
RCS file: /home/cvs/cvsroot/freeside/fs_selfservice/drupal/signup.inc,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -d -r1.1 -r1.2
--- signup.inc 12 Aug 2010 21:31:19 -0000 1.1
+++ signup.inc 28 Sep 2010 23:12:52 -0000 1.2
@@ -7,32 +7,36 @@
/* "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);
+ $cid = 'FS_signup_info';
$info = cache_get($cid);
if($info) {
return($info->data);
}
else {
+ $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);
}
}
- else {
- $freeside = new FreesideSelfService();
- return $freeside->signup_info($packet);
- }
-}
function subextract($array, $key) {
// map { $_->{$key} } (...)
@@ -44,6 +48,7 @@
}
function freeside_signup_form($form_state) {
+ dkpr($form_state);
$agentnum = variable_get('freeside_agentnum','');
if( !$agentnum || !(variable_get('freeside_hostname','')) ) {
@@ -52,12 +57,17 @@
}
$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_info = signup_info($packet);
+ $signup_info = signup_info($keys);
dkpr($signup_info);
$form = array();
@@ -249,6 +259,7 @@
'#type' => 'password_confirm',
'#size' => 20,
'#required'=>1,
+ '#process'=> array('freeside_expand_password_confirm'),
),
);
$form['package']['pkgpart']['#default_value'] = $signup_info['default_pkgpart'];
@@ -260,6 +271,14 @@
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 +297,7 @@
'night',
'fax',
'payby',
+ 'refnum',
'invoicing_list',
'pkgpart',
'username'
@@ -306,12 +326,14 @@
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'] = variable_get('freeside_redirect_after_signup','/');
}
}
Index: admin.inc
===================================================================
RCS file: /home/cvs/cvsroot/freeside/fs_selfservice/drupal/admin.inc,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -d -r1.1 -r1.2
--- admin.inc 12 Aug 2010 21:31:19 -0000 1.1
+++ admin.inc 28 Sep 2010 23:12:52 -0000 1.2
@@ -18,7 +18,11 @@
if($hostname) {
$freeside = new FreesideSelfService();
- $signup_info = $freeside->signup_info(); // no agent in this request
+ $signup_info = $freeside->signup_info(
+ array(
+ 'keys' => array('agent')
+ )
+ ); // no agent in this request
$agents = array();
foreach((array)$signup_info['agent'] as $a) {
@@ -38,6 +42,12 @@
'#title' => t('Enable debugging'),
'#default_value'=>variable_get('freeside_debug',0),
);
+
+ $form['freeside_redirect_after_signup'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Success page (URL or Drupal path)'),
+ '#default_value'=>variable_get('freeside_redirect_after_signup','/'),
+ );
}
return system_settings_form($form);
More information about the freeside-commits
mailing list