New naming convention applied to many functions, see #118 for details
[mailer.git] / inc / modules / member / what-order.php
index 1b29ed347c1276cc936f7c1a0dadfef2bd4f100d..0f1f3f6169feb083501a3d80e345bd81059181c6 100644 (file)
@@ -41,7 +41,7 @@ if (!defined('__SECURITY')) {
        $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
        require($INC);
 } elseif (!IS_MEMBER()) {
-       LOAD_URL('modules.php?module=index');
+       redirectToUrl('modules.php?module=index');
 } elseif ((!EXT_IS_ACTIVE('order')) && (!IS_ADMIN())) {
        addFatalMessage(__FILE__, __LINE__, sprintf(getMessage('EXTENSION_PROBLEM_EXT_INACTIVE'), 'order'));
        return;
@@ -166,7 +166,7 @@ WHERE sender=%s AND url='%s' AND timestamp > (UNIX_TIMESTAMP() - %s) LIMIT 1",
                } // END - if
 
                // Validate URL
-               if (!VALIDATE_URL(REQUEST_POST('url'))) {
+               if (!isUrlValid(REQUEST_POST('url'))) {
                        // URL is invalid!
                        $URL = 'modules.php?module=login&what=order&msg=' . getCode('INVALID_URL');
                } // END - if
@@ -226,7 +226,7 @@ ORDER BY d.%s %s",
                        while ($content = SQL_FETCHARRAY($result)) {
                                if ($HOLIDAY) {
                                        // Check for his holiday status
-                                       $result_holiday = SQL_QUERY_ESC("SELECT id FROM `{!_MYSQL_PREFIX!}_user_holidays`
+                                       $result_holiday = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_user_holidays`
 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
@@ -259,16 +259,16 @@ WHERE userid=%s AND holiday_start < UNIX_TIMESTAMP() AND holiday_end > UNIX_TIME
                        if ($MAX_SEND > REQUEST_POST('receiver')) $MAX_SEND = REQUEST_POST('receiver');
 
                        // Calculate used points
-                       $USED = $MAX_SEND * GET_PAY_POINTS(bigintval(REQUEST_POST('type')));
+                       $USED = $MAX_SEND * getPaymentPoints(bigintval(REQUEST_POST('type')));
 
                        // Fix empty zip code
-                       if (!REQUEST_ISSET_POST('zip')) REQUEST_SET_POST('zip', "0");
+                       if (!REQUEST_ISSET_POST('zip')) REQUEST_SET_POST('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)) {
                                // Gettings points is okay, so we can add $USED later from
                                $TIME = time();
-                               if (($id == "0") || ($type != "TEMP")) {
+                               if (($id == '0') || ($type != "TEMP")) {
                                        // New order
                                        $id = 0;
                                        if (EXT_IS_ACTIVE('html_mail')) {
@@ -320,7 +320,7 @@ cat_id=%s,
 target_send=%s,
 zip=%s,
 html_msg='%s'
-WHERE id=%s LIMIT 1",
+WHERE `id`=%s LIMIT 1",
 array(
        REQUEST_POST('subject'),
        REQUEST_POST('text'),
@@ -345,7 +345,7 @@ url='%s',
 cat_id=%s,
 target_send=%s,
 zip=%s
-WHERE id=%s LIMIT 1",
+WHERE `id`=%s LIMIT 1",
 array(
        REQUEST_POST('subject'),
        REQUEST_POST('text'),
@@ -363,7 +363,7 @@ array(
                                // 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=%s LIMIT 1",
                                        array(
                                                getUserId(),
                                                REQUEST_POST('subject'),
@@ -422,7 +422,7 @@ array(
                                $CATS['name'][] = $content['cat'];
 
                                // Select users in current category
-                               $result_uids = SQL_QUERY_ESC("SELECT userid FROM `{!_MYSQL_PREFIX!}_user_cats` WHERE cat_id=%s AND userid != '%s' ORDER BY userid",
+                               $result_uids = 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__);
 
                                $uid_cnt = 0;
@@ -483,12 +483,12 @@ LIMIT 1", array(bigintval($ucat)), __FILE__, __LINE__);
                                switch (REQUEST_GET('msg'))
                                {
                                case getCode('URL_TLOCK'):
-                                       $result = SQL_QUERY_ESC("SELECT timestamp FROM `{!_MYSQL_PREFIX!}_pool` WHERE id=%s LIMIT 1",
+                                       $result = SQL_QUERY_ESC("SELECT timestamp FROM `{!_MYSQL_PREFIX!}_pool` WHERE `id`=%s LIMIT 1",
                                         array(bigintval(REQUEST_GET('id'))), __FILE__, __LINE__);
 
                                        // Load timestamp from last order
                                        list($LORDER) = SQL_FETCHROW($result);
-                                       $LORDER = MAKE_DATETIME($LORDER, "1");
+                                       $LORDER = generateDateTime($LORDER, "1");
 
                                        // Free memory
                                        SQL_FREERESULT($result);
@@ -522,7 +522,7 @@ LIMIT 1", array(bigintval($ucat)), __FILE__, __LINE__);
                                        break;
 
                                case getCode('BLIST_URL'):
-                                       $message = "{--MEMBER_URL_BLACK_LISTED--}<br />\n{--MEMBER_BLIST_TIME--}: ".MAKE_DATETIME(REQUEST_GET('blist'), "0");
+                                       $message = "{--MEMBER_URL_BLACK_LISTED--}<br />\n{--MEMBER_BLIST_TIME--}: ".generateDateTime(REQUEST_GET('blist'), '0');
                                        break;
 
                                case getCode('NO_RECS_LEFT'):
@@ -576,7 +576,7 @@ LIMIT 1", array(bigintval($ucat)), __FILE__, __LINE__);
                                SQL_FREERESULT($result);
 
                                // Output user's points
-                               $total = TRANSLATE_COMMA($total);
+                               $total = translateComma($total);
 
                                // Check how many mail orders he has placed today and how many he's allowed to send
                                switch (getConfig('order_max_full'))
@@ -622,7 +622,6 @@ LIMIT 1", array(bigintval($ucat)), __FILE__, __LINE__);
                                // Free result
                                SQL_FREERESULT($result);
 
-                               // 01      2              21    12                                    2    23         443    3          3210
                                if ((REQUEST_ISSET_POST(('data'))) || ((getConfig('order_multi_page') != 'Y') && ((!IS_ADMIN()) && (!EXT_IS_ACTIVE('html_mail'))))) {
                                        // Pre-output categories
                                        $CAT = '';
@@ -635,7 +634,7 @@ LIMIT 1", array(bigintval($ucat)), __FILE__, __LINE__);
                                        // Mail type
                                        $type = '';
                                        foreach ($typeS as $key => $value) {
-                                               $P = TRANSLATE_COMMA($typeS[$key][1]);
+                                               $P = translateComma($typeS[$key][1]);
                                                if (is_array($value)) {
                                                        // Output option line
                                                        $type .= "      <option value=\"".$typeS[$key][0]."\"";
@@ -717,7 +716,7 @@ LIMIT 1", array(bigintval($ucat)), __FILE__, __LINE__);
                // No cateogries are defined yet
                LOAD_TEMPLATE('admin_settings_saved', false, "<span class=\"member_failed\">{--MEMBER_NO_CATS--}</span>");
        }
-} elseif ($mmails == "0") {
+} elseif ($mmails == '0') {
        // Please set more than 0 mails per day
        LOAD_TEMPLATE('admin_settings_saved', false, getMessage('MEMBER_HAS_ZERO_MMAILS'));
 } else {
@@ -727,7 +726,7 @@ LIMIT 1", array(bigintval($ucat)), __FILE__, __LINE__);
 
 if (!empty($URL)) {
        // Redirect to requested URL
-       LOAD_URL($URL);
+       redirectToUrl($URL);
 } // END - if
 
 //