Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

How to show special & post count ranks at same time

Asked Modified Viewed 3,593 times
P
Penguinish
P
  • Junior Member, joined since
  • Contributed 24 posts on the community forums.
  • Started 6 threads in the forums
  • Started this discussions
asked
Junior Member

I want both "special ranks" and post count ranks to show in the view thread. Special Ranks on top and post count on bottom.

I know its gotta be done somewhere in this code

      if ($data['user_level'] >= 102) {
         echo $settings['forum_ranks'] ? show_forum_rank($data['user_posts'], $data['user_level'], $data['user_groups']) : getuserlevel($data['user_level']);
      } else {
         $is_mod = false;
         foreach ($mod_groups as $mod_group) {
            if (!$is_mod && preg_match("(^\.{$mod_group}$|\.{$mod_group}\.|\.{$mod_group}$)", $data['user_groups'])) {
               $is_mod = true;
            }
         }
         if ($settings['forum_ranks']) {
            echo $is_mod ? show_forum_rank($data['user_posts'], 104, $data['user_groups']) : show_forum_rank($data['user_posts'], $data['user_level'], $data['user_groups']);
         } else {
            echo $is_mod ? $locale['userf1'] : getuserlevel($data['user_level']);
         }
      }


but for the love of god I cant seem to figure it out. Any help in the right direction?
0 replies

4 posts

P
PolarFox
P
  • Veteran Member, joined since
  • Contributed 1,633 posts on the community forums.
  • Started 29 threads in the forums
answered
Veteran Member

Try to:
         if ($settings['forum_ranks']) {
            echo $is_mod ? show_forum_rank($data['user_posts'], 104, $data['user_groups']) : show_forum_rank($data['user_posts'], $data['user_level'], $data['user_groups']);
         } else {
            echo $is_mod ? $locale['userf1'] : getuserlevel($data['user_level']);
         }



echo $is_mod ? show_forum_rank($data['user_posts'], 104, $data['user_groups']) : show_forum_rank($data['user_posts'], $data['user_level'], $data['user_groups']);

echo $is_mod ? $locale['userf1'] : getuserlevel($data['user_level']);

no IF and no ELSE...
0 replies
P
Penguinish
P
  • Junior Member, joined since
  • Contributed 24 posts on the community forums.
  • Started 6 threads in the forums
  • Started this discussions
answered
Junior Member

That did not work at first but I changed the last line in your suggestion from
echo $is_mod ? $locale['userf1'] : getuserlevel($data['user_level']);

to
echo $is_mod ? $locale['userf1'] : show_forum_rank($data['user_posts']);


It now works! Unless the person has mod permissions then it takes off post cost rank any idea on that?

i.imgur.com/4a5ikJV.png
I just want the rank images to show not the "labels"
0 replies
K
krystian1988
K
  • Newbie, joined since
  • Contributed 4 posts on the community forums.
  • Started 1 thread in the forums
answered
Newbie

