Get started with PHP-Fusion

Start a New Thread

Users Participated

  • Penguinish
    Post made: 3
  • PolarFox
    Post made: 1
  • krystian1988
    Post made: 1

  1. PHP-Fusion Support Forums
  2. General Addon and Modification Support
  3. Modifications and Requests

How to show special & post count ranks at same time

Post your modification and request questions here

4 Replies 2,436 Views Last Updated on 2 years ago

Penguinish


Junior Member

#1

Posted 2 years ago

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

Code Gist: Download source  
      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?

Posts: 24

Joined: 13/09/2007

PolarFox


Admin

#2

Posted 2 years ago

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



Code Gist: Download source  
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...

Posts: 1641

Joined: 26/08/2008

Penguinish


Junior Member

#3

Posted 2 years ago

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

to
Code Gist: Download source  
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"

Posts: 24

Joined: 13/09/2007

krystian1988


Newbie

#4

Posted 2 years ago

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]

Posts: 4

Joined: 03/11/2010

Penguinish


Junior Member

#5

Posted 2 years ago

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 07:04

Posts: 24

Joined: 13/09/2007

Jump to Forum:
8 users are online
0 member and 8 guests