]> git.mxchange.org Git - mailer.git/commitdiff
Renamed function, used more "pool functions":
authorRoland Häder <roland@mxchange.org>
Wed, 23 Jan 2013 14:14:06 +0000 (14:14 +0000)
committerRoland Häder <roland@mxchange.org>
Wed, 23 Jan 2013 14:14:06 +0000 (14:14 +0000)
- Renamed SQL_INSERTID() to SQL_INSERT_ID()
- Used more functions from inc/pool-funtions.php instead of JOINs and queries
- TODOs.txt updated

26 files changed:
DOCS/TODOs.txt
inc/db/lib-mysql3.php
inc/extensions-functions.php
inc/filter/user_filter.php
inc/filters.php
inc/functions.php
inc/language/bonus_de.php
inc/libs/earning_functions.php
inc/libs/network_functions.php
inc/libs/register_functions.php
inc/libs/surfbar_functions.php
inc/modules/admin/what-add_rallye.php
inc/modules/admin/what-edit_emails.php
inc/modules/admin/what-list_unconfirmed.php
inc/modules/admin/what-send_coupon.php
inc/modules/member/what-order.php
inc/modules/member/what-unconfirmed.php
inc/mysql-manager.php
inc/pool-functions.php
templates/de/html/admin/admin_edit_email_row.tpl
templates/de/html/member/member_mail_normal_active.tpl
templates/de/html/member/member_mail_normal_admin.tpl
templates/de/html/member/member_mail_normal_deleted.tpl
templates/de/html/member/member_mail_normal_new.tpl
templates/de/html/member/member_mail_normal_send.tpl
templates/de/html/member/member_mail_normal_temp.tpl

index 265b12d2427c00ec2c4343001ccaf16afcadebf0..5359e40fdb7710dd844a2e8afceff2febf79c5e0 100644 (file)
@@ -9,7 +9,8 @@
 ./inc/config-functions.php:326:                                        // @TODO Call setConfigEntry() somehow
 ./inc/config-functions.php:354:                // @TODO Call setConfigEntry() somehow
 ./inc/daily/daily_beg.php:52:// @TODO This should be converted in a daily beg rallye
-./inc/daily/daily_birthday.php:99:                     // @TODO 4 is hard-coded here, should we move it out in config?
+./inc/daily/daily_birthday.php:107:                    // @TODO 4 is hard-coded here, should we move it out in config?
+./inc/daily/daily_birthday.php:68:// @TODO Rewrite these if() blocks to a filter
 ./inc/email-functions.php:113: * @TODO Rewrite this to an extension 'smtp'
 ./inc/email-functions.php:209:// @TODO $rawUserId is currently unused
 ./inc/expression-functions.php:173:// @TODO FILTER_COMPILE_CONFIG does not handle call-back functions so we handle it here again
 ./inc/filter/forced_filter.php:73:             // @TODO This part is unfinished
 ./inc/filter-functions.php:119:        // @TODO Remove this forced removal after a year or so
 ./inc/filters.php:1380:                // @TODO No banner found, output some default banner
-./inc/functions.php:1131:                      // @TODO Move this SQL code into a function, let's say 'getTimestampFromPoolId($id) ?
-./inc/functions.php:1217:                      // @TODO Are these convertions still required?
-./inc/functions.php:1238:// @TODO Rewrite this function to use readFromFile() and writeToFile()
-./inc/functions.php:1865:      // @TODO Find a way to cache this
-./inc/functions.php:1969:      // @TODO This is still very static, rewrite it somehow
-./inc/functions.php:2173:      // @TODO Rename column data_type to e.g. mail_status
-./inc/functions.php:2523:// @TODO cacheFiles is not yet supported
+./inc/functions.php:1210:                      // @TODO Are these convertions still required?
+./inc/functions.php:1231:// @TODO Rewrite this function to use readFromFile() and writeToFile()
+./inc/functions.php:1858:      // @TODO Find a way to cache this
+./inc/functions.php:1962:      // @TODO This is still very static, rewrite it somehow
+./inc/functions.php:2166:      // @TODO Rename column data_type to e.g. mail_status
+./inc/functions.php:2516:// @TODO cacheFiles is not yet supported
 ./inc/gen_sql_patches.php:95:// @TODO Rewrite this to a filter
 ./inc/header.php:66:// @TODO Find a way to not use direct module comparison
 ./inc/install-functions.php:446:       // @TODO Comparing with DEFAULT_MAIN_TITLE doesn't work
@@ -92,7 +92,7 @@
 ./inc/language/refback_de.php:51:      // @TODO Rewrite these constants to one
 ./inc/libs/admins_functions.php:537:           // @TODO This can be, somehow, rewritten
 ./inc/libs/bonus_functions.php:115:    // @TODO Rewrite this to a filter
-./inc/libs/bonus_functions.php:199:            // @TODO Move this HTML to a template
+./inc/libs/bonus_functions.php:201:            // @TODO Move this HTML to a template
 ./inc/libs/doubler_functions.php:130:// @TODO This could be rewritten to a filter
 ./inc/libs/doubler_functions.php:44:// @TODO Lame description
 ./inc/libs/doubler_functions.php:96:                   // @TODO Can't this be moved into EL?
 ./inc/libs/surfbar_functions.php:1696:         // @TODO This can be somehow rewritten
 ./inc/libs/surfbar_functions.php:479:          // @TODO if (($urlData['url_views_allowed'] != $urlData['edit']['limit']) || ($url1 != $url2)) {
 ./inc/libs/surfbar_functions.php:790:// @TODO Can't we use our new expression language instead of this ugly code?
-./inc/libs/task_functions.php:256:             // @TODO These can be rewritten to filter
+./inc/libs/task_functions.php:258:             // @TODO This can be rewritten to filter
 ./inc/libs/task_functions.php:51:// @TODO Move all extension-dependent queries into filters
 ./inc/libs/theme_functions.php:96:     // @TODO Can't this be rewritten to an API function?
 ./inc/libs/user_functions.php:325:                     // @TODO Make this filter working: $ADDON = runFilterChain('post_login_update', $content);
 ./inc/libs/yoomedia_functions.php:108: $response = YOOMEDIA_QUERY_API('out_textmail.php', TRUE); // @TODO Ask Yoo!Media for test script
 ./inc/load_config.php:75:      // @TODO Rewrite them to avoid this else block
 ./inc/loader/load-extension.php:13: * @TODO Rewrite this whole file                                        *
+./inc/mails/beg_mails.php:84:  // @TODO Rewrite these if() blocks to a filter
+./inc/mails/bonus_mails.php:84:        // @TODO Rewrite these if() blocks to a filter
 ./inc/mails/doubler_mails.php:53:// @TODO Can this be rewritten to a filter?
+./inc/mails/doubler_mails.php:75:// @TODO Rewrite these if() blocks to a filter
 ./inc/module-functions.php:273:                        // @TODO Nothing helped???
 ./inc/module-functions.php:314:                        // @TODO Rewrite this to a filter
 ./inc/modules/admin/admin-inc.php:1055:// @TODO rawUserId/content is not yet supported
 ./inc/modules/admin/what-guest_add.php:80:             // @TODO This can be somehow rewritten to a function
 ./inc/modules/admin/what-holiday_list.php:46:// @TODO Unused at the moment
 ./inc/modules/admin/what-list_admins_acls.php:126:     // @TODO Rewrite this to filter 'run_sqls'
-./inc/modules/admin/what-list_autopurge.php:47:// @TODO Rewrite those lines to filter
+./inc/modules/admin/what-list_autopurge.php:54:// @TODO Rewrite this as a filter
 ./inc/modules/admin/what-list_bonus.php:136:           // @TODO Can't this be moved into our expression language?
 ./inc/modules/admin/what-list_links.php:96:                                    // @TODO Rewrite this to includes/filter
 ./inc/modules/admin/what-list_mods.php:55:                     // @TODO This can be moved into mysql-function.php, see checkModulePermissions() function
 ./inc/modules/admin/what-list_rallye_prices.php:222:                   // @TODO Rewrite these two constants
 ./inc/modules/admin/what-list_refs.php:101:                                                    // @TODO Try to rewrite some to EL
-./inc/modules/admin/what-list_unconfirmed.php:118:     // @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:89:      // @TODO This constant might be unused? define('__LIST_UNCON_TITLE', '{--ADMIN_LIST_UNCONFIRMED_BONUS_LINKS--}');
-./inc/modules/admin/what-list_unconfirmed.php:92:      // @TODO `id` has been used two times???
+./inc/modules/admin/what-list_unconfirmed.php:115:     // @TODO "Please do not call me directly." Should be rewritten to a nice selection depending on ext-bonus
 ./inc/modules/admin/what-list_user_cats.php:54:                // @TODO No longer needed? define('__CATEGORIES_BASE'   , '<a href="{%url=modules.php?module=admin&amp;userid=');
 ./inc/modules/admin/what-list_user_cats.php:68:                                // @TODO Rewrite this to countSum.....() function
 ./inc/modules/admin/what-list_user.php:104:            // @TODO Refacture these old link generation to functions
 ./inc/modules/member/what-logout.php:17: * @TODO Rewrite the code to a filter                                   *
 ./inc/modules/member/what-logout.php:52:       // @TODO Move this in a filter, e.g. member_logout
 ./inc/modules/member/what-mydata.php:82:               // @TODO Move this to a function (for better EL code)
-./inc/modules/member/what-order.php:464:                       // @TODO Rewrite this to a filter
+./inc/modules/member/what-order.php:362:                       // @TODO Rewrite this to a filter
 ./inc/modules/member/what-order.php:72:        // @TODO Try to move out url_tlock to a filter for extra SQL statements
 ./inc/modules/member/what-payout.php:208:                                      // @TODO Rewrite this to a filter
 ./inc/modules/member/what-points.php:61:// @TODO Should we rewrite this to a filter?
 ./inc/modules/member/what-rallyes.php:99:      // @TODO Reactivate this: $content['admin'] = '<a href="{%url=modules.php?module=index&amp;what=impressum&amp;id=' . $content['admin_id'] . '%}">' . $content['login'] . '</a>';
 ./inc/modules/member/what-reflinks.php:52:// @TODO Move this into a filter
 ./inc/modules/member/what-transfer.php:128:                            // @TODO Rewrite this to a filter
-./inc/modules/member/what-unconfirmed.php:130: // @TODO This call cannot be saved as EL code cannot be "framed" in other EL code
-./inc/modules/member/what-unconfirmed.php:174: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY()
-./inc/modules/member/what-unconfirmed.php:241:                 // @TODO cat_id is unused
-./inc/modules/member/what-unconfirmed.php:244:                         // @TODO This 'userid' cannot be saved because of encapsulated EL code
+./inc/modules/member/what-unconfirmed.php:124: // @TODO This call cannot be saved as EL code cannot be "framed" in other EL code
+./inc/modules/member/what-unconfirmed.php:168: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY()
+./inc/modules/member/what-unconfirmed.php:235:                 // @TODO cat_id is unused
+./inc/modules/member/what-unconfirmed.php:238:                         // @TODO This 'userid' cannot be saved because of encapsulated EL code
 ./inc/modules/order.php:71:            // @TODO Unused: timestamp
