Login
Username

Password



Not a member yet?
Click here to register.

Forgotten your password?
Request a new one here.
Navigation
Follow us on Facebook
Follow us on Google+
View Thread
Official Home of PHP-Fusion » General Addon and Modification Support » Modifications and Requests
Who is here? 1 guest(s)
 Print Thread
How to show special & post count ranks at same time
Penguinish
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

Download source  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?
 
PolarFox
Try to:
Download source  Code
         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']);
         }





Download source  Code
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...
 
http://unlogic.info
Penguinish
That did not work at first but I changed the last line in your suggestion from
Download source  Code
echo $is_mod ? $locale['userf1'] : getuserlevel($data['user_level']);



to
Download source  Code
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"
 
krystian1988
Change includes_forum_include.php this:
[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]<?php
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) 2002 - 2011 Nick Jones
| http://www.php-fu...
+--------------------------------------------------------+
| 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/licen... Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
if (!defined("IN_FUSION")) { die("Access Denied"); }

$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, "."));
$file_ext = strrchr($file, ".");
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");
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 = "") {
$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']."'");
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']."'");
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");
}
}
exit;
}
?>[/syntaxhighlighter]
 
Penguinish
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}$)"Wink) {
$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 Smile
Edited by Penguinish on 30-01-2013 06:04
 
Jump to Forum:
Similar Threads
Thread Forum Replies Last Post
How to show "Forum Activity"? Site & Forum Issues 4 10-04-2014 12:30
Ajax Forum Post Ratings Panel V2.00 Released Panels and Infusions 11 28-03-2014 21:06
Guest post in a single forum User Administration 4 23-03-2014 04:33
Centar panels won't show up Site & Forum Issues 6 16-03-2014 13:00
Special Multisite Modifications and Requests 3 08-03-2014 14:36
Official Home of PHP-Fusion uses cookies. Some may already have been set. Read more about our Cookies here.
Please click the button I Consent Cookies to hide this bar and accept our cookies. If you continue to use the site with no action taken, we'll assume that you consent our cookies anyway.
Cookiebar Panel fromVenue