Change includes_forum_include.php this:
[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]<?php
/*-------------------------------------------------------+
| PHPFusion Content Management System
| Copyright (C) 2002 - 2011 Nick Jones
| http://www.php-fusion.co.uk/
+--------------------------------------------------------+
| Filename: forum_include.php
| Author: Nick Jones (Digitanium)
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
if (!defined("IN_FUSION"wink) { die("Access Denied"wink; }

$imagetypes = array(
".bmp",
".gif",
".iff",
".jpg",
".jpeg",
".png",
".psd",
".tiff",
".wbmp"
);

function attach_exists($file) {
$dir = FORUM."attachments/";
$i = 1;
$file_name = substr($file, 0, strrpos($file, "."wink);
$file_ext = strrchr($file, "."wink;
while (file_exists($dir.$file)) {
$file = $file_name."_".$i.$file_ext;
$i++;
}
return $file;
}

function forum_rank_cache() {
global $settings, $forum_mod_rank_cache, $forum_post_rank_cache, $forum_special_rank_cache;
$forum_post_rank_cache = array();
$forum_mod_rank_cache = array();
$forum_special_rank_cache = array();
if ($settings['forum_ranks']) {
$result = dbquery("SELECT rank_title, rank_image, rank_type, rank_posts, rank_apply FROM ".DB_FORUM_RANKS." ORDER BY rank_apply DESC, rank_posts ASC"wink;
if (dbrows($result)) {
while ($data = dbarray($result)) {
if ($data['rank_type'] == 0) {
$forum_post_rank_cache[] = $data;
} elseif ($data['rank_type'] == 1) {
$forum_mod_rank_cache[] = $data;
} else {
$forum_special_rank_cache[] = $data;
}
}
}
}
}

function show_forum_rank($posts, $level, $groups) {
global $locale, $settings, $forum_mod_rank_cache, $forum_post_rank_cache, $forum_special_rank_cache;
$res = "";
if ($settings['forum_ranks']) {
if (!$forum_post_rank_cache) { forum_rank_cache(); }
// Moderator ranks
if ($level > 101 && is_array($forum_mod_rank_cache) && count($forum_mod_rank_cache)) {
for ($i = 0; $i < count($forum_mod_rank_cache) && !$res; $i++) {
if ($level == $forum_mod_rank_cache[$i]['rank_apply']) {
//$res = $forum_mod_rank_cache[$i]['rank_title']."<br />\n<img src='".RANKS.$forum_mod_rank_cache[$i]['rank_image']."' alt='' style='border:0' /><br />";
$res = "<img src='".RANKS.$forum_mod_rank_cache[$i]['rank_image']."' alt='' style='border:0' /><br />";
}
}
}
// Special ranks
if ($groups != "" && is_array($forum_special_rank_cache) && count($forum_special_rank_cache)) {
for ($i = 0; $i < count($forum_special_rank_cache); $i++) {
if (in_array($forum_special_rank_cache[$i]['rank_apply'], explode(".", $groups))) {
//$res .= $forum_special_rank_cache[$i]['rank_title']."<br />\n<img src='".RANKS.$forum_special_rank_cache[$i]['rank_image']."' alt='' style='border:0' /><br />";
$res .= "<img src='".RANKS.$forum_special_rank_cache[$i]['rank_image']."' alt='' style='border:0' /><br />";
}
}
}
// Post count ranks
if (!$res && is_array($forum_post_rank_cache) && count($forum_post_rank_cache)) {
for ($i = 0; $i < count($forum_post_rank_cache); $i++) {
if ($posts >= $forum_post_rank_cache[$i]['rank_posts']) {
//$res = $forum_post_rank_cache[$i]['rank_title']."<br />\n<img src='".RANKS.$forum_post_rank_cache[$i]['rank_image']."' alt='' style='border:0' /><br />";
$res .= "<img src='".RANKS.$forum_post_rank_cache[$i]['rank_image']."' alt='' style='border:0' /><br />";
}
}
if (!$res) {
//$res .= $forum_post_rank_cache[0]['rank_title']."<br />\n<img src='".RANKS.$forum_post_rank_cache[0]['rank_image']."' alt='' style='border:0' /><br />";
$res .= "<img src='".RANKS.$forum_post_rank_cache[0]['rank_image']."' alt='' style='border:0' /><br />";
}
}
}
return $res;
}

function display_image($file) {
$size = @getimagesize(FORUM."attachments/".$file);

if ($size[0] > 300 || $size[1] > 200) {
if ($size[0] <= $size[1]) {
$img_w = round(($size[0] * 200) / $size[1]);
$img_h = 200;
} elseif ($size[0] > $size[1]) {
$img_w = 300;
$img_h = round(($size[1] * 300) / $size[0]);
} else {
$img_w = 300;
$img_h = 200;
}
} else {
$img_w = $size[0];
$img_h = $size[1];
}

if ($size[0] != $img_w || $size[1] != $img_h) {
$res = "<a href='".FORUM."attachments/".$file."'><img src='".FORUM."attachments/".$file."' width='".$img_w."' height='".$img_h."' style='border:0;' alt='".$file."' /></a>";
} else {
$res = "<img src='".FORUM."attachments/".$file."' width='".$img_w."' height='".$img_h."' style='border:0;' alt='".$file."' />";
}

return $res;
}

function display_image_attach($file, $width = 50, $height = 50, $rel = ""wink {
$size = @getimagesize(FORUM."attachments/".$file);

if ($size [0] > $height || $size [1] > $width) {
if ($size [0] < $size [1]) {
$img_w = round ( ($size [0] * $width) / $size [1] );
$img_h = $width;
} elseif ($size [0] > $size [1]) {
$img_w = $height;
$img_h = round ( ($size [1] * $height) / $size [0] );
} else {
$img_w = $height;
$img_h = $width;
}
} else {
$img_w = $size [0];
$img_h = $size [1];
}


$res = "<a target='_blank' href='".FORUM."attachments/".$file."' rel='attach_".$rel."' title='".$file."'><img src='".FORUM."attachments/".$file."' alt='".$file."' style='border:0px; width:".$img_w."px; height:".$img_h."px;' /></a>\n";

return $res;
}

if (isset($_GET['getfile']) && isnum($_GET['getfile'])) {
$result = dbquery("SELECT attach_id, attach_name FROM ".DB_FORUM_ATTACHMENTS." WHERE attach_id='".$_GET['getfile']."'"wink;
if (dbrows($result)) {
$data = dbarray($result);
if (file_exists(FORUM."attachments/".$data['attach_name'])) {
$attach_count = dbquery("UPDATE ".DB_FORUM_ATTACHMENTS." SET attach_count=attach_count+1 WHERE attach_id='".$data['attach_id']."'"wink;
require_once INCLUDES."class.httpdownload.php";
ob_end_clean();
$object = new httpdownload;
$object->set_byfile(FORUM."attachments/".$data['attach_name']);
$object->use_resume = true;
$object->download();
} else {
redirect("index.php"wink;
}
}
exit;
}
?>[/syntaxhighlighter]
0 replies
P
Penguinish
P
  • Junior Member, joined since
  • Contributed 24 posts on the community forums.
  • Started 6 threads in the forums
  • Started this discussions
answered
Junior Member

Thanks Krystian that worked! Ok after some condition checking I found an issue. If someones post count reaches the next rank in this example pawn =0 posts miner =1 post. You can see the post count ranks stack. only the special ranks should stack and post count ranks change. Picture example.
i.imgur.com/AJxuEo9.png
Here is my current code I also have krystians includes edit running as well.

[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]if ($data['user_level'] >= 102) {
echo $settings['forum_ranks'] ? show_forum_rank($data['user_posts'], $data['user_level'], $data['user_groups']) : getuserlevel($data['user_level']);
} else {
$is_mod = false;
foreach ($mod_groups as $mod_group) {
if (!$is_mod && preg_match("(^\.{$mod_group}$|\.{$mod_group}\.|\.{$mod_group}$)")) {
$is_mod = true;
}

}
echo $is_mod ? show_forum_rank($data['user_posts'], 104, $data['user_groups']) : show_forum_rank($data['user_posts'], $data['user_level'], $data['user_groups']);

echo $is_mod ? $locale['userf1'] : show_forum_rank($data['user_posts']);


}[/syntaxhighlighter]

Merged on Jan 30 2013 at 06:03:09:
Ok its been a few days and im still at a loss on this issue. Let me try to clarify what Im trying to achieve and go from there.

If user is admin or super admin
> display usergroup special rank
> do not display post count rank

If user is forum mod
> display all user group special ranks (top)
> display post count rank (bottom)

if user is member
> display all special ranks (top)
> display post count rank (bottom)

right now the default code only allows one or the other, and the solution polar provided only fixes if use is member issue, not if user is form mod issue. Thanks :)
Edited by Penguinish on 30-01-2013 08:04,
0 replies

Labels

None yet

Statistics

  • Views 0 views
  • Posts 4 posts
  • Votes 0 votes
  • Topic users 3 members

3 participants

P
P
  • Junior Member, joined since
  • Contributed 24 posts on the community forums.
  • Started 6 threads in the forums
  • Started this discussions
P
P
  • Veteran Member, joined since
  • Contributed 1,633 posts on the community forums.
  • Started 29 threads in the forums
K
K
  • Newbie, joined since
  • Contributed 4 posts on the community forums.
  • Started 1 thread in the forums

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet