New naming convention applied to many functions, see #118 for details
[mailer.git] / inc / modules / member / what-payout.php
index 84d5483cd2d477f0c09d97b85bb351b955f44e24..4eb6016eda609d4b49c727cf6125ff7ae4fc9cfa 100644 (file)
@@ -43,7 +43,7 @@ if (!defined('__SECURITY')) {
        require($INC);
 } elseif (!IS_MEMBER()) {
        // Not logged in
-       LOAD_URL('modules.php?module=index');
+       redirectToUrl('modules.php?module=index');
 } elseif ((!EXT_IS_ACTIVE('payout')) && (!IS_ADMIN())) {
        addFatalMessage(__FILE__, __LINE__, sprintf(getMessage('EXTENSION_PROBLEM_EXT_INACTIVE'), 'payout'));
        return;
@@ -79,7 +79,7 @@ SQL_FREERESULT($result_depths);
 $USED = GET_TOTAL_DATA(getUserId(), "user_data", "used_points");
 
 // Translate point into comma
-$TPTS = TRANSLATE_COMMA($TPTS - $USED);
+$TPTS = translateComma($TPTS - $USED);
 
 // Sanity check...
 if (empty($TPTS)) $TPTS = "0.00000";
@@ -89,7 +89,8 @@ if (!REQUEST_ISSET_GET(('payout'))) {
        $result = SQL_QUERY_ESC("SELECT id, type, rate, min_points, allow_url
 FROM `{!_MYSQL_PREFIX!}_payout_types`
 WHERE %s >= min_points
-ORDER BY type", array(REVERT_COMMA($TPTS)), __FILE__, __LINE__);
+ORDER BY type ASC",
+               array(convertCommaToDot($TPTS)), __FILE__, __LINE__);
        if (SQL_NUMROWS($result) > 0) {
                // Free memory
                SQL_FREERESULT($result);
@@ -132,9 +133,9 @@ ORDER BY p.payout_timestamp DESC",
                                $content = array(
                                        'sw'     => $SW,
                                        'acc'    => $content['target_account'],
-                                       'points' => TRANSLATE_COMMA($content['payout_total'])." ".COMPILE_CODE($content['type']),
+                                       'points' => translateComma($content['payout_total'])." ".COMPILE_CODE($content['type']),
                                        'bank'   => $content['target_bank'],
-                                       'stamp'  => MAKE_DATETIME($content['payout_timestamp'], "2"),
+                                       'stamp'  => generateDateTime($content['payout_timestamp'], "2"),
                                        'status' => $content['status']
                                );
 
@@ -159,7 +160,7 @@ ORDER BY p.payout_timestamp DESC",
        }
 } else {
        // Chedk if he can get paid by selected type
-       $result = SQL_QUERY_ESC("SELECT type, rate, min_points, allow_url AS allow FROM `{!_MYSQL_PREFIX!}_payout_types` WHERE id=%s LIMIT 1",
+       $result = SQL_QUERY_ESC("SELECT type, rate, min_points, allow_url AS allow FROM `{!_MYSQL_PREFIX!}_payout_types` WHERE `id`=%s LIMIT 1",
                array(bigintval(REQUEST_GET('payout'))), __FILE__, __LINE__);
 
        if (SQL_NUMROWS($result) == 1) {
@@ -182,7 +183,7 @@ ORDER BY p.payout_timestamp DESC",
                define('PAYOUT_MAX_VALUE' , $max);
                define('PAYOUT_TYPE_VALUE', COMPILE_CODE($content['type']));
 
-               if (REVERT_COMMA($TPTS) >= $content['min_points']) {
+               if (convertCommaToDot($TPTS) >= $content['min_points']) {
                        // Ok, he can get be paid
                        if ((IS_FORM_SENT()) && ($PAYOUT <= $PAY_MAX) && ($PAYOUT >= $content['min_points'])) {
                                // Calculate exact value
@@ -230,8 +231,9 @@ VALUES (%s,%s,%s,'%s',%s, UNIX_TIMESTAMP(), 'NEW','%s')",
                                        $msg_mem = LOAD_EMAIL_TEMPLATE("member_payout_request", array(), getUserId());
                                        $msg_adm = LOAD_EMAIL_TEMPLATE("admin_payout_request", array(), getUserId());
                                        $admin_tpl = '';
-                                       if (GET_EXT_VERSION('admins') >= '0.4.1')
-                                       {
+
+                                       // @TODO Rewrite this to a filter
+                                       if (GET_EXT_VERSION('admins') >= '0.4.1') {
                                                $admin_tpl = "admin_payout_request";
                                        }
                                }
@@ -245,10 +247,10 @@ VALUES (0, 'NEW','PAYOUT_REQUEST','[payout:] {--PAYOUT_REQUEST_ADMIN--}','%s', U
 ), __FILE__, __LINE__);
 
                                // Send out mails
-                               SEND_EMAIL(getUserId(), getMessage('PAYOUT_REQUEST_MEMBER'), $msg_mem);
+                               sendEmail(getUserId(), getMessage('PAYOUT_REQUEST_MEMBER'), $msg_mem);
 
                                // To admin(s)
-                               SEND_ADMIN_NOTIFICATION(getMessage('PAYOUT_REQUEST_ADMIN'), $admin_tpl, array(), getUserId());
+                               sendAdminNotification(getMessage('PAYOUT_REQUEST_ADMIN'), $admin_tpl, array(), getUserId());
 
                                // Load template and output it
                                LOAD_TEMPLATE('admin_settings_saved', false, getMessage('PAYOUT_REQUEST_SENT'));