Skip to content

Instantly share code, notes, and snippets.

@AmauryCarrade
Last active September 4, 2016 13:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AmauryCarrade/4fdb17c9804ff390db7cbc67a288c19d to your computer and use it in GitHub Desktop.
Save AmauryCarrade/4fdb17c9804ff390db7cbc67a288c19d to your computer and use it in GitHub Desktop.
Changes to display ranks on FluxBB topics
diff --git a/viewtopic.php b/viewtopic.php
index 87f47b5..9b36032 100755
--- a/viewtopic.php
+++ b/viewtopic.php
@@ -194,6 +194,53 @@ require PUN_ROOT.'header.php';
<?php
+// ------ DISPLAYED RANKS ON THE FORUMS - CONFIG
+
+// True to display the ranks
+$zcraft_ranks_enabled = true;
+
+// Association between the rank name in database (not title!) and the displayed name.
+// Unlisted groups are not displayed.
+// Style from CSS (using lowercased display name).
+$zcraft_ranks_displayed = array(
+ 'Administrateurs' => 'Admin',
+ 'Gardiens' => 'Gardien',
+ 'Animateurs' => 'Animateur'
+);
+
+// Users excluded from ranks display
+$zcraft_ranks_excluded = array('Admin1');
+
+// CSS styles
+?>
+
+<style type="text/css">
+ .zcraft-rank {
+ font-size: 1.1em;
+ font-variant: small-caps;
+ font-weight: initial;
+ margin-right: 12px;
+ margin-left: 14px;
+ float: right;
+ }
+
+ .zcraft-rank.gardien {
+ color: green;
+ }
+
+ .zcraft-rank.admin {
+ color: red;
+ }
+
+ .zcraft-rank.animateur {
+ color: #db49ff;
+ }
+</style>
+
+<?php
+// ------ END RANKS CONFIG
+
+
require PUN_ROOT.'include/parser.php';
$post_count = 0; // Keep track of post numbers
@@ -206,7 +253,7 @@ for ($i = 0;$cur_post_id = $db->result($result, $i);$i++)
$post_ids[] = $cur_post_id;
// Retrieve the posts (and their respective poster/online status)
-$result = $db->query('SELECT u.email, u.title, u.url, u.location, 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.id IN ('.implode(',', $post_ids).') ORDER BY p.id', true) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
+$result = $db->query('SELECT u.email, u.title, u.url, u.location, 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_title, 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.id IN ('.implode(',', $post_ids).') ORDER BY p.id', true) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
while ($cur_post = $db->fetch_assoc($result))
{
$post_count++;
@@ -230,6 +277,7 @@ while ($cur_post = $db->fetch_assoc($result))
$username = pun_htmlspecialchars($cur_post['username']);
$user_title = get_title($cur_post);
+ $user_rank = $zcraft_ranks_enabled && !in_array($cur_post['username'], $zcraft_ranks_excluded) && array_key_exists($cur_post['g_title'], $zcraft_ranks_displayed) ? $zcraft_ranks_displayed[$cur_post['g_title']] : null;
if ($pun_config['o_censoring'] == '1')
$user_title = censor_words($user_title);
@@ -351,7 +399,12 @@ while ($cur_post = $db->fetch_assoc($result))
<div class="postbody">
<div class="postleft">
<dl>
- <dt><strong><?php echo $username ?></strong></dt>
+ <dt>
+ <strong><?php echo $username ?></strong>
+ <?php if ($user_rank != null): ?>
+ <span class="zcraft-rank <?php echo strtolower($user_rank); ?>"><?php echo strtolower($user_rank); ?></span>
+ <?php endif; ?>
+ </dt>
<dd class="usertitle"><strong><?php echo $user_title ?></strong></dd>
<?php if ($user_avatar != '') echo "\t\t\t\t\t\t".'<dd class="postavatar">'.$user_avatar.'</dd>'."\n"; ?>
<?php if (count($user_info)) echo "\t\t\t\t\t\t".implode("\n\t\t\t\t\t\t", $user_info)."\n"; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment