From: Roland Häder <roland@mxchange.org>
Date: Wed, 6 Jul 2011 08:47:01 +0000 (+0000)
Subject: More code parts could take advantage of previously improved fixEmptyContentToDashes():
X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=9b93cb80c13ee59fbd935b2988127cf4a1135000;p=mailer.git

More code parts could take advantage of previously improved fixEmptyContentToDashes():
- More code parts, all checked for ext-nickname is installed/active in an extra
  ugly looking if() block, could be improved by previously rewritten function
  fixEmptyContentToDashes().
- Some internal TODOs closed
- TODOs.txt updated
---

diff --git a/DOCS/TODOs.txt b/DOCS/TODOs.txt
index 3f99346055..605bc0690f 100644
--- a/DOCS/TODOs.txt
+++ b/DOCS/TODOs.txt
@@ -55,9 +55,9 @@
 ./inc/functions.php:2201:	// @TODO Rename column data_type to e.g. mail_status
 ./inc/gen_sql_patches.php:95:// @TODO Rewrite this to a filter
 ./inc/install-functions.php:57:	// @TODO DEACTIVATED: changeDataInLocalConfigurationFile('OUTPUT-MODE', "setConfigEntry('OUTPUT_MODE', '", "');", postRequestParameter('omode'), 0);
-./inc/language/de.php:1080:	// @TODO Rewrite these two constants
-./inc/language/de.php:1101:	// @TODO Rewrite these three constants
-./inc/language/de.php:772:// @TODO Are these constants longer used?
+./inc/language/de.php:1079:	// @TODO Rewrite these two constants
+./inc/language/de.php:1100:	// @TODO Rewrite these three constants
+./inc/language/de.php:771:// @TODO Are these constants longer used?
 ./inc/language-functions.php:255:	// @TODO These are all valid languages, again hard-coded
 ./inc/language-functions.php:44:// @TODO Rewrite all language constants to this function.
 ./inc/language/newsletter_de.php:13: * @TODO This language file is completely out-dated, please do no       *
@@ -66,7 +66,7 @@
 ./inc/language/sponsor_de.php:117:// @TODO Rewrite these four constants to one and use sprintf()
 ./inc/libs/admins_functions.php:451:		// @TODO This can be, somehow, rewritten
 ./inc/libs/beg_functions.php:55:		// @TODO Try to rewrite the following unset()
-./inc/libs/bonus_functions.php:203:		// @TODO Move this HTML to a template
+./inc/libs/bonus_functions.php:194:		// @TODO Move this HTML to a template
 ./inc/libs/doubler_functions.php:44:// @TODO Lame description
 ./inc/libs/doubler_functions.php:91:			// @TODO Can't this be moved into EL?
 ./inc/libs/mailid_functions.php:47:		// @TODO Rewrite this to a dynamic include or so
@@ -87,11 +87,11 @@
 ./inc/libs/task_functions.php:240:		// @TODO These can be rewritten to filter
 ./inc/libs/task_functions.php:51:// @TODO Move all extension-dependent queries into filters
 ./inc/libs/theme_functions.php:93:	// @TODO Can't this be rewritten to an API function?
-./inc/libs/user_functions.php:144:	// @TODO These two constants are no longer used, maybe we reactivate this code?
-./inc/libs/user_functions.php:232:// @TODO Double-check configuration entry here
-./inc/libs/user_functions.php:327:			// @TODO Make this filter working: $ADDON = runFilterChain('post_login_update', $content);
-./inc/libs/user_functions.php:356:			// @TODO Make this filter working: $url = runFilterChain('do_login', array('content' => $content, 'addon' => $ADDON));
-./inc/libs/user_functions.php:623:					// @TODO Try to rewrite the following unset()
+./inc/libs/user_functions.php:146:	// @TODO These two constants are no longer used, maybe we reactivate this code?
+./inc/libs/user_functions.php:234:// @TODO Double-check configuration entry here
+./inc/libs/user_functions.php:329:			// @TODO Make this filter working: $ADDON = runFilterChain('post_login_update', $content);
+./inc/libs/user_functions.php:358:			// @TODO Make this filter working: $url = runFilterChain('do_login', array('content' => $content, 'addon' => $ADDON));
+./inc/libs/user_functions.php:625:					// @TODO Try to rewrite the following unset()
 ./inc/libs/yoomedia_functions.php:114:	$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                                        *
