Topic: Coloured Groups ( By Group Title )
The good thing about this modification is that nothing has to be added/installed in to the database. Not only that, but you are able to modify the classification via css, and it is alot easier to customize. Also, you have the ability to customize it for each seperate style sheet. Let me know how it turns out .
Let's start by opening up your index.php
Begin this step by finding the following line:
$result = $db->query('SELECT user_id, ident FROM '.$db->prefix.'online WHERE idle=0 ORDER BY ident', true) or error('Unable to fetch online list', __FILE__, __LINE__, $db->error());
Replace this line with the following:
$result = $db->query('SELECT o.user_id, o.ident, g.g_id, g.g_title FROM '.$db->prefix.'online AS o INNER JOIN '.$db->prefix.'users AS u ON o.user_id=u.id INNER JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id WHERE o.idle=0 ORDER BY o.ident', true) or error('Unable to fetch online list', __FILE__, __LINE__, $db->error());
Now, find this line:
$users[] = "\n\t\t\t\t".'<dd><a href="profile.php?id='.$pun_user_online['user_id'].'">'.pun_htmlspecialchars($pun_user_online['ident']).'</a>';
Replace it with:
$users[] = "\n\t\t\t\t".'<dd><span class="'.$pun_user_online['g_title'].'"><a href="profile.php?id='.$pun_user_online['user_id'].'">'.pun_htmlspecialchars($pun_user_online['ident']).'</a></span>';
Okay, now open up viewtopic.php.
Find:
$result = $db->query('SELECT u.email, u.title, u.url, u.location, u.use_avatar, u.signature, u.email_setting, u.num_posts, u.registered, u.admin_note, p.id, p.poster AS username, p.poster_id, p.poster_ip, p.poster_email, p.message, p.hide_smilies, p.posted, p.edited, p.edited_by, g.g_id, g.g_user_title, o.user_id AS is_online FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'users AS u ON u.id=p.poster_id INNER JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id LEFT JOIN '.$db->prefix.'online AS o ON (o.user_id=u.id AND o.user_id!=1 AND o.idle=0) WHERE p.topic_id='.$id.' ORDER BY p.id LIMIT '.$start_from.','.$pun_user['disp_posts'], true) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
Replace with:
$result = $db->query('SELECT u.email, u.title, u.url, u.location, u.use_avatar, u.signature, u.email_setting, u.num_posts, u.registered, u.admin_note, p.id, p.poster AS username, p.poster_id, p.poster_ip, p.poster_email, p.message, p.hide_smilies, p.posted, p.edited, p.edited_by, g.g_id, g.g_user_title, g.g_title, o.user_id AS is_online FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'users AS u ON u.id=p.poster_id INNER JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id LEFT JOIN '.$db->prefix.'online AS o ON (o.user_id=u.id AND o.user_id!=1 AND o.idle=0) WHERE p.topic_id='.$id.' ORDER BY p.id LIMIT '.$start_from.','.$pun_user['disp_posts'], true) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
Next find:
$username = '<a href="profile.php?id='.$cur_post['poster_id'].'">'.pun_htmlspecialchars($cur_post['username']).'</a>';
Replace that with:
$username = '<span class="'.$cur_post['g_title'].'"><a href="profile.php?id='.$cur_post['poster_id'].'">'.pun_htmlspecialchars($cur_post['username']).'</a></span>';
Now we move on to userlist.php
First find:
$result = $db->query('SELECT u.id, u.username, u.title, u.num_posts, u.registered, g.g_id, g.g_user_title FROM '.$db->prefix.'users AS u LEFT JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id WHERE u.id>1'.(!empty($where_sql) ? ' AND '.implode(' AND ', $where_sql) : '').' ORDER BY '.$sort_by.' '.$sort_dir.' LIMIT '.$start_from.', 50') or error('Unable to fetch user list', __FILE__, __LINE__, $db->error());
Replace with:
$result = $db->query('SELECT u.id, u.username, u.title, u.num_posts, u.registered, g.g_id, g.g_user_title, g.g_title FROM '.$db->prefix.'users AS u LEFT JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id WHERE u.id>1'.(!empty($where_sql) ? ' AND '.implode(' AND ', $where_sql) : '').' ORDER BY '.$sort_by.' '.$sort_dir.' LIMIT '.$start_from.', 50') or error('Unable to fetch user list', __FILE__, __LINE__, $db->error());
Next find:
<td class="tcl"><?php echo '<a href="profile.php?id='.$user_data['id'].'">'.pun_htmlspecialchars($user_data['username']).'</a>' ?></td>
Replace that with:
<td class="tcl"><?php echo '<span class="'.$user_data['g_title'].'"><a href="profile.php?id='.$user_data['id'].'">'.pun_htmlspecialchars($user_data['username']).'</a></span>' ?></td>
Open profile.php.
Find:
$result = $db->query('SELECT u.username, u.email, u.title, u.realname, u.url, u.jabber, u.icq, u.msn, u.aim, u.yahoo, u.location, u.use_avatar, u.signature, u.disp_topics, u.disp_posts, u.email_setting, u.save_pass, u.notify_with_post, u.show_smilies, u.show_img, u.show_img_sig, u.show_avatars, u.show_sig, u.timezone, u.language, u.style, u.num_posts, u.last_post, u.registered, u.registration_ip, u.admin_note, g.g_id, g.g_user_title FROM '.$db->prefix.'users AS u LEFT JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id WHERE u.id='.$id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
Replace with:
$result = $db->query('SELECT u.username, u.email, u.title, u.realname, u.url, u.jabber, u.icq, u.msn, u.aim, u.yahoo, u.location, u.use_avatar, u.signature, u.disp_topics, u.disp_posts, u.email_setting, u.save_pass, u.notify_with_post, u.show_smilies, u.show_img, u.show_img_sig, u.show_avatars, u.show_sig, u.timezone, u.language, u.style, u.num_posts, u.last_post, u.registered, u.registration_ip, u.admin_note, g.g_id, g.g_user_title, g.g_title FROM '.$db->prefix.'users AS u LEFT JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id WHERE u.id='.$id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
Now find:
<dd><?php echo pun_htmlspecialchars($user['username']) ?></dd>
Replace that with:
<dd><?php echo '<span class="'.$user['g_title'].'"><a href="profile.php?id='.$id.'">'.pun_htmlspecialchars($user['username']).'</a></span>' ?></dd>
Now, this is where we style the links for each of the groups .
Open up either your main.tpl, or a specific style sheet ( your_style.css ).
For main.tpl
Add this in between the <head> tag:
<style type="text/css">
span.Administrators a:link, span.Administrators a:visited {
color: #ff9900;
font-size: 12px;
}
span.Administrators a:hover {
color: #ff9966;
font-size: 12px;
text-decoration: underline;
}
span.Moderators a:link, span.Moderators a:visited {
color: #009900;
font-size: 12px;
}
span.Moderators a:hover {
color: #00bb00;
font-size: 12px;
text-decoration: underline;
}
</style>
For the style sheet
Add this at the end of it:
span.Administrators a:link, span.Administrators a:visited {
color: #ff9900;
font-size: 12px;
}
span.Administrators a:hover {
color: #ff9966;
font-size: 12px;
text-decoration: underline;
}
span.Moderators a:link, span.Moderators a:visited {
color: #009900;
font-size: 12px;
}
span.Moderators a:hover {
color: #00bb00;
font-size: 12px;
text-decoration: underline;
}
That should be all! Let me know how it works.