From c1ce3b98c13fabf834d11a847eb2d297ead8d53d Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 8 Apr 2014 23:03:17 +0200 Subject: [PATCH] - Introduced generateDateMonthYearSelectionBox() which is suitable for e.g. birthday input fields. - Introduced doTemplateDisplayReferralIdContent() template helper to get rid of an unneccessary if() block and $content[foo] in template - Content of template register_header.tpl has now been moved to inc/language/register_de.php and has marked as deprecated - Added new template (unfinished) for ext-wernis registration provider MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- inc/language/register_de.php | 1 + inc/language/wernis_de.php | 1 + inc/libs/user_functions.php | 19 +- inc/libs/wernis_functions.php | 18 +- inc/template-functions.php | 32 ++++ templates/de/html/guest/guest_register.tpl | 5 +- .../guest/guest_wernis_registration_form.tpl | 168 ++++++++++++++++++ templates/de/html/register_header.tpl | 2 +- 8 files changed, 220 insertions(+), 26 deletions(-) create mode 100644 templates/de/html/guest/guest_wernis_registration_form.tpl diff --git a/inc/language/register_de.php b/inc/language/register_de.php index fef5e3a823..6691e6da82 100644 --- a/inc/language/register_de.php +++ b/inc/language/register_de.php @@ -47,6 +47,7 @@ addMessages(array( 'COUNTRY_CODE' => "Ländercode", 'GUEST_EMAIL_IS_ALREADY_REGISTERED' => "Sie haben sich bereits mit dieser Email-Adresse angemeldet, oder jemand anderes verwendet Ihre. Doppelte Anmeldungen sind bei uns verboten.", 'GUEST_ENTER_PASSWORDS' => "Passwort und -wiederholung eingeben:", + 'GUEST_REGISTER_GENERIC_TITLE' => "Anmeldeformular zum {?mt_word?} {?MAIN_TITLE?}:", // Points accounts - subject 'POINTS_SUBJECT_REGISTER_WELCOME' => "Anmeldegutschrift", diff --git a/inc/language/wernis_de.php b/inc/language/wernis_de.php index 42c4e1db3c..5c9b41b1bb 100644 --- a/inc/language/wernis_de.php +++ b/inc/language/wernis_de.php @@ -150,6 +150,7 @@ addMessages(array( 'GUEST_WERNIS_REGISTRATION_PASSWORD_NOT_SET' => "Bitte geben Sie Ihr Wernis-Passwort ein. Tipp: Dies ist nicht Ihr Account-Passwort.", 'GUEST_WERNIS_REGISTRATION_INVALID_CHALLENGE_RESPONSE' => "Es ist beim Anmeldeversuch ein Fehler unterlaufen: Falsche Challenge-Response", 'GUEST_WERNIS_REGISTRATION_ZERO_ROWS_FOUND' => "Es konnte keine Anmeldedaten von der WDS66-API gefunden werden. Haben Sie auch den richtigen Link aufgerufen?", + 'GUEST_REGISTER_WERNIS_PROVIDER_TITLE' => "Anmeldung mit WDS66 am {?mt_word?} {?MAIN_TITLE?}:", // Points accounts - subject 'POINTS_SUBJECT_WERNIS_WITHDRAW' => "Einzahlung vom WDS66-Account", diff --git a/inc/libs/user_functions.php b/inc/libs/user_functions.php index fbf7c455dd..5041a8c3a6 100644 --- a/inc/libs/user_functions.php +++ b/inc/libs/user_functions.php @@ -971,24 +971,7 @@ function doDisplayGenericUserRegistrationForm () { } // END - if // Generate birthday selection - switch (getLanguage()) { - case 'de': // German date format - $content['birthday_selection'] = addSelectionBox('da', postRequestElement('day')).addSelectionBox('mo', postRequestElement('month')).addSelectionBox('ye', postRequestElement('year')); - break; - - default: // Default is the US date format... :) - $content['birthday_selection'] = addSelectionBox('mo', postRequestElement('month')).addSelectionBox('da', postRequestElement('day')).addSelectionBox('ye', postRequestElement('year')); - break; - } // END - switch - - // Shall I display the refid or shall I make it editable? - if (isDisplayRefidEnabled()) { - // Load "hide" form template - $content['refid_content'] = loadTemplate('guest_register_refid_hide', TRUE); - } else { - // Load template to enter it - $content['refid_content'] = loadTemplate('guest_register_refid', TRUE); - } + $content['birthday_selection'] = generateDayMonthYearSelectionBox(postRequestElement('day'),postRequestElement('month'),postRequestElement('year')); // ZIP codes are numerical values $content['zip'] = ''; diff --git a/inc/libs/wernis_functions.php b/inc/libs/wernis_functions.php index 90e88a01e7..1db29a77bb 100644 --- a/inc/libs/wernis_functions.php +++ b/inc/libs/wernis_functions.php @@ -539,11 +539,20 @@ function doWernisFinishUserRegistration ($challenge, $challengeResponse, $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']); + // 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; } @@ -587,7 +596,7 @@ function getWernisMapedDataFromApiByChallenge ($challenge, $status) { } // 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)) { @@ -602,10 +611,10 @@ function getWernisMapedDataFromApiByChallenge ($challenge, $status) { /* * 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 @@ -613,7 +622,6 @@ function getWernisMapedDataFromApiByChallenge ($challenge, $status) { // All mappings WDS66->mailer $mappings = array( - 'anrede' => 'gender', 'vorname' => 'surname', 'name' => 'family', 'strasse' => 'street_nr', diff --git a/inc/template-functions.php b/inc/template-functions.php index 5eb84e4339..cc04cdeb79 100644 --- a/inc/template-functions.php +++ b/inc/template-functions.php @@ -2401,6 +2401,21 @@ function doTemplateMetaFavIcon ($templateName, $clear = FALSE) { return $out; } +// Helper function to display referral id or hide it depending on settings +function doTemplateDisplayReferralIdContent ($template, $clear = FALSE) { + // Ddisplay the refid or make it editable? + if (isDisplayRefidEnabled()) { + // Load "hide" form template + $out = loadTemplate('guest_register_refid_hide', TRUE); + } else { + // Load template to enter it + $out = loadTemplate('guest_register_refid', TRUE); + } + + // Return code + return $out; +} + // "Getter" for template base path function getTemplateBasePath ($part) { // Is there cache? @@ -2435,5 +2450,22 @@ function removeDeprecatedComment ($output) { return $return; } +// Generates a selection box suitable for e.g. birthdays: day, month and year +function generateDayMonthYearSelectionBox ($day, $month, $year) { + // This depends on selected language + switch (getLanguage()) { + case 'de': // German date format + $content = addSelectionBox('da', $day) . addSelectionBox('mo', $month) . addSelectionBox('ye', $year); + break; + + default: // Default is the US date format... :) + $content = addSelectionBox('mo', $month) . addSelectionBox('da', $day) . addSelectionBox('ye', $year); + break; + } // END - switch + + // Return content + return $content; +} + // [EOF] ?> diff --git a/templates/de/html/guest/guest_register.tpl b/templates/de/html/guest/guest_register.tpl index 9b2d2e3b2f..1deb8760a4 100644 --- a/templates/de/html/guest/guest_register.tpl +++ b/templates/de/html/guest/guest_register.tpl @@ -4,7 +4,7 @@ @@ -133,7 +133,7 @@ - $content[refid_content] + {%template,DisplayReferralIdContent%}
- {%template,LoadTemplate=register_header%} + {--GUEST_REGISTER_GENERIC_TITLE--}
@@ -156,6 +156,7 @@
+ diff --git a/templates/de/html/guest/guest_wernis_registration_form.tpl b/templates/de/html/guest/guest_wernis_registration_form.tpl new file mode 100644 index 0000000000..706fc083b3 --- /dev/null +++ b/templates/de/html/guest/guest_wernis_registration_form.tpl @@ -0,0 +1,168 @@ +
+{%form,formMethodPost,formNameRegister=modules.php?module=index&what=register%} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {%template,DisplayReferralIdContent%} + + + + + + + + + + + + +
+ {--GUEST_REGISTER_WERNIS_PROVIDER_TITLE--} +
+ {--REGISTER_PERSONAL_DATA--}: +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ {--GENDER--}$content[must_fillout_gender]: + + {%pipe,generateGenderSelectionBox=$content[gender]%} +
+ {--SURNAME--}$content[must_fillout_surname], + {--FAMILY--}$content[must_fillout_family]: + + + +
+ {--STREET_NR--}$content[must_fillout_street_nr]: + + +
+ {--COUNTRY--}$content[must_fillout_cntry], {--ZIP--}$content[must_fillout_zip], + {--CITY--}$content[must_fillout_city]: + + {%pipe,postRequestElement,addCountryCodeSelectionBox=country_code%} + + +
+ {--EMAIL--}$content[must_fillout_email]: + + +
+ {--BIRTHDAY--}$content[must_fillout_birthday]: + + $content[birthday_selection] +
+
+ $content[must_fillout_marker]:{--GUEST_REGISTER_MUST_SET_NOTICE--} +
+
+
+ {--REGISTER_CATEGORIES--}: +
+ {--GUEST_SELECT_LEAST_CATEGORIES--} +
+ {%pipe,registerGenerateCategoryTable=guest%} +
+ {--REGISTER_MISC--}: +
+
{--GUEST_EMPTY_PASSWORD_HINT--}
+
+ {--GUEST_ENTER_PASSWORDS--} + + + +
+ {%pipe,addMaxReceiveList=guest%} +
+ {--TERMS_OF_USAGE--}: +
+ + + + + +
+ {--AGREE_TO_THIS--} + + {--YES--}
+ {--NO--} +
+
+{%form_close%} +
diff --git a/templates/de/html/register_header.tpl b/templates/de/html/register_header.tpl index 8cc84651c5..11f5d85d80 100644 --- a/templates/de/html/register_header.tpl +++ b/templates/de/html/register_header.tpl @@ -1 +1 @@ -Anmeldeformular zum {?mt_word?} {?MAIN_TITLE?}: + -- 2.30.2