From: Roland Häder Date: Tue, 21 Dec 2010 22:48:08 +0000 (+0000) Subject: The usual asset of bugfixes/improvements: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=c529712f8b52273e47c3d6c49af890cb9eb9a3da;p=mailer.git The usual asset of bugfixes/improvements: - Variable $bonus renamed in function to make clear it is boolean type - Counting of sent mails (column mails_sent) added - No longer needed header comments removed (it is heavily rewritten anyway) - A lot missing/wrong array elements fixed in templates and PHP scripts - New wrapper added (used several times in pool-user.php) - CSS classes fixed in several 'order' templates - Several other minor improvements/fixes - TODOs.txt updated --- diff --git a/DOCS/TODOs.txt b/DOCS/TODOs.txt index 6bb20a927b..b99f1752a8 100644 --- a/DOCS/TODOs.txt +++ b/DOCS/TODOs.txt @@ -46,7 +46,7 @@ ./inc/functions.php:1593: // @TODO Are these convertions still required? ./inc/functions.php:1611:// @TODO Rewrite this function to use readFromFile() and writeToFile() ./inc/functions.php:181:// @TODO Rewrite this to an extension 'smtp' -./inc/functions.php:2269: // @TODO This is still very static, rewrite it somehow +./inc/functions.php:2272: // @TODO This is still very static, rewrite it somehow ./inc/gen_sql_patches.php:95:// @TODO Rewrite this to a filter ./inc/install-functions.php:57: // @TODO DEACTIVATED: changeDataInInclude(getCachePath() . 'config-local.php', 'OUTPUT-MODE', "setConfigEntry('OUTPUT_MODE', '", "');", postRequestParameter('omode'), 0); ./inc/language/de.php:1085:// @TODO Rewrite these two constants @@ -61,8 +61,8 @@ ./inc/language/sponsor_de.php:117:// @TODO Rewrite these four constants to one and use sprintf() ./inc/libs/admins_functions.php:435: // @TODO This can be, somehow, rewritten ./inc/libs/beg_functions.php:55: // @TODO Try to rewrite the following unset() -./inc/libs/bonus_functions.php:199: // @TODO Move this HTML to a template -./inc/libs/bonus_functions.php:287: // @TODO This query isn't right, it will only update if the user was for a longer time away! +./inc/libs/bonus_functions.php:201: // @TODO Move this HTML to a template +./inc/libs/bonus_functions.php:293: // @TODO This query isn't right, it will only update if the user was for a longer time away! ./inc/libs/cache_functions.php:78: // @TODO This should be rewritten not to load the cache file for just checking if it is there for save removal. ./inc/libs/doubler_functions.php:44:// @TODO Lame description ./inc/libs/doubler_functions.php:91: // @TODO Can't this be moved into EL? @@ -119,7 +119,6 @@ ./inc/modules/admin/what-config_points.php:111: // @TODO Rewrite this to a filter ./inc/modules/admin/what-config_rallye_prices.php:195: // @TODO Rewrite these two constants ./inc/modules/admin/what-config_register.php:75: // @TODO Move this HTML code into a template -./inc/modules/admin/what-del_email.php:60: // @TODO Unused: $price = getPaymentPoints($content['payment_id'], 'price'); ./inc/modules/admin/what-del_email.php:61: // @TODO Unused: cat_id, payment_id ./inc/modules/admin/what-edit_user.php:18: * @TODO Add support for ext-country * ./inc/modules/admin/what-email_stats.php:46:// @TODO Unused at the moment @@ -175,11 +174,11 @@ ./inc/modules/member/what-unconfirmed.php:206: // @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:67: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:1183: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:1441: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY() -./inc/mysql-manager.php:1547: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:1918: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:1962:// @TODO Fix inconsistency between last_module and getWhat() +./inc/mysql-manager.php:1195: // @TODO Rewrite this to a filter +./inc/mysql-manager.php:1453: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY() +./inc/mysql-manager.php:1559: // @TODO Rewrite this to a filter +./inc/mysql-manager.php:1933: // @TODO Rewrite this to a filter +./inc/mysql-manager.php:1977:// @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/reset/reset_beg.php:52:// @TODO This should be converted in a daily beg rallye diff --git a/inc/extensions/ext-bonus.php b/inc/extensions/ext-bonus.php index c1e40a09aa..6a948845a3 100644 --- a/inc/extensions/ext-bonus.php +++ b/inc/extensions/ext-bonus.php @@ -119,7 +119,7 @@ PRIMARY KEY (`id`) addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_bonus` SET `target_send`=`mails_sent` WHERE `target_send`=0 AND `mails_sent`>0 AND `receivers` != ''"); // Update notes (these will be set as task text!) - setExtensionUpdateNotes("Behebt ein Versand-Problem mit den Bonus-Mails. Es wurde die Spalte target_send nicht beim Einfügen der Buchung gessetzt. Bitte laden Sie sich dazu - wenn nicht bereits geschehen - alle Patches bis mindestens Patch 240 unter Updates prüfen herunter."); + setExtensionUpdateNotes("Behebt ein Versand-Problem mit den Bonus-Mails. Es wurde die Spalte target_send nicht beim Einfügen der Buchung gessetzt."); break; case '0.2.1': // SQL queries for v0.2.1 diff --git a/inc/extensions/ext-sql_patches.php b/inc/extensions/ext-sql_patches.php index bc2a715b92..7d8d591bfa 100644 --- a/inc/extensions/ext-sql_patches.php +++ b/inc/extensions/ext-sql_patches.php @@ -41,10 +41,10 @@ if (!defined('__SECURITY')) { } // END - if // Version number -setThisExtensionVersion('0.7.3'); +setThisExtensionVersion('0.7.4'); // Version history array (add more with , '0.1.0' and so on) -setExtensionVersionHistory(array('0.0', '0.0.1', '0.0.2', '0.0.3', '0.0.4', '0.0.5', '0.0.6', '0.0.7', '0.0.8', '0.0.9', '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', '0.5.4', '0.5.5', '0.5.6', '0.5.7', '0.5.8', '0.5.9', '0.6.0', '0.6.1', '0.6.2', '0.6.3', '0.6.4', '0.6.4', '0.6.5', '0.6.6', '0.6.7', '0.6.8', '0.6.9', '0.7.0', '0.7.1', '0.7.2', '0.7.3')); +setExtensionVersionHistory(array('0.0', '0.0.1', '0.0.2', '0.0.3', '0.0.4', '0.0.5', '0.0.6', '0.0.7', '0.0.8', '0.0.9', '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', '0.5.4', '0.5.5', '0.5.6', '0.5.7', '0.5.8', '0.5.9', '0.6.0', '0.6.1', '0.6.2', '0.6.3', '0.6.4', '0.6.4', '0.6.5', '0.6.6', '0.6.7', '0.6.8', '0.6.9', '0.7.0', '0.7.1', '0.7.2', '0.7.3', '0.7.4')); // Keep this extension always active! setExtensionAlwaysActive('Y'); @@ -751,6 +751,13 @@ INDEX (`ip`) addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_filters` CHANGE `filter_name` `filter_name` VARCHAR(50) NOT NULL DEFAULT ''"); addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_filters` CHANGE `filter_function` `filter_function` VARCHAR(100) NOT NULL DEFAULT ''"); + // Update notes (these will be set as task text!) + setExtensionUpdateNotes("Spalten in Filtertabelle gekürzt (SQL-Fehler wegen zu grossem Schlüssel)."); + break; + + case '0.7.4': // SQL queries for v0.7.4 + addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_pool` ADD `mails_sent` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0"); + // Update notes (these will be set as task text!) setExtensionUpdateNotes("Spalten in Filtertabelle gekürzt (SQL-Fehler wegen zu grossem Schlüssel)."); break; diff --git a/inc/functions.php b/inc/functions.php index aa59a596b2..f045a8c5a9 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -1685,13 +1685,16 @@ function changeDataInFile ($FQFN, $comment, $prefix, $suffix, $DATA, $seek=0) { // An error was detected! return false; } + // Send notification to admin -function sendAdminNotification ($subject, $templateName, $content=array(), $userid = '0') { +function sendAdminNotification ($subject, $templateName, $content = array(), $userid = '0') { if ((isExtensionInstalledAndNewer('admins', '0.4.1')) && (function_exists('sendAdminsEmails'))) { // Send new way + /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'admins=Y,subject=' . $subject . ',templateName=' . $templateName); sendAdminsEmails($subject, $templateName, $content, $userid); } else { - // Send out out-dated way + // Send out-dated way + /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'admins=N,subject=' . $subject . ',templateName=' . $templateName); $message = loadEmailTemplate($templateName, $content, $userid); sendAdminEmails($subject, $message); } diff --git a/inc/language/de.php b/inc/language/de.php index 69a19905a7..95be0696ab 100644 --- a/inc/language/de.php +++ b/inc/language/de.php @@ -985,7 +985,7 @@ addMessages(array( 'ADMIN_CONFIG_POINTS_TITLE' => "Einstellungen für {?POINTS?}", 'APP_DIE_TITLE' => "Bug im Script erkannt!", 'ADMIN_CONTACT_LINK_TITLE' => "Kontakt zum Administrator", - 'ADMIN_MAIL_NOTHING_DELETED' => "Die Mail mit der Id %s "Die Mail mit der Id %s weisst keine Mitglieder auf.", 'ADMIN_SEND_RESET_LINK_TITLE' => "1/4: Administratorkennwort zurücksetzen", 'ADMIN_VALIDATE_HASH_TITLE' => "2/4: Validierung Iher Logindaten", diff --git a/inc/modules/admin/what-add_points.php b/inc/modules/admin/what-add_points.php index e1b3d1a518..93a1923a90 100644 --- a/inc/modules/admin/what-add_points.php +++ b/inc/modules/admin/what-add_points.php @@ -55,6 +55,9 @@ if (getRequestParameter('userid') == 'all') { // Process all entries while ($row = SQL_FETCHARRAY($result_main)) { + // Merge $row into $content + $content = merge_array($content, $row); + // Remove depth to prevent booking errors. This is a bad coding // practice, thats also why we need to write this project from // scratch... @@ -66,7 +69,8 @@ if (getRequestParameter('userid') == 'all') { // Prepare content $content = array( 'reason' => SQL_ESCAPE(postRequestParameter('reason')), - 'points' => bigintval(postRequestParameter('points')) + 'points' => bigintval(postRequestParameter('points')), + 'userid' => $row['userid'] ); // Load email template and send email away diff --git a/inc/modules/admin/what-del_email.php b/inc/modules/admin/what-del_email.php index 5ebc2b96db..f90e1abd31 100644 --- a/inc/modules/admin/what-del_email.php +++ b/inc/modules/admin/what-del_email.php @@ -10,10 +10,10 @@ * -------------------------------------------------------------------- * * Kurzbeschreibung : Bonus- / Normal-Mail loeschen * * -------------------------------------------------------------------- * - * * - * Module by Robert Niedziela, Megacomputing * - * web : http://mc-p.mcserver.de * - * * + * $Revision:: $ * + * $Date:: $ * + * $Tag:: 0.2.1-FINAL $ * + * $Author:: $ * * -------------------------------------------------------------------- * * Copyright (c) 2003 - 2009 by Roland Haeder * * Copyright (c) 2009, 2010 by Mailer Developer Team * @@ -57,7 +57,7 @@ if (isGetRequestParameterSet('mid')) { $content = SQL_FETCHARRAY($result); // Get points we shall pay back per mail - // @TODO Unused: $price = getPaymentPoints($content['payment_id'], 'price'); + $content['price'] = getPaymentPoints($content['payment_id'], 'price'); // @TODO Unused: cat_id, payment_id // Prepare data for the template @@ -67,8 +67,8 @@ if (isGetRequestParameterSet('mid')) { loadTemplate('admin_delete_email_normal', false, $content); // Load email template and send the email away - $message_user = loadEmailTemplate('order-deleted', $content, $sender); - sendEmail($sender, '{--MEMBER_ORDER_DELETED--}', $message_user); + $message_user = loadEmailTemplate('order-deleted', $content, $content['sender']); + sendEmail($content['sender'], '{--MEMBER_ORDER_DELETED--}', $message_user); // Fetch right stats_id from pool $result_pool = SQL_QUERY_ESC("SELECT @@ -94,23 +94,23 @@ LIMIT 1", reduceRecipientReceivedMails('stats_id', getRequestParameter('mid'), $links); // Calc total points and pay them back - $totalPoints = $links * $price; + $totalPoints = $links * $content['price']; // Shall we pay the points back to the user? if ($totalPoints == 0) { // No points repayed! loadTemplate('admin_settings_saved', false, '{--ADMIN_NO_POINTS_REPAYED--}'); } elseif (getConfig('repay_deleted_mails') != 'SHRED') { - //* DEBUG: */ debugOutput($stats_id.':'.$totalPoints.'/'.$links.'/'.$price); + //* DEBUG: */ debugOutput($stats_id.':'.$totalPoints.'/'.$links.'/'.$content['price']); // Shall we payback to user or jackpot? if (getConfig('repay_deleted_mails') == 'JACKPOT') { // Set jackpot - $sender = '0'; + $content['sender'] = '0'; } // END - if // Pay back points - //* DEBUG: */ debugOutput('PAYBACK:'.$sender); - addPointsDirectly('mail_deleted', $sender, $totalPoints); + //* DEBUG: */ debugOutput('PAYBACK:'.$content['sender']); + addPointsDirectly('mail_deleted', $content['sender'], $totalPoints); // Output message if (getConfig('repay_deleted_mails') == 'REPAY') { diff --git a/inc/modules/admin/what-email_details.php b/inc/modules/admin/what-email_details.php index a35844f01c..52775b3073 100644 --- a/inc/modules/admin/what-email_details.php +++ b/inc/modules/admin/what-email_details.php @@ -33,16 +33,6 @@ * along with this program; if not, write to the Free Software * * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * * MA 02110-1301 USA * - * -------------------------------------------------------------------- * - * Moded What-email_details.php / also Editet ! * - * Auf langsammen Servern (wie mein z.B Dauert das Laden) * - * enorm hoch zu lang. Jetzt werden nur auftraege aufgelistet die * - * NEU sind ( DB NEW) oder ADMIN freischalten muss (DB ADMIN ) * - * oder noch als TEMP gespecihert sind * - * der rest der schon als SEND sich melden darf wird per * - * what-email_archiv .php aufgerufen * - * beste gruesse Robert Niedziela / www.personal-webserver.de * - * oder auch www.mc-p.org * ************************************************************************/ // Some security stuff... @@ -55,7 +45,7 @@ addYouAreHereLink('admin', __FILE__); // Normal mails ordered by your members $sql = "SELECT - `id`, `sender`, `subject`, `text`, `receivers`, `payment_id`, `data_type`, `timestamp`, `url`, `target_send`, `cat_id` + `id`, `sender`, `subject`, `text`, `receivers`, `payment_id`, `data_type`, `timestamp`, `url`, `target_send`, `mails_sent`, `cat_id` FROM `{?_MYSQL_PREFIX?}_pool` WHERE diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index bf1a9baec9..981d6f65a7 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -809,6 +809,8 @@ function getPaymentTitlePrice ($pid, $full=false) { // Load payment data $result = SQL_QUERY_ESC("SELECT `mail_title`, `price` FROM `{?_MYSQL_PREFIX?}_payments` WHERE `id`=%s LIMIT 1", array(bigintval($pid)), __FUNCTION__, __LINE__); + + // Do we have an entry? if (SQL_NUMROWS($result) == 1) { // Payment type found... :-) $data = SQL_FETCHARRAY($result); @@ -819,7 +821,7 @@ function getPaymentTitlePrice ($pid, $full=false) { } else { $ret = $data['mail_title'] . ' / {%pipe,translateComma=' . $data['price'] . '%} {?POINTS?}'; } - } + } // END - if // Free result SQL_FREERESULT($result); @@ -851,7 +853,7 @@ function getPaymentPoints ($pid, $lookFor = 'price') { } // Remove a receiver's id from $receivers and add a link for him to confirm -function removeReceiver (&$receivers, $key, $userid, $pool_id, $stats_id = '', $bonus = false) { +function removeReceiver (&$receivers, $key, $userid, $pool_id, $stats_id = 0, $isBonusMail = false) { // Default is not removed $ret = 'failed'; @@ -862,9 +864,12 @@ function removeReceiver (&$receivers, $key, $userid, $pool_id, $stats_id = '', $ // Is there already a line for this user available? if ($stats_id > 0) { + // Default is 'normal' mail + $type = 'NORMAL'; + $rowName = 'stats_id'; + // Only when we got a real stats id continue searching for the entry - $type = 'NORMAL'; $rowName = 'stats_id'; - if ($bonus) { + if ($isBonusMail === true) { $type = 'BONUS'; $rowName = 'bonus_id'; } // END - if @@ -878,6 +883,13 @@ function removeReceiver (&$receivers, $key, $userid, $pool_id, $stats_id = '', $ // So we add one! SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_links` (`%s`, `userid`, `link_type`) VALUES ('%s','%s','%s')", array($rowName, $stats_id, bigintval($userid), $type), __FUNCTION__, __LINE__); + + // Update 'mails_sent' if sql_patches is updated + if (isExtensionInstalledAndNewer('sql_patches', '0.7.4')) { + // Update the pool + SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_pool` SET `mails_sent`=`mails_sent`+1 WHERE `id`=%s LIMIT 1", + array(bigintval($pool_id)), __FUNCTION__, __LINE__); + } // END - if $ret = 'done'; } else { // Already found @@ -1719,7 +1731,10 @@ function addBonusMailToQueue ($subject, $text, $receiverList, $points, $seconds, $HTML = 'N'; // HTML mode? - if ($mode == 'html') $HTML = 'Y'; + if ($mode == 'html') { + // Yes, please + $HTML = 'Y'; + } // END - if // Add HTML mail SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_bonus` diff --git a/inc/pool/pool- b/inc/pool/pool- index a881964a65..741abdd1bb 100644 --- a/inc/pool/pool- +++ b/inc/pool/pool- @@ -41,7 +41,7 @@ if (!defined('__SECURITY')) { } // Don't run on daily reset -if (isResetModeEnabled()) { +if ((isResetModeEnabled()) || (!isHtmlOutputMode())) { // Skip here return false; } elseif (!isExtensionActive('foo')) { diff --git a/inc/pool/pool-bonus.php b/inc/pool/pool-bonus.php index dc07cfdb2a..5e9c743b8a 100644 --- a/inc/pool/pool-bonus.php +++ b/inc/pool/pool-bonus.php @@ -41,7 +41,7 @@ if (!defined('__SECURITY')) { } // END - if // Don't run on daily reset -if (isResetModeEnabled()) { +if ((isResetModeEnabled()) || (!isHtmlOutputMode())) { // Skip here return false; } elseif (!isExtensionActive('bonus')) { @@ -51,7 +51,7 @@ if (isResetModeEnabled()) { // Need this here // Only send bonus mail when bonus extension is active and maximum send-mails is not reached -if ($GLOBALS['pool_cnt'] < getConfig('max_send')) { +if ($GLOBALS['pool_cnt'] < getMaxSend()) { // Do we need to send out bonus mails? if (isExtensionActive('html_mail')) { // 0 1 2 3 4 5 6 7 8 9 10 11 @@ -72,54 +72,63 @@ if ($GLOBALS['pool_cnt'] < getConfig('max_send')) { // "Explode" all receivers into an array if (isInString(';', $DATA['receivers'])) { // There's more than one receiver in the list... - $receiverS = explode(';', $DATA['receivers']); + $receivers = explode(';', $DATA['receivers']); } elseif (!empty($DATA['points'])) { // Only one user left - $receiverS = array($DATA['receivers']); + $receivers = array($DATA['receivers']); } else { // No users left - $receiverS = array(0); + $receivers = array(0); } - $dummy = $receiverS; + $dummy = $receivers; // Now, if we are good little boys and girls Santa Claus left us some user-ids. // We can now send mails to them... - foreach ($receiverS as $key => $userid) { + foreach ($receivers as $key => $userid) { // Load personal data if (fetchUserData($userid)) { // The final receiver does exists so we can continue... //* DEBUG: */ debugOutput('OK!/L:'.__LINE__); - // Mark this user as "spammed" ;-) And place a line for him... - if (removeReceiver($dummy, $key, $userid, $DATA['id'], $DATA['id'], true) == 'done') { - // Prepare the mail - $mailText = loadEmailTemplate('bonus-mail', $DATA, $userid); - - // Send mail away - if (isset($DATA['html_msg'])) { - // Send HTML? - sendEmail(getUserData('email'), $DATA['subject'], $mailText, $DATA['html_msg']); - } else { - // No HTML mail! - sendEmail(getUserData('email'), $DATA['subject'], $mailText); - } - - // Count one up and remove entry from dummy array - $GLOBALS['pool_cnt']++; unset($dummy[$key]); - - if (isExtensionInstalledAndNewer('user', '0.1.4')) { - // Update mails received for receiver - SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `emails_received`=`emails_received`+1 WHERE `userid`=%s LIMIT 1", - array(bigintval($userid)), __FILE__, __LINE__); - } // END - if - - // Do we have send maximum mails? - if (($GLOBALS['pool_cnt'] >= getConfig('max_send')) || (countSelection($dummy) == 0)) { - // Yes, we have - //* DEBUG: */ debugOutput('*EXIT/L:'.__LINE__); + // Remove receiver from list + $status = removeReceiver($dummy, $key, $userid, $DATA['id'], $DATA['id'], true); + + // Did it work? + switch ($status) { + case 'done': // Done! + // Prepare the mail + $mailText = loadEmailTemplate('bonus-mail', $DATA, $userid); + + // Send mail away + if (isset($DATA['html_msg'])) { + // Send HTML? + sendEmail(getUserData('email'), $DATA['subject'], $mailText, $DATA['html_msg']); + } else { + // No HTML mail! + sendEmail(getUserData('email'), $DATA['subject'], $mailText); + } + + // Count one up and remove entry from dummy array + $GLOBALS['pool_cnt']++; unset($dummy[$key]); + + if (isExtensionInstalledAndNewer('user', '0.1.4')) { + // Update mails received for receiver + SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `emails_received`=`emails_received`+1 WHERE `userid`=%s LIMIT 1", + array(bigintval($userid)), __FILE__, __LINE__); + } // END - if + + // Do we have send maximum mails? + if (($GLOBALS['pool_cnt'] >= getMaxSend()) || (countSelection($dummy) == 0)) { + // Yes, we have + //* DEBUG: */ debugOutput('*EXIT/L:'.__LINE__); + break; + } // END - if break; - } // END - if - } // END - if + + default: // Unknown return type + logDebugMessage(__FILE__, __LINE__, 'Unknown status ' . $status . ' detected. pool_id=' . $DATA['id'] . ',sender=' . $DATA['sender'] . ',stats_id=' . $stats_id); + break; + } // END - switch } // END - if } // END - foreach @@ -154,7 +163,7 @@ LIMIT 1", //* DEBUG: */ debugOutput('*MEDIA/L:'.__LINE__.'*'); updateMediadataEntry(array('total_orders', 'bonus_orders'), 'add', 1); } // END - if - } elseif ($GLOBALS['pool_cnt'] >= getConfig('max_send')) { + } elseif ($GLOBALS['pool_cnt'] >= getMaxSend()) { // Update bonus pool SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_bonus` diff --git a/inc/pool/pool-user.php b/inc/pool/pool-user.php index 5293a5b28a..c2bcfda3f8 100644 --- a/inc/pool/pool-user.php +++ b/inc/pool/pool-user.php @@ -41,7 +41,7 @@ if (!defined('__SECURITY')) { } // END - if // Don't run on daily reset -if (isResetModeEnabled()) { +if ((isResetModeEnabled()) || (!isHtmlOutputMode())) { // Skip here return false; } elseif (!isExtensionActive('user')) { @@ -49,18 +49,33 @@ if (isResetModeEnabled()) { return false; } -// Need this here +// No HTML is default +$HTML = ''; + // Check for freed mail orders to send out if (isExtensionActive('html_mail')) { - // 0 1 2 3 4 5 6 7 8 9 10 - $result_main = SQL_QUERY("SELECT id, sender, subject, text, receivers, payment_id, timestamp, url, target_send, cat_id, html_msg FROM `{?_MYSQL_PREFIX?}_pool` WHERE `data_type`='NEW' ORDER BY timestamp DESC", __FILE__, __LINE__); -} else { - // 0 1 2 3 4 5 6 7 8 9 10 - $result_main = SQL_QUERY("SELECT id, sender, subject, text, receivers, payment_id, timestamp, url, target_send, cat_id, id FROM `{?_MYSQL_PREFIX?}_pool` WHERE `data_type`='NEW' ORDER BY timestamp DESC", __FILE__, __LINE__); -} + // With HTML mails + $HTML = ', `html_msg`'; +} // END - if + +// Main query +$result_main = SQL_QUERY("SELECT + `id`, `sender` AS `sender_userid`, `subject`, `text`, `receivers`, + `payment_id`, `timestamp`, `url`, `target_send`, `cat_id` + ".$HTML." +FROM + `{?_MYSQL_PREFIX?}_pool` +WHERE + `data_type`='NEW' +ORDER BY + `timestamp` DESC", __FILE__, __LINE__); // Reset variables -$count2 = '0'; $lastSentId = '0'; $count_back = array(0); $pointsBack = array(0); +$count2 = '0'; +$lastSentId = '0'; +$count_back = array(0); +$pointsBack = array(0); + if (!SQL_HASZERONUMS($result_main)) { // Parse all mails while ($DATA = SQL_FETCHARRAY($result_main, 0, false)) { @@ -69,44 +84,44 @@ if (!SQL_HASZERONUMS($result_main)) { array($DATA['id']), __FILE__, __LINE__); // Check fetched data for HTML - $HTML = 'N'; - if (isset($DATA['html_msg'])) $HTML = $DATA['html_msg']; + $isHtml = 'N'; + if (isset($DATA['html_msg'])) $isHtml = $DATA['html_msg']; // Entry updated? if (!SQL_HASZEROAFFECTED()) { // "Explode" all receivers into an array if (isInString(';', $DATA['receivers'])) { // There's more than one receiver in the list... - $receiverS = explode(';', $DATA['receivers']); + $receivers = explode(';', $DATA['receivers']); } elseif (!empty($DATA['receivers'])) { // Only one user left - $receiverS = array($DATA['receivers']); + $receivers = array($DATA['receivers']); } else { // No users left - $receiverS = array(0); + $receivers = array(0); } - $dummy = $receiverS; + $dummy = $receivers; // Now, if we are good little boys and girls Santa Claus left us some user-ids. // We can now send mails to them... - foreach ($receiverS as $key => $userid) { + foreach ($receivers as $key => $userid) { // Lookup user id //* DEBUG: */ debugOutput('*L:'.__LINE__.'/'.SQL_NUMROWS($result_user).'*'); if (fetchUserData($userid)) { // Do we have a stats entry? $result_stats = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `pool_id`=%s AND `userid`=%s AND timestamp_ordered='%s' LIMIT 1", - array($DATA['id'], $DATA['sender'], $DATA['timestamp']), __FILE__, __LINE__); + array($DATA['id'], $DATA['sender_userid'], $DATA['timestamp']), __FILE__, __LINE__); // If there's no stats entry add it! //* DEBUG: */ debugOutput('!L:'.__LINE__.'/'.SQL_NUMROWS($result_stats).'!'); if (SQL_HASZERONUMS($result_stats)) { // No entry was found, so we add him! SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_stats` (`pool_id` , `userid`, `cat_id`, `payment_id`, `subject`, `url` , `max_rec` , `timestamp_ordered`, `timestamp_sstart`) VALUES ('%s','%s','%s','%s','%s','%s','%s','%s' , UNIX_TIMESTAMP())", - array(bigintval($DATA['id']), bigintval($DATA['sender']), bigintval($DATA['cat_id']), bigintval($DATA['payment_id']), $DATA['subject'], $DATA['url'], $DATA['target_send'], bigintval($DATA['timestamp'])), __FILE__, __LINE__); + array(bigintval($DATA['id']), bigintval($DATA['sender_userid']), bigintval($DATA['cat_id']), bigintval($DATA['payment_id']), $DATA['subject'], $DATA['url'], $DATA['target_send'], bigintval($DATA['timestamp'])), __FILE__, __LINE__); // Receive it's id for the links table $result_stats = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `pool_id`=%s AND `userid`=%s AND timestamp_ordered='%s' LIMIT 1", - array(bigintval($DATA['id']), bigintval($DATA['sender']), bigintval($DATA['timestamp'])), __FILE__, __LINE__); + array(bigintval($DATA['id']), bigintval($DATA['sender_userid']), bigintval($DATA['timestamp'])), __FILE__, __LINE__); } // END - if //* DEBUG: */ debugOutput('!L:'.__LINE__.'/'.SQL_NUMROWS($result_stats).'!'); @@ -114,9 +129,11 @@ if (!SQL_HASZERONUMS($result_main)) { // We got one! list($stats_id) = SQL_FETCHROW($result_stats); - // Mark this user as "spammed" ;-) And place a line for him... - //* DEBUG: */ debugOutput('?L:'.__LINE__.'/'.$dummy.'/'.$key.'/'.$userid.'('.['sender'].')/'.$DATA['id'].'/'.$stats_id.'?'); - switch (removeReceiver($dummy, $key, bigintval($userid), bigintval($DATA['id']), bigintval($stats_id))) { + // Remove receiver from list + $status = removeReceiver($dummy, $key, bigintval($userid), bigintval($DATA['id']), bigintval($stats_id)); + + //* DEBUG: */ debugOutput('?L:'.__LINE__.'/'.$dummy.'/'.$key.'/'.$userid.'('.['sender_userid'].')/'.$DATA['id'].'/'.$stats_id.'?'); + switch ($status) { case 'done': // Prepare the mail $DATA['stats_id'] = bigintval($stats_id); @@ -129,11 +146,11 @@ if (!SQL_HASZERONUMS($result_main)) { $mailText = loadEmailTemplate('normal-mail', $DATA, bigintval($userid)); // Send mail away - sendEmail(getUserData('email'), $DATA['subject'], $mailText, $HTML); + sendEmail(getUserData('email'), $DATA['subject'], $mailText, $isHtml); // Count sent mails... - SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET emails_sent=emails_sent+1 WHERE `userid`=%s LIMIT 1", - array(bigintval($DATA['sender'])), __FILE__, __LINE__); + SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `emails_sent`=`emails_sent`+1 WHERE `userid`=%s LIMIT 1", + array(bigintval($DATA['sender_userid'])), __FILE__, __LINE__); if (isExtensionInstalledAndNewer('user', '0.1.4')) { // Update mails received for receiver @@ -158,15 +175,19 @@ if (!SQL_HASZERONUMS($result_main)) { $GLOBALS['pool_cnt']++; //* DEBUG: */ debugOutput('*EXIT/L:'.__LINE__.'/'.$GLOBALS['pool_cnt']); break; - } - } + + default: // Unknown return type + logDebugMessage(__FILE__, __LINE__, 'Unknown status ' . $status . ' detected. pool_id=' . $DATA['id'] . ',sender=' . $DATA['sender_userid'] . ',stats_id=' . $stats_id); + break; + } // END - switch + } // END - if // Do we have reached the maximum to send mails? || (getConfig('max_send') >= $GLOBALS['pool_cnt']) //* DEBUG: */ debugOutput('*L:'.__LINE__.'/'.$GLOBALS['pool_cnt'].'>='.$DATA['target_send'].'/'.getConfig('max_send').'>='.$GLOBALS['pool_cnt'].'/'.$lastSentId.'!='.$DATA['id'].'*'); if ((($GLOBALS['pool_cnt'] >= $DATA['target_send'])) && ($lastSentId != $DATA['id'])) { // Prepare content $content = array( - 'sender_userid' => $DATA['sender'], + 'sender_userid' => $DATA['sender_userid'], 'cat_id' => $DATA['cat_id'], 'text' => $DATA['text'], 'url' => $DATA['url'], @@ -177,9 +198,9 @@ if (!SQL_HASZERONUMS($result_main)) { sendAdminNotification('{--ADMIN_SEND_DONE_SUBJECT--}', 'done-admin', $content, $userid); // Get sender's data - if (fetchUserData($DATA['sender'])) { + if (fetchUserData($DATA['sender_userid'])) { // Load email template - $mailText = loadEmailTemplate('done-member', $content, $DATA['sender']); + $mailText = loadEmailTemplate('done-member', $content, $DATA['sender_userid']); // Send it also waway sendEmail(getUserData('email'), '{--MEMBER_SEND_DONE_SUBJECT--}', $mailText); @@ -225,7 +246,7 @@ if (!SQL_HASZERONUMS($result_main)) { SQL_FREERESULT($result_stats); } else { // User does not exists so we have add the sender's points back to sender's account - if (($receiverS['id'] == '0') || (empty($receiverS['id']))) { + if (($receivers['id'] == '0') || (empty($receivers['id']))) { // List was empty SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_pool` SET `data_type`='SEND' WHERE `id`=%s LIMIT 1", array(bigintval($DATA['id'])), __FILE__, __LINE__); @@ -234,14 +255,14 @@ if (!SQL_HASZERONUMS($result_main)) { if (isValidUserId($userid)) { // User does not exists, pay points back $points = getPaymentPoints($DATA['payment_id']); - addPointsDirectly('pool_payback', $DATA['sender'], $points); + addPointsDirectly('pool_payback', $DATA['sender_userid'], $points); // Add points together and remove user - $pointsBack[$DATA['sender']] += $points; + $pointsBack[$DATA['sender_userid']] += $points; } // END - if // Count up - $count_back[$DATA['sender']]++; + $count_back[$DATA['sender_userid']]++; } // Remove entry from list diff --git a/inc/wrapper-functions.php b/inc/wrapper-functions.php index 4a6e0e0dc9..80a4236061 100644 --- a/inc/wrapper-functions.php +++ b/inc/wrapper-functions.php @@ -2009,6 +2009,18 @@ function getLastMonth () { return $GLOBALS[__FUNCTION__]; } +// "Getter" for max_send +function getMaxSend () { + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('max_send'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + // "Getter" for __DB_NAME function getDbName () { // Do we have cache? diff --git a/templates/de/emails/order-deleted.tpl b/templates/de/emails/order-deleted.tpl index dde7ca66fd..9a0b6d332e 100644 --- a/templates/de/emails/order-deleted.tpl +++ b/templates/de/emails/order-deleted.tpl @@ -3,7 +3,7 @@ Hallo {%user,gender,translateGender=$userid%} {%user,surname=$userid%} {%user,fa Einer unserer Administratoren hat soeben Ihre Mailbuchung gelöscht. Hier sind nochmals Ihre URL und Betreff Ihrer Mailbuchung: --------------- -Beworbene URL: $content[url_raw] +Beworbene URL: $content[url] --------------- Betreffzeile: $content[subject] --------------- diff --git a/templates/de/html/admin/admin_list_unconfirmed_list.tpl b/templates/de/html/admin/admin_list_unconfirmed_list.tpl index d4daba540e..7b11e7c3da 100644 --- a/templates/de/html/admin/admin_list_unconfirmed_list.tpl +++ b/templates/de/html/admin/admin_list_unconfirmed_list.tpl @@ -2,10 +2,10 @@ - - - - + + + + $content
{--ID_SELECT--}{--MAILID_LINK--}{--SURNAME_FAMILY--}{--ACCOUNT_STATUS--}{--ID_SELECT--}{--MAILID_LINK--}{--SURNAME_FAMILY--}{--ACCOUNT_STATUS--}
diff --git a/templates/de/html/admin/admin_unlock_emails.tpl b/templates/de/html/admin/admin_unlock_emails.tpl index 418f469d5a..7b1bbec8e2 100644 --- a/templates/de/html/admin/admin_unlock_emails.tpl +++ b/templates/de/html/admin/admin_unlock_emails.tpl @@ -1,3 +1,4 @@ +
@@ -31,3 +32,4 @@
+
diff --git a/templates/de/html/member/member_order-html_ext.tpl b/templates/de/html/member/member_order-html_ext.tpl index e875d96afe..7691111d41 100644 --- a/templates/de/html/member/member_order-html_ext.tpl +++ b/templates/de/html/member/member_order-html_ext.tpl @@ -1,5 +1,5 @@ - + {--MEMBER_HTML_VALID_TAGS--}:
$content diff --git a/templates/de/html/member/member_order-zip1.tpl b/templates/de/html/member/member_order-zip1.tpl index b29023c224..677a17026c 100644 --- a/templates/de/html/member/member_order-zip1.tpl +++ b/templates/de/html/member/member_order-zip1.tpl @@ -25,8 +25,8 @@ - {--MEMBER_ENTER_ZIP_CODE--}: - + {--MEMBER_ENTER_ZIP_CODE--}: + diff --git a/templates/de/html/member/member_order_page1.tpl b/templates/de/html/member/member_order_page1.tpl index bfd76d3d17..961cfe5b90 100644 --- a/templates/de/html/member/member_order_page1.tpl +++ b/templates/de/html/member/member_order_page1.tpl @@ -4,7 +4,7 @@ $content[zip_content] $content[html_extension] - +