- Major change in LOAD_EMAIL_TEMPLATE(). The deprecated switch() block has
[mailer.git] / inc / mysql-manager.php
index e1df712..5d52c25 100644 (file)
@@ -728,7 +728,7 @@ function SEND_MODE_MAILS($mod, $modes)
                $hash = generatePassString($hashDB);
                if (($hash == get_session('u_hash')) || ($_POST['pass1'] == $_POST['pass2'])) {
                        // Load user's data
-                       $result = SQL_QUERY_ESC("SELECT sex, surname, family, street_nr, country, zip, city, email FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s AND password='%s' LIMIT 1",
+                       $result = SQL_QUERY_ESC("SELECT gender, surname, family, street_nr, country, zip, city, email FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s AND password='%s' LIMIT 1",
                         array($GLOBALS['userid'], $hashDB), __FILE__, __LINE__);
                        if (SQL_NUMROWS($result) == 1) {
                                // Load the data
@@ -737,8 +737,8 @@ function SEND_MODE_MAILS($mod, $modes)
                                // Free result
                                SQL_FREERESULT($result);
 
-                               // Translate salutation
-                               $DATA[0] = TRANSLATE_SEX($DATA[0]);
+                               // Translate gender
+                               $DATA[0] = TRANSLATE_GENDER($DATA[0]);
 
                                // Clear/init the content variable
                                $content = "";
@@ -910,16 +910,20 @@ function GET_CATEGORY ($cid) {
        // Default is not found
        $ret = _CATEGORY_404;
 
-       // Lookup the category
-       $result = SQL_QUERY_ESC("SELECT cat FROM "._MYSQL_PREFIX."_cats WHERE id=%s LIMIT 1",
-               array(bigintval($cid)), __FILE__, __LINE__);
-       if (SQL_NUMROWS($result) == 1) {
-               // Category found... :-)
-               list($ret) = SQL_FETCHROW($result);
-       } // END - if
+       // Is the category id set?
+       if (!empty($cid)) {
 
-       // Free result
-       SQL_FREERESULT($result);
+               // Lookup the category
+               $result = SQL_QUERY_ESC("SELECT cat FROM "._MYSQL_PREFIX."_cats WHERE id=%s LIMIT 1",
+                       array(bigintval($cid)), __FILE__, __LINE__);
+               if (SQL_NUMROWS($result) == 1) {
+                       // Category found... :-)
+                       list($ret) = SQL_FETCHROW($result);
+               } // END - if
+
+               // Free result
+               SQL_FREERESULT($result);
+       } // END - if
 
        // Return result
        return $ret;
@@ -1121,9 +1125,16 @@ function ADD_POINTS_REFSYSTEM($uid, $points, $send_notify=false, $rid="0", $lock
 
                        // Points updated, maybe I shall send him an email?
                        if (($send_notify) && ($ref > 0) && (!$locked)) {
-                               //              0                1      2              3
-                               $DATA = array($per, bigintval($DEPTH), $ref_points, bigintval($ref));
-                               $msg = LOAD_EMAIL_TEMPLATE("confirm-referral", "", bigintval($uid));
+                               // Prepare content
+                               $content = array(
+                                       'percent' => $per,
+                                       'level'   => bigintval($DEPTH),
+                                       'points'  => $ref_points,
+                                       'refid'   => bigintval($ref)
+                               );
+
+                               // Load email template
+                               $msg = LOAD_EMAIL_TEMPLATE("confirm-referral", $content, bigintval($uid));
 
                                SEND_EMAIL($email, THANX_REFERRAL_ONE, $msg);
                        } elseif (($send_notify) && ($ref == 0) && (!$locked) && ($add_mode == "direct") && (!defined('__POINTS_VALUE'))) {
@@ -1435,7 +1446,7 @@ WHERE p.userid=%s", array(bigintval($uid)), __FILE__, __LINE__);
                if (GET_EXT_VERSION("mediadata") >= "0.0.4") {
                        // Update database
                        MEDIA_UPDATE_ENTRY(array("total_points"), "sub", $points);
-               }
+               } // END - if
 
                // Now, when we have all his points adds them do the jackpot!
                ADD_JACKPOT($points);