More misc fixes and rewrites (sorry, lame description)
[mailer.git] / inc / functions.php
index b0bc5e475a7ad9337709d7d356e3ee065630c318..010cad850080d80485c4f72b0e44db0ca4d2ecc9 100644 (file)
@@ -238,7 +238,7 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) {
        // @DEPRECATED Try to rewrite the if() condition
        if ($template == 'member_support_form') {
                // Support request of a member
-               $result = SQL_QUERY_ESC("SELECT userid, gender, surname, family, email FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
+               $result = SQL_QUERY_ESC("SELECT `userid`, `gender`, `surname`, `family`, `email` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `userid`=%s LIMIT 1",
                        array(getUserId()), __FUNCTION__, __LINE__);
 
                // Is content an array?
@@ -250,13 +250,13 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) {
                        $content['gender'] = translateGender($content['gender']);
                } else {
                        // @DEPRECATED
-                       // @TODO Fine all templates which are using these direct variables and rewrite them.
+                       // @TODO Find all templates which are using these direct variables and rewrite them.
                        // @TODO After this step is done, this else-block is history
                        list($gender, $surname, $family, $email) = SQL_FETCHROW($result);
 
                        // Translate gender
                        $gender = translateGender($gender);
-                       DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("DEPRECATION-WARNING: content is not array (%s).", gettype($content)));
+                       DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("DEPRECATION-WARNING: content is not array [%s], template=%s.", gettype($content), $template));
                }
 
                // Free result
@@ -799,13 +799,13 @@ function LOAD_EMAIL_TEMPLATE ($template, $content = array(), $UID = '0') {
                if (EXT_IS_ACTIVE('nickname')) {
                        //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):NICKNAME!<br />\n";
                        // Load nickname
-                       $result = SQL_QUERY_ESC("SELECT surname, family, gender, email, nickname FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
-                       array(bigintval($UID)), __FUNCTION__, __LINE__);
+                       $result = SQL_QUERY_ESC("SELECT `surname`, `family`, `gender`, `email`, `nickname` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `userid`=%s LIMIT 1",
+                               array(bigintval($UID)), __FUNCTION__, __LINE__);
                } else {
                        //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):NO-NICK!<br />\n";
                        /// Load normal data
-                       $result = SQL_QUERY_ESC("SELECT surname, family, gender, email FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
-                       array(bigintval($UID)), __FUNCTION__, __LINE__);
+                       $result = SQL_QUERY_ESC("SELECT `surname`, `family`, `gender`, `email` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `userid`=%s LIMIT 1",
+                               array(bigintval($UID)), __FUNCTION__, __LINE__);
                }
 
                // Fetch and merge data
@@ -922,7 +922,7 @@ function redirectToUrl ($URL) {
        } // END - if
 
        // Three different debug ways...
-       //* DEBUG: */ debug_report_bug(sprintf("%s[%s:] URL=%s", __FUNCTION__, __LINE__, $URL));
+       /* DEBUG: */ debug_report_bug(sprintf("%s[%s:] URL=%s", __FUNCTION__, __LINE__, $URL));
        //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, $URL);
        //* DEBUG: */ die($URL);
 
@@ -2026,10 +2026,10 @@ function generateEmailLink ($email, $table = 'admins') {
                $EMAIL = generateAdminEmailLink($email);
        } elseif ((EXT_IS_ACTIVE('user')) && (GET_EXT_VERSION('user') >= '0.3.3') && ($table == 'user_data')) {
                // Create email link for contacting a member within admin area (or later in other areas, too?)
-               $EMAIL = generateEmailLink($email, 'user_data');
+               $EMAIL = generateUserEmailLink($email, 'admin');
        } elseif ((EXT_IS_ACTIVE('sponsor')) && ($table == 'sponsor_data')) {
                // Create email link to contact sponsor within admin area (or like the link above?)
-               $EMAIL = generateEmailLink($email, 'sponsor_data');
+               $EMAIL = generateSponsorEmailLink($email, 'sponsor_data');
        }
 
        // Shall I close the link when there is no admin?