+./inc/monthly/monthly_beg.php:58:      // @TODO Rewrite these if() blocks to a filter
+./inc/monthly/monthly_bonus.php:57:    // @TODO Rewrite these if() blocks to a filter
 ./inc/mysql-manager.php:1509:          // @TODO Rewrite these lines to a filter
 ./inc/mysql-manager.php:1533:  // @TODO Rewrite this to a filter
 ./inc/mysql-manager.php:1849:                  // @TODO Rewrite this to a filter
index 48415aa28abc4cf97b638fc6bae1af3f8b8b2563..a6267f171b3ac7b52aa06ecf380fb09a9d3442b1 100644 (file)
@@ -282,10 +282,10 @@ function SQL_FREERESULT ($resource) {
        return $res;
 }
 
-// Get id from last INSERT command
-function SQL_INSERTID () {
+// Get id from last INSERT command and secure id
+function SQL_INSERT_ID () {
        if (!SQL_IS_LINK_UP()) return FALSE;
-       return mysql_insert_id();
+       return bigintval(mysql_insert_id());
 }
 
 // Escape a string for the database
index c026edd0736736da53ba3e3ff606a9f2181f467f..6fbbe22afaa825ee9f24c758e0b6ffb690c7d503 100644 (file)
@@ -395,7 +395,7 @@ function registerExtension ($ext_name, $taskId, $isDryRun = FALSE, $ignoreUpdate
                                 * Use the insert id as extension id and "cache" all data for
                                 * this extension for early usage.
                                 */
-                               copyExtensionDataToCacheArray($currentName, SQL_INSERTID());
+                               copyExtensionDataToCacheArray($currentName, SQL_INSERT_ID());
 
                                // Mark it as installed
                                $GLOBALS['ext_is_installed'][$currentName] = TRUE;
index 62e6a195fb6c6fe199d98da15701f1d92c7c2e88..ebc2ef5a3f1858c1d614ee04b1c2da5213407b0e 100644 (file)
@@ -217,7 +217,7 @@ function FILTER_UPDATE_USER_SUBID ($filterData) {
                        ), __FUNCTION__, __LINE__);
 
                // Add insert id for other filters
-               $filterData['insert_id'] = SQL_INSERTID();
+               $filterData['insert_id'] = SQL_INSERT_ID();
 
                // Register sub id in filter
                setSession('subid', $subId);
index c1e54c7c7de609f3f3dd569dc73e194c99ae71c9..073bf4a83778a994b26dee6fda32a9468d2f2d2d 100644 (file)
@@ -1268,7 +1268,7 @@ function FILTER_ADD_HISTORY_ENTRY ($filterData) {
                __FUNCTION__, __LINE__);
 
        // Remember insert id for other filters
-       $filterData['history_id'] = SQL_INSERTID();
+       $filterData['history_id'] = SQL_INSERT_ID();
 
        // Return data
        return $filterData;
index 8470a3a239eb2e7a8ad3fb77d7b07849db039426..857d2c41b2f14cb955a368691463ee88f9e9651f 100644 (file)
@@ -1128,15 +1128,8 @@ function getMessageFromErrorCode ($code) {
                        break;
 
                case getCode('URL_TIME_LOCK'):
-                       // @TODO Move this SQL code into a function, let's say 'getTimestampFromPoolId($id) ?
-                       $result = SQL_QUERY_ESC("SELECT `timestamp` FROM `{?_MYSQL_PREFIX?}_pool` WHERE `id`=%s LIMIT 1",
-                               array(bigintval(getRequestElement('id'))), __FUNCTION__, __LINE__);
-
                        // Load timestamp from last order
-                       $content = SQL_FETCHARRAY($result);
-
-                       // Free memory
-                       SQL_FREERESULT($result);
+                       $content = getPoolDataFromId(getRequestElement('id'));
 
                        // Translate it for templates
                        $content['timestamp'] = generateDateTime($content['timestamp'], 1);
index 8ea3dd0334f13b6ecadb2e1d2af6178fe9384734..bafbdeac2ad0164ab7840751dc2ee825010364c0 100644 (file)
@@ -103,7 +103,6 @@ addMessages(array(
        'MEMBER_BONUS_STATS_SUBJECT' => "Ihr Aktiv-Bonus wegen 100% Klickrate",
        'MEMBER_BONUS_LOGIN_BONUS_ADDED' => "Login-Bonus mit <strong>{%config,translateComma=login_bonus%} {?POINTS?}</strong> verg&uuml;tet.",
        'MEMBER_BONUS_LOGIN_BONUS_NOT_ADDED' => "Login-Bonus nicht verg&uuml;tet.",
-       'ADMIN_LIST_UNCONFIRMED_BONUS_LINKS' => "Unbest. Bonus-Mail",
        'ADMIN_BONUS_MAIL_ALREADY_DELETED' => "Bonus-Mail bereits gel&ouml;scht.",
        'ADMIN_CONFIG_BONUS_RALLYE_TITLE' => "Einstellungen an der Aktiv-Rallye",
        'ADMIN_TOTAL_MEMBER_BONUS' => "Gesamtbonus aller teilnehmenden Mitglieder",
index a1bb9a79f74048f3cf3d1fd00acc67111eb89349..11310fad883104c67096a055280e35b31829c210 100644 (file)
@@ -113,7 +113,7 @@ function insertMemberEarning ($earningId, $dailyAmount, $isActive = 'Y') {
 
        // Prepare content
        $content = array(
-               'insert_id'    => SQL_INSERTID(),
+               'insert_id'    => SQL_INSERT_ID(),
                'earning_id'   => bigintval($earningId),
                'daily_amount' => bigintval($dailyAmount),
                'is_active'    => $isActive
index 405d557a35fe9cc288ea4f2e043a5de1908d80fa..a8155e78812e7f39c481e650439ac518f8882e20 100644 (file)
@@ -1827,7 +1827,7 @@ function doAdminNetworkProcessAddNetwork () {
        SQL_QUERY(getInsertSqlFromArray(postRequestArray(), 'network_data'), __FUNCTION__, __LINE__);
 
        // Add the id for output only
-       setPostRequestElement('network_id', SQL_INSERTID());
+       setPostRequestElement('network_id', SQL_INSERT_ID());
 
        // Output message
        if (!SQL_HASZEROAFFECTED()) {
index 2231732d842ac7a1c7e88ec3928da7513316cf7d..2d6c8e719eb6647449807a168632aa4dad4910ca 100644 (file)
@@ -381,7 +381,7 @@ function doUserRegistration () {
        ), __FUNCTION__, __LINE__);
 
        // Get his userid
-       $filterData['register_insert_id'] = bigintval(SQL_INSERTID());
+       $filterData['register_insert_id'] = SQL_INSERT_ID();
 
        // Did this work?
        if (!isValidId($filterData['register_insert_id'])) {
index b4c4982b90bb043ccaddc2e0118595bf18879052..4eee54dc4f965cebd97578528c943fdb6395e285 100644 (file)
@@ -728,8 +728,8 @@ function insertSurfbarUrlByArray ($urlData) {
                ), __FUNCTION__, __LINE__
        );
 
-       // Return insert id
-       return SQL_INSERTID();
+       // Return secured insert id
+       return SQL_INSERT_ID();
 }
 
 // Notify admin(s) with a selected message and content
@@ -953,18 +953,18 @@ function isSurfbarReloadFull () {
 
        // Ask the database
        $result = SQL_QUERY_ESC("SELECT
-       COUNT(l.`locks_id`) AS `cnt`
+       COUNT(`l`.`locks_id`) AS `cnt`
 FROM
        `{?_MYSQL_PREFIX?}_surfbar_locks` AS `l`
 INNER JOIN
        `{?_MYSQL_PREFIX?}_surfbar_urls` AS `u`
 ON
-       `u`.`url_id`=l.`locks_url_id`
+       `u`.`url_id`=`l`.`locks_url_id`
 WHERE
-       l.`locks_userid`=%s AND
-       (UNIX_TIMESTAMP() - {%%pipe,getSurfbarSurfLock%%}) < UNIX_TIMESTAMP(l.`locks_last_surfed`) AND
+       `l`.`locks_userid`=%s AND
+       (UNIX_TIMESTAMP() - {%%pipe,getSurfbarSurfLock%%}) < UNIX_TIMESTAMP(`l`.`locks_last_surfed`) AND
        (
-               ((UNIX_TIMESTAMP(l.`locks_last_surfed`) - `u`.`url_fixed_reload`) < 0 AND `u`.`url_fixed_reload` > 0) OR
+               ((UNIX_TIMESTAMP(`l`.`locks_last_surfed`) - `u`.`url_fixed_reload`) < 0 AND `u`.`url_fixed_reload` > 0) OR
                `u`.`url_fixed_reload` = 0
        )
 LIMIT 1",
@@ -1616,7 +1616,7 @@ ON
 LEFT JOIN
        `{?_MYSQL_PREFIX?}_surfbar_locks` AS `l`
 ON
-       `sbu`.`url_id`=l.`locks_url_id`
+       `sbu`.`url_id`=`l`.`locks_url_id`
 WHERE
        `sbu`.`url_userid` NOT IN (" . implode(',', $userids) . ") AND
        (`sbu`.`url_views_allowed`=0 OR (`sbu`.`url_views_allowed` > 0 AND `sbu`.`url_views_max` > 0)) AND
@@ -1771,7 +1771,7 @@ function determineSurfbarNextId ($urlId = NULL) {
        `sbu`.`url_views_total`,
        `sbu`.`url_views_max`,
        `sbu`.`url_views_allowed`,
-       UNIX_TIMESTAMP(l.`locks_last_surfed`) AS `last_surfed`,
+       UNIX_TIMESTAMP(`l`.`locks_last_surfed`) AS `last_surfed`,
        `sbu`.`url_fixed_reload`
 FROM
        `{?_MYSQL_PREFIX?}_surfbar_urls` AS `sbu`
@@ -1782,7 +1782,7 @@ ON
 LEFT JOIN
        `{?_MYSQL_PREFIX?}_surfbar_locks` AS `l`
 ON
-       `sbu`.`url_id`=l.`locks_url_id`
+       `sbu`.`url_id`=`l`.`locks_url_id`
 WHERE
        (`sbu`.`url_userid` NOT IN (" . implode(',', $userids['url_userid']) . ") OR `sbu`.`url_userid` IS NULL) AND
        `sbu`.`url_status`='ACTIVE' AND
@@ -1791,7 +1791,7 @@ WHERE
 GROUP BY
        `sbu`.`url_id`
 ORDER BY
-       l.`locks_last_surfed` ASC,
+       `l`.`locks_last_surfed` ASC,
        `sbu`.`url_id` ASC
 LIMIT %s,1",
                        array($randNum), __FUNCTION__, __LINE__
@@ -1807,7 +1807,7 @@ LIMIT %s,1",
        `sbu`.`url_views_total`,
        `sbu`.`url_views_max`,
        `sbu`.`url_views_allowed`,
-       UNIX_TIMESTAMP(l.`locks_last_surfed`) AS `last_surfed`,
+       UNIX_TIMESTAMP(`l`.`locks_last_surfed`) AS `last_surfed`,
        `sbu`.`url_fixed_reload`
 FROM
        `{?_MYSQL_PREFIX?}_surfbar_urls` AS `sbu`
@@ -1818,7 +1818,7 @@ ON
 LEFT JOIN
        `{?_MYSQL_PREFIX?}_surfbar_locks` AS `l`
 ON
-       `sbu`.`url_id`=l.`locks_url_id`
+       `sbu`.`url_id`=`l`.`locks_url_id`
 WHERE
        (`sbu`.`url_userid` != %s OR `sbu`.`url_userid` IS NULL) AND
        `sbu`.`url_status`='ACTIVE' AND
index b4662eaa82ee3177e07a90813a2b3bd4772a3a1b..6779f604dbb3a2ae93bc6ca0816e872e79772de7 100644 (file)
@@ -96,7 +96,7 @@ if (isFormSent()) {
                        ), __FILE__, __LINE__);
 
                // Load id
-               $id = SQL_INSERTID();
+               $id = SQL_INSERT_ID();
 
                if (!empty($id)) {
                        // Reload to prices...
index f3c938ba991545f90a5e7ca561e8c3926c25e780..e1f325c56435d3a65b0b8fafa9774d11d8927bef 100644 (file)
@@ -48,49 +48,9 @@ if ((isFormSent()) && (!isPostRequestElementSet('id'))) {
 } // END - if
 
 // Form sent or anything else? ;-)
-if ((isFormSent()) && (isPostRequestElementSet('id')) && (isGetRequestElementSet('type')) && (postRequestElement('type') == 'normal')) {
-       // Make mail editable...
-       $result = SQL_QUERY_ESC('SELECT
-       `id`,
-       `sender` AS `userid`,
-       `subject`,
-       `text`,
-       `url`
-FROM
-       `{?_MYSQL_PREFIX?}_pool`
-WHERE
-       `id`=%s
-LIMIT 1',
-               array(bigintval(postRequestElement('id'))), __FILE__, __LINE__);
-
-       // Fetch row
-       $content = SQL_FETCHARRAY($result);
-
-       // Free result
-       SQL_FREERESULT($result);
-
-       // Load template
-       loadTemplate('admin_edit_email', FALSE, $content);
-} elseif ((isPostRequestElementSet('id')) && (isGetRequestElementSet('type')) && (postRequestElement('type') == 'normal')) {
-       // Make also this email editable
-       $result = SQL_QUERY_ESC('SELECT
-       `id`,
-       `sender` AS `userid`,
-       `subject`,
-       `text`,
-       `url`
-FROM
-       `{?_MYSQL_PREFIX?}_pool`
-WHERE
-       `id`=%s
-LIMIT 1',
-               array(bigintval(getRequestElement('id'))), __FILE__, __LINE__);
-
-       // Fetch row
-       $content = SQL_FETCHARRAY($result);
-
-       // Free result
-       SQL_FREERESULT($result);
+if ((isFormSent('edit')) && (isPostRequestElementSet('id')) && (isGetRequestElementSet('type')) && (postRequestElement('type') == 'normal')) {
+       // Get data
+       $content = getPoolDataFromId(postRequestElement('id'));
 
        // Load template
        loadTemplate('admin_edit_email', FALSE, $content);
@@ -120,23 +80,8 @@ LIMIT 1',
        // Save changes
        if ((isPostRequestElementSet('id')) && (isGetRequestElementSet('type')) && (postRequestElement('type') == 'normal')) {
                // Update pool
-               SQL_QUERY_ESC("UPDATE
-       `{?_MYSQL_PREFIX?}_pool`
-SET
-       `subject`='%s',
-       `text`='%s',
-       `url`='%s'
-WHERE
-       `id`=%s
-LIMIT 1",
-                       array(
-                               postRequestElement('subject'),
-                               postRequestElement('text'),
-                               postRequestElement('url'),
-                               bigintval(postRequestElement('id')),
-                       ), __FILE__, __LINE__);
-
-               if (!SQL_HASZEROAFFECTED()) {
+               $isUpdated = updatePoolDataById(postRequestElement('id'), NULL, array('subject' => postRequestElement('subject'), 'text' => postRequestElement('text'), 'url' => postRequestElemenet('url')));
+               if ($isUpdated === TRUE) {
                        $content = '{--ADMIN_EMAIL_CHANGES_SAVED--}';
                } else {
                        $content = '<span class="bad">{--ADMIN_EMAIL_CHANGES_NOT_SAVED--}</span>';
@@ -175,13 +120,14 @@ LIMIT 1",
        // Query the pool
        $result = SQL_QUERY('SELECT
        `id`,
-       `sender` AS `userid`,
+       `sender`,
        `subject`,
        `payment_id`,
        `cat_id`
 FROM
        `{?_MYSQL_PREFIX?}_pool`
 ORDER BY
+       `sender` ASC,
        `timestamp` ASC', __FILE__, __LINE__);
 
        // Entries found?
index aec2a6935d7099b7b088dde969a9fa9b177ec6bc..48d905bc168bfcb5630c3bf5baa1b6a5ccda92ea 100644 (file)
@@ -72,7 +72,7 @@ LEFT JOIN
 ON
        `p`.`id`=`s`.`pool_id`
 WHERE
-       `p`.`id`=%s
+       `s`.`pool_id`=%s
 LIMIT 1",
                bigintval(getRequestElement('id'))
        );
@@ -86,13 +86,10 @@ LIMIT 1",
        $listed = TRUE;
        $DATA = getRequestElement('id');
 } elseif (((isPostRequestElementSet('id')) && (isGetRequestElementSet('type')) && (postRequestElement('type') == 'bonus')) && (isExtensionActive('bonus'))) {
-       // @TODO This constant might be unused? define('__LIST_UNCON_TITLE', '{--ADMIN_LIST_UNCONFIRMED_BONUS_LINKS--}');
-
        // SQL query for mail data (both ids are required for compatiblity to above normal mail
-       // @TODO `id` has been used two times???
        $sql = sprintf("SELECT
        `id`,
-       `id` AS `sender`,
+       NULL AS `sender`,
        `subject`,
        `text`,
        `url`,
@@ -143,7 +140,7 @@ if (($listed === TRUE) && (!empty($sql))) {
                // but it does only show unconfirmed mail links from existing user
                // accounts. So if you have delete one you did not see those links
                $result = SQL_QUERY_ESC("SELECT
-       l.`userid`,
+       `l`.`userid`,
        `u`.`status`,
        `u`.`surname`,
        `u`.`family`,
@@ -154,11 +151,11 @@ FROM
 LEFT JOIN
        `{?_MYSQL_PREFIX?}_user_data` AS `u`
 ON
-       l.`userid`=`u`.`userid`
+       `l`.`userid`=`u`.`userid`
 WHERE
-       l.`%s`=%s
+       `l`.`%s`=%s
 ORDER BY
-       l.`userid` ASC
+       `l`.`userid` ASC
 LIMIT %s",
                        array(
                                $col,
index 5d8ec24a8254d25303bb63603161de92747f47bd..90c6ce402372772461a2628eba497892b70cf430 100644 (file)
@@ -82,7 +82,7 @@ ORDER BY
                        );
 
                        // Get the insert id from the table
-                       $couponId = SQL_INSERTID();
+                       $couponId = SQL_INSERT_ID();
 
                        // Init userid array
                        $adminUserids = array();
index 38c953be9906c1a25073a9a6caba076e9279b7e1..a084b89e4a183d00f3de18ee64636fefff2e7cc4 100644 (file)
@@ -94,8 +94,11 @@ LIMIT 1",
        SQL_FREERESULT($result);
 
        if ($data['data_type'] == 'TEMP') {
-               // No entry found, so we need to check out the stats table as well... :)
-               // We have to add that suff here, now we continue WITHOUT checking and check the text and subject against some filters
+               /*
+                * No entry found, so we need to check out the stats table as well...
+                * :) We have to add that suff here, now we continue WITHOUT checking
+                * and check the text and subject against some filters
+                */
                $data['url'] = '';
                if (getConfig('allow_url_in_text') == 'Y') {
                        // Test submitted text against some filters (length, URLs in text etc.)
@@ -257,163 +260,58 @@ LIMIT 1",
                        if (($usedPoints > 0) && ($usedPoints <= $totalPoints) && ($content['target_send'] > 0)) {
                                // Gettings points is okay, so we can add $usedPoints later from
                                if ((!isValidId($data['id'])) || ($data['data_type'] != 'TEMP')) {
-                                       // New order
-                                       $data['id'] = '0';
+                                       // New order, init data array elements
+                                       $data = array(
+                                               'sender'      => getMemberId(),
+                                               'subject'     => postRequestElement('subject'),
+                                               'text'        => postRequestElement('text'),
+                                               'receivers'   => $receiver
+                                               'payment_id'  => bigintval(postRequestElement('mail_type')),
+                                               'data_type'   => 'TEMP',
+                                               'timestamp'   => 'UNIX_TIMESTAMP()',
+                                               'url'         => postRequestElement('url'),
+                                               'cat_id'      => bigintval(postRequestElement('cat')),
+                                               'target_send' => bigintval($content['target_send']),
+                                               'zip'         => bigintval(postRequestElement('zip'), TRUE, FALSE),
+                                       );
+
+                                       // Is ext-html_mail active?
                                        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',
-       UNIX_TIMESTAMP(),
-       '%s',
-       %s,
-       %s,
-       %s,
-       '%s'
-)",
-                                                       array(
-                                                               getMemberId(),
-                                                               postRequestElement('subject'),
-                                                               postRequestElement('text'),
-                                                               $receiver,
-                                                               bigintval(postRequestElement('mail_type')),
-                                                               postRequestElement('url'),
-                                                               bigintval(postRequestElement('cat')),
-                                                               bigintval($content['target_send']),
-                                                               bigintval(postRequestElement('zip'), TRUE, FALSE),
-                                                               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',
-       UNIX_TIMESTAMP(),
-       '%s',
-       %s,
-       %s,
-       %s
-)",
-                                                       array(
-                                                               getMemberId(),
-                                                               postRequestElement('subject'),
-                                                               postRequestElement('text'),
-                                                               $receiver,
-                                                               bigintval(postRequestElement('mail_type')),
-                                                               postRequestElement('url'),
-                                                               bigintval(postRequestElement('cat')),
-                                                               bigintval($content['target_send']),
-                                                               bigintval(postRequestElement('zip'), TRUE, FALSE),
-                                                       ), __FILE__, __LINE__);
-                                       }
+                                               $data['html_msg'] = postRequestElement('html');
+                                       } // END - if
 
                                        // Get insert id
-                                       $data['id'] = SQL_INSERTID();
+                                       $data['id'] = insertDataIntoPool($data);
                                } else {
-                                       // Change current order
+                                       // Update this data
+                                       $data = array(
+                                               'subject'     => postRequestElement('subject'),
+                                               'text'        => postRequestElement('text'),
+                                               'receivers'   => $receiver
+                                               'payment_id'  => bigintval(postRequestElement('mail_type')),
+                                               'timestamp'   => 'UNIX_TIMESTAMP()',
+                                               'url'         => postRequestElement('url'),
+                                               'cat_id'      => bigintval(postRequestElement('cat')),
+                                               'target_send' => bigintval($content['target_send']),
+                                               'zip'         => bigintval(postRequestElement('zip'), TRUE, FALSE),
+                                       );
+
+                                       // Is ext-html_mail active?
                                        if (isExtensionActive('html_mail')) {
                                                // HTML extension is active
-                                               SQL_QUERY_ESC("UPDATE
-       `{?_MYSQL_PREFIX?}_pool`
-SET
-       `subject`='%s',
-       `text`='%s',
-       `receivers`='%s',
-       `payment_id`=%s,
-       `timestamp`=UNIX_TIMESTAMP(),
-       `url`='%s',
-       `cat_id`=%s,
-       `target_send`=%s,
-       `zip`=%s,
-       `html_msg`='%s'
-WHERE
-       `id`=%s
-LIMIT 1",
-                                                       array(
-                                                               postRequestElement('subject'),
-                                                               postRequestElement('text'),
-                                                               $receiver,
-                                                               bigintval(postRequestElement('mail_type')),
-                                                               postRequestElement('url'),
-                                                               bigintval(postRequestElement('cat')),
-                                                               $content['target_send'],
-                                                               bigintval(postRequestElement('zip')),
-                                                               postRequestElement('html'),
-                                                               bigintval($data['id'])
-                                                       ), __FILE__, __LINE__);
-                                       } else {
-                                               // No HTML extension is active
-                                               SQL_QUERY_ESC("UPDATE
-       `{?_MYSQL_PREFIX?}_pool`
-SET
-       `subject`='%s',
-       `text`='%s',
-       `receivers`='%s',
-       `payment_id`=%s,
-       `timestamp`=UNIX_TIMESTAMP(),
-       `url`='%s',
-       `cat_id`=%s,
-       `target_send`=%s,
-       `zip`=%s
-WHERE
-       `id`=%s
-LIMIT 1",
-                                                       array(
-                                                               postRequestElement('subject'),
-                                                               postRequestElement('text'),
-                                                               $receiver,
-                                                               bigintval(postRequestElement('mail_type')),
-                                                               postRequestElement('url'),
-                                                               bigintval(postRequestElement('cat')),
-                                                               $content['target_send'],
-                                                               bigintval(postRequestElement('zip')),
-                                                               bigintval($data['id'])
-                                                       ), __FILE__, __LINE__);
-                                       }
+                                               $data['html_msg'] = postRequestElement('html');
+                                       } // END - if
+
+                                       // Update pool data
+                                       updatePoolDataById($data['id'], NULL, $data);
                                }
 
                                // Make sure only valid id numbers can pass
                                assert(isValidId($data['id']));
 
                                // Id is received so we can redirect the user, used points will be added when he send's out the mail
-                               $data['url'] = 'modules.php?module=frametester&amp;order=' . $data['id'];
+                               $data['url'] = 'modules.php?module=frametester&amp;order=' . bigintval($data['id']);
                        } elseif ($content['target_send'] == '0') {
                                // Not enougth receivers found which can receive mails
                                $data['url'] = 'modules.php?module=login&amp;what=order&amp;code=' . getCode('MORE_RECEIVERS2');
index 34515878f862b59cbd8472f2f3639432aff8da15..2b2810191d86f1c7111f0251602bacd687f52a88 100644 (file)
@@ -103,30 +103,24 @@ LIMIT 1',
 } elseif (isGetRequestElementSet('mailid')) {
        // Display regular member mail by loading its full data
        $result_data = SQL_QUERY_ESC("SELECT
-       `s`.`id`,
-       `s`.`subject`,
-       `p`.`text`,
-       `s`.`timestamp_ordered` AS `timestamp`,
-       `s`.`cat_id`,
-       `p`.`payment_id`,
-       `p`.`sender`,
-       `p`.`data_type`
+       `id` AS `stats_id`,
+       `pool_id`,
+       `subject`,
+       `timestamp_ordered`,
+       `cat_id`,
 FROM
        `{?_MYSQL_PREFIX?}_user_stats` AS `s`
-LEFT JOIN
-       `{?_MYSQL_PREFIX?}_pool` AS `p`
-ON
-       s.pool_id=p.id
 WHERE
-       `s`.`id`=%s
+       `id`=%s
 LIMIT 1",
                array(bigintval(getRequestElement('mailid'))), __FILE__, __LINE__);
 
        // Load data
        $content = SQL_FETCHARRAY($result_data);
+       $content = merge_array($content, getPoolDataFromId($content['pool_id']));
 
        // Translate some data
-       $content['timestamp'] = generateDateTime($content['timestamp'], '2');
+       $content['timestamp_ordered'] = generateDateTime($content['timestamp_ordered'], '2');
        // @TODO This call cannot be saved as EL code cannot be "framed" in other EL code
        $content['userid'] = getMemberId();
        $content['user_mail_status'] = '{%message,MEMBER_MAIL_NORMAL_CONFIRMED_UNKNOWN=' . $content['id'] . '%}';
index d42cd4ecdce94b2af26066db9c3c08e7d7989076..28ba603cfe196063e7e2302e87b53ce23212ba87 100644 (file)
@@ -1891,7 +1891,7 @@ function createNewTask ($subject, $notes, $taskType, $userid = NULL, $adminId =
                ), __FUNCTION__, __LINE__, TRUE, $strip);
 
        // Return insert id which is the task id
-       return SQL_INSERTID();
+       return SQL_INSERT_ID();
 }
 
 // Updates last module / online time
@@ -2128,14 +2128,14 @@ function doGenericAddEntries ($tableName, $columns = array(), $filterFunctions =
                SQL_QUERY($sql, __FUNCTION__, __LINE__);
 
                // Add id number
-               setPostRequestElement('id', SQL_INSERTID());
+               setPostRequestElement('id', SQL_INSERT_ID());
 
                // Prepare filter data array
                $filterData = array(
                        'mode'          => 'add',
                        'table_name'    => $tableName,
                        'content'       => postRequestArray(),
-                       'id'            => SQL_INSERTID(),
+                       'id'            => SQL_INSERT_ID(),
                        'subject'       => '',
                        // @TODO Used generic 'userid' here
                        'userid_column' => array('userid'),
index 81a303eea527037197153eebb00cb08ec5ab1cde..b183001d23e4c50a2e92dda1dced98d9d6f4ad6a 100644 (file)
@@ -126,5 +126,17 @@ function updatePoolDataById ($poolId, $columnName, $data, $updateMode = NULL, $w
        return (SQL_AFFECTEDROWS() == 1);
 }
 
+// Insert data into pool and return its insert id
+function insertDataIntoPool ($data) {
+       // Construct SQL query
+       $sql = 'INSERT INTO `{?_MYSQL_PREFIX?}_pool (`' . implode('`,`', array_map('SQL_ESCAPE', array_keys($data))) . "`) VALUES ('" . implode("','", array_values($data)) . "')";
+
+       // Run the query
+       SQL_QUERY($sql, __FUNCTION__, __LINE__);
+
+       // Return insert id
+       return SQL_INSERT_ID();
+}
+
 // [EOF]
 ?>
index 75754f5c37cea22f8635d37ef881b71f153b4a79..2d50c2597f726e0abff9f990ea4d0de220ab863e 100644 (file)
@@ -6,7 +6,7 @@
        <td class="{%template,ColorSwitch%} bottom">
                $content[subject]
                ({--EMAIL_SENDER--}:
-               {%pipe,generateUserProfileLink=$content[userid]%};
+               {%pipe,generateUserProfileLink=$content[sender]%};
                {%pipe,getPaymentTitlePrice=$content[payment_id]%};
                {%pipe,getCategory=$content[cat_id]%})
        </td>
index 1f1e50b65b7e14acc6d78d5f4268a59c980a5849..e8043c3425603f884e8bc7a6637b3bee126c5a83 100644 (file)
@@ -37,7 +37,7 @@
 <tr>
        <td align="center" class="switch_sw1 bottom right">{--EMAIL_TIMESTAMP--}:</td>
        <td align="center" class="switch_sw1 bottom">
-               $content[timestamp]
+               $content[timestamp_ordered]
        </td>
 </tr>
 <tr>
index 35bba3525cc54cd03f1fd7ea8b86451f56aca338..15b10113ff202814b0ddb5472f1e9427d0f45346 100644 (file)
@@ -36,7 +36,7 @@
 <tr>
        <td align="center" class="switch_sw1 bottom right">{--EMAIL_TIMESTAMP--}:</td>
        <td align="center" class="switch_sw1 bottom">
-               $content[timestamp]
+               $content[timestamp_ordered]
        </td>
 </tr>
 <tr>
index bef3acb3eff232b922e6cef6315c4b2d890cb56d..d6025a364e87155783788142ebc31cbcb98caf2e 100644 (file)
@@ -36,7 +36,7 @@
 <tr>
        <td align="center" class="switch_sw1 bottom right">{--EMAIL_TIMESTAMP--}:</td>
        <td align="center" class="switch_sw1 bottom">
-               $content[timestamp]
+               $content[timestamp_ordered]
        </td>
 </tr>
 <tr>
index 3a20cb0d6034407b9ecff7192df311e0abc4bbc2..0ad3b9c0bb64b0a07965cc076179f856223c564f 100644 (file)
@@ -36,7 +36,7 @@
 <tr>
        <td align="center" class="switch_sw1 bottom right">{--EMAIL_TIMESTAMP--}:</td>
        <td align="center" class="switch_sw1 bottom">
-               $content[timestamp]
+               $content[timestamp_ordered]
        </td>
 </tr>
 <tr>
index 0609c6242f4281ea0dd7abe3cdf2d1b2ee568b95..8a7393da214290da3daf0156152eab45f530cdcd 100644 (file)
@@ -38,7 +38,7 @@
 <tr>
        <td align="center" class="switch_sw1 bottom right">{--EMAIL_TIMESTAMP--}:</td>
        <td align="center" class="switch_sw1 bottom">
-               $content[timestamp]
+               $content[timestamp_ordered]
        </td>
 </tr>
 <tr>
index 863cd8438f2455342a412e3cc86d07be1c07d021..6264dbd2c9e9320477e294476ed6650dd04fb38b 100644 (file)
@@ -36,7 +36,7 @@
 <tr>
        <td align="center" class="switch_sw1 bottom right">{--EMAIL_TIMESTAMP--}:</td>
        <td align="center" class="switch_sw1 bottom">
-               $content[timestamp]
+               $content[timestamp_ordered]
        </td>
 </tr>
 <tr>