Rewrote handling of extra SQL columns/data for registration. The very generic filter...
authorRoland Häder <roland@mxchange.org>
Mon, 1 Oct 2012 20:00:19 +0000 (20:00 +0000)
committerRoland Häder <roland@mxchange.org>
Mon, 1 Oct 2012 20:00:19 +0000 (20:00 +0000)
inc/filter/beg_filter.php
inc/filter/bonus_filter.php
inc/filter/order_filter.php
inc/filter/register_filter.php
inc/filter/theme_filter.php
inc/libs/register_functions.php

index c8def8276d04e9e6cef5f4c81b64f8a4ac11563a..c96ba0b254e82f252d2b27d346b439a6d1d79a93 100644 (file)
@@ -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
index 7c6815affdba4b78d365a3424df973ff6a2c9851..63aafff99354db6470c986d60810f664a774cadc 100644 (file)
@@ -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
 
index 4abbd40c7c6972dfd70bf8ba93677f5bbcf5ec39..3fd044f61466cf061e60cec7d01bdbee8240a820 100644 (file)
@@ -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'))
                        );
                }
index 9b242a2aa75dfb051e685ba765012eacaf6ed9ea..0120da91eebcfd1b38e651062a178e4ddf18de39 100644 (file)
@@ -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');
index 37b6bc5bc847b93cb50df6e154cf90f21dae273b..9cd0749e5ce5ed18c8ceb1102cf15dcc3437334e 100644 (file)
@@ -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!');
index 667b83c0f78252f5da6a9d782ca7c1cbc1cbd491..3c750c2284a1e8433c7678f7c3de9cc994e12212 100644 (file)
@@ -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
 //-----------------------------------------------------------------------------