From a13cee9b7e7f0e4b40969c8957af72cb46bdb3a3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 3 Aug 2011 16:11:27 +0000 Subject: [PATCH] Extension ext-earning continued: - JOIN doesn't work if the joined table contains data but with wrong entries, so it needs be splitted up into two queries - Renamed earnings->earning - TODOs.txt updated --- .gitattributes | 2 + DOCS/TODOs.txt | 1 + inc/extensions/ext-earning.php | 19 ++- inc/filter/earning_filter.php | 99 ++++++++++++++ inc/filter/forced_filter.php | 2 +- inc/libs/forced_functions.php | 5 + inc/modules/member/what-earning.php | 123 ++++++++++++++++++ inc/modules/member/what-earnings.php | 110 +--------------- inc/template-functions.php | 22 ++++ .../member/member_earning_popup_form_row.tpl | 2 +- .../html/member/member_earning_popup_row.tpl | 2 +- templates/de/html/member/member_footer.tpl | 3 +- 12 files changed, 271 insertions(+), 119 deletions(-) create mode 100644 inc/filter/earning_filter.php create mode 100644 inc/modules/member/what-earning.php diff --git a/.gitattributes b/.gitattributes index f465bb5705..f93f232da8 100644 --- a/.gitattributes +++ b/.gitattributes @@ -212,6 +212,7 @@ inc/filter/bonus_filter.php svneol=native#text/plain inc/filter/booking_filter.php svneol=native#text/plain inc/filter/cache_filter.php svneol=native#text/plain inc/filter/coupon_filter.php svneol=native#text/plain +inc/filter/earning_filter.php svneol=native#text/plain inc/filter/forced_filter.php svneol=native#text/plain inc/filter/mediadata_filter.php svneol=native#text/plain inc/filter/online_filter.php svneol=native#text/plain @@ -650,6 +651,7 @@ inc/modules/member/what-booking.php svneol=native#text/plain inc/modules/member/what-cash_coupon.php svneol=native#text/plain inc/modules/member/what-categories.php svneol=native#text/plain inc/modules/member/what-doubler.php svneol=native#text/plain +inc/modules/member/what-earning.php svneol=native#text/plain inc/modules/member/what-earnings.php svneol=native#text/plain inc/modules/member/what-guest.php svneol=native#text/plain inc/modules/member/what-holiday.php svneol=native#text/plain diff --git a/DOCS/TODOs.txt b/DOCS/TODOs.txt index 4af4c4178f..2d2002df6d 100644 --- a/DOCS/TODOs.txt +++ b/DOCS/TODOs.txt @@ -234,6 +234,7 @@ ./inc/modules/admin/what-chk_regs.php:2:// @DEPRECATED ./inc/modules/admin/what-config_admins.php:2:// @DEPRECATED ./inc/modules/admin/what-config_email.php:2:// @DEPRECATED +./inc/modules/member/what-earnings.php:2:// @DEPRECATED ./inc/modules/member/what-surfbar_book.php:2:// @DEPRECATED ./inc/modules/member/what-surfbar_start.php:2:// @DEPRECATED ./inc/modules/member/what-surfbar_stats.php:2:// @DEPRECATED diff --git a/inc/extensions/ext-earning.php b/inc/extensions/ext-earning.php index a4b61dddd4..4934f2a78c 100644 --- a/inc/extensions/ext-earning.php +++ b/inc/extensions/ext-earning.php @@ -52,10 +52,10 @@ enableExtensionProductive(false); switch (getExtensionMode()) { case 'register': // Do stuff when installation is running // Add member menu - addMemberMenuSql('earn', 'earnings', 'Zusatzverdienste', 2); + addMemberMenuSql('earn', 'earning', 'Zusatzverdienste', 2); // Admin menu - addAdminMenuSql('setup', 'list_earnings', 'Zusatzverdienste...', 'Veralten Sie hier bequem alle Zusatzverdienste (wie z.B. vergütete PopUps usw.).', 6); + addAdminMenuSql('setup', 'list_earning', 'Zusatzverdienste...', 'Veralten Sie hier bequem alle Zusatzverdienste (wie z.B. vergütete PopUps usw.).', 6); // Earning data table addDropTableSql('earning_data'); @@ -78,11 +78,15 @@ UNIQUE `earning_group_name` (`earning_group`,`earning_name`)", `earning_added` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, `earning_cancelled` TIMESTAMP NULL DEFAULT NULL, `earning_daily_amount` SMALLINT(7) NOT NULL DEFAULT 0, +`earning_current_amount` SMALLINT(7) NOT NULL DEFAULT 0, `earning_points` FLOAT(20,5) NOT NULL DEFAULT 0.00000, PRIMARY KEY (`id`), UNIQUE `user_earning` (`earning_id`,`earning_userid`), INDEX (`earning_userid`)", 'User->Earning connections'); + + // Register filter + registerFilter('member_footer_extras', 'ADD_EARNING_GROUP_POPUP', false, true, isExtensionDryRun()); break; case 'remove': // Do stuff when removing extension @@ -91,18 +95,21 @@ INDEX (`earning_userid`)", addDropTableSql('user_earning'); // Delete entries in menus - addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `what`='earnings' LIMIT 1"); - addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `what`='list_earnings' LIMIT 1"); + addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `what`='earning' LIMIT 1"); + addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `what`='list_earning' LIMIT 1"); + + // Unregister filter + unregisterFilter(__FUNCTION__, __LINE__, 'member_footer_extras', 'ADD_EARNING_GROUP_POPUP', true, isExtensionDryRun()); break; case 'activate': // Do stuff when admin activates this extension // SQL commands to run - addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='Y', `locked`='N' WHERE `what`='earnings' LIMIT 1"); + addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='Y', `locked`='N' WHERE `what`='earning' LIMIT 1"); break; case 'deactivate': // Do stuff when admin deactivates this extension // SQL commands to run - addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='N', `locked`='Y' WHERE `what`='earnings' LIMIT 1"); + addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='N', `locked`='Y' WHERE `what`='earning' LIMIT 1"); break; case 'update': // Update an extension diff --git a/inc/filter/earning_filter.php b/inc/filter/earning_filter.php new file mode 100644 index 0000000000..3378375c5f --- /dev/null +++ b/inc/filter/earning_filter.php @@ -0,0 +1,99 @@ + 0) { + // Load all names + while ($content = SQL_FETCHARRAY($result)) { + // Merge the $filterData array in + $content = merge_array($content, $filterData); + + // Construct callback function name + $callbackName = 'get' . capitalizeUnderscoreString($content['earning_name']) . 'DataByEarningArray'; + + // And call it + $content = call_user_func($callbackName, $content); + } // END - if + } // END - if + + // Free result + SQL_FREERESULT($result); + + // Return filter data + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!'); + return $filterData; +} + +// [EOF] +?> diff --git a/inc/filter/forced_filter.php b/inc/filter/forced_filter.php index 4b69b26547..2ddd254bdf 100644 --- a/inc/filter/forced_filter.php +++ b/inc/filter/forced_filter.php @@ -72,9 +72,9 @@ function FILTER_FORCED_POPUP_TABLE_DATA ($filterData) { // Get max/min/count of all popups //die(__FUNCTION__.':OK!'); } // END - if - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!'); // Return filter data array + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!'); return $filterData; } diff --git a/inc/libs/forced_functions.php b/inc/libs/forced_functions.php index 84f57641e9..cd2aba8ba1 100644 --- a/inc/libs/forced_functions.php +++ b/inc/libs/forced_functions.php @@ -75,5 +75,10 @@ function translateForcedAdType ($status) { return $return; } +// "Getter" for an array of data from all Forced-PopUps +function getForcedPopupDataByEarningArray ($content) { + die(__FUNCTION__ . ':content=
'.print_r($content,true).'
'); +} + // [EOF] ?> diff --git a/inc/modules/member/what-earning.php b/inc/modules/member/what-earning.php new file mode 100644 index 0000000000..a9ffe4f708 --- /dev/null +++ b/inc/modules/member/what-earning.php @@ -0,0 +1,123 @@ + 0) { + // Init output + $OUT = ''; + + // List all entries + while ($content = SQL_FETCHARRAY($result)) { + // Load user_earning data + $result2 = SQL_QUERY_ESC('SELECT + u.`earning_active`, + UNIX_TIMESTAMP(u.`earning_added`) AS `earning_added`, + UNIX_TIMESTAMP(u.`earning_cancelled`) AS `earning_cancelled`, + u.`earning_daily_amount`, + u.`earning_points` +FROM + `{?_MYSQL_PREFIX?}_user_earning` AS u +WHERE + u.`earning_id`=%s AND + u.`earning_userid`=%s +LIMIT 1', + array( + bigintval($content['earning_id']), + getMemberId() + ), __FILE__, __LINE__); + + // Do we have an entry? + if (SQL_NUMROWS($result2) == 1) { + // Load it + $content = merge_array($content, SQL_FETCHARRAY($result2)); + } // END - if + + // Free result + SQL_FREERESULT($result2); + + // Do we have user_earning data available? + if (!isset($content['earning_active'])) { + // Load row template "open subscription" + $OUT .= loadTemplate('member_earning_' . strtolower($content['earning_group']) . '_form_row', true, $content); + } else { + // Load row template "already subscribed" + $OUT .= loadTemplate('member_earning_' . strtolower($content['earning_group']) . '_row', true, $content); + } + } // END - while + + // Load main template + loadTemplate('member_earning', false, $OUT); +} else { + // Display message + displayMessage('{--MEMBER_EARNINGS_404--}'); +} + +// Free result +SQL_FREERESULT($result); + +// [EOF] +?> diff --git a/inc/modules/member/what-earnings.php b/inc/modules/member/what-earnings.php index 3842cd7709..f551ef47b7 100644 --- a/inc/modules/member/what-earnings.php +++ b/inc/modules/member/what-earnings.php @@ -1,111 +1,3 @@ 0) { - // Init output - $OUT = ''; - - // List all entries - while ($content = SQL_FETCHARRAY($result)) { - // Do we have user_earning data available? - if (is_null($content['earning_active'])) { - // Load row template "open subscription" - $OUT .= loadTemplate('member_earning_' . strtolower($content['earning_group']) . '_form_row', true, $content); - } else { - // Load row template "already subscribed" - $OUT .= loadTemplate('member_earning_' . strtolower($content['earning_group']) . '_row', true, $content); - } - } // END - while - - // Load main template - loadTemplate('member_earning', false, $OUT); -} else { - // Display message - displayMessage('{--MEMBER_EARNINGS_404--}'); -} - -// Free result -SQL_FREERESULT($result); - -// [EOF] +// @DEPRECATED ?> diff --git a/inc/template-functions.php b/inc/template-functions.php index 19d2459be3..889e5c7431 100644 --- a/inc/template-functions.php +++ b/inc/template-functions.php @@ -1859,5 +1859,27 @@ function doTemplateNoYesSelectionBox ($template, $clear, $formField) { return $OUT; } +// Helper function to add extra content for member area (module=login) +function doTemplateMemberFooterExtras ($template, $clear) { + // Is a member logged in? + if (!isMember()) { + // This shall not happen + debug_report_bug(__FUNCTION__, __LINE__, 'Please use this template helper only for logged-in members.'); + } // END - if + + // Init filter data + $filterData = array( + 'userid' => getMemberId(), + 'template' => $template, + 'output' => '', + ); + + // Run the filter chain + $filterData = runFilterChain('member_footer_extras', $filterData); + + // Return output + return $filterData['output']; +} + // [EOF] ?> diff --git a/templates/de/html/member/member_earning_popup_form_row.tpl b/templates/de/html/member/member_earning_popup_form_row.tpl index e6599d2524..267e31f130 100644 --- a/templates/de/html/member/member_earning_popup_form_row.tpl +++ b/templates/de/html/member/member_earning_popup_form_row.tpl @@ -1,5 +1,5 @@
-
+
{%message,MEMBER_EARNING_POPUP_FORM_TITLE=$content[earning_name]%} diff --git a/templates/de/html/member/member_earning_popup_row.tpl b/templates/de/html/member/member_earning_popup_row.tpl index 6510c7072b..20d763be3c 100644 --- a/templates/de/html/member/member_earning_popup_row.tpl +++ b/templates/de/html/member/member_earning_popup_row.tpl @@ -1,5 +1,5 @@
- +
{%message,MEMBER_EARNING_POPUP_FORM_TITLE=$content[earning_name]%} diff --git a/templates/de/html/member/member_footer.tpl b/templates/de/html/member/member_footer.tpl index be554d58a5..8773c0411c 100644 --- a/templates/de/html/member/member_footer.tpl +++ b/templates/de/html/member/member_footer.tpl @@ -4,4 +4,5 @@ - + +{%template,MemberFooterExtras%} -- 2.39.5