From: Roland Häder Date: Sat, 2 Jul 2011 19:23:29 +0000 (+0000) Subject: Getting total/own points rewritten to filter: X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=commitdiff_plain;h=adb05fb6876bdca84e73f4ea04998c1400e2cfb7 Getting total/own points rewritten to filter: - Rewritten of getting total user points to a filter, same will follow with locked points - Extension ext-msg will never come back, so relevant code has been removed - TODOs.txt updated --- diff --git a/.gitattributes b/.gitattributes index 376dced169..b928345c9a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -211,6 +211,7 @@ inc/filter/cache_filter.php svneol=native#text/plain inc/filter/coupon_filter.php svneol=native#text/plain inc/filter/mediadata_filter.php svneol=native#text/plain inc/filter/online_filter.php svneol=native#text/plain +inc/filter/order_filter.php svneol=native#text/plain inc/filter/other_filter.php svneol=native#text/plain inc/filter/politician_stop_filter.php svneol=native#text/plain inc/filter/rallye_filter.php svneol=native#text/plain @@ -219,6 +220,7 @@ inc/filter/removeip_filter.php svneol=native#text/plain inc/filter/theme_filter.php svneol=native#text/plain inc/filter/timezone_filter.php svneol=native#text/plain inc/filter/uberwach_filter.php svneol=native#text/plain +inc/filter/user_filter.php svneol=native#text/plain inc/filters.php svneol=native#text/plain inc/fix_filters.php svneol=native#text/plain inc/fix_menu.php svneol=native#text/plain diff --git a/DOCS/TODOs.txt b/DOCS/TODOs.txt index 4f50e24e6b..3e4f77a6cd 100644 --- a/DOCS/TODOs.txt +++ b/DOCS/TODOs.txt @@ -35,29 +35,28 @@ ./inc/extensions/ext-network.php:38: * @TODO Yoo!Media: What is LayerAd compared to Layer click? * ./inc/extensions/ext-network.php:93: // @TODO network_type_handle is an internal name and needs documentation ./inc/extensions/ext-newsletter.php:218: // @TODO Move these into configuration -./inc/extensions/ext-order.php:336: // @TODO This should be moved out to inc/daily/ +./inc/extensions/ext-order.php:351: // @TODO This should be moved out to inc/daily/ ./inc/extensions/ext-rallye.php:329: // @TODO Move this code into a hook ./inc/extensions/ext-rallye.php:92: // @TODO Fix config_rallye_prices to list_rallye_prices ./inc/extensions/ext-yoomedia.php:121: // @TODO Can this be moved into a database table? ./inc/extensions/ext-yoomedia.php:54:// @TODO Only deprecated when 'ext-network' is ready! setExtensionDeprecated('Y'); ./inc/extensions-functions.php:155: // @TODO Do we still need this? setExtensionUpdateNotes(''); -./inc/extensions-functions.php:1927:// @TODO This should be rewrittten to allow, more development states, e.g. 'planing','alpha','beta','beta2','stable' +./inc/extensions-functions.php:1939:// @TODO This should be rewrittten to allow, more development states, e.g. 'planing','alpha','beta','beta2','stable' ./inc/extensions-functions.php:424:// @TODO Change from ext_id to ext_name (not just even the variable! ;-) ) ./inc/extensions-functions.php:554: // @TODO Extension is loaded, what next? ./inc/filter/bonus_filter.php:56: // @TODO This query isn't right, it will only update if the user was for a longer time away! ./inc/filter/cache_filter.php:92: // @TODO This should be rewritten not to load the cache file for just checking if it is there for save removal. -./inc/functions.php:1230: // @TODO Move this SQL code into a function, let's say 'getTimestampFromPoolId($id) ? -./inc/functions.php:1318: // @TODO Are these convertions still required? -./inc/functions.php:1336:// @TODO Rewrite this function to use readFromFile() and writeToFile() -./inc/functions.php:163:// @TODO Rewrite this to an extension 'smtp' -./inc/functions.php:1927: // @TODO Find a way to cache this -./inc/functions.php:2028: // @TODO This is still very static, rewrite it somehow -./inc/functions.php:2208: // @TODO Rename column data_type to e.g. mail_status -./inc/functions.php:92: // @TODO Extension 'msg' does not exist +./inc/functions.php:1223: // @TODO Move this SQL code into a function, let's say 'getTimestampFromPoolId($id) ? +./inc/functions.php:1311: // @TODO Are these convertions still required? +./inc/functions.php:1329:// @TODO Rewrite this function to use readFromFile() and writeToFile() +./inc/functions.php:156:// @TODO Rewrite this to an extension 'smtp' +./inc/functions.php:1920: // @TODO Find a way to cache this +./inc/functions.php:2021: // @TODO This is still very static, rewrite it somehow +./inc/functions.php:2201: // @TODO Rename column data_type to e.g. mail_status ./inc/gen_sql_patches.php:95:// @TODO Rewrite this to a filter ./inc/install-functions.php:57: // @TODO DEACTIVATED: changeDataInLocalConfigurationFile('OUTPUT-MODE', "setConfigEntry('OUTPUT_MODE', '", "');", postRequestParameter('omode'), 0); -./inc/language/de.php:1079: // @TODO Rewrite these two constants -./inc/language/de.php:1100: // @TODO Rewrite these three constants +./inc/language/de.php:1080: // @TODO Rewrite these two constants +./inc/language/de.php:1101: // @TODO Rewrite these three constants ./inc/language/de.php:772:// @TODO Are these constants longer used? ./inc/language-functions.php:255: // @TODO These are all valid languages, again hard-coded ./inc/language-functions.php:44:// @TODO Rewrite all language constants to this function. @@ -143,9 +142,9 @@ ./inc/modules/admin/what-list_refs.php:107: // @TODO Try to rewrite some to EL ./inc/modules/admin/what-list_unconfirmed.php:107: // @TODO "Please do not call me directly." Should be rewritten to a nice selection depending on ext-bonus ./inc/modules/admin/what-list_unconfirmed.php:84: // @TODO This constant might be unused? define('__LIST_UNCON_TITLE', '{--ADMIN_LIST_UNCONFIRMED_BONUS_LINKS--}'); -./inc/modules/admin/what-list_user.php:154: // @TODO Rewrite these to filters -./inc/modules/admin/what-list_user.php:262: // @TODO Rewrite this into a filter -./inc/modules/admin/what-list_user.php:311: // @TODO Rewrite this into a filter +./inc/modules/admin/what-list_user.php:165: // @TODO Rewrite these to filters +./inc/modules/admin/what-list_user.php:273: // @TODO Rewrite this into a filter +./inc/modules/admin/what-list_user.php:322: // @TODO Rewrite this into a filter ./inc/modules/admin/what-list_user.php:57:// @TODO Rewrite these if-blocks in a filter ./inc/modules/admin/what-logs.php:64: // @TODO Fix content-type here ./inc/modules/admin/what-logs.php:70: // @TODO Fix content-type here @@ -157,12 +156,12 @@ ./inc/modules/admin/what-usr_online.php:49: // @TODO Add a filter for sponsor ./inc/modules/guest/what-beg.php:51:// @TODO No more needed? define('__BEG_USERID_TIMEOUT', createFancyTime(getBegUseridTimeout())); ./inc/modules/guest/what-login.php:121: // @TODO Move this HTML code into a template -./inc/modules/guest/what-mediadata.php:181:// @TODO Rewrite all these if-blocks to filters -./inc/modules/guest/what-mediadata.php:68: // @TODO Find a better formular than this one +./inc/modules/guest/what-mediadata.php:180:// @TODO Rewrite all these if-blocks to filters +./inc/modules/guest/what-mediadata.php:67: // @TODO Find a better formular than this one ./inc/modules/guest/what-rallyes.php:89: // @TODO Reactivate this: $content['admin'] = '' . $login . ''; ./inc/modules/guest/what-sponsor_reg.php:287: // @TODO Maybe a default referal id? -./inc/modules/guest/what-stats.php:100: // @TODO This can be somehow rewritten -./inc/modules/guest/what-stats.php:74:// @TODO This can be rewritten in a dynamic include +./inc/modules/guest/what-stats.php:108: // @TODO This can be somehow rewritten +./inc/modules/guest/what-stats.php:82:// @TODO This can be rewritten in a dynamic include ./inc/modules/member/what-beg.php:54:// @TODO Can't this be moved into EL? ./inc/modules/member/what-beg.php:63:// @TODO No more needed? define('__BEG_USERID_TIMEOUT', createFancyTime(getBegUseridTimeout())); ./inc/modules/member/what-bonus.php:55: // @TODO Rewrite this to a filter @@ -182,12 +181,12 @@ ./inc/modules/member/what-unconfirmed.php:207: // @TODO This 'userid' cannot be saved because of encapsulated EL code ./inc/modules/order.php:74: // @TODO Unused: 2,4 ./inc/monthly/monthly_bonus.php:64: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:1214: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:1476: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY() -./inc/mysql-manager.php:1564: // @TODO Rewrite these lines to a filter -./inc/mysql-manager.php:1588: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:1962: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:2006:// @TODO Fix inconsistency between last_module and getWhat() +./inc/mysql-manager.php:1217: // @TODO Rewrite this to a filter +./inc/mysql-manager.php:1479: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY() +./inc/mysql-manager.php:1567: // @TODO Rewrite these lines to a filter +./inc/mysql-manager.php:1591: // @TODO Rewrite this to a filter +./inc/mysql-manager.php:1965: // @TODO Rewrite this to a filter +./inc/mysql-manager.php:2009:// @TODO Fix inconsistency between last_module and getWhat() ./inc/mysql-manager.php:368: // @TODO Try to rewrite this to one or more functions ./inc/mysql-manager.php:44:// @TODO Can we cache this? ./inc/purge/purge-inact.php:55: // @TODO Rewrite these if() blocks to a filter @@ -289,6 +288,7 @@ ./templates/de/emails/register-member.tpl:1: ./templates/de/emails/sub-points.tpl:1: ./templates/de/emails/unlock-user.tpl:1: +./templates/de/html/admin/admin_admins_contct_select.tpl:1: ./templates/de/html/admin/admin_config_admins_del_row.tpl:1: ./templates/de/html/admin/admin_config_admins_del.tpl:1: ./templates/de/html/admin/admin_config_admins_edit_row.tpl:1: diff --git a/inc/extensions/ext-order.php b/inc/extensions/ext-order.php index fbb550dd2c..1341bb39bd 100644 --- a/inc/extensions/ext-order.php +++ b/inc/extensions/ext-order.php @@ -41,10 +41,10 @@ if (!defined('__SECURITY')) { } // END - if // Version number -setThisExtensionVersion('0.5.2'); +setThisExtensionVersion('0.5.3'); // Version history array (add more with , '0.0.1' and so on) -setExtensionVersionHistory(array('0.0.0', '0.1.0', '0.1.1', '0.1.2', '0.1.3', '0.1.4', '0.1.5', '0.1.6', '0.1.7', '0.1.8', '0.1.9', '0.2.0', '0.2.1', '0.2.2', '0.2.3', '0.2.4', '0.2.5', '0.2.6', '0.2.7', '0.2.8', '0.2.9', '0.3.0', '0.3.1', '0.3.2', '0.3.3', '0.3.4', '0.3.5', '0.3.6', '0.3.7', '0.3.8', '0.3.9', '0.4.0', '0.4.1', '0.4.2', '0.4.3', '0.4.4', '0.4.5', '0.4.6', '0.4.7', '0.4.8', '0.4.9', '0.5.0', '0.5.1', '0.5.2')); +setExtensionVersionHistory(array('0.0.0', '0.1.0', '0.1.1', '0.1.2', '0.1.3', '0.1.4', '0.1.5', '0.1.6', '0.1.7', '0.1.8', '0.1.9', '0.2.0', '0.2.1', '0.2.2', '0.2.3', '0.2.4', '0.2.5', '0.2.6', '0.2.7', '0.2.8', '0.2.9', '0.3.0', '0.3.1', '0.3.2', '0.3.3', '0.3.4', '0.3.5', '0.3.6', '0.3.7', '0.3.8', '0.3.9', '0.4.0', '0.4.1', '0.4.2', '0.4.3', '0.4.4', '0.4.5', '0.4.6', '0.4.7', '0.4.8', '0.4.9', '0.5.0', '0.5.1', '0.5.2', '0.5.3')); switch (getExtensionMode()) { case 'register': // Do stuff when installation is running @@ -322,6 +322,21 @@ INDEX (`pool_id`) // Update notes (these will be set as task text!) setExtensionUpdateNotes("Inkonsistenz in Konfigurationsnamen korregiert."); break; + + case '0.5.3': // SQL queries for v0.5.3 + addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_points` ADD `order_points` FLOAT(20,5) NOT NULL DEFAULT 0.00000'); + addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_points` ADD `locked_order_points` FLOAT(20,5) NOT NULL DEFAULT 0.00000'); + + // This update depends on ext-user + addExtensionDependency('user'); + + // Register filters for gathering points + registerFilter(__FUNCTION__, __LINE__, 'get_total_points', 'ORDER_POINTS', true, isExtensionDryRun()); + registerFilter(__FUNCTION__, __LINE__, 'get_own_points', 'ORDER_POINTS', true, isExtensionDryRun()); + + // Update notes (these will be set as task text!) + setExtensionUpdateNotes("Weiteres {?POINTS?}-Guthabenkonto "Werbeguthaben" hinzugefügt (verschoben von ext-user) und neue Filter zum Zurückliefern des Werbeguthabens hinzugefügt."); + break; } // END - switch break; diff --git a/inc/extensions/ext-user.php b/inc/extensions/ext-user.php index d59ca08dc0..0bcac1b6b7 100644 --- a/inc/extensions/ext-user.php +++ b/inc/extensions/ext-user.php @@ -41,10 +41,10 @@ if (!defined('__SECURITY')) { } // END - if // Version number -setThisExtensionVersion('0.3.8'); +setThisExtensionVersion('0.3.9'); // Version history array (add more with , '0.0.1' and so on) -setExtensionVersionHistory(array('0.0.0', '0.1.0', '0.1.1', '0.1.2', '0.1.2', '0.1.3', '0.1.4', '0.1.5', '0.1.6', '0.1.7', '0.1.8', '0.1.9', '0.2.0', '0.2.1', '0.2.2', '0.2.3', '0.2.4', '0.2.5', '0.2.6', '0.2.7', '0.2.8', '0.2.9', '0.3.0', '0.3.1', '0.3.2', '0.3.3', '0.3.4', '0.3.5', '0.3.6', '0.3.7', '0.3.8')); +setExtensionVersionHistory(array('0.0.0', '0.1.0', '0.1.1', '0.1.2', '0.1.2', '0.1.3', '0.1.4', '0.1.5', '0.1.6', '0.1.7', '0.1.8', '0.1.9', '0.2.0', '0.2.1', '0.2.2', '0.2.3', '0.2.4', '0.2.5', '0.2.6', '0.2.7', '0.2.8', '0.2.9', '0.3.0', '0.3.1', '0.3.2', '0.3.3', '0.3.4', '0.3.5', '0.3.6', '0.3.7', '0.3.8', '0.3.9')); // Keep this extension always active! setExtensionAlwaysActive('Y'); @@ -181,6 +181,10 @@ INDEX (`stats_type`) addDropTableSql('user_stats'); addDropTableSql('user_stats_data'); addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `what` IN('config_user','user_contct','list_user_del') OR `action`='user'"); + + // Register new filters for gathering points + unregisterFilter(__FUNCTION__, __LINE__, 'get_total_points', 'USER_POINTS', true, isExtensionDryRun()); + unregisterFilter(__FUNCTION__, __LINE__, 'get_own_points', 'USER_POINTS', true, isExtensionDryRun()); break; case 'activate': // Do stuff when admin activates this extension @@ -421,11 +425,17 @@ PRIMARY KEY (`id`) break; case '0.3.8': // SQL queries for v0.3.8 - addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_points` ADD `order_points` FLOAT(20,5) NOT NULL DEFAULT 0.00000'); - addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_points` ADD `locked_order_points` FLOAT(20,5) NOT NULL DEFAULT 0.00000'); + // Update notes (these will be set as task text!) + setExtensionUpdateNotes("Update verschoben nach ext-order (da es Werbeguthaben ist und nichts mit dem Mitglied selbst zu tun hat)."); + break; + + case '0.3.9': // SQL queries for v0.3.9 + // Register new filters for gathering points + registerFilter(__FUNCTION__, __LINE__, 'get_total_points', 'USER_POINTS', true, isExtensionDryRun()); + registerFilter(__FUNCTION__, __LINE__, 'get_own_points', 'USER_POINTS', true, isExtensionDryRun()); // Update notes (these will be set as task text!) - setExtensionUpdateNotes("Weiteres {?POINTS?}-Guthabenkonto "Werbeguthaben" hinzugefügt."); + setExtensionUpdateNotes("Filter registriert, die das eigene {?POINTS?}-Guthaben des Mitgliedes zurückliefern."); break; } // END - switch break; diff --git a/inc/filter/order_filter.php b/inc/filter/order_filter.php new file mode 100644 index 0000000000..9a37798888 --- /dev/null +++ b/inc/filter/order_filter.php @@ -0,0 +1,56 @@ + diff --git a/inc/filter/user_filter.php b/inc/filter/user_filter.php new file mode 100644 index 0000000000..d0b8cdc5c4 --- /dev/null +++ b/inc/filter/user_filter.php @@ -0,0 +1,53 @@ + diff --git a/inc/functions.php b/inc/functions.php index 2a0e1d0530..2b9f431af1 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -88,20 +88,13 @@ function sendEmail ($toEmail, $subject, $message, $isHtml = 'N', $mailHeader = ' // Set from header if ((!isInStringIgnoreCase('@', $toEmail)) && ($toEmail > 0)) { - // Value detected, is the message extension installed? - // @TODO Extension 'msg' does not exist - if (isExtensionActive('msg')) { - ADD_MESSAGE_TO_BOX($toEmail, $subject, $message, $isHtml); - return; + // Does the user exist? + if (fetchUserData($toEmail)) { + // Get the email + $toEmail = getUserData('email'); } else { - // Does the user exist? - if (fetchUserData($toEmail)) { - // Get the email - $toEmail = getUserData('email'); - } else { - // Set webmaster - $toEmail = getWebmaster(); - } + // Set webmaster + $toEmail = getWebmaster(); } } elseif ($toEmail == '0') { // Is the webmaster! diff --git a/inc/modules/admin/what-admins_contct.php b/inc/modules/admin/what-admins_contct.php index 1674350b7e..a84cdcdd4c 100644 --- a/inc/modules/admin/what-admins_contct.php +++ b/inc/modules/admin/what-admins_contct.php @@ -45,18 +45,12 @@ addYouAreHereLink('admin', __FILE__); if ((isFormSent()) && (isGetRequestParameterSet('admin'))) { // Send mail or message - if ((isExtensionActive('msg')) && (postRequestParameter('type') == 'message')) { - // Add message - $message = loadEmailTemplate('admins_msg_contct_admin', postRequestParameter('text'), 0); - sendAdminMessage(getRequestParameter('admin'), '{--ADMIN_ADMINS_MESSAGE_FROM_ADMIN--}', $message); - } else { - // Load admin's email address - $email = getAdminEmail(bigintval(getRequestParameter('admin'))); + // Load admin's email address + $email = getAdminEmail(bigintval(getRequestParameter('admin'))); - // Load email template and send the mail to the admin - $message = loadEmailTemplate('admins_mail_contct_admin', postRequestParameter('text'), 0); - sendEmail($email, '{--ADMIN_ADMINS_MESSAGE_FROM_ADMIN--}', $message); - } + // Load email template and send the mail to the admin + $message = loadEmailTemplate('admins_mail_contct_admin', postRequestParameter('text'), 0); + sendEmail($email, '{--ADMIN_ADMINS_MESSAGE_FROM_ADMIN--}', $message); // Mail / message dropped displayMessage('{--ADMIN_ADMINS_ADMIN_CONTACTED--}'); @@ -64,14 +58,6 @@ if ((isFormSent()) && (isGetRequestParameterSet('admin'))) { // Load contact form template $content['admin'] = getRequestParameter('admin'); - if (isExtensionActive('msg')) { - // Add option to select between mail and message - $content['message_selection'] = loadTemplate('admin_admins_contct_select', true); - } else { - // Outout hidden input - $content['message_selection'] = loadTemplate('admin_admins_contct_default', true); - } - // Load main form loadTemplate('admin_admins_contct_form', false, $content); } else { diff --git a/inc/modules/admin/what-list_user.php b/inc/modules/admin/what-list_user.php index c7a5470493..2d6592c839 100644 --- a/inc/modules/admin/what-list_user.php +++ b/inc/modules/admin/what-list_user.php @@ -140,14 +140,25 @@ LIMIT 1", $content['last_update'] = generateDateTime($content['last_update'], 0); $content['last_profile_sent'] = generateDateTime($content['last_profile_sent'], 0); $content['total_points'] = getTotalPoints($content['userid']); - $content['locked_points'] = countSumTotalData($userid, 'user_points', 'locked_points') + countSumTotalData($userid, 'user_points', 'locked_order_points'); - $content['own_points'] = countSumTotalData($userid, 'user_points', 'points') + countSumTotalData($userid, 'user_points', 'order_points'); + $content['locked_points'] = countSumTotalData($content['userid'], 'user_points', 'locked_points') + countSumTotalData($content['userid'], 'user_points', 'locked_order_points'); + + // Prepare array for filter + $data = array( + 'userid' => $content['userid'], + 'points' => 0 + ); + + // Run the filter chain + $data = runFilterChain('get_own_points', $data); + + // Add more data + $content['own_points'] = $data['points']; $content['lock_timestamp'] = generateDateTime($content['lock_timestamp'], 2); $content['nickname'] = '{--EXT_NICKNAME_404--}'; // Link to email_details if some are sent if ($content['emails_sent'] > 0) { - $content['emails_sent'] = $base . '&what=email_details&userid=' . $userid . '%}">}{%pipe,translateComma=' . $content['emails_sent'] . '%}]'; + $content['emails_sent'] = $base . '&what=email_details&userid=' . $content['userid'] . '%}">}{%pipe,translateComma=' . $content['emails_sent'] . '%}]'; } // END - if // Nickname inclusion? diff --git a/inc/wrapper-functions.php b/inc/wrapper-functions.php index 279c8dec72..eb9419c94e 100644 --- a/inc/wrapper-functions.php +++ b/inc/wrapper-functions.php @@ -2347,8 +2347,17 @@ function isVerboseSqlEnabled () { function getTotalPoints ($userid) { // Do we have cache? if (!isset($GLOBALS[__FUNCTION__][$userid])) { + // Init array for filter chain + $data = array( + 'userid' => $userid, + 'points' => 0 + ); + + // Run filter chain for getting more point values + $data = runFilter('get_total_points', $data); + // Determine it - $GLOBALS[__FUNCTION__][$userid] = countSumTotalData($userid, 'user_points', 'points') - countSumTotalData($userid, 'user_points', 'order_points') - countSumTotalData($userid, 'user_data', 'used_points'); + $GLOBALS[__FUNCTION__][$userid] = $data['points'] - countSumTotalData($userid, 'user_data', 'used_points'); } // END - if // Return cache diff --git a/templates/de/html/admin/admin_admins_contct_select.tpl b/templates/de/html/admin/admin_admins_contct_select.tpl index 623af8ae97..11f5d85d80 100644 --- a/templates/de/html/admin/admin_admins_contct_select.tpl +++ b/templates/de/html/admin/admin_admins_contct_select.tpl @@ -1,13 +1 @@ - - - {--ADMIN_ADMINS_SELECT_CONTACT_TYPE--} - - - - - {--ADMIN_ADMINS_CONTACT_TYPE_MAIL--} - - - {--ADMIN_ADMINS_CONTACT_TYPE_MSG--} - - +