// Finish user registration with WDS66 API
function doWernisFinishUserRegistration ($challenge, $challengeResponse, $status) {
- // Check status from GET parameters and stored value
+ // Check status from GET parameters and if the form has been sent
if (($status == '1') && (isFormSent('wernis_register'))) {
- // Form has been sent
- die(__FUNCTION__ . ':' . __LINE__ . ': Reached!');
+ // The form has been sent and challenge is fine
+ die(__FUNCTION__ . ':' . __LINE__ . '<pre>'.print_r(postRequestArray(), TRUE).'</pre>');
} elseif ($status == '1') {
// Get mapped data based on challenge
- $return = getWernisMapedDataFromApiByChallenge($challenge, $status);
+ $return = getWernisMappedDataFromApiByChallenge($challenge, $status);
// Is the array filled?
if ((count($return['mapped_data']) > 0) && (empty($return['message']))) {
+ // Set must-fillout fields
+ $return['mapped_data'] = runFilterChain('register_must_fillout', $return['mapped_data']);
+
+ // Add missing elements
+ $return['mapped_data']['gender'] = NULL;
+ $return['mapped_data']['birthday_selection'] = generateDayMonthYearSelectionBox($return['mapped_data']['birth_day'], $return['mapped_data']['birth_month'], $return['mapped_data']['birth_year']);
+ $return['mapped_data']['challenge'] = getRequestElement('challenge');
+ $return['mapped_data']['__challenge_response'] = getRequestElement('__challenge_response');
+
// Display form
loadTemplate('guest_wernis_registration_form', FALSE, $return['mapped_data']);
+
+ // All fine
return TRUE;
} else {
- // Something bad happened
+ // Something unexpected happened (e.g. no API requests left)
displayMessage($return['message']);
return FALSE;
}
}
// "Getter" for mapped data by calling the API and given challenge and status
-function getWernisMapedDataFromApiByChallenge ($challenge, $status) {
+function getWernisMappedDataFromApiByChallenge ($challenge, $status) {
// Get stored registration data
$rows = getWernisRegistrationDataByKey('api_redirect_challenge', $challenge);
} // END - if
// Now call "get.php"
- $response = executeWernisApiGet($rows[0], 'data', 'anrede|vorname|name|strasse|plz|ort|birth_day|birth_month|birth_year|email|werber');
+ $response = executeWernisApiGet($rows[0], 'data', 'vorname|name|strasse|plz|ort|birth_day|birth_month|birth_year|email|werber');
// Was the status okay?
if (isHttpResponseStatusOkay($response)) {
/*
* Do some checks on the decoded string, it should be a
- * serialized array with 11 entries (see above
+ * serialized array with 10 entries (see above
* executeWernisApiGet() call).
*/
- assert(substr($decodedData, 0, 6) == 'a:11:{');
+ assert(substr($decodedData, 0, 6) == 'a:10:{');
assert(substr($decodedData, -1, 1) == '}');
// The array seems to be fine, unserialize it
// All mappings WDS66->mailer
$mappings = array(
- 'anrede' => 'gender',
'vorname' => 'surname',
'name' => 'family',
'strasse' => 'street_nr',
// auth_key and wernis_userid must be set
assert(isset($args['auth_key']));
assert(isset($args['wernis_userid']));
- die(__FUNCTION__ . '<pre>'.print_r($args, TRUE).'</pre>');
+ die(__FUNCTION__ . ':' . __LINE__ . '<pre>' . print_r($args, TRUE) . '</pre>');
}
//-----------------------------------------------------------------------------