@@ -142,10 +142,8 @@
 ./inc/modules/admin/what-list_refs.php:107:								// @TODO Try to rewrite some to EL
 ./inc/modules/admin/what-list_unconfirmed.php:107:	// @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:84:	// @TODO This constant might be unused? define('__LIST_UNCON_TITLE', '{--ADMIN_LIST_UNCONFIRMED_BONUS_LINKS--}');
-./inc/modules/admin/what-list_user.php:165:		// @TODO Rewrite these to filters
-./inc/modules/admin/what-list_user.php:273:		// @TODO Rewrite this into a filter
-./inc/modules/admin/what-list_user.php:322:			// @TODO Rewrite this into a filter
-./inc/modules/admin/what-list_user.php:57:// @TODO Rewrite these if-blocks in a filter
+./inc/modules/admin/what-list_user.php:257:		// @TODO Rewrite this into a filter
+./inc/modules/admin/what-list_user.php:300:			// @TODO Rewrite this into a filter
 ./inc/modules/admin/what-logs.php:64:			// @TODO Fix content-type here
 ./inc/modules/admin/what-logs.php:70:			// @TODO Fix content-type here
 ./inc/modules/admin/what-mem_add.php:124:				// @TODO This can be somehow rewritten to a function
@@ -174,9 +172,7 @@
 ./inc/modules/member/what-rallyes.php:89:	// @TODO Reactivate this: $content['admin'] = '<a href="{%url=modules.php?module=index&amp;what=impressum&amp;admin=' . $content['admin_id'] . '%}">' . $content['login'] . '</a>';
 ./inc/modules/member/what-refback.php:124:			// @TODO UNUSED: $refRow['status']      = translateUserStatus($refRow['status']);
 ./inc/modules/member/what-reflinks.php:52:// @TODO Move this into a filter
-./inc/modules/member/what-transfer.php:134:				// @TODO Rewrite this to a filter
-./inc/modules/member/what-transfer.php:223:				// @TODO Try to rewrite his to $content = SQL_FETCHARRAY(), see some lines above for two different queries
-./inc/modules/member/what-transfer.php:96:			// @TODO Rewrite this to a filter
+./inc/modules/member/what-transfer.php:127:				// @TODO Rewrite this to a filter
 ./inc/modules/member/what-unconfirmed.php:138:	// @TODO Try to rewrite this to $content = SQL_FETCHARRAY()
 ./inc/modules/member/what-unconfirmed.php:203:				// @TODO This 'userid' cannot be saved because of encapsulated EL code
 ./inc/modules/order.php:74:		// @TODO Unused: 2,4
@@ -185,8 +181,8 @@
 ./inc/mysql-manager.php:1485:			// @TODO Try to rewrite this to $content = SQL_FETCHARRAY()
 ./inc/mysql-manager.php:1573:		// @TODO Rewrite these lines to a filter
 ./inc/mysql-manager.php:1597:	// @TODO Rewrite this to a filter
-./inc/mysql-manager.php:1965:			// @TODO Rewrite this to a filter
-./inc/mysql-manager.php:2009:// @TODO Fix inconsistency between last_module and getWhat()
+./inc/mysql-manager.php:1961:			// @TODO Rewrite this to a filter
+./inc/mysql-manager.php:2005:// @TODO Fix inconsistency between last_module and getWhat()
 ./inc/mysql-manager.php:371:	// @TODO Try to rewrite this to one or more functions
 ./inc/mysql-manager.php:44:// @TODO Can we cache this?
 ./inc/purge/purge-inact.php:55:	// @TODO Rewrite these if() blocks to a filter
diff --git a/inc/gen_refback.php b/inc/gen_refback.php
index fe3b8672b2..59e457098d 100644
--- a/inc/gen_refback.php
+++ b/inc/gen_refback.php
@@ -44,7 +44,7 @@ if (!defined('__SECURITY')) {
 loadIncludeOnce('inc/libs/refback_functions.php');
 
 // Sanity-check: Do we have ref level 0?
-$result = SQL_QUERY('SELECT `id` FROM `{?_MYSQL_PREFIX?}_refsystem` WHERE `level`=0', __FILE__, __LINE__);
+$result = SQL_QUERY('SELECT `id` FROM `{?_MYSQL_PREFIX?}_refsystem` WHERE `level`=0 OR `level` IS NULL', __FILE__, __LINE__);
 if (!SQL_HASZERONUMS($result)) {
 	// Remove index temporaly
 	SQL_ALTER_TABLE('ALTER TABLE `{?_MYSQL_PREFIX?}_refsystem` DROP INDEX `userid_level`', __FILE__, __LINE__);
diff --git a/inc/language/de.php b/inc/language/de.php
index b3578e0a24..886d79ea0a 100644
--- a/inc/language/de.php
+++ b/inc/language/de.php
@@ -740,7 +740,6 @@ addMessages(array(
 	'OWN_POINTS' => "Eigenes Guthaben",
 	'ADMIN_TASK_INFOS' => "Infos",
 	'NICKNAME' => "Nickname",
-	'EXT_NICKNAME_404' => "Erweiterung <span class=\"data\">nickname</span> fehlt.",
 	'ADMIN_PROBLEM_NO_MENU' => "Konnte keine Men&uuml;eintr&auml;ge finden.",
 	'USER_REFERAL_404' => "Dieses Mitglied hat keine Referals gemacht.",
 	'USER_NICKNAME' => "Nickname",
diff --git a/inc/libs/bonus_functions.php b/inc/libs/bonus_functions.php
index 7bbf24eee9..fe9d30de02 100644
--- a/inc/libs/bonus_functions.php
+++ b/inc/libs/bonus_functions.php
@@ -173,15 +173,6 @@ LIMIT 1",
 			if (SQL_NUMROWS($result_users) == 1) {
 				// Load data
 				$rows = merge_array($rows, SQL_FETCHARRAY($result_users));
-
-				// Is ext-nickname active?
-				if (isExtensionActive('nickname')) {
-					// Then get the nickname
-					$nick = getNickname($rows['userid']);
-
-					// Is it not empty? Then use it
-					if (!empty($nick)) $rows['userid'] = $nick;
-				} // END - if
 			} // END - if
 
 			// Free result
diff --git a/inc/libs/refback_functions.php b/inc/libs/refback_functions.php
index 0911ea9b45..18b9ff9490 100644
--- a/inc/libs/refback_functions.php
+++ b/inc/libs/refback_functions.php
@@ -285,33 +285,28 @@ function updateRefbackTable ($userid) {
 function getArrayFromRefbackUserRefs ($userid, $level) {
 	//* DEBUG: */ print("----------------------- <font color=\"#00aa00\">".__FUNCTION__." - ENTRY</font> ------------------------<ul><li>\n");
 	// Default is no refs and no nickname
-	$add = '';
 	$refs = array();
 
-	// Do we have nickname extension installed?
-	if (isExtensionActive('nickname')) {
-		$add = ", d.`nickname`";
-	} // END - if
-
 	// Get refs from database
 	$result = SQL_QUERY_ESC("SELECT
-	r.id,
-	r.refid,
-	r.refback,
-	r.points,
-	d.status".$add.",
-	d.joined,
-	d.refid AS level_refid
+	r.`id`,
+	r.`refid`,
+	r.`refback`,
+	r.`points`,
+	d.`status`
+	d.`joined`,
+	d.`refid` AS `level_refid`
 FROM
 	`{?_MYSQL_PREFIX?}_user_refs` AS r
 LEFT JOIN
 	`{?_MYSQL_PREFIX?}_user_data` AS d
 ON
-	r.refid=d.userid
+	r.`refid`=d.`userid`
 WHERE
-	r.userid=%s AND r.level=%s
+	r.`userid`=%s AND
+	r.`level`=%s
 ORDER BY
-	r.refid ASC",
+	r.`refid` ASC",
 		array(bigintval($userid), bigintval($level)), __FUNCTION__, __LINE__);
 
 	// Are there some entries?
diff --git a/inc/libs/user_functions.php b/inc/libs/user_functions.php
index 8e1eea9389..18b0cd64c4 100644
--- a/inc/libs/user_functions.php
+++ b/inc/libs/user_functions.php
@@ -99,7 +99,9 @@ function addSortLinks ($letter, $sortby, $colspan, $return=false) {
 	elseif (isGetRequestParameterSet('mode')) $add .= '&amp;mode=' . getRequestParameter('mode');
 
 	// Makes order by links..
-	if ($letter == 'front') $letter = '';
+	if ($letter == 'front') {
+		$letter = '';
+	} // END - if
 
 	// Prepare array with all possible sorters
 	$list = array(
diff --git a/inc/modules/admin/what-list_user.php b/inc/modules/admin/what-list_user.php
index 70120a8d3f..36fc44e79c 100644
--- a/inc/modules/admin/what-list_user.php
+++ b/inc/modules/admin/what-list_user.php
@@ -53,15 +53,6 @@ if ((!isExtensionInstalled('user')) || (!isExtensionActive('user'))) {
 $MORE = '';
 $colspan = 4;
 
-// Add nickname if extension is found&active
-// @TODO Rewrite these if-blocks in a filter
-if (isExtensionActive('nickname')) {
-	// Add nickname
-	$MORE .= ", `nickname`";
-} else {
-	$MORE .= ", `userid`";
-}
-
 // Add random confirmed if extension version matches
 if (isExtensionInstalledAndNewer('user', '0.3.4')) {
 	// Add it...
@@ -154,19 +145,12 @@ LIMIT 1",
 		// Add more data
 		$content['own_points']        = $data['points'];
 		$content['lock_timestamp']    = generateDateTime($content['lock_timestamp'], 2);
-		$content['nickname']          = '{--EXT_NICKNAME_404--}';
 
 		// Link to email_details if some are sent
 		if ($content['emails_sent'] > 0) {
 			$content['emails_sent'] = $base . '&amp;what=email_details&amp;userid=' . $content['userid'] . '%}">}{%pipe,translateComma=' . $content['emails_sent'] . '%}</a>]';
 		} // END - if
 
-		// Nickname inclusion?
-		// @TODO Rewrite these to filters
-		if (isExtensionInstalled('nickname')) {
-			$content['nickname'] = getNickname($content['userid']);
-		} // END - if
-
 		// Clickrate
 		$content['click_rate'] = '0';
 		if ($content['emails_received'] > 0) {
@@ -294,12 +278,6 @@ LIMIT 1",
 				$content['emails_sent'] = $base . '&amp;what=email_details&amp;userid=' . $content['userid'] . '%}">{%pipe,translateComma=' . $content['emails_sent'] . '%}</a>]';
 			} // END - if
 
-			// Add nickname
-			$content['nickname'] = '{--EXT_NICKNAME_404--}';
-			if (isExtensionInstalled('nickname')) {
-				$content['nickname'] = getNickname($content['userid']);
-			} // END - if
-
 			// Clickrate
 			$content['rate'] = '0';
 			if ($content['emails_received'] > 0) {
diff --git a/inc/modules/guest/what-active.php b/inc/modules/guest/what-active.php
index 36dd9e4443..a0075a13c9 100644
--- a/inc/modules/guest/what-active.php
+++ b/inc/modules/guest/what-active.php
@@ -48,17 +48,9 @@ if ((!isExtensionActive('active')) && (!isAdmin())) {
 	return;
 } // END - if
 
-// Extra field to include is by default userid
-$add = '';
-
-// If nickname is installed the extra field is the nickname of the user
-if (isExtensionActive('nickname')) {
-	$add = ', `nickname`';
-} // END - if
-
 // Check for members who were active only this day
 $result = SQL_QUERY("SELECT
-	`userid``, `last_online`".$add."
+	`userid``, `last_online`
 FROM
 	`{?_MYSQL_PREFIX?}_user_data`
 WHERE
diff --git a/inc/modules/guest/what-top10.php b/inc/modules/guest/what-top10.php
index ebde2cb86c..139f7f248a 100644
--- a/inc/modules/guest/what-top10.php
+++ b/inc/modules/guest/what-top10.php
@@ -65,12 +65,6 @@ LIMIT {?top10_max?}", __FILE__, __LINE__);
 
 $OUT = ''; $count = 1;
 while ($content = SQL_FETCHARRAY($result)) {
-	// Init nickname
-	$content['nickname'] = '';
-
-	// Get nickname
-	if (isExtensionActive('nickname')) $content['nickname'] = getNickname($content['userid']);
-
 	// Prepare data for template
 	$content = array(
 		'cnt'          => $count,
@@ -130,12 +124,6 @@ LIMIT {?top10_max?}", __FILE__, __LINE__);
 
 $OUT = ''; $count = 1;
 while ($content = SQL_FETCHARRAY($result)) {
-	// Init nickname
-	$content['nickname'] = '';
-
-	// Get nickname
-	if (isExtensionActive('nickname')) $content['nickname'] = getNickname($content['userid']);
-
 	// Prepare data for template
 	$content = array(
 		'cnt'         => $count,
@@ -194,14 +182,6 @@ LIMIT {?top10_max?}", __FILE__, __LINE__);
 
 $OUT = ''; $count = 1;
 while ($content = SQL_FETCHARRAY($result)) {
-	// Init nickname
-	$content['nickname'] = '';
-
-	// Get nickname
-	if (isExtensionActive('nickname')) {
-		$content['nickname'] = getNickname($content['userid']);
-	} // END - if
-
 	// Prepare data for template
 	$content = array(
 		'cnt'         => $count,
diff --git a/inc/modules/member/what-doubler.php b/inc/modules/member/what-doubler.php
index 3687b6aeea..45f5512c68 100644
--- a/inc/modules/member/what-doubler.php
+++ b/inc/modules/member/what-doubler.php
@@ -50,15 +50,6 @@ if ((!isExtensionActive('doubler')) && (!isAdmin())) {
 	return;
 } // END - if
 
-// Init nickname
-$content['nickname'] = '';
-
-// Transfer referal id
-if (isExtensionActive('nickname')) {
-	// Load nickname from DB
-	$content['nickname'] = getNickname(getMemberId());
-} // END - if
-
 // Which mail-send-mode did the admin setup?
 $content['payout_time'] = '{--DOUBLER_PAYOUT_TIME_' . getConfig('doubler_send_mode') . '--}';
 
diff --git a/inc/modules/member/what-transfer.php b/inc/modules/member/what-transfer.php
index 1c78c583dd..03231df4cc 100644
--- a/inc/modules/member/what-transfer.php
+++ b/inc/modules/member/what-transfer.php
@@ -92,15 +92,8 @@ switch ($mode) {
 			// Test if a recipient is selected
 			$valid_recipient = isValidUserId(postRequestParameter('to_userid'));
 
-			// Check for nickname extension and set additional data
-			// @TODO Rewrite this to a filter
-			$add = '';
-			if (isExtensionActive('nickname')) {
-				$add = ', `nickname`';
-			} // END - if
-
 			// Re-check receivers and own personal data
-			$result = SQL_QUERY_ESC("SELECT `userid`, `gender`, `surname`, `family`, `email`".$add." FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid` IN ('%s','%s') AND `status`='CONFIRMED' LIMIT 2",
+			$result = SQL_QUERY_ESC("SELECT `userid`, `gender`, `surname`, `family`, `email` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid` IN ('%s','%s') AND `status`='CONFIRMED' LIMIT 2",
 				array(
 					getMemberId(),
 					bigintval(postRequestParameter('to_userid'))
@@ -206,34 +199,20 @@ switch ($mode) {
 
 		if (!isFormSent()) {
 			// Load member list
-			if (isExtensionActive('nickname')) {
-				// Load userid and nickname
-				$result = SQL_QUERY_ESC("SELECT `userid`, `nickname` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `status`='CONFIRMED' AND `opt_in`='Y' AND `userid` != '%s' ORDER BY `userid` ASC",
-					array(getMemberId()), __FILE__, __LINE__);
-			} else {
-				// Load only userid
-				$result = SQL_QUERY_ESC("SELECT `userid`, `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `status`='CONFIRMED' AND `opt_in`='Y' AND `userid` != '%s' ORDER BY `userid` ASC",
-					array(getMemberId()), __FILE__, __LINE__);
-			}
+			$result = SQL_QUERY_ESC("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `status`='CONFIRMED' AND `opt_in`='Y' AND `userid` != '%s' ORDER BY `userid` ASC",
+				array(getMemberId()), __FILE__, __LINE__);
 
 			if (!SQL_HASZERONUMS($result)) {
 				// Load list
 				$OUT  = '<select name="to_userid" size="1" class="form_select">
 	<option value="0">{--SELECT_NONE--}</option>';
-				// @TODO Try to rewrite his to $content = SQL_FETCHARRAY(), see some lines above for two different queries
-				while (list($userid, $nick) = SQL_FETCHROW($result)) {
+				while (list($userid) = SQL_FETCHROW($result)) {
 					$OUT .= '	<option value="' . $userid . '"';
-					if ((isPostRequestParameterSet('to_userid')) && (postRequestParameter('to_userid') == $userid)) $OUT .= ' selected="selected"';
-					$OUT .= '>';
-					if (($nick != $userid) && (!empty($nick))) {
-						// Output nickname
-						$OUT .= $nick;
-					} else {
-						// Output userid
-						$OUT .= $userid;
-					}
-					$OUT .= '</option>';
-				}
+					if ((isPostRequestParameterSet('to_userid')) && (postRequestParameter('to_userid') == $userid)) {
+						$OUT .= ' selected="selected"';
+					} // END - if
+					$OUT .= '>' . $userid . ' ({%user,nickname,fixEmptyContentToDashes=' . $userid . '%})</option>';
+				} // END - while
 				$OUT .= '</select>';
 				$content['to_disabled'] = '';
 
diff --git a/inc/modules/member/what-unconfirmed.php b/inc/modules/member/what-unconfirmed.php
index 7511489674..1389c33d6a 100644
--- a/inc/modules/member/what-unconfirmed.php
+++ b/inc/modules/member/what-unconfirmed.php
@@ -65,8 +65,8 @@ LIMIT 1",
 	$content['userid']      = getMemberId();
 	$content['user_status'] = '{%message,MEMBER_MAIL_BONUS_CONFIRMED_UNKNOWN=' . $content['id'] . '%}';
 
-	// Is ext-user installed?
-	if (isExtensionInstalled('user')) {
+	// Is ext-user active?
+	if (isExtensionActive('user')) {
 		// Get timestamp from insert
 		$content['user_status'] = '{%message,MEMBER_MAIL_BONUS_CONFIRMED_ON=' . generateDateTime(getEpocheTimeFromUserStats('bonusid', $content['id']), '2') . '%}';
 	} // END - if
@@ -104,8 +104,8 @@ LIMIT 1",
 	$content['userid']      = getMemberId();
 	$content['user_status'] = '{%message,MEMBER_MAIL_NORMAL_CONFIRMED_UNKNOWN=' . $content['id'] . '%}';
 
-	// Is ext-user installed?
-	if (isExtensionInstalled('user')) {
+	// Is ext-user active?
+	if (isExtensionActive('user')) {
 		// Get timestamp from insert
 		$content['user_status'] = '{%message,MEMBER_MAIL_NORMAL_CONFIRMED_ON=' . generateDateTime(getEpocheTimeFromUserStats('mailid', $content['id']), '2') . '%}';
 	} // END - if
diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php
index 41a80d2e7d..e80d559b85 100644
--- a/inc/mysql-manager.php
+++ b/inc/mysql-manager.php
@@ -1871,31 +1871,27 @@ function generateReceiverList ($categoryId, $receiver, $mode = '') {
 function getUserReferalPoints ($userid, $level) {
 	//* DEBUG: */ debugOutput('----------------------- <font color="#00aa00">'.__FUNCTION__.' - ENTRY</font> ------------------------<ul><li>');
 	// Default is no refs and no nickname
-	$add = '';
 	$refs = array();
 
-	// Do we have nickname extension installed?
-	if (isExtensionActive('nickname')) {
-		$add = ', ud.nickname';
-	} // END - if
-
 	// Get refs from database
 	$result = SQL_QUERY_ESC("SELECT
-	ur.id, ur.refid, ud.status, ud.last_online, ud.mails_confirmed, ud.emails_received".$add."
+	ur.`id`, ur.`refid`, ud.`status`, ud.`last_online`, ud.`mails_confirmed`, ud.`emails_received`
 FROM
 	`{?_MYSQL_PREFIX?}_user_refs` AS ur
 LEFT JOIN
 	`{?_MYSQL_PREFIX?}_user_points` AS up
 ON
-	ur.refid=up.userid AND ur.level=0
+	ur.refid=up.userid AND
+	(ur.level=0 OR ur.level IS NULL)
 LEFT JOIN
 	`{?_MYSQL_PREFIX?}_user_data` AS ud
 ON
-	ur.refid=ud.userid
+	ur.`refid`=ud.`userid`
 WHERE
-	ur.userid=%s AND ur.level=%s
+	ur.`userid`=%s AND
+	ur.`level`=%s
 ORDER BY
-	ur.refid ASC",
+	ur.`refid` ASC",
 		array(
 			bigintval($userid),
 			bigintval($level)
diff --git a/templates/de/html/admin/admin_list_user_row.tpl b/templates/de/html/admin/admin_list_user_row.tpl
index d797a40a57..669ab0baa9 100644
--- a/templates/de/html/admin/admin_list_user_row.tpl
+++ b/templates/de/html/admin/admin_list_user_row.tpl
@@ -10,7 +10,7 @@
 	<td align="center" class="bottom right {%template,ColorSwitch%}">{%pipe,translateGender=$content[gender]%}</td>
 	<td align="center" class="bottom right {%template,ColorSwitch%}">$content[surname]</td>
 	<td align="center" class="bottom right {%template,ColorSwitch%}">$content[family]</td>
-	<td align="center" class="bottom {%template,ColorSwitch%}">{%pipe,fixEmptyContentToDashes=$content[nickname]%}</td>
+	<td align="center" class="bottom {%template,ColorSwitch%}">{%user,nickname,fixEmptyContentToDashes=$content[userid]%}</td>
 </tr>
 <tr>
 	<td align="center" class="right {%template,ColorSwitch%}"><strong>{--EMAIL--}:</strong></td>
diff --git a/templates/de/html/admin/admin_user_details.tpl b/templates/de/html/admin/admin_user_details.tpl
index 01733e34ed..d2a61d817b 100644
--- a/templates/de/html/admin/admin_user_details.tpl
+++ b/templates/de/html/admin/admin_user_details.tpl
@@ -156,7 +156,7 @@
 		</td>
 		<td align="center" class="top right">
 			{--USER_NICKNAME--}:<br />
-			<strong>$content[nickname]</strong>
+			<strong>{%user,nickname,fixEmptyContentToDashes=$content[userid]%}</strong>
 		</td>
 		<td align="center" class="top right">
 			{--CLICK_RATE--}:<br />
diff --git a/templates/de/html/guest/guest_active_row.tpl b/templates/de/html/guest/guest_active_row.tpl
index 0616c12211..be39d2aa9a 100644
--- a/templates/de/html/guest/guest_active_row.tpl
+++ b/templates/de/html/guest/guest_active_row.tpl
@@ -1,5 +1,5 @@
 <tr>
-	<td class="{%template,ColorSwitch%} bottom right">$content[userid] ({%pipe,fixEmptyContentToDashes=$content[nickname]%})</td>
+	<td class="{%template,ColorSwitch%} bottom right">$content[userid] ({%user,nickname,fixEmptyContentToDashes=$content[userid]%})</td>
 	<td class="{%template,ColorSwitch%} bottom right">{%pipe,getTotalPoints,translateComma=$content[userid]%}</td>
 	<td class="{%template,ColorSwitch%} bottom">$content[last_online]</td>
 </tr>
diff --git a/templates/de/html/guest/guest_top10_row_earner.tpl b/templates/de/html/guest/guest_top10_row_earner.tpl
index ce7b649947..5f2b0ed38f 100644
--- a/templates/de/html/guest/guest_top10_row_earner.tpl
+++ b/templates/de/html/guest/guest_top10_row_earner.tpl
@@ -1,6 +1,6 @@
 <tr>
 	<td class="top10_row1 {%template,ColorSwitch%} bottom right" align="center">$content[cnt]</td>
-	<td class="top10_row2 {%template,ColorSwitch%} bottom right">$content[userid] ({%pipe,fixEmptyContentToDashes=$content[nickname]%})</td>
+	<td class="top10_row2 {%template,ColorSwitch%} bottom right">$content[userid] ({%user,nickname,fixEmptyContentToDashes=$content[userid]%})</td>
 	<td class="top10_row3 {%template,ColorSwitch%} bottom right">{%pipe,translateComma=$content[points]%}</td>
 	<td class="top10_row5 {%template,ColorSwitch%} bottom">$content[last_online]</td>
 </tr>
diff --git a/templates/de/html/guest/guest_top10_row_login.tpl b/templates/de/html/guest/guest_top10_row_login.tpl
index 0293b25c4c..d390c75858 100644
--- a/templates/de/html/guest/guest_top10_row_login.tpl
+++ b/templates/de/html/guest/guest_top10_row_login.tpl
@@ -1,6 +1,6 @@
 <tr>
 	<td class="top10_row1 {%template,ColorSwitch%} bottom right" align="center">$content[cnt]</td>
-	<td class="top10_row2 {%template,ColorSwitch%} bottom right">$content[userid] ({%pipe,fixEmptyContentToDashes=$content[nickname]%})</td>
+	<td class="top10_row2 {%template,ColorSwitch%} bottom right">$content[userid] ({%user,nickname,fixEmptyContentToDashes=$content[userid]%})</td>
 	<td class="top10_row3 {%template,ColorSwitch%} bottom right">{%pipe,translateComma=$content[total_logins]%}</td>
 	<td class="top10_row4 {%template,ColorSwitch%} bottom right">{%pipe,translateComma=$content[points]%}</td>
 	<td class="top10_row5 {%template,ColorSwitch%} bottom">$content[last_online]</td>
diff --git a/templates/de/html/guest/guest_top10_row_refs.tpl b/templates/de/html/guest/guest_top10_row_refs.tpl
index 22c3a7784c..d37ec997a0 100644
--- a/templates/de/html/guest/guest_top10_row_refs.tpl
+++ b/templates/de/html/guest/guest_top10_row_refs.tpl
@@ -1,6 +1,6 @@
 <tr>
 	<td class="top10_row1 {%template,ColorSwitch%} bottom right" align="center">$content[cnt]</td>
-	<td class="top10_row2 {%template,ColorSwitch%} bottom right">$content[userid] ({%pipe,fixEmptyContentToDashes=$content[nickname]%})</td>
+	<td class="top10_row2 {%template,ColorSwitch%} bottom right">$content[userid] ({%user,nickname,fixEmptyContentToDashes=$content[userid]%})</td>
 	<td class="top10_row3 {%template,ColorSwitch%} bottom right">{%pipe,translateComma=$content[refs]%}</td>
 	<td class="top10_row4 {%template,ColorSwitch%} bottom right">{%pipe,getTotalPoints,translateComma=$content[userid]%}</td>
 	<td class="top10_row5 {%template,ColorSwitch%} bottom">$content[last_online]</td>
diff --git a/templates/de/html/member/member_bonus_turbo_row.tpl b/templates/de/html/member/member_bonus_turbo_row.tpl
index 855c1c6f8a..efab5bbf4e 100644
--- a/templates/de/html/member/member_bonus_turbo_row.tpl
+++ b/templates/de/html/member/member_bonus_turbo_row.tpl
@@ -1,5 +1,11 @@
 <tr>
-  <td class="rank_$content[rank] bottom {%template,ColorSwitch%}">{%pipe,translateComma=$content[rank]%}.</td>
-  <td class="rank_$content[rank] bottom {%template,ColorSwitch%}" align="center">$content[userid]</td>
-  <td class="rank_$content[rank] bottom {%template,ColorSwitch%}" align="center">{%pipe,translateComma=$content[points]%}</td>
+	<td class="rank_$content[rank] bottom {%template,ColorSwitch%}">
+		{%pipe,translateComma=$content[rank]%}.
+	</td>
+	<td class="rank_$content[rank] bottom {%template,ColorSwitch%}" align="center">
+		$content[userid] ({%user,nickname,fixEmptyContentToDashes=$content[userid]%})
+	</td>
+	<td class="rank_$content[rank] bottom {%template,ColorSwitch%}" align="center">
+		{%pipe,translateComma=$content[points]%}
+	</td>
 </tr>
diff --git a/templates/de/html/member/member_doubler.tpl b/templates/de/html/member/member_doubler.tpl
index 875990e861..567d94609e 100644
--- a/templates/de/html/member/member_doubler.tpl
+++ b/templates/de/html/member/member_doubler.tpl
@@ -1,6 +1,6 @@
 <div align="center">
 	<div class="para">
-	{--MEMBER_DOUBLER_YOUR_LINK--}:
+		{--MEMBER_DOUBLER_YOUR_LINK--}:
 	</div>
 
 	<div>
diff --git a/templates/de/html/member/member_ref_list_row.tpl b/templates/de/html/member/member_ref_list_row.tpl
index c76dd27505..0a6570f6ea 100644
--- a/templates/de/html/member/member_ref_list_row.tpl
+++ b/templates/de/html/member/member_ref_list_row.tpl
@@ -1,6 +1,6 @@
 <tr>
 	<td align="center" class="{%template,ColorSwitch%} bottom right">
-		$content[refid] ({%pipe,fixEmptyContentToDashes=$content[nickname]%})
+		$content[refid] ({%user,nickname,fixEmptyContentToDashes=$content[userid]%})
 	</td>
 	<td align="center" class="{%template,ColorSwitch%} bottom right">
 		{%pipe,translateUserStatus=$content[status]%}