From 60929c313ccc10e74e2724373f7bc9ee00d774d1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Mon, 1 Oct 2012 20:00:19 +0000 Subject: [PATCH] Rewrote handling of extra SQL columns/data for registration. The very generic filter didn't register first :( --- inc/filter/beg_filter.php | 4 ++-- inc/filter/bonus_filter.php | 2 +- inc/filter/order_filter.php | 4 ++-- inc/filter/register_filter.php | 3 +-- inc/filter/theme_filter.php | 4 ++-- inc/libs/register_functions.php | 40 ++++++++++++++++++++++++++++----- 6 files changed, 43 insertions(+), 14 deletions(-) diff --git a/inc/filter/beg_filter.php b/inc/filter/beg_filter.php index c8def8276d..c96ba0b254 100644 --- a/inc/filter/beg_filter.php +++ b/inc/filter/beg_filter.php @@ -46,8 +46,8 @@ function FILTER_BEG_RALLYE_USER_REGISTRATION_ADD_SQL_COLUMNS ($filterData) { // Add columns for begging rallye, if active if (!isBegNewMemberNotifyEnabled()) { - $GLOBALS['register_sql_columns'] .= ', `beg_rallye_enable_notify`, `beg_rallye_disable_notify`'; - $GLOBALS['register_sql_data'] .= ', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()'; + addExtraRegistrationColumns(', `beg_rallye_enable_notify`, `beg_rallye_disable_notify`'); + addExtraRegistrationData(', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()'); } // END - if // Return filter data diff --git a/inc/filter/bonus_filter.php b/inc/filter/bonus_filter.php index 7c6815affd..63aafff993 100644 --- a/inc/filter/bonus_filter.php +++ b/inc/filter/bonus_filter.php @@ -127,7 +127,7 @@ function FILTER_BONUS_USER_REGISTRATION_ADD_SQL_COLUMNS ($filterData) { // Next: active rallye if (!isBonusNewMemberNotifyEnabled()) { - $GLOBALS['register_sql_columns'] .= ', `bonus_rallye_enable_notify`, `bonus_rallye_disable_notify`'; + addExtraRegistrationColumns(', `bonus_rallye_enable_notify`, `bonus_rallye_disable_notify`'); $GLOBALS['register_sql_data'] .= ', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()'; } // END - if diff --git a/inc/filter/order_filter.php b/inc/filter/order_filter.php index 4abbd40c7c..3fd044f614 100644 --- a/inc/filter/order_filter.php +++ b/inc/filter/order_filter.php @@ -85,11 +85,11 @@ function FILTER_ORDER_ZIP_CODE_SQL ($sql) { if ((isOrderMultiPageEnabled()) && (isPostRequestElementSet('zip')) && (postRequestElement('zip') != '')) { // Choose recipients by ZIP code if (empty($sql)) { - $sql = sprintf(" WHERE d.`zip` LIKE '%s%%'", + $sql = sprintf(" WHERE `zip` LIKE '%s%%%%'", bigintval(postRequestElement('zip')) ); } else { - $sql .= sprintf(" AND d.`zip` LIKE '%s%%'", + $sql .= sprintf(" AND `zip` LIKE '%s%%%%'", bigintval(postRequestElement('zip')) ); } diff --git a/inc/filter/register_filter.php b/inc/filter/register_filter.php index 9b242a2aa7..0120da91ee 100644 --- a/inc/filter/register_filter.php +++ b/inc/filter/register_filter.php @@ -105,8 +105,7 @@ function FILTER_PRE_USER_REGISTRATION_GENERIC ($filterData) { $GLOBALS['register_country_data'] = substr(postRequestElement('cntry'), 0, 2); // Init extra SQL data - $GLOBALS['register_sql_columns'] = ''; - $GLOBALS['register_sql_data'] = ''; + initExtraRegistrationSql(); // Init "status" as for many users setPostRequestElement('status', 'UNCONFIRMED'); diff --git a/inc/filter/theme_filter.php b/inc/filter/theme_filter.php index 37b6bc5bc8..9cd0749e5c 100644 --- a/inc/filter/theme_filter.php +++ b/inc/filter/theme_filter.php @@ -90,8 +90,8 @@ function FILTER_THEME_USER_REGISTRATION_ADD_SQL_COLUMNS ($filterData) { //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!'); // Okay, add design here - $GLOBALS['register_sql_columns'] .= ', `curr_theme`'; - $GLOBALS['register_sql_data'] .= ", '{%%pipe,getCurrentTheme%%}'"; + addExtraRegistrationColumns(', `curr_theme`'); + addExtraRegistrationData(", '{%%pipe,getCurrentTheme%%}'"); // Return filter data //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!'); diff --git a/inc/libs/register_functions.php b/inc/libs/register_functions.php index 667b83c0f7..3c750c2284 100644 --- a/inc/libs/register_functions.php +++ b/inc/libs/register_functions.php @@ -159,7 +159,7 @@ function isRegistrationDataComplete () { // Did he enter a valid email address? (we really don't care about // that, he has to click on a confirmation link :P ) - if ((!isPostRequestElementSet('email')) || (!isEmailValid(postRequestElement('email')))) { + if ((!isAdmin()) && ((!isPostRequestElementSet('email')) || (!isEmailValid(postRequestElement('email'))))) { setPostRequestElement('email', '!'); //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'User did not enter proper email address.'); $isOkay = false; @@ -254,7 +254,7 @@ function isRegistrationDataComplete () { } // END - if // Enougth categories selected? - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'isOkay='.intval($isOkay).',selected='.$GLOBALS['registration_selected_cats'].'/'.getLeastCats()); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'isOkay=' . intval($isOkay) . ',selected=' . $GLOBALS['registration_selected_cats'] . '/' . getLeastCats()); $isOkay = (($isOkay) && ($GLOBALS['registration_selected_cats'] >= getLeastCats())); if ((postRequestElement('email') != '!') && (isCheckDoubleEmailEnabled())) { @@ -267,16 +267,16 @@ function isRegistrationDataComplete () { } // END - if // Check for IP timeout? - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'isOkay='.intval($isOkay)); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'isOkay=' . intval($isOkay)); if ((!isAdmin()) && (getIpTimeout() > 0)) { // Check his IP number $GLOBALS['registration_ip_timeout'] = (countSumTotalData(detectRemoteAddr() , 'user_data', 'userid', 'REMOTE_ADDR', true, ' AND ((UNIX_TIMESTAMP() - `joined`) < {?ip_timeout?} OR (UNIX_TIMESTAMP() - `last_update`) < {?ip_timeout?})') == 1); - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'isOkay='.intval($isOkay).',timeout='.intval($GLOBALS['registration_ip_timeout'])); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'isOkay=' . intval($isOkay).',timeout='.intval($GLOBALS['registration_ip_timeout'])); $isOkay = (($isOkay) && (!$GLOBALS['registration_ip_timeout'])); } // END - if // Return result - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'isOkay='.intval($isOkay)); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'isOkay=' . intval($isOkay) . ' - EXIT!'); return $isOkay; } @@ -498,6 +498,36 @@ function doUserRegistration () { return true; } +// Initialize extra registration SQL +function initExtraRegistrationSql () { + $GLOBALS['register_sql_columns'] = ''; + $GLOBALS['register_sql_data'] = ''; +} + +// Add extra column for registration SQL +function addExtraRegistrationColumns ($column) { + // Is it set? + if (!isset($GLOBALS['register_sql_columns'])) { + // Then initialize it + initExtraRegistrationSql(); + } // END - if + + // Add column + $GLOBALS['register_sql_columns'] .= $column; +} + +// Add extra data for registration SQL +function addExtraRegistrationData ($data) { + // Is it set? + if (!isset($GLOBALS['register_sql_data'])) { + // Then initialize it + initExtraRegistrationSql(); + } // END - if + + // Add column + $GLOBALS['register_sql_data'] .= $data; +} + //----------------------------------------------------------------------------- // Wrapper functions for ext-register //----------------------------------------------------------------------------- -- 2.39.2