From d92d8b4ddd219b65df8e0bba5e4354c0bbfba5c9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 28 Oct 2009 21:22:27 +0000 Subject: [PATCH 1/1] Fixes for broken order page and themes --- inc/language/order_de.php | 2 + inc/modules/guest/action-themes.php | 2 +- inc/modules/member/action-themes.php | 2 +- inc/modules/member/what-order.php | 133 +++++++++++++++------------ 4 files changed, 76 insertions(+), 63 deletions(-) diff --git a/inc/language/order_de.php b/inc/language/order_de.php index a75de0d35e..ec3c5673c7 100644 --- a/inc/language/order_de.php +++ b/inc/language/order_de.php @@ -70,6 +70,8 @@ addMessages(array( 'ORDER_SELECT_COLUMN_TOTAL_LOGINS' => "Gesamtlogins", 'ORDER_SELECT_COLUMN_MAIL_ORDERS' => "Heutige Mailbuchungen", + 'ORDER_DEFAULT_SUBJECT' => "Betreffzeile in allen Mails", + 'ORDER_DEFAULT_TEXT' => "Geben Sie hier Ihren Werbetext ein.", 'ADMIN_AUTOSEND_INACTIVE' => "Der Auto-Versand ist in Ihrem {?mt_word?} derzeit deaktiviert. Bitte loggen Sie sich in den Admin-Bereich ein und schalten Sie diese Mailbuchung frei!", 'ADMIN_AUTOSEND_ACTIVE' => "Der Auto-Versand ist in Ihrem {?mt_word?} derzeit aktiviert. Die Mailbuchung wird aktiviert und dann automatisch versand.", 'MEMBER_AUTOSEND_INACTIVE' => "Der Auto-Versand ist in unserem {?mt_word?} derzeit deaktiviert. Ihre Mailbuchung wird bald von einem Administrator ueberprueft und dann freigegeben.", diff --git a/inc/modules/guest/action-themes.php b/inc/modules/guest/action-themes.php index 00b6bf45f5..b239377473 100644 --- a/inc/modules/guest/action-themes.php +++ b/inc/modules/guest/action-themes.php @@ -67,7 +67,7 @@ if ($num_themes > 1) { $OUT = loadTemplate('theme_one', true, getCurrentThemeName()); } elseif (isAdmin()) { // If there is no theme installed and there's an admin notify him! - $OUT = loadTemplate('admin_settings_saved', true, "
{--ADMIN_NO_THEME_INSTALLED_WARNING--}
"); + $OUT = '{--ADMIN_NO_THEME_INSTALLED_WARNING--}'; } // Load final box template diff --git a/inc/modules/member/action-themes.php b/inc/modules/member/action-themes.php index 7dadc2abda..22a22725ce 100644 --- a/inc/modules/member/action-themes.php +++ b/inc/modules/member/action-themes.php @@ -68,7 +68,7 @@ if ($num_themes > 1) { $OUT = loadTemplate('theme_one', true, getCurrentThemeName()); } elseif (isAdmin()) { // If there is no theme installed and there's an admin notify him! - $OUT = loadTemplate('admin_settings_saved', true, "
{--ADMIN_NO_THEME_INSTALLED_WARNING--}
"); + $OUT = '{--ADMIN_NO_THEME_INSTALLED_WARNING--}'; } // Load final box template diff --git a/inc/modules/member/what-order.php b/inc/modules/member/what-order.php index 491160aa2d..b214a719c6 100644 --- a/inc/modules/member/what-order.php +++ b/inc/modules/member/what-order.php @@ -63,22 +63,26 @@ $content['min'] = getConfig('order_min'); // Count unconfirmed mails $links = countSumTotalData(getUserId(), 'user_links', 'id', 'userid', true); -// Does the user has more than 0 mails per day set? -$HOLIDAY = 'userid'; +// Do we have ext-holiday installed? +$HOLIDAY = 'serid'; if ((isExtensionActive('holiday')) && (getExtensionVersion('holiday') >= '0.1.3')) { // Fetch also holiday activation data - $HOLIDAY = '`holiday_active`'; + $HOLIDAY = 'holiday_active'; } // END - if -$result_mmails = SQL_QUERY_ESC("SELECT `userid`, `receive_mails`, `mail_orders`, ".$HOLIDAY." +$result_mmails = SQL_QUERY_ESC("SELECT `userid`, `receive_mails`, `mail_orders`, `".$HOLIDAY."` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid`=%s AND `max_mails` > 0 LIMIT 1", array(getUserId()), __FILE__, __LINE__); $mmails = SQL_NUMROWS($result_mmails); list($DMY, $MAXI, $ORDERS, $HOLIDAY) = SQL_FETCHROW($result_mmails); + +// Free result SQL_FREERESULT($result_mmails); -if ($HOLIDAY == $DMY) $HOLIDAY='N'; + +// Fix non-existent ext-holidy +if ($HOLIDAY == $DMY) $HOLIDAY = 'N'; $ALLOWED = $MAXI - $ORDERS; if (getConfig('order_max_full') == 'MAX') $ALLOWED = $MAXI; @@ -89,7 +93,7 @@ $total = countSumTotalData(getUserId(), 'user_points', 'points') - countSumTotal if (($HOLIDAY == 'Y') && (getExtensionVersion('holiday') >= '0.1.3')) { // Holiday is active! loadTemplate('admin_settings_saved', false, getMessage('HOLIDAY_ORDER_NOT_POSSIBLE')); -} elseif ((isPostRequestElementSet(('frametester'))) && ($ALLOWED > 0) && (postRequestElement('receiver') > 0)) { +} elseif ((isPostRequestElementSet('frametester')) && ($ALLOWED > 0) && (postRequestElement('receiver') > 0)) { // Continue with the frametester, we first need to store the data temporary in the pool // // First we would like to store the data and get it's pool position back... @@ -97,7 +101,9 @@ if (($HOLIDAY == 'Y') && (getExtensionVersion('holiday') >= '0.1.3')) { FROM `{?_MYSQL_PREFIX?}_pool` WHERE - `sender`=%s AND `url`='%s' AND `timestamp` > (UNIX_TIMESTAMP() - %s) + `sender`=%s AND + `url`='%s' AND + `timestamp` > (UNIX_TIMESTAMP() - %s) LIMIT 1", array( getUserId(), @@ -234,7 +240,7 @@ ORDER BY // Load receivers from database $TEST = array(); $cnt = 0; - while ($content = SQL_FETCHARRAY($result)) { + while ($holidayContent = SQL_FETCHARRAY($result)) { if ($HOLIDAY) { // Check for his holiday status $result_holiday = SQL_QUERY_ESC("SELECT @@ -244,16 +250,16 @@ FROM WHERE `userid`=%s AND `holiday_start` < UNIX_TIMESTAMP() AND `holiday_end` > UNIX_TIMESTAMP() LIMIT 1", - array(bigintval($content['userid'])), __FILE__, __LINE__); - if (SQL_NUMROWS($result_holiday) == 1) $content['userid'] = 0; // Exclude user who are in holiday + array($holidayContent['userid']), __FILE__, __LINE__); + if (SQL_NUMROWS($result_holiday) == 1) $holidayContent['userid'] = 0; // Exclude user who are in holiday // Free memory SQL_FREERESULT($result_holiday); } // END - if - if ($content['userid'] > 0) { + if ($holidayContent['userid'] > 0) { // Add receiver - $TEST[] = $content['userid']; + $TEST[] = $holidayContent['userid']; $cnt++; } // END - if } // END - while @@ -265,59 +271,56 @@ LIMIT 1", $RECEIVER = implode($TEST, ';'); // Count array for maximum sent - $MAX_SEND = count($TEST); + $content['target_send'] = count($TEST); // Update receiver list SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `receive_mails`=`receive_mails`-1 WHERE `userid` IN (%s) LIMIT %s", - array(str_replace(';', ", ", $RECEIVER), $MAX_SEND), __FILE__, __LINE__); + array(str_replace(';', ", ", $RECEIVER), $content['target_send']), __FILE__, __LINE__); // Is calculated max receivers larger than wanted receivers then reset it - if ($MAX_SEND > postRequestElement('receiver')) $MAX_SEND = bigintval(postRequestElement('receiver')); + if ($content['target_send'] > postRequestElement('receiver')) $content['target_send'] = bigintval(postRequestElement('receiver')); // Calculate used points - $USED = $MAX_SEND * getPaymentPoints(bigintval(postRequestElement('type'))); + $USED = $content['target_send'] * getPaymentPoints(bigintval(postRequestElement('type'))); // Fix empty zip code if (!isPostRequestElementSet('zip')) setRequestPostElement('zip', '0'); // Check if he has enougth points for this order and selected more than 0 receivers - if (($USED > 0) && ($USED <= $total) && ($MAX_SEND > 0)) { + if (($USED > 0) && ($USED <= $total) && ($content['target_send'] > 0)) { // Gettings points is okay, so we can add $USED later from - $TIME = time(); if (($id == '0') || ($type != 'TEMP')) { // New order $id = 0; if (isExtensionActive('html_mail')) { // HTML extension is active SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_pool` (`sender`, `subject`, `text`, `receivers`, `payment_id`, `data_type`, `timestamp`, `url`, `cat_id`, `target_send`, `zip`, `html_msg`) - VALUES ('%s','%s','%s','%s','%s','TEMP','%s','%s','%s','%s','%s','%s')", + VALUES ('%s','%s','%s','%s','%s','TEMP',UNIX_TIMESTAMP(),'%s','%s','%s','%s','%s')", array( getUserId(), postRequestElement('subject'), postRequestElement('text'), $RECEIVER, bigintval(postRequestElement('type')), - $TIME, postRequestElement('url'), bigintval(postRequestElement('cat')), - $MAX_SEND, + $content['target_send'], bigintval(postRequestElement('zip')), postRequestElement('html') ), __FILE__, __LINE__); } else { // No HTML extension is active SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_pool` (`sender`, `subject`, `text`, `receivers`, `payment_id`, `data_type`, `timestamp`, `url`, `cat_id`, `target_send`, `zip`) - VALUES ('%s','%s','%s','%s','%s','TEMP','%s','%s','%s','%s','%s')", + VALUES ('%s','%s','%s','%s','%s','TEMP',UNIX_TIMESTAMP(),'%s','%s','%s','%s')", array( getUserId(), postRequestElement('subject'), postRequestElement('text'), $RECEIVER, bigintval(postRequestElement('type')), - $TIME, postRequestElement('url'), bigintval(postRequestElement('cat')), - $MAX_SEND, + $content['target_send'], bigintval(postRequestElement('zip')), ), __FILE__, __LINE__); } @@ -348,7 +351,7 @@ LIMIT 1", bigintval(postRequestElement('type')), postRequestElement('url'), bigintval(postRequestElement('cat')), - $MAX_SEND, + $content['target_send'], bigintval(postRequestElement('zip')), postRequestElement('html'), bigintval($id) @@ -377,7 +380,7 @@ LIMIT 1", bigintval(postRequestElement('type')), postRequestElement('url'), bigintval(postRequestElement('cat')), - $MAX_SEND, + $content['target_send'], bigintval(postRequestElement('zip')), bigintval($id) ), __FILE__, __LINE__); @@ -387,21 +390,23 @@ LIMIT 1", // Do we need to get the ID number? if ($id == 0) { // Order is placed as temporary. We need to get it's id for the frametester - $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_pool` WHERE `sender`=%s AND `subject`='%s' AND `payment_id`=%s AND `data_type`='TEMP' AND `timestamp`=%s LIMIT 1", + $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_pool` WHERE `sender`=%s AND `subject`='%s' AND `payment_id`=%s AND `data_type`='TEMP' AND `timestamp`=UNIX_TIMESTAMP() LIMIT 1", array( getUserId(), postRequestElement('subject'), - bigintval(postRequestElement('type')), - $TIME + bigintval(postRequestElement('type')) ), __FILE__, __LINE__); + // Get pool id list($id) = SQL_FETCHROW($result); + + // Free result SQL_FREERESULT($result); - } + } // END - if // ID is received so we can redirect the user, used points will be added when he send's out the mail $URL = 'modules.php?module=frametester&order=' . $id; - } elseif ($MAX_SEND == 0) { + } elseif ($content['target_send'] == 0) { // Not enougth receivers found which can receive mails $URL = 'modules.php?module=login&what=order&code=' . getCode('MORE_RECEIVERS2'); } else { @@ -431,7 +436,7 @@ ORDER BY if (SQL_NUMROWS($result_cats) > 0) { if ($total > 0) { // Initialize array... - $CATS = array( + $categories = array( 'id' => array(), 'name' => array(), 'userids' => array() @@ -447,13 +452,13 @@ ORDER BY } // END - if // ... and begin loading stuff - while ($content = SQL_FETCHARRAY($result_cats)) { - $CATS['id'][] = bigintval($content['id']); - $CATS['name'][] = $content['cat']; + while ($categoriesContent = SQL_FETCHARRAY($result_cats)) { + $categories['id'][] = bigintval($categoriesContent['id']); + $categories['name'][] = $categoriesContent['cat']; // Select users in current category $result_userids = SQL_QUERY_ESC("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_cats` WHERE `cat_id`=%s AND `userid` != '%s' ORDER BY `userid` ASC", - array(bigintval($content['id']), getUserId()), __FILE__, __LINE__); + array(bigintval($categoriesContent['id']), getUserId()), __FILE__, __LINE__); $userid_cnt = 0; while (list($ucat) = SQL_FETCHROW($result_userids)) { @@ -486,8 +491,8 @@ LIMIT 1", array(bigintval($ucat)), __FILE__, __LINE__); if ((SQL_NUMROWS($result_ver) == 1) && (isPostRequestElementSet('zip')) && (getConfig('order_multi_page') == 'Y')) { + // Get zip code list($zip) = SQL_FETCHROW($result_ver); - SQL_FREERESULT($result_ver); if (substr($zip, 0, strlen(postRequestElement('zip'))) == postRequestElement('zip')) { // Ok, ZIP part is found $userid_cnt++; @@ -496,12 +501,15 @@ LIMIT 1", // Count numbers up! $userid_cnt += SQL_NUMROWS($result_ver); } + + // Free result + SQL_FREERESULT($result_ver); } // END - if } // END - while // Free memory SQL_FREERESULT($result_userids); - $CATS['userids'][] = $userid_cnt; + $categories['userids'][] = $userid_cnt; } // END - while // Free memory @@ -510,7 +518,7 @@ LIMIT 1", // Now we need to load the mail types... $result = SQL_QUERY("SELECT `id`, `price`, `payment`, `mail_title` FROM `{?_MYSQL_PREFIX?}_payments` ORDER BY `payment` ASC", __FILE__, __LINE__); - $typeS = array(); + $types = array(); if (SQL_NUMROWS($result) > 0) { // Check for message ID in URL $message = getMessageFromErrorCode(getRequestElement('code')); @@ -521,7 +529,7 @@ LIMIT 1", } // END - if // Load all email types... - while ($typeS[] = SQL_FETCHROW($result)) { + while ($types[] = SQL_FETCHROW($result)) { // Nothing to do here... ;-) } // END - while @@ -562,22 +570,29 @@ LIMIT 1", FROM `{?_MYSQL_PREFIX?}_pool` WHERE - `sender`=%s AND `data_type`='TEMP' + `sender`=%s AND + `data_type`='TEMP' LIMIT 1", array(getUserId()), __FILE__, __LINE__); if (SQL_NUMROWS($result) == 1) { // Old order found - $content = SQL_FETCHARRAY($result); + $content = merge_array($content, SQL_FETCHARRAY($result)); // Fix max receivers when it is too much - if ((isset($CATS['userids'][$content['cat_id']])) && ($content['target_send'] > $CATS['userids'][$content['cat_id']])) $content['target_send'] = $CATS['userids'][$content['cat_id']]; + if ((isset($categories['userids'][$content['cat_id']])) && ($content['target_send'] > $categories['userids'][$content['cat_id']])) { + // Fix it + $content['target_send'] = $categories['userids'][$content['cat_id']]; + } // END - if // Old order is grabbed $OLD_ORDER = true; } else { // Default output for that your members don't forget it... - $content['url'] = 'http://'; + $content['url'] = 'http://'; + $content['target_send'] = $content['min']; + $content['subject'] = '{--ORDER_DEFAULT_SUBJECT--}'; + $content['text'] = '{--ORDER_DEFAULT_TEXT--}'; } // Free result @@ -585,29 +600,25 @@ LIMIT 1", if ((isPostRequestElementSet('data')) || ((getConfig('order_multi_page') != 'Y') && ((!isAdmin()) && (!isExtensionActive('html_mail'))))) { // Pre-output categories - $CAT = ''; - foreach ($CATS['id'] as $key => $value) { - $CAT .= "