Code: Alles auswählen
function color_group_colorize_name($user_id, $no_profile = false)
{
global $board_config, $phpEx, $db, $phpbb_root_path, $lang;
if ($user_id == ANONYMOUS)
{
return $lang['Guest'];
}
// Version cache mod start
// Change following two variables if you need to:
$cache_update = 86400; // 1 day cache timeout. change it to whatever you want
$cache_file = $phpbb_root_path . '/cache/cg-user.'.$phpEx;
$do_update = true;
if (@file_exists($cache_file))
{
$last_update = 0;
$user_style_color = array();
$user_style_name = array();
include($cache_file);
if($last_update > (time() - $cache_update))
{
$do_update = false;
}
}
if($do_update)
{
$user_color_id = '';
$group_style_color = array();
$write_string = "<?php\n".'$last_update'." = ".time().";\n";
// Start looking for user group memberships //
$sql = 'SELECT c.group_color, u.user_id FROM ' . USER_GROUP_TABLE . ' ug, ' . USERS_TABLE . ' u, ' . COLOR_GROUPS_TABLE . ' c, ' . GROUPS_TABLE . ' g
WHERE u.user_id = ug.user_id
AND ug.group_id = g.group_id
AND g.group_color_group = c.group_id
AND g.group_single_user = 0
GROUP BY u.user_id
ORDER BY c.order_num';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$group_style_color[$row['user_id']] = 'font-weight:bold;color:' . $row['group_color'];
}
$db->sql_freeresult($result);
// Get the user info and see if they are assigned a color_group //
$sql = "SELECT user_color_group, username, user_id FROM " . USERS_TABLE . "
WHERE user_id <> " . ANONYMOUS . "
ORDER BY user_id";
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$style_color = '';
$user_color_id = $row['user_id'];
$username = $row['username'];
if ($row['user_color_group'] > 0)
{
$sql_usercolor = "SELECT group_color FROM " . COLOR_GROUPS_TABLE . "
WHERE group_id = ".$row['user_color_group'];
$result2 = $db->sql_query($sql_usercolor);
$row2 = $db->sql_fetchrow($result2);
if ($row2['group_color'])
{
$style_color = 'font-weight:bold;color:' . $row2['group_color'];
}
}
else
{
$style_color = $group_style_color[$user_color_id];
}
$user_style_color[$user_color_id] = $style_color;
$user_style_name[$user_color_id] = addslashes($username);
$write_string .= '$user_style_name['.$user_color_id.'] = \''.addslashes($username)."';\n";
if ($style_color != '')
{
$write_string .= '$user_style_color['.$user_color_id."] = '$style_color';\n";
}
}
$db->sql_freeresult($result);
$write_string .= "?>";
@unlink($cache_file);
// Version cache mod start
if(@$f = fopen($cache_file, 'w'))
{
fwrite($f, $write_string);
fclose($f);
@chmod($cache_file, 0666);
}
}
if ($user_style_color[$user_id] != '')
{
$style_color = 'style="'.$user_style_color[$user_id].'"';
}
else
{
$style_color = '';
}
$username = str_replace("\'", "'", $user_style_name[$user_id]);
$username = str_replace('\"', '"', $username);
if ($username == '')
{
$sql = "SELECT username FROM " . USERS_TABLE . "
WHERE user_id = $user_id";
if (!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not get username for new registered user', '', __LINE__, __FILE__, $sql);
}
$row = $db->sql_fetchrow($result);
$username = $row['username'];
$db->sql_freeresult($result);
}
// Make the profile link or no and return it //
if ($no_profile)
{
$user_link = "<span $style_color>$username</span>";
}
else
{
$user_link = '<a href="' . append_sid($phpbb_root_path."profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=$user_id") . '" '.$style_color.'>'.$username.'</a>';
}
return $user_link;
}
Für Benutzer, die meinen bisherigen Fix für den Color Group Mod installiert haben oder ein Plus 1.5.x verwenden, muss hierzu der Part in der common.php ebenfalls komplett entfernt werden.
Im Plus ist es dieser hier:
Code: Alles auswählen
$sql = "SELECT user_id, user_color_group, username FROM " . USERS_TABLE;
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not read user color groups', '', __LINE__, __FILE__, $sql);
}
$colorusers = array();
$coloruname = array();
while ( $row = $db->sql_fetchrow($result) )
{
$userid = $row['user_id'];
$colorusers[$userid] = $row['user_color_group'];
$coloruname[$userid] = $row['username'];
}
$colorgroup = array();
$sql = "SELECT ug.user_id FROM " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g
WHERE g.group_single_user = 0
AND g.group_id = ug.group_id
GROUP BY ug.user_id
ORDER BY ug.user_id";
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not read user color groups', '', __LINE__, __FILE__, $sql);
}
while ( $row = $db->sql_fetchrow($result) )
{
$colorgroup[] = $row['user_id'];
}
Der Cache ist auch aktuell mit diesem Fix auf einen Tag, also 24 Stunden eingestellt und erzeugt eine Cache-Datei für alle Usernamen. Der Zeitraum sollte mehr als ausreichend sein.
Es sind dann auch alle bisherigen Cache-Dateien, die im Ordner cache/ existieren und mit "cg_user" beginnen, vollständig zu löschen!
Eine Installation des Fixes von Titus im ACP-Modul des Color Group Mods ist ebenfalls nicht nötig und muß rückgängig gemacht werden!
Anmerkung:
Das hier verwendete Cache-Systems basiert auf der Version von CyberAlien. Quelle: phpbb.com