Warning: The author of this contribution does not provide support for it anymore.

Avatar of poster on Index and Viewforum

Default avatar thumb in viewforum - Avatar of poster on Index and Viewforum

Default avatar thumb in viewforum

by stokerpiller » Sun Jun 06, 2010 7:16 pm

Hello Lefty,

I have folloved your guide for displaying resized default avatar here: viewtopic.php?f=69&t=1369535&start=30#p9055405
Works fine exept viewforum where the avatar isnt resized.
Do you have a solution for this?


EDIT
Found the answer on your site: http://www.lefty74.com/viewtopic.php?f= ... =100#p3823
I am done with phpBB
stokerpiller
Registered User
Posts: 1934
Joined: Wed Feb 28, 2007 8:06 pm

Re: Default avatar thumb in viewforum

by lefty74 » Sun Jun 06, 2010 9:30 pm

hi Stoker,
Glad you found it. Will have to add this to the FAQs one of these days...
lefty74
zoocrew.eu - help us save our wildlife
My MODS | Due to lack of time I unfortunately am unable to work on my mods anymore, anyone who has ideas to improve them and would like to take any of them over, please PM me.
User avatar
lefty74
Registered User
Posts: 3649
Joined: Wed Sep 14, 2005 8:26 pm
Location: NL

Re: Default avatar thumb in viewforum

by stokerpiller » Thu Jun 10, 2010 6:29 am

I found a new error:

Code: Select all

[phpBB Debug] PHP Notice: in file /includes/functions_display.php  on line 505: Undefined variable: avatar_width
[phpBB Debug] PHP Notice: in file /includes/functions_display.php on line 505: Undefined variable: avatar_height
[phpBB Debug] PHP Notice: in file /includes/functions_display.php on line 506: Undefined variable: avatar_width
[phpBB Debug] PHP Notice: in file /includes/functions_display.php on line 506: Undefined variable: avatar_width


The bug only occur when viewing a category and the default avatar is not resized.
I am done with phpBB
stokerpiller
Registered User
Posts: 1934
Joined: Wed Feb 28, 2007 8:06 pm

Re: Default avatar thumb in viewforum

by stokerpiller » Mon Jun 14, 2010 1:10 pm

Bump :)
I am done with phpBB
stokerpiller
Registered User
Posts: 1934
Joined: Wed Feb 28, 2007 8:06 pm

Re: Default avatar thumb in viewforum

by lefty74 » Tue Jun 15, 2010 6:51 pm

hi stoker, not forgotten, just havent gotten round looking at it.
lefty74
zoocrew.eu - help us save our wildlife
My MODS | Due to lack of time I unfortunately am unable to work on my mods anymore, anyone who has ideas to improve them and would like to take any of them over, please PM me.
User avatar
lefty74
Registered User
Posts: 3649
Joined: Wed Sep 14, 2005 8:26 pm
Location: NL

Re: Default avatar thumb in viewforum

by lefty74 » Sat Jun 19, 2010 3:33 pm

stokerpiller wrote:I found a new error:

Code: Select all

[phpBB Debug] PHP Notice: in file /includes/functions_display.php  on line 505: Undefined variable: avatar_width
[phpBB Debug] PHP Notice: in file /includes/functions_display.php on line 505: Undefined variable: avatar_height
[phpBB Debug] PHP Notice: in file /includes/functions_display.php on line 506: Undefined variable: avatar_width
[phpBB Debug] PHP Notice: in file /includes/functions_display.php on line 506: Undefined variable: avatar_width


The bug only occur when viewing a category and the default avatar is not resized.


stoker, what do you mean by 'is not resized'. the default avatar is smaller than 40 px?
lefty74
zoocrew.eu - help us save our wildlife
My MODS | Due to lack of time I unfortunately am unable to work on my mods anymore, anyone who has ideas to improve them and would like to take any of them over, please PM me.
User avatar
lefty74
Registered User
Posts: 3649
Joined: Wed Sep 14, 2005 8:26 pm
Location: NL

Re: Default avatar thumb in viewforum

by stokerpiller » Sat Jun 19, 2010 3:52 pm

I use the the default avatar thing posted by you partly here and on your own site.

We have a category and when we click on it, like here: viewforum.php?f=81
and one of the last posts is made by a user with no avatar it gives the debug error. And the default avatar is not resized to 40 px

Hope it makes sense.
I am done with phpBB
stokerpiller
Registered User
Posts: 1934
Joined: Wed Feb 28, 2007 8:06 pm

Re: Default avatar thumb in viewforum

by lefty74 » Sat Jun 19, 2010 4:26 pm

it makes sense but i can't recreate that error.
http://screencast.com/t/MDc1NmFiO

it works fine for me.
lefty74
zoocrew.eu - help us save our wildlife
My MODS | Due to lack of time I unfortunately am unable to work on my mods anymore, anyone who has ideas to improve them and would like to take any of them over, please PM me.
User avatar
lefty74
Registered User
Posts: 3649
Joined: Wed Sep 14, 2005 8:26 pm
Location: NL

Re: Default avatar thumb in viewforum

by stokerpiller » Sat Jun 19, 2010 4:44 pm

Its because you are in forum view. That works fine for me too.
You need to go to category view, just like this (we are viewing a catagory): viewforum.php?f=81
I am done with phpBB
stokerpiller
Registered User
Posts: 1934
Joined: Wed Feb 28, 2007 8:06 pm

Re: Default avatar thumb in viewforum

by lefty74 » Sat Jun 19, 2010 5:10 pm

category view, forum view, makes no difference on my testboard, avatar shows fine in both views.
lefty74
zoocrew.eu - help us save our wildlife
My MODS | Due to lack of time I unfortunately am unable to work on my mods anymore, anyone who has ideas to improve them and would like to take any of them over, please PM me.
User avatar
lefty74
Registered User
Posts: 3649
Joined: Wed Sep 14, 2005 8:26 pm
Location: NL

Re: Default avatar thumb in viewforum

by stokerpiller » Sat Jun 19, 2010 5:41 pm

Take a look here: http://www.phpbb3bbcodes.com/viewforum.php?f=1
I have disabled debug, but take a look at the avatar size.
I am done with phpBB
stokerpiller
Registered User
Posts: 1934
Joined: Wed Feb 28, 2007 8:06 pm

Re: Default avatar thumb in viewforum

by stokerpiller » Sat Jun 19, 2010 6:27 pm

Maybe you can post up your viewforum.php?
I am done with phpBB
stokerpiller
Registered User
Posts: 1934
Joined: Wed Feb 28, 2007 8:06 pm

Re: Default avatar thumb in viewforum

by lefty74 » Sat Jun 19, 2010 6:31 pm

what does your viewforum.php and includes/functions_display.php look like?
lefty74
zoocrew.eu - help us save our wildlife
My MODS | Due to lack of time I unfortunately am unable to work on my mods anymore, anyone who has ideas to improve them and would like to take any of them over, please PM me.
User avatar
lefty74
Registered User
Posts: 3649
Joined: Wed Sep 14, 2005 8:26 pm
Location: NL

Re: Default avatar thumb in viewforum

by lefty74 » Sat Jun 19, 2010 6:33 pm

Code: Select all

<?php
/**
*
* @package phpBB3
* @version $Id: viewforum.php 8 2010-03-13 03:07:00Z jari $
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
* @ignore
*/
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);

// Start session
$user->session_begin();
$auth->acl($user->data);

// Start initial var setup
$forum_id   = request_var('f', 0);
$mark_read   = request_var('mark', '');
$start      = request_var('start', 0);

$default_sort_days   = (!empty($user->data['user_topic_show_days'])) ? $user->data['user_topic_show_days'] : 0;
$default_sort_key   = (!empty($user->data['user_topic_sortby_type'])) ? $user->data['user_topic_sortby_type'] : 't';
$default_sort_dir   = (!empty($user->data['user_topic_sortby_dir'])) ? $user->data['user_topic_sortby_dir'] : 'd';

$sort_days   = request_var('st', $default_sort_days);
$sort_key   = request_var('sk', $default_sort_key);
$sort_dir   = request_var('sd', $default_sort_dir);

// Check if the user has actually sent a forum ID with his/her request
// If not give them a nice error page.
if (!$forum_id)
{
   trigger_error('NO_FORUM');
}

$sql_from = FORUMS_TABLE . ' f';
$lastread_select = '';

// Grab appropriate forum data
if ($config['load_db_lastread'] && $user->data['is_registered'])
{
   $sql_from .= ' LEFT JOIN ' . FORUMS_TRACK_TABLE . ' ft ON (ft.user_id = ' . $user->data['user_id'] . '
      AND ft.forum_id = f.forum_id)';
   $lastread_select .= ', ft.mark_time';
}

if ($user->data['is_registered'])
{
   $sql_from .= ' LEFT JOIN ' . FORUMS_WATCH_TABLE . ' fw ON (fw.forum_id = f.forum_id AND fw.user_id = ' . $user->data['user_id'] . ')';
   $lastread_select .= ', fw.notify_status';
}

$sql = "SELECT f.* $lastread_select
   FROM $sql_from
   WHERE f.forum_id = $forum_id";
$result = $db->sql_query($sql);
$forum_data = $db->sql_fetchrow($result);
$db->sql_freeresult($result);

if (!$forum_data)
{
   trigger_error('NO_FORUM');
}


// Configure style, language, etc.
$user->setup('viewforum', $forum_data['forum_style']);

// Redirect to login upon emailed notification links
if (isset($_GET['e']) && !$user->data['is_registered'])
{
   login_box('', $user->lang['LOGIN_NOTIFY_FORUM']);
}

// Permissions check
if (!$auth->acl_gets('f_list', 'f_read', $forum_id) || ($forum_data['forum_type'] == FORUM_LINK && $forum_data['forum_link'] && !$auth->acl_get('f_read', $forum_id)))
{
   if ($user->data['user_id'] != ANONYMOUS)
   {
      trigger_error('SORRY_AUTH_READ');
   }

   login_box('', $user->lang['LOGIN_VIEWFORUM']);
}

// Forum is passworded ... check whether access has been granted to this
// user this session, if not show login box
if ($forum_data['forum_password'])
{
   login_forum_box($forum_data);
}

// Is this forum a link? ... User got here either because the
// number of clicks is being tracked or they guessed the id
if ($forum_data['forum_type'] == FORUM_LINK && $forum_data['forum_link'])
{
   // Does it have click tracking enabled?
   if ($forum_data['forum_flags'] & FORUM_FLAG_LINK_TRACK)
   {
      $sql = 'UPDATE ' . FORUMS_TABLE . '
         SET forum_posts = forum_posts + 1
         WHERE forum_id = ' . $forum_id;
      $db->sql_query($sql);
   }

   // We redirect to the url. The third parameter indicates that external redirects are allowed.
   redirect($forum_data['forum_link'], false, true);
   return;
}

// Build navigation links
generate_forum_nav($forum_data);

// Forum Rules
if ($auth->acl_get('f_read', $forum_id))
{
   generate_forum_rules($forum_data);
}

// Do we have subforums?
$active_forum_ary = $moderators = array();

if ($forum_data['left_id'] != $forum_data['right_id'] - 1)
{
   list($active_forum_ary, $moderators) = display_forums($forum_data, $config['load_moderators'], $config['load_moderators']);
}
else
{
   $template->assign_var('S_HAS_SUBFORUM', false);
   if ($config['load_moderators'])
   {
      get_moderators($moderators, $forum_id);
   }
}

// Dump out the page header and load viewforum template
page_header($user->lang['VIEW_FORUM'] . ' - ' . $forum_data['forum_name'], true, $forum_id);

$template->set_filenames(array(
   'body' => 'viewforum_body.html')
);

make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"), $forum_id);

$template->assign_vars(array(
   'U_VIEW_FORUM'         => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id&amp;start=$start"),
));

// Not postable forum or showing active topics?
if (!($forum_data['forum_type'] == FORUM_POST || (($forum_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS) && $forum_data['forum_type'] == FORUM_CAT)))
{
   page_footer();
}

// Ok, if someone has only list-access, we only display the forum list.
// We also make this circumstance available to the template in case we want to display a notice. ;)
if (!$auth->acl_get('f_read', $forum_id))
{
   $template->assign_vars(array(
      'S_NO_READ_ACCESS'      => true,
   ));

   page_footer();
}

// Handle marking posts
if ($mark_read == 'topics')
{
   $token = request_var('hash', '');
   if (check_link_hash($token, 'global'))
   {
      // Add 0 to forums array to mark global announcements correctly
      markread('topics', array($forum_id, 0));
   }
   $redirect_url = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id);
   meta_refresh(3, $redirect_url);

   trigger_error($user->lang['TOPICS_MARKED'] . '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="' . $redirect_url . '">', '</a>'));
}

// Is a forum specific topic count required?
if ($forum_data['forum_topics_per_page'])
{
   $config['topics_per_page'] = $forum_data['forum_topics_per_page'];
}

// Do the forum Prune thang - cron type job ...
if ($forum_data['prune_next'] < time() && $forum_data['enable_prune'])
{
   $template->assign_var('RUN_CRON_TASK', '<img src="' . append_sid($phpbb_root_path . 'cron.' . $phpEx, 'cron_type=prune_forum&amp;f=' . $forum_id) . '" alt="cron" width="1" height="1" />');
}

// Forum rules and subscription info
$s_watching_forum = array(
   'link'         => '',
   'title'         => '',
   'is_watching'   => false,
);

if (($config['email_enable'] || $config['jab_enable']) && $config['allow_forum_notify'] && $forum_data['forum_type'] == FORUM_POST && $auth->acl_get('f_subscribe', $forum_id))
{
   $notify_status = (isset($forum_data['notify_status'])) ? $forum_data['notify_status'] : NULL;
   watch_topic_forum('forum', $s_watching_forum, $user->data['user_id'], $forum_id, 0, $notify_status);
}

$s_forum_rules = '';
gen_forum_auth_level('forum', $forum_id, $forum_data['forum_status']);

// Topic ordering options
$limit_days = array(0 => $user->lang['ALL_TOPICS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);

$sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 'r' => $user->lang['REPLIES'], 's' => $user->lang['SUBJECT'], 'v' => $user->lang['VIEWS']);
$sort_by_sql = array('a' => 't.topic_first_poster_name', 't' => 't.topic_last_post_time', 'r' => 't.topic_replies', 's' => 't.topic_title', 'v' => 't.topic_views');

$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param, $default_sort_days, $default_sort_key, $default_sort_dir);

// Limit topics to certain time frame, obtain correct topic count
// global announcements must not be counted, normal announcements have to
// be counted, as forum_topics(_real) includes them
if ($sort_days)
{
   $min_post_time = time() - ($sort_days * 86400);

   $sql = 'SELECT COUNT(topic_id) AS num_topics
      FROM ' . TOPICS_TABLE . "
      WHERE forum_id = $forum_id
         AND ((topic_type <> " . POST_GLOBAL . " AND topic_last_post_time >= $min_post_time)
            OR topic_type = " . POST_ANNOUNCE . ")
      " . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND topic_approved = 1');
   $result = $db->sql_query($sql);
   $topics_count = (int) $db->sql_fetchfield('num_topics');
   $db->sql_freeresult($result);

   if (isset($_POST['sort']))
   {
      $start = 0;
   }
   $sql_limit_time = "AND t.topic_last_post_time >= $min_post_time";

   // Make sure we have information about day selection ready
   $template->assign_var('S_SORT_DAYS', true);
}
else
{
   $topics_count = ($auth->acl_get('m_approve', $forum_id)) ? $forum_data['forum_topics_real'] : $forum_data['forum_topics'];
   $sql_limit_time = '';
}

// Make sure $start is set to the last page if it exceeds the amount
if ($start < 0 || $start > $topics_count)
{
   $start = ($start < 0) ? 0 : floor(($topics_count - 1) / $config['topics_per_page']) * $config['topics_per_page'];
}

// Basic pagewide vars
$post_alt = ($forum_data['forum_status'] == ITEM_LOCKED) ? $user->lang['FORUM_LOCKED'] : $user->lang['POST_NEW_TOPIC'];

// Display active topics?
$s_display_active = ($forum_data['forum_type'] == FORUM_CAT && ($forum_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS)) ? true : false;

$template->assign_vars(array(
   'MODERATORS'   => (!empty($moderators[$forum_id])) ? implode(', ', $moderators[$forum_id]) : '',

   'POST_IMG'               => ($forum_data['forum_status'] == ITEM_LOCKED) ? $user->img('button_topic_locked', $post_alt) : $user->img('button_topic_new', $post_alt),
   'NEWEST_POST_IMG'         => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'),
   'LAST_POST_IMG'            => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'),
   'FOLDER_IMG'            => $user->img('topic_read', 'NO_NEW_POSTS'),
   'FOLDER_NEW_IMG'         => $user->img('topic_unread', 'NEW_POSTS'),
   'FOLDER_HOT_IMG'         => $user->img('topic_read_hot', 'NO_NEW_POSTS_HOT'),
   'FOLDER_HOT_NEW_IMG'      => $user->img('topic_unread_hot', 'NEW_POSTS_HOT'),
   'FOLDER_LOCKED_IMG'         => $user->img('topic_read_locked', 'NO_NEW_POSTS_LOCKED'),
   'FOLDER_LOCKED_NEW_IMG'      => $user->img('topic_unread_locked', 'NEW_POSTS_LOCKED'),
   'FOLDER_STICKY_IMG'         => $user->img('sticky_read', 'POST_STICKY'),
   'FOLDER_STICKY_NEW_IMG'      => $user->img('sticky_unread', 'POST_STICKY'),
   'FOLDER_ANNOUNCE_IMG'      => $user->img('announce_read', 'POST_ANNOUNCEMENT'),
   'FOLDER_ANNOUNCE_NEW_IMG'   => $user->img('announce_unread', 'POST_ANNOUNCEMENT'),
   'FOLDER_MOVED_IMG'         => $user->img('topic_moved', 'TOPIC_MOVED'),
   'REPORTED_IMG'            => $user->img('icon_topic_reported', 'TOPIC_REPORTED'),
   'UNAPPROVED_IMG'         => $user->img('icon_topic_unapproved', 'TOPIC_UNAPPROVED'),
   'GOTO_PAGE_IMG'            => $user->img('icon_post_target', 'GOTO_PAGE'),

   'L_NO_TOPICS'          => ($forum_data['forum_status'] == ITEM_LOCKED) ? $user->lang['POST_FORUM_LOCKED'] : $user->lang['NO_TOPICS'],

   'S_DISPLAY_POST_INFO'   => ($forum_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS)) ? true : false,

   'S_IS_POSTABLE'         => ($forum_data['forum_type'] == FORUM_POST) ? true : false,
   'S_USER_CAN_POST'      => ($auth->acl_get('f_post', $forum_id)) ? true : false,
   'S_DISPLAY_ACTIVE'      => $s_display_active,
   'S_SELECT_SORT_DIR'      => $s_sort_dir,
   'S_SELECT_SORT_KEY'      => $s_sort_key,
   'S_SELECT_SORT_DAYS'   => $s_limit_days,
   'S_TOPIC_ICONS'         => ($s_display_active && sizeof($active_forum_ary)) ? max($active_forum_ary['enable_icons']) : (($forum_data['enable_icons']) ? true : false),
   'S_WATCH_FORUM_LINK'   => $s_watching_forum['link'],
   'S_WATCH_FORUM_TITLE'   => $s_watching_forum['title'],
   'S_WATCHING_FORUM'      => $s_watching_forum['is_watching'],
   'S_FORUM_ACTION'      => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id&amp;start=$start"),
   'S_DISPLAY_SEARCHBOX'   => ($auth->acl_get('u_search') && $auth->acl_get('f_search', $forum_id) && $config['load_search']) ? true : false,
   'S_SEARCHBOX_ACTION'   => append_sid("{$phpbb_root_path}search.$phpEx", 'fid[]=' . $forum_id),
   'S_SINGLE_MODERATOR'   => (!empty($moderators[$forum_id]) && sizeof($moderators[$forum_id]) > 1) ? false : true,
   'S_IS_LOCKED'         => ($forum_data['forum_status'] == ITEM_LOCKED) ? true : false,
   'S_VIEWFORUM'         => true,

   'U_MCP'            => ($auth->acl_get('m_', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "f=$forum_id&amp;i=main&amp;mode=forum_view", true, $user->session_id) : '',
   'U_POST_NEW_TOPIC'   => ($auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS) ? append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=post&amp;f=' . $forum_id) : '',
   'U_VIEW_FORUM'      => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id" . ((strlen($u_sort_param)) ? "&amp;$u_sort_param" : '') . "&amp;start=$start"),
   'U_MARK_TOPICS'      => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'hash=' . generate_link_hash('global') . "&amp;f=$forum_id&amp;mark=topics") : '',
));

// Grab icons
$icons = $cache->obtain_icons();

// Grab all topic data
$rowset = $announcement_list = $topic_list = $global_announce_list = array();

$sql_array = array(
   'SELECT'   => 't.*',
   'FROM'      => array(
      TOPICS_TABLE      => 't'
   ),
   'LEFT_JOIN'   => array(),
);

$sql_approved = ($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND t.topic_approved = 1';

if ($user->data['is_registered'])
{
   if ($config['load_db_track'])
   {
      $sql_array['LEFT_JOIN'][] = array('FROM' => array(TOPICS_POSTED_TABLE => 'tp'), 'ON' => 'tp.topic_id = t.topic_id AND tp.user_id = ' . $user->data['user_id']);
      $sql_array['SELECT'] .= ', tp.topic_posted';
   }

   if ($config['load_db_lastread'])
   {
      $sql_array['LEFT_JOIN'][] = array('FROM' => array(TOPICS_TRACK_TABLE => 'tt'), 'ON' => 'tt.topic_id = t.topic_id AND tt.user_id = ' . $user->data['user_id']);
      $sql_array['SELECT'] .= ', tt.mark_time';

      if ($s_display_active && sizeof($active_forum_ary))
      {
         $sql_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_TRACK_TABLE => 'ft'), 'ON' => 'ft.forum_id = t.forum_id AND ft.user_id = ' . $user->data['user_id']);
         $sql_array['SELECT'] .= ', ft.mark_time AS forum_mark_time';
      }
   }
}

if ($forum_data['forum_type'] == FORUM_POST)
{
   // Obtain announcements ... removed sort ordering, sort by time in all cases
   $sql = $db->sql_build_query('SELECT', array(
      'SELECT'   => $sql_array['SELECT'],
      'FROM'      => $sql_array['FROM'],
      'LEFT_JOIN'   => $sql_array['LEFT_JOIN'],

      'WHERE'      => 't.forum_id IN (' . $forum_id . ', 0)
         AND t.topic_type IN (' . POST_ANNOUNCE . ', ' . POST_GLOBAL . ')',

      'ORDER_BY'   => 't.topic_time DESC',
   ));
   $result = $db->sql_query($sql);

   while ($row = $db->sql_fetchrow($result))
   {
      $rowset[$row['topic_id']] = $row;
      $announcement_list[] = $row['topic_id'];

      if ($row['topic_type'] == POST_GLOBAL)
      {
         $global_announce_list[$row['topic_id']] = true;
      }
      else
      {
         $topics_count--;
      }
   }
   $db->sql_freeresult($result);
}

// If the user is trying to reach late pages, start searching from the end
$store_reverse = false;
$sql_limit = $config['topics_per_page'];
if ($start > $topics_count / 2)
{
   $store_reverse = true;

   if ($start + $config['topics_per_page'] > $topics_count)
   {
      $sql_limit = min($config['topics_per_page'], max(1, $topics_count - $start));
   }

   // Select the sort order
   $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'ASC' : 'DESC');
   $sql_start = max(0, $topics_count - $sql_limit - $start);
}
else
{
   // Select the sort order
   $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC');
   $sql_start = $start;
}

if ($forum_data['forum_type'] == FORUM_POST || !sizeof($active_forum_ary))
{
   $sql_where = 't.forum_id = ' . $forum_id;
}
else if (empty($active_forum_ary['exclude_forum_id']))
{
   $sql_where = $db->sql_in_set('t.forum_id', $active_forum_ary['forum_id']);
}
else
{
   $get_forum_ids = array_diff($active_forum_ary['forum_id'], $active_forum_ary['exclude_forum_id']);
   $sql_where = (sizeof($get_forum_ids)) ? $db->sql_in_set('t.forum_id', $get_forum_ids) : 't.forum_id = ' . $forum_id;
}

// Grab just the sorted topic ids
$sql = 'SELECT t.topic_id
   FROM ' . TOPICS_TABLE . " t
   WHERE $sql_where
      AND t.topic_type IN (" . POST_NORMAL . ', ' . POST_STICKY . ")
      $sql_approved
      $sql_limit_time
   ORDER BY t.topic_type " . ((!$store_reverse) ? 'DESC' : 'ASC') . ', ' . $sql_sort_order;
$result = $db->sql_query_limit($sql, $sql_limit, $sql_start);

while ($row = $db->sql_fetchrow($result))
{
   $topic_list[] = (int) $row['topic_id'];
}
$db->sql_freeresult($result);

// For storing shadow topics
$shadow_topic_list = array();

if (sizeof($topic_list))
{
   // SQL array for obtaining topics/stickies
   $sql_array = array(
      'SELECT'      => $sql_array['SELECT'],
      'FROM'         => $sql_array['FROM'],
      'LEFT_JOIN'      => $sql_array['LEFT_JOIN'],

      'WHERE'         => $db->sql_in_set('t.topic_id', $topic_list),
   );

   // If store_reverse, then first obtain topics, then stickies, else the other way around...
   // Funnily enough you typically save one query if going from the last page to the middle (store_reverse) because
   // the number of stickies are not known
   $sql = $db->sql_build_query('SELECT', $sql_array);
   $result = $db->sql_query($sql);

   while ($row = $db->sql_fetchrow($result))
   {
      if ($row['topic_status'] == ITEM_MOVED)
      {
         $shadow_topic_list[$row['topic_moved_id']] = $row['topic_id'];
      }

      $rowset[$row['topic_id']] = $row;
   }
   $db->sql_freeresult($result);
}

// If we have some shadow topics, update the rowset to reflect their topic information
if (sizeof($shadow_topic_list))
{
   $sql = 'SELECT *
      FROM ' . TOPICS_TABLE . '
      WHERE ' . $db->sql_in_set('topic_id', array_keys($shadow_topic_list));
   $result = $db->sql_query($sql);

   while ($row = $db->sql_fetchrow($result))
   {
      $orig_topic_id = $shadow_topic_list[$row['topic_id']];

      // If the shadow topic is already listed within the rowset (happens for active topics for example), then do not include it...
      if (isset($rowset[$row['topic_id']]))
      {
         // We need to remove any trace regarding this topic. :)
         unset($rowset[$orig_topic_id]);
         unset($topic_list[array_search($orig_topic_id, $topic_list)]);
         $topics_count--;

         continue;
      }

      // Do not include those topics the user has no permission to access
      if (!$auth->acl_get('f_read', $row['forum_id']))
      {
         // We need to remove any trace regarding this topic. :)
         unset($rowset[$orig_topic_id]);
         unset($topic_list[array_search($orig_topic_id, $topic_list)]);
         $topics_count--;

         continue;
      }

      // We want to retain some values
      $row = array_merge($row, array(
         'topic_moved_id'   => $rowset[$orig_topic_id]['topic_moved_id'],
         'topic_status'      => $rowset[$orig_topic_id]['topic_status'],
         'topic_type'      => $rowset[$orig_topic_id]['topic_type'],
      ));

      // Shadow topics are never reported
      $row['topic_reported'] = 0;

      $rowset[$orig_topic_id] = $row;
   }
   $db->sql_freeresult($result);
}
unset($shadow_topic_list);

// Ok, adjust topics count for active topics list
if ($s_display_active)
{
   $topics_count = 1;
}

$template->assign_vars(array(
   'PAGINATION'   => generate_pagination(append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id" . ((strlen($u_sort_param)) ? "&amp;$u_sort_param" : '')), $topics_count, $config['topics_per_page'], $start),
   'PAGE_NUMBER'   => on_page($topics_count, $config['topics_per_page'], $start),
   'TOTAL_TOPICS'   => ($s_display_active) ? false : (($topics_count == 1) ? $user->lang['VIEW_FORUM_TOPIC'] : sprintf($user->lang['VIEW_FORUM_TOPICS'], $topics_count)))
);

$topic_list = ($store_reverse) ? array_merge($announcement_list, array_reverse($topic_list)) : array_merge($announcement_list, $topic_list);
$topic_tracking_info = $tracking_topics = array();

// Okay, lets dump out the page ...
if (sizeof($topic_list))
{
   $mark_forum_read = true;
   $mark_time_forum = 0;

   // Active topics?
   if ($s_display_active && sizeof($active_forum_ary))
   {
      // Generate topic forum list...
      $topic_forum_list = array();
      foreach ($rowset as $t_id => $row)
      {
         $topic_forum_list[$row['forum_id']]['forum_mark_time'] = ($config['load_db_lastread'] && $user->data['is_registered'] && isset($row['forum_mark_time'])) ? $row['forum_mark_time'] : 0;
         $topic_forum_list[$row['forum_id']]['topics'][] = $t_id;
      }

      if ($config['load_db_lastread'] && $user->data['is_registered'])
      {
         foreach ($topic_forum_list as $f_id => $topic_row)
         {
            $topic_tracking_info += get_topic_tracking($f_id, $topic_row['topics'], $rowset, array($f_id => $topic_row['forum_mark_time']), false);
         }
      }
      else if ($config['load_anon_lastread'] || $user->data['is_registered'])
      {
         foreach ($topic_forum_list as $f_id => $topic_row)
         {
            $topic_tracking_info += get_complete_topic_tracking($f_id, $topic_row['topics'], false);
         }
      }

      unset($topic_forum_list);
   }
   else
   {
      if ($config['load_db_lastread'] && $user->data['is_registered'])
      {
         $topic_tracking_info = get_topic_tracking($forum_id, $topic_list, $rowset, array($forum_id => $forum_data['mark_time']), $global_announce_list);
         $mark_time_forum = (!empty($forum_data['mark_time'])) ? $forum_data['mark_time'] : $user->data['user_lastmark'];
      }
      else if ($config['load_anon_lastread'] || $user->data['is_registered'])
      {
         $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_list, $global_announce_list);

         if (!$user->data['is_registered'])
         {
            $user->data['user_lastmark'] = (isset($tracking_topics['l'])) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0;
         }
         $mark_time_forum = (isset($tracking_topics['f'][$forum_id])) ? (int) (base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate']) : $user->data['user_lastmark'];
      }
   }

   $s_type_switch = 0;
   foreach ($topic_list as $topic_id)
   {
      $row = &$rowset[$topic_id];

      // This will allow the style designer to output a different header
      // or even separate the list of announcements from sticky and normal topics
      $s_type_switch_test = ($row['topic_type'] == POST_ANNOUNCE || $row['topic_type'] == POST_GLOBAL) ? 1 : 0;

      // Replies
      $replies = ($auth->acl_get('m_approve', $forum_id)) ? $row['topic_replies_real'] : $row['topic_replies'];

      if ($row['topic_status'] == ITEM_MOVED)
      {
         $topic_id = $row['topic_moved_id'];
         $unread_topic = false;
      }
      else
      {
         $unread_topic = (isset($topic_tracking_info[$topic_id]) && $row['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
      }

      // Get folder img, topic status/type related information
      $folder_img = $folder_alt = $topic_type = '';
      topic_status($row, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type);

      // Generate all the URIs ...
      $view_topic_url_params = 'f=' . (($row['forum_id']) ? $row['forum_id'] : $forum_id) . '&amp;t=' . $topic_id;
      $view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params);

      $topic_unapproved = (!$row['topic_approved'] && $auth->acl_get('m_approve', (($row['forum_id']) ? $row['forum_id'] : $forum_id))) ? true : false;
      $posts_unapproved = ($row['topic_approved'] && $row['topic_replies'] < $row['topic_replies_real'] && $auth->acl_get('m_approve', (($row['forum_id']) ? $row['forum_id'] : $forum_id))) ? true : false;
      $u_mcp_queue = ($topic_unapproved || $posts_unapproved) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&amp;mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . "&amp;t=$topic_id", true, $user->session_id) : '';


          $avatar_img = '';
        $avatar_max_dimensions = $topic_last_poster_avatar_height = $topic_last_poster_avatar_width = $topic_first_poster_avatar_width = $topic_first_poster_avatar_height = 40;
         
          if ( !empty($row['topic_first_poster_avatar']) || !empty($row['topic_last_poster_avatar']))
          {
             $avatar_max_dimensions = 40; // here you can change the max-width you would like to have the avatars displayed
             
             if ( !empty($row['topic_first_poster_avatar']))
             {     
                if ( $row['topic_first_poster_avatar_width'] >= $row['topic_first_poster_avatar_height'] )
                {
                   $topic_first_poster_avatar_width = ( $row['topic_first_poster_avatar_width'] > $avatar_max_dimensions ) ? $avatar_max_dimensions : $row['topic_first_poster_avatar_width'] ;
                   $topic_first_poster_avatar_height = ( $topic_first_poster_avatar_width == $avatar_max_dimensions ) ? round($avatar_max_dimensions / $row['topic_first_poster_avatar_width'] * $row['topic_first_poster_avatar_height']) : $row['topic_first_poster_avatar_height'] ;
                }
                else
                {
                   $topic_first_poster_avatar_height = ( $row['topic_first_poster_avatar_height'] > $avatar_max_dimensions ) ? $avatar_max_dimensions : $row['topic_first_poster_avatar_height'] ;
                   $topic_first_poster_avatar_width = ( $topic_first_poster_avatar_height == $avatar_max_dimensions ) ? round($avatar_max_dimensions / $row['topic_first_poster_avatar_height'] * $row['topic_first_poster_avatar_width']) : $row['topic_first_poster_avatar_width'] ;
                }
             }
         
             if ( !empty($row['topic_last_poster_avatar']))
             {     
                if ( $row['topic_last_poster_avatar_width'] >= $row['topic_last_poster_avatar_height'] )
                {
                   $topic_last_poster_avatar_width = ( $row['topic_last_poster_avatar_width'] > $avatar_max_dimensions ) ? $avatar_max_dimensions : $row['topic_last_poster_avatar_width'] ;
                   $topic_last_poster_avatar_height = ( $topic_last_poster_avatar_width == $avatar_max_dimensions ) ? round($avatar_max_dimensions / $row['topic_last_poster_avatar_width'] * $row['topic_last_poster_avatar_height']) : $row['topic_last_poster_avatar_height'] ;
                }
                else
                {
                   $topic_last_poster_avatar_height = ( $row['topic_last_poster_avatar_height'] > $avatar_max_dimensions ) ? $avatar_max_dimensions : $row['topic_last_poster_avatar_height'] ;
                   $topic_last_poster_avatar_width = ( $topic_last_poster_avatar_height == $avatar_max_dimensions ) ? round($avatar_max_dimensions / $row['topic_last_poster_avatar_height'] * $row['topic_last_poster_avatar_width']) : $row['topic_last_poster_avatar_width'] ;
                }
             }   
         

       
      }
      // Send vars to template
      $template->assign_block_vars('topicrow', array(
         'FORUM_ID'               => $forum_id,
         'TOPIC_ID'               => $topic_id,
         'TOPIC_AUTHOR'            => get_username_string('username', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
         'TOPIC_AUTHOR_COLOUR'      => get_username_string('colour', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
         'TOPIC_AUTHOR_FULL'         => get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
         'TOPIC_AUTHOR_AVATAR'      => ($config['enable_avatar_index']) ? get_user_avatar($row['topic_first_poster_avatar'], $row['topic_first_poster_avatar_type'], $topic_first_poster_avatar_width, $topic_first_poster_avatar_height) : false,
         'TOPIC_AUTHOR_AVATAR_MARGIN'   => ( $topic_first_poster_avatar_width == '' ) ? '' : (( $topic_first_poster_avatar_width == $avatar_max_dimensions ) ? 5 : ( $avatar_max_dimensions - $topic_first_poster_avatar_width + 5 )),
         'AVATAR_WIDTH'            => $avatar_max_dimensions ,
         'FIRST_POST_TIME'         => $user->format_date($row['topic_time']),
         'LAST_POST_SUBJECT'         => censor_text($row['topic_last_post_subject']),
         'LAST_POST_TIME'         => $user->format_date($row['topic_last_post_time']),
         'LAST_VIEW_TIME'         => $user->format_date($row['topic_last_view_time']),
         'LAST_POST_AUTHOR'         => get_username_string('username', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
         'LAST_POST_AUTHOR_COLOUR'   => get_username_string('colour', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
         'LAST_POST_AUTHOR_FULL'      => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
         'LAST_POST_AUTHOR_AVATAR'   => ($config['enable_avatar_index']) ? get_user_avatar($row['topic_last_poster_avatar'], $row['topic_last_poster_avatar_type'], $topic_last_poster_avatar_width, $topic_last_poster_avatar_height) : false,
         'LAST_POST_AUTHOR_AVATAR_MARGIN'=> ( $topic_last_poster_avatar_width == $avatar_max_dimensions ) ? 5 : ( $avatar_max_dimensions - $topic_last_poster_avatar_width + 5 ),

         'PAGINATION'      => topic_generate_pagination($replies, $view_topic_url),
         'REPLIES'         => $replies,
         'VIEWS'            => $row['topic_views'],
         'TOPIC_TITLE'      => censor_text($row['topic_title']),
         'TOPIC_TYPE'      => $topic_type,

         'TOPIC_FOLDER_IMG'      => $user->img($folder_img, $folder_alt),
         'TOPIC_FOLDER_IMG_SRC'   => $user->img($folder_img, $folder_alt, false, '', 'src'),
         'TOPIC_FOLDER_IMG_ALT'   => $user->lang[$folder_alt],
         'TOPIC_FOLDER_IMG_WIDTH'=> $user->img($folder_img, '', false, '', 'width'),
         'TOPIC_FOLDER_IMG_HEIGHT'   => $user->img($folder_img, '', false, '', 'height'),

         'TOPIC_ICON_IMG'      => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['img'] : '',
         'TOPIC_ICON_IMG_WIDTH'   => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['width'] : '',
         'TOPIC_ICON_IMG_HEIGHT'   => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['height'] : '',
         'ATTACH_ICON_IMG'      => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $forum_id) && $row['topic_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
         'UNAPPROVED_IMG'      => ($topic_unapproved || $posts_unapproved) ? $user->img('icon_topic_unapproved', ($topic_unapproved) ? 'TOPIC_UNAPPROVED' : 'POSTS_UNAPPROVED') : '',

         'S_TOPIC_TYPE'         => $row['topic_type'],
         'S_USER_POSTED'         => (isset($row['topic_posted']) && $row['topic_posted']) ? true : false,
         'S_UNREAD_TOPIC'      => $unread_topic,
         'S_TOPIC_REPORTED'      => (!empty($row['topic_reported']) && $auth->acl_get('m_report', $forum_id)) ? true : false,
         'S_TOPIC_UNAPPROVED'   => $topic_unapproved,
         'S_POSTS_UNAPPROVED'   => $posts_unapproved,
         'S_HAS_POLL'         => ($row['poll_start']) ? true : false,
         'S_POST_ANNOUNCE'      => ($row['topic_type'] == POST_ANNOUNCE) ? true : false,
         'S_POST_GLOBAL'         => ($row['topic_type'] == POST_GLOBAL) ? true : false,
         'S_POST_STICKY'         => ($row['topic_type'] == POST_STICKY) ? true : false,
         'S_TOPIC_LOCKED'      => ($row['topic_status'] == ITEM_LOCKED) ? true : false,
         'S_TOPIC_MOVED'         => ($row['topic_status'] == ITEM_MOVED) ? true : false,

         'U_NEWEST_POST'         => append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params . '&amp;view=unread') . '#unread',
         'U_LAST_POST'         => append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params . '&amp;p=' . $row['topic_last_post_id']) . '#p' . $row['topic_last_post_id'],
         'U_LAST_POST_AUTHOR'   => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
         'U_TOPIC_AUTHOR'      => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
         'U_VIEW_TOPIC'         => $view_topic_url,
         'U_MCP_REPORT'         => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&amp;mode=reports&amp;f=' . $forum_id . '&amp;t=' . $topic_id, true, $user->session_id),
         'U_MCP_QUEUE'         => $u_mcp_queue,

         'S_TOPIC_TYPE_SWITCH'   => ($s_type_switch == $s_type_switch_test) ? -1 : $s_type_switch_test)
      );

      $s_type_switch = ($row['topic_type'] == POST_ANNOUNCE || $row['topic_type'] == POST_GLOBAL) ? 1 : 0;

      if ($unread_topic)
      {
         $mark_forum_read = false;
      }

      unset($rowset[$topic_id]);
   }
}

// This is rather a fudge but it's the best I can think of without requiring information
// on all topics (as we do in 2.0.x). It looks for unread or new topics, if it doesn't find
// any it updates the forum last read cookie. This requires that the user visit the forum
// after reading a topic
if ($forum_data['forum_type'] == FORUM_POST && sizeof($topic_list) && $mark_forum_read)
{
   update_forum_tracking_info($forum_id, $forum_data['forum_last_post_time'], false, $mark_time_forum);
}

page_footer();

?>
lefty74
zoocrew.eu - help us save our wildlife
My MODS | Due to lack of time I unfortunately am unable to work on my mods anymore, anyone who has ideas to improve them and would like to take any of them over, please PM me.
User avatar
lefty74
Registered User
Posts: 3649
Joined: Wed Sep 14, 2005 8:26 pm
Location: NL

Re: Default avatar thumb in viewforum

by stokerpiller » Sat Jun 19, 2010 6:49 pm

No errors in viewforum.php

My includes/functions_display.php

Code: Select all

<?php
/**
*
* @package phpBB3
* @version $Id: functions_display.php 10405 2010-01-12 21:15:32Z bantu $
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
   exit;
}

/**
* Display Forums
*/
function display_forums($root_data = '', $display_moderators = true, $return_moderators = false)
{
   global $db, $auth, $user, $template;
   global $phpbb_root_path, $phpEx, $config;

   $forum_rows = $subforums = $forum_ids = $forum_ids_moderator = $forum_moderators = $active_forum_ary = array();
   $parent_id = $visible_forums = 0;
   $sql_from = '';

   // Mark forums read?
   $mark_read = request_var('mark', '');

   if ($mark_read == 'all')
   {
      $mark_read = '';
   }

   if (!$root_data)
   {
      if ($mark_read == 'forums')
      {
         $mark_read = 'all';
      }

      $root_data = array('forum_id' => 0);
      $sql_where = '';
   }
   else
   {
      $sql_where = 'left_id > ' . $root_data['left_id'] . ' AND left_id < ' . $root_data['right_id'];
   }

   // Display list of active topics for this category?
   $show_active = (isset($root_data['forum_flags']) && ($root_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS)) ? true : false;

   $sql_array = array(
      'SELECT'   => 'f.*',
      'FROM'      => array(
         FORUMS_TABLE      => 'f'
      ),
      'LEFT_JOIN'   => array(),
   );

   if ($config['load_db_lastread'] && $user->data['is_registered'])
   {
      $sql_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_TRACK_TABLE => 'ft'), 'ON' => 'ft.user_id = ' . $user->data['user_id'] . ' AND ft.forum_id = f.forum_id');
      $sql_array['SELECT'] .= ', ft.mark_time';
   }
   else if ($config['load_anon_lastread'] || $user->data['is_registered'])
   {
      $tracking_topics = (isset($_COOKIE[$config['cookie_name'] . '_track'])) ? ((STRIP) ? stripslashes($_COOKIE[$config['cookie_name'] . '_track']) : $_COOKIE[$config['cookie_name'] . '_track']) : '';
      $tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array();

      if (!$user->data['is_registered'])
      {
         $user->data['user_lastmark'] = (isset($tracking_topics['l'])) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0;
      }
   }

   if ($show_active)
   {
      $sql_array['LEFT_JOIN'][] = array(
         'FROM'   => array(FORUMS_ACCESS_TABLE => 'fa'),
         'ON'   => "fa.forum_id = f.forum_id AND fa.session_id = '" . $db->sql_escape($user->session_id) . "'"
      );

      $sql_array['SELECT'] .= ', fa.user_id';
   }

   $sql = $db->sql_build_query('SELECT', array(
      'SELECT'   => $sql_array['SELECT'],
      'FROM'      => $sql_array['FROM'],
      'LEFT_JOIN'   => $sql_array['LEFT_JOIN'],

      'WHERE'      => $sql_where,

      'ORDER_BY'   => 'f.left_id',
   ));

   $result = $db->sql_query($sql);

   $forum_tracking_info = array();
   $branch_root_id = $root_data['forum_id'];

   // Check for unread global announcements (index page only)
   $ga_unread = false;
   if ($root_data['forum_id'] == 0)
   {
      $unread_ga_list = get_unread_topics($user->data['user_id'], 'AND t.forum_id = 0', '', 1);

      if (!empty($unread_ga_list))
      {
         $ga_unread = true;
      }
   }

   while ($row = $db->sql_fetchrow($result))
   {
      $forum_id = $row['forum_id'];

      // Mark forums read?
      if ($mark_read == 'forums' || $mark_read == 'all')
      {
         if ($auth->acl_get('f_list', $forum_id))
         {
            $forum_ids[] = $forum_id;
            continue;
         }
      }

      // Category with no members
      if ($row['forum_type'] == FORUM_CAT && ($row['left_id'] + 1 == $row['right_id']))
      {
         continue;
      }

      // Skip branch
      if (isset($right_id))
      {
         if ($row['left_id'] < $right_id)
         {
            continue;
         }
         unset($right_id);
      }

      if (!$auth->acl_get('f_list', $forum_id))
      {
         // if the user does not have permissions to list this forum, skip everything until next branch
         $right_id = $row['right_id'];
         continue;
      }

      $forum_ids[] = $forum_id;

      if ($config['load_db_lastread'] && $user->data['is_registered'])
      {
         $forum_tracking_info[$forum_id] = (!empty($row['mark_time'])) ? $row['mark_time'] : $user->data['user_lastmark'];
      }
      else if ($config['load_anon_lastread'] || $user->data['is_registered'])
      {
         if (!$user->data['is_registered'])
         {
            $user->data['user_lastmark'] = (isset($tracking_topics['l'])) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0;
         }
         $forum_tracking_info[$forum_id] = (isset($tracking_topics['f'][$forum_id])) ? (int) (base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate']) : $user->data['user_lastmark'];
      }

      // Count the difference of real to public topics, so we can display an information to moderators
      $row['forum_id_unapproved_topics'] = ($auth->acl_get('m_approve', $forum_id) && ($row['forum_topics_real'] != $row['forum_topics'])) ? $forum_id : 0;
      $row['forum_topics'] = ($auth->acl_get('m_approve', $forum_id)) ? $row['forum_topics_real'] : $row['forum_topics'];

      // Display active topics from this forum?
      if ($show_active && $row['forum_type'] == FORUM_POST && $auth->acl_get('f_read', $forum_id) && ($row['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS))
      {
         if (!isset($active_forum_ary['forum_topics']))
         {
            $active_forum_ary['forum_topics'] = 0;
         }

         if (!isset($active_forum_ary['forum_posts']))
         {
            $active_forum_ary['forum_posts'] = 0;
         }

         $active_forum_ary['forum_id'][]      = $forum_id;
         $active_forum_ary['enable_icons'][]   = $row['enable_icons'];
         $active_forum_ary['forum_topics']   += $row['forum_topics'];
         $active_forum_ary['forum_posts']   += $row['forum_posts'];

         // If this is a passworded forum we do not show active topics from it if the user is not authorised to view it...
         if ($row['forum_password'] && $row['user_id'] != $user->data['user_id'])
         {
            $active_forum_ary['exclude_forum_id'][] = $forum_id;
         }
      }

      //
      if ($row['parent_id'] == $root_data['forum_id'] || $row['parent_id'] == $branch_root_id)
      {
         if ($row['forum_type'] != FORUM_CAT)
         {
            $forum_ids_moderator[] = (int) $forum_id;
         }

         // Direct child of current branch
         $parent_id = $forum_id;
         $forum_rows[$forum_id] = $row;

         if ($row['forum_type'] == FORUM_CAT && $row['parent_id'] == $root_data['forum_id'])
         {
            $branch_root_id = $forum_id;
         }
         $forum_rows[$parent_id]['forum_id_last_post'] = $row['forum_id'];
         $forum_rows[$parent_id]['orig_forum_last_post_time'] = $row['forum_last_post_time'];
      }
      else if ($row['forum_type'] != FORUM_CAT)
      {
         $subforums[$parent_id][$forum_id]['display'] = ($row['display_on_index']) ? true : false;
         $subforums[$parent_id][$forum_id]['name'] = $row['forum_name'];
         $subforums[$parent_id][$forum_id]['orig_forum_last_post_time'] = $row['forum_last_post_time'];
         $subforums[$parent_id][$forum_id]['children'] = array();

         if (isset($subforums[$parent_id][$row['parent_id']]) && !$row['display_on_index'])
         {
            $subforums[$parent_id][$row['parent_id']]['children'][] = $forum_id;
         }

         if (!$forum_rows[$parent_id]['forum_id_unapproved_topics'] && $row['forum_id_unapproved_topics'])
         {
            $forum_rows[$parent_id]['forum_id_unapproved_topics'] = $forum_id;
         }

         $forum_rows[$parent_id]['forum_topics'] += $row['forum_topics'];

         // Do not list redirects in LINK Forums as Posts.
         if ($row['forum_type'] != FORUM_LINK)
         {
            $forum_rows[$parent_id]['forum_posts'] += $row['forum_posts'];
         }

         if ($row['forum_last_post_time'] > $forum_rows[$parent_id]['forum_last_post_time'])
         {
            $forum_rows[$parent_id]['forum_last_post_id'] = $row['forum_last_post_id'];
            $forum_rows[$parent_id]['forum_last_post_subject'] = $row['forum_last_post_subject'];
            $forum_rows[$parent_id]['forum_last_post_time'] = $row['forum_last_post_time'];
            $forum_rows[$parent_id]['forum_last_poster_id'] = $row['forum_last_poster_id'];
            $forum_rows[$parent_id]['forum_last_poster_name'] = $row['forum_last_poster_name'];
            $forum_rows[$parent_id]['forum_last_poster_colour'] = $row['forum_last_poster_colour'];
            $forum_rows[$parent_id]['forum_last_poster_avatar'] = $row['forum_last_poster_avatar'];
            $forum_rows[$parent_id]['forum_last_poster_avatar_type'] = $row['forum_last_poster_avatar_type'];
            $forum_rows[$parent_id]['forum_last_poster_avatar_width'] = $row['forum_last_poster_avatar_width'];
            $forum_rows[$parent_id]['forum_last_poster_avatar_height'] = $row['forum_last_poster_avatar_height'];
            $forum_rows[$parent_id]['forum_id_last_post'] = $forum_id;
         }
      }
   }
   $db->sql_freeresult($result);

   // Handle marking posts
   if ($mark_read == 'forums' || $mark_read == 'all')
   {
      $redirect = build_url(array('mark', 'hash'));
      $token = request_var('hash', '');
      if (check_link_hash($token, 'global'))
      {
         if ($mark_read == 'all')
         {
            markread('all');
            $message = sprintf($user->lang['RETURN_INDEX'], '<a href="' . $redirect . '">', '</a>');
         }
         else
         {
            // Add 0 to forums array to mark global announcements correctly
            $forum_ids[] = 0;
            markread('topics', $forum_ids);
            $message = sprintf($user->lang['RETURN_FORUM'], '<a href="' . $redirect . '">', '</a>');
         }
         meta_refresh(3, $redirect);
         trigger_error($user->lang['FORUMS_MARKED'] . '<br /><br />' . $message);
      }
      else
      {
         $message = sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>');
         meta_refresh(3, $redirect);
         trigger_error($message);
      }

   }

   // Grab moderators ... if necessary
   if ($display_moderators)
   {
      if ($return_moderators)
      {
         $forum_ids_moderator[] = $root_data['forum_id'];
      }
      get_moderators($forum_moderators, $forum_ids_moderator);
   }

   // Used to tell whatever we have to create a dummy category or not.
   $last_catless = true;
   foreach ($forum_rows as $row)
   {
      // Empty category
      if ($row['parent_id'] == $root_data['forum_id'] && $row['forum_type'] == FORUM_CAT)
      {
         $template->assign_block_vars('forumrow', array(
            'S_IS_CAT'            => true,
            'FORUM_ID'            => $row['forum_id'],
            'FORUM_NAME'         => $row['forum_name'],
            'FORUM_DESC'         => generate_text_for_display($row['forum_desc'], $row['forum_desc_uid'], $row['forum_desc_bitfield'], $row['forum_desc_options']),
            'FORUM_FOLDER_IMG'      => '',
            'FORUM_FOLDER_IMG_SRC'   => '',
            'FORUM_IMAGE'         => ($row['forum_image']) ? '<img src="' . $phpbb_root_path . $row['forum_image'] . '" alt="' . $user->lang['FORUM_CAT'] . '" />' : '',
            'FORUM_IMAGE_SRC'      => ($row['forum_image']) ? $phpbb_root_path . $row['forum_image'] : '',
            'U_VIEWFORUM'         => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']))
         );

         continue;
      }

      $visible_forums++;
      $forum_id = $row['forum_id'];

      $forum_unread = (isset($forum_tracking_info[$forum_id]) && $row['orig_forum_last_post_time'] > $forum_tracking_info[$forum_id]) ? true : false;

      // Mark the first visible forum on index as unread if there's any unread global announcement
      if ($ga_unread && !empty($forum_ids_moderator) && $forum_id == $forum_ids_moderator[0])
      {
         $forum_unread = true;
      }

      $folder_image = $folder_alt = $l_subforums = '';
      $subforums_list = array();

      // Generate list of subforums if we need to
      if (isset($subforums[$forum_id]))
      {
         foreach ($subforums[$forum_id] as $subforum_id => $subforum_row)
         {
            $subforum_unread = (isset($forum_tracking_info[$subforum_id]) && $subforum_row['orig_forum_last_post_time'] > $forum_tracking_info[$subforum_id]) ? true : false;

            if (!$subforum_unread && !empty($subforum_row['children']))
            {
               foreach ($subforum_row['children'] as $child_id)
               {
                  if (isset($forum_tracking_info[$child_id]) && $subforums[$forum_id][$child_id]['orig_forum_last_post_time'] > $forum_tracking_info[$child_id])
                  {
                     // Once we found an unread child forum, we can drop out of this loop
                     $subforum_unread = true;
                     break;
                  }
               }
            }

            if ($subforum_row['display'] && $subforum_row['name'])
            {
               $subforums_list[] = array(
                  'link'      => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $subforum_id),
                  'name'      => $subforum_row['name'],
                  'unread'   => $subforum_unread,
               );
            }
            else
            {
               unset($subforums[$forum_id][$subforum_id]);
            }

            // If one subforum is unread the forum gets unread too...
            if ($subforum_unread)
            {
               $forum_unread = true;
            }
         }

         $l_subforums = (sizeof($subforums[$forum_id]) == 1) ? $user->lang['SUBFORUM'] . ': ' : $user->lang['SUBFORUMS'] . ': ';
         $folder_image = ($forum_unread) ? 'forum_unread_subforum' : 'forum_read_subforum';
      }
      else
      {
         switch ($row['forum_type'])
         {
            case FORUM_POST:
               $folder_image = ($forum_unread) ? 'forum_unread' : 'forum_read';
            break;

            case FORUM_LINK:
               $folder_image = 'forum_link';
            break;
         }
      }

      // Which folder should we display?
      if ($row['forum_status'] == ITEM_LOCKED)
      {
         $folder_image = ($forum_unread) ? 'forum_unread_locked' : 'forum_read_locked';
         $folder_alt = 'FORUM_LOCKED';
      }
      else
      {
         $folder_alt = ($forum_unread) ? 'NEW_POSTS' : 'NO_NEW_POSTS';
      }

      // Create last post link information, if appropriate
      if ($row['forum_last_post_id'])
      {
      if (substr($row['forum_last_post_subject'], 0, 4) == 'Re: ')
      {
            $last_post_subject = substr(censor_text($row['forum_last_post_subject']), 4);
      }
      else
      {
            $last_post_subject = censor_text($row['forum_last_post_subject']);
      }
         $last_post_time = $user->format_date($row['forum_last_post_time']);
         $last_post_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id_last_post'] . '&amp;p=' . $row['forum_last_post_id']) . '#p' . $row['forum_last_post_id'];
      }
      else
      {
         $last_post_subject = $last_post_time = $last_post_url = '';
      }

      // Output moderator listing ... if applicable
      $l_moderator = $moderators_list = '';
      if ($display_moderators && !empty($forum_moderators[$forum_id]))
      {
         $l_moderator = (sizeof($forum_moderators[$forum_id]) == 1) ? $user->lang['MODERATOR'] : $user->lang['MODERATORS'];
         $moderators_list = implode(', ', $forum_moderators[$forum_id]);
      }

      $l_post_click_count = ($row['forum_type'] == FORUM_LINK) ? 'CLICKS' : 'POSTS';
      $post_click_count = ($row['forum_type'] != FORUM_LINK || $row['forum_flags'] & FORUM_FLAG_LINK_TRACK) ? $row['forum_posts'] : '';

      $s_subforums_list = array();
      foreach ($subforums_list as $subforum)
      {
         $s_subforums_list[] = '<a href="' . $subforum['link'] . '" class="subforum ' . (($subforum['unread']) ? 'unread' : 'read') . '" title="' . (($subforum['unread']) ? $user->lang['NEW_POSTS'] : $user->lang['NO_NEW_POSTS']) . '">' . $subforum['name'] . '</a>';
      }
      $s_subforums_list = (string) implode(', ', $s_subforums_list);
      $catless = ($row['parent_id'] == $root_data['forum_id']) ? true : false;

      if ($row['forum_type'] != FORUM_LINK)
      {
         $u_viewforum = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']);
      }
      else
      {
         // If the forum is a link and we count redirects we need to visit it
         // If the forum is having a password or no read access we do not expose the link, but instead handle it in viewforum
         if (($row['forum_flags'] & FORUM_FLAG_LINK_TRACK) || $row['forum_password'] || !$auth->acl_get('f_read', $forum_id))
         {
            $u_viewforum = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']);
         }
         else
         {
            $u_viewforum = $row['forum_link'];
         }
      }


      $avatar_max_dimensions = 40;
      if ( !empty($row['forum_last_poster_avatar']) )
      {
         $avatar_max_dimensions = 40; // here you can change the max-width you would like to have the avatars displayed
      
         if ( $row['forum_last_poster_avatar_width'] >= $row['forum_last_poster_avatar_height'] )
         {
            $avatar_width = ( $row['forum_last_poster_avatar_width'] > $avatar_max_dimensions ) ? $avatar_max_dimensions : $row['forum_last_poster_avatar_width'] ;
            $avatar_height = ( $avatar_width == $avatar_max_dimensions ) ? round($avatar_max_dimensions / $row['forum_last_poster_avatar_width'] * $row['forum_last_poster_avatar_height']) : $row['forum_last_poster_avatar_height'] ;
         }
         else
         {
            $avatar_height = ( $row['forum_last_poster_avatar_height'] > $avatar_max_dimensions ) ? $avatar_max_dimensions : $row['forum_last_poster_avatar_height'] ;
            $avatar_width = ( $avatar_height == $avatar_max_dimensions ) ? round($avatar_max_dimensions / $row['forum_last_poster_avatar_height'] * $row['forum_last_poster_avatar_width']) : $row['forum_last_poster_avatar_width'] ;
         }
      }
      $template->assign_block_vars('forumrow', array(
         'S_IS_CAT'         => false,
         'S_NO_CAT'         => $catless && !$last_catless,
         'S_IS_LINK'         => ($row['forum_type'] == FORUM_LINK) ? true : false,
         'S_UNREAD_FORUM'   => $forum_unread,
         'S_LOCKED_FORUM'   => ($row['forum_status'] == ITEM_LOCKED) ? true : false,
         'S_LIST_SUBFORUMS'   => ($row['display_subforum_list']) ? true : false,
         'S_SUBFORUMS'      => (sizeof($subforums_list)) ? true : false,
         'S_FEED_ENABLED'   => ($config['feed_forum'] && !phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $row['forum_options'])) ? true : false,

         'FORUM_ID'            => $row['forum_id'],
         'FORUM_NAME'         => $row['forum_name'],
         'FORUM_DESC'         => generate_text_for_display($row['forum_desc'], $row['forum_desc_uid'], $row['forum_desc_bitfield'], $row['forum_desc_options']),
         'TOPICS'            => $row['forum_topics'],
         $l_post_click_count      => $post_click_count,
         'FORUM_FOLDER_IMG'      => $user->img($folder_image, $folder_alt),
         'FORUM_FOLDER_IMG_SRC'   => $user->img($folder_image, $folder_alt, false, '', 'src'),
         'FORUM_FOLDER_IMG_ALT'   => isset($user->lang[$folder_alt]) ? $user->lang[$folder_alt] : '',
         'FORUM_IMAGE'         => ($row['forum_image']) ? '<img src="' . $phpbb_root_path . $row['forum_image'] . '" alt="' . $user->lang[$folder_alt] . '" />' : '',
         'FORUM_IMAGE_SRC'      => ($row['forum_image']) ? $phpbb_root_path . $row['forum_image'] : '',
         'LAST_POST_SUBJECT'      => $last_post_subject,
         'LAST_POST_SHORTENED_SUBJECT'   => (utf8_strlen($last_post_subject) > 26) ? truncate_string($last_post_subject, 25) . "\xE2\x80\xA6" : $last_post_subject,
         'LAST_POST_TIME'      => $last_post_time,
         'LAST_POSTER'         => get_username_string('username', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']),
         'LAST_POSTER_COLOUR'   => get_username_string('colour', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']),
         'LAST_POSTER_FULL'      => get_username_string('full', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']),
         'LAST_POSTER_AVATAR'   => ($config['enable_avatar_index']) ? get_user_avatar($row['forum_last_poster_avatar'], $row['forum_last_poster_avatar_type'], $avatar_width, $avatar_height) : false,
         'LAST_POSTER_AVATAR_MARGIN'   => ( $avatar_width == $avatar_max_dimensions ) ? 5 : ( $avatar_max_dimensions - $avatar_width + 5 ),
         'AVATAR_WIDTH'         => $avatar_max_dimensions,
         'MODERATORS'         => $moderators_list,
         'SUBFORUMS'            => $s_subforums_list,

         'L_SUBFORUM_STR'      => $l_subforums,
         'L_FORUM_FOLDER_ALT'   => $folder_alt,
         'L_MODERATOR_STR'      => $l_moderator,

         'U_UNAPPROVED_TOPICS'   => ($row['forum_id_unapproved_topics']) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&amp;mode=unapproved_topics&amp;f=' . $row['forum_id_unapproved_topics']) : '',
         'U_VIEWFORUM'      => $u_viewforum,
         'U_LAST_POSTER'      => get_username_string('profile', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']),
         'U_LAST_POST'      => $last_post_url)
      );

      // Assign subforums loop for style authors
      foreach ($subforums_list as $subforum)
      {
         $template->assign_block_vars('forumrow.subforum', array(
            'U_SUBFORUM'   => $subforum['link'],
            'SUBFORUM_NAME'   => $subforum['name'],
            'S_UNREAD'      => $subforum['unread'])
         );
      }

      $last_catless = $catless;
   }

   $template->assign_vars(array(
      'U_MARK_FORUMS'      => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'hash=' . generate_link_hash('global') . '&amp;f=' . $root_data['forum_id'] . '&amp;mark=forums') : '',
      'S_HAS_SUBFORUM'   => ($visible_forums) ? true : false,
      'L_SUBFORUM'      => ($visible_forums == 1) ? $user->lang['SUBFORUM'] : $user->lang['SUBFORUMS'],
      'LAST_POST_IMG'      => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'),
      'UNAPPROVED_IMG'   => $user->img('icon_topic_unapproved', 'TOPICS_UNAPPROVED'),
   ));

   if ($return_moderators)
   {
      return array($active_forum_ary, $forum_moderators);
   }

   return array($active_forum_ary, array());
}

/**
* Create forum rules for given forum
*/
function generate_forum_rules(&$forum_data)
{
   if (!$forum_data['forum_rules'] && !$forum_data['forum_rules_link'])
   {
      return;
   }

   global $template, $phpbb_root_path, $phpEx;

   if ($forum_data['forum_rules'])
   {
      $forum_data['forum_rules'] = generate_text_for_display($forum_data['forum_rules'], $forum_data['forum_rules_uid'], $forum_data['forum_rules_bitfield'], $forum_data['forum_rules_options']);
   }

   $template->assign_vars(array(
      'S_FORUM_RULES'   => true,
      'U_FORUM_RULES'   => $forum_data['forum_rules_link'],
      'FORUM_RULES'   => $forum_data['forum_rules'])
   );
}

/**
* Create forum navigation links for given forum, create parent
* list if currently null, assign basic forum info to template
*/
function generate_forum_nav(&$forum_data)
{
   global $db, $user, $template, $auth, $config;
   global $phpEx, $phpbb_root_path;

   if (!$auth->acl_get('f_list', $forum_data['forum_id']))
   {
      return;
   }

   // Get forum parents
   $forum_parents = get_forum_parents($forum_data);

   // Build navigation links
   if (!empty($forum_parents))
   {
      foreach ($forum_parents as $parent_forum_id => $parent_data)
      {
         list($parent_name, $parent_type) = array_values($parent_data);

         // Skip this parent if the user does not have the permission to view it
         if (!$auth->acl_get('f_list', $parent_forum_id))
         {
            continue;
         }

         $template->assign_block_vars('navlinks', array(
            'S_IS_CAT'      => ($parent_type == FORUM_CAT) ? true : false,
            'S_IS_LINK'      => ($parent_type == FORUM_LINK) ? true : false,
            'S_IS_POST'      => ($parent_type == FORUM_POST) ? true : false,
            'FORUM_NAME'   => $parent_name,
            'FORUM_ID'      => $parent_forum_id,
            'U_VIEW_FORUM'   => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $parent_forum_id))
         );
      }
   }

   $template->assign_block_vars('navlinks', array(
      'S_IS_CAT'      => ($forum_data['forum_type'] == FORUM_CAT) ? true : false,
      'S_IS_LINK'      => ($forum_data['forum_type'] == FORUM_LINK) ? true : false,
      'S_IS_POST'      => ($forum_data['forum_type'] == FORUM_POST) ? true : false,
      'FORUM_NAME'   => $forum_data['forum_name'],
      'FORUM_ID'      => $forum_data['forum_id'],
      'U_VIEW_FORUM'   => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_data['forum_id']))
   );

   $template->assign_vars(array(
      'FORUM_ID'       => $forum_data['forum_id'],
      'FORUM_NAME'   => $forum_data['forum_name'],
      'FORUM_DESC'   => generate_text_for_display($forum_data['forum_desc'], $forum_data['forum_desc_uid'], $forum_data['forum_desc_bitfield'], $forum_data['forum_desc_options']),
      'SEO_KEY'         => $forum_data['forum_seo_key'],
      'SEO_DESC'        => $forum_data['forum_seo_desc'],
      'SEO_BOTTOM'      => $forum_data['forum_seo_bottom'],

      'S_ENABLE_FEEDS_FORUM'   => ($config['feed_forum'] && $forum_data['forum_type'] == FORUM_POST && !phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $forum_data['forum_options'])) ? true : false,
   ));

   return;
}

/**
* Returns forum parents as an array. Get them from forum_data if available, or update the database otherwise
*/
function get_forum_parents(&$forum_data)
{
   global $db;

   $forum_parents = array();

   if ($forum_data['parent_id'] > 0)
   {
      if ($forum_data['forum_parents'] == '')
      {
         $sql = 'SELECT forum_id, forum_name, forum_type
            FROM ' . FORUMS_TABLE . '
            WHERE left_id < ' . $forum_data['left_id'] . '
               AND right_id > ' . $forum_data['right_id'] . '
            ORDER BY left_id ASC';
         $result = $db->sql_query($sql);

         while ($row = $db->sql_fetchrow($result))
         {
            $forum_parents[$row['forum_id']] = array($row['forum_name'], (int) $row['forum_type']);
         }
         $db->sql_freeresult($result);

         $forum_data['forum_parents'] = serialize($forum_parents);

         $sql = 'UPDATE ' . FORUMS_TABLE . "
            SET forum_parents = '" . $db->sql_escape($forum_data['forum_parents']) . "'
            WHERE parent_id = " . $forum_data['parent_id'];
         $db->sql_query($sql);
      }
      else
      {
         $forum_parents = unserialize($forum_data['forum_parents']);
      }
   }

   return $forum_parents;
}

/**
* Generate topic pagination
*/
function topic_generate_pagination($replies, $url)
{
   global $config, $user;

   // Make sure $per_page is a valid value
   $per_page = ($config['posts_per_page'] <= 0) ? 1 : $config['posts_per_page'];

   if (($replies + 1) > $per_page)
   {
      $total_pages = ceil(($replies + 1) / $per_page);
      $pagination = '';

      $times = 1;
      for ($j = 0; $j < $replies + 1; $j += $per_page)
      {
         $pagination .= '<a href="' . $url . '&amp;start=' . $j . '">' . $times . '</a>';
         if ($times == 1 && $total_pages > 5)
         {
            $pagination .= ' ... ';

            // Display the last three pages
            $times = $total_pages - 3;
            $j += ($total_pages - 4) * $per_page;
         }
         else if ($times < $total_pages)
         {
            $pagination .= '<span class="page-sep">' . $user->lang['COMMA_SEPARATOR'] . '</span>';
         }
         $times++;
      }
   }
   else
   {
      $pagination = '';
   }

   return $pagination;
}

/**
* Obtain list of moderators of each forum
*/
function get_moderators(&$forum_moderators, $forum_id = false)
{
   global $config, $template, $db, $phpbb_root_path, $phpEx, $user, $auth;

   $forum_id_ary = array();

   if ($forum_id !== false)
   {
      if (!is_array($forum_id))
      {
         $forum_id = array($forum_id);
      }

      // Exchange key/value pair to be able to faster check for the forum id existence
      $forum_id_ary = array_flip($forum_id);
   }

   $sql_array = array(
      'SELECT'   => 'm.*, u.user_colour, g.group_colour, g.group_type',

      'FROM'      => array(
         MODERATOR_CACHE_TABLE   => 'm',
      ),

      'LEFT_JOIN'   => array(
         array(
            'FROM'   => array(USERS_TABLE => 'u'),
            'ON'   => 'm.user_id = u.user_id',
         ),
         array(
            'FROM'   => array(GROUPS_TABLE => 'g'),
            'ON'   => 'm.group_id = g.group_id',
         ),
      ),

      'WHERE'      => 'm.display_on_index = 1',
   );

   // We query every forum here because for caching we should not have any parameter.
   $sql = $db->sql_build_query('SELECT', $sql_array);
   $result = $db->sql_query($sql, 3600);

   while ($row = $db->sql_fetchrow($result))
   {
      $f_id = (int) $row['forum_id'];

      if (!isset($forum_id_ary[$f_id]))
      {
         continue;
      }

      if (!empty($row['user_id']))
      {
         $forum_moderators[$f_id][] = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);
      }
      else
      {
         $group_name = (($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']);

         if ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile'))
         {
            $forum_moderators[$f_id][] = '<span' . (($row['group_colour']) ? ' style="color:#' . $row['group_colour'] . ';"' : '') . '>' . $group_name . '</span>';
         }
         else
         {
            $forum_moderators[$f_id][] = '<a' . (($row['group_colour']) ? ' style="color:#' . $row['group_colour'] . ';"' : '') . ' href="' . append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&amp;g=' . $row['group_id']) . '">' . $group_name . '</a>';
         }
      }
   }
   $db->sql_freeresult($result);

   return;
}

/**
* User authorisation levels output
*
* @param   string   $mode         Can be forum or topic. Not in use at the moment.
* @param   int      $forum_id      The current forum the user is in.
* @param   int      $forum_status   The forums status bit.
*/
function gen_forum_auth_level($mode, $forum_id, $forum_status)
{
   global $template, $auth, $user, $config;

   $locked = ($forum_status == ITEM_LOCKED && !$auth->acl_get('m_edit', $forum_id)) ? true : false;

   $rules = array(
      ($auth->acl_get('f_post', $forum_id) && !$locked) ? $user->lang['RULES_POST_CAN'] : $user->lang['RULES_POST_CANNOT'],
      ($auth->acl_get('f_reply', $forum_id) && !$locked) ? $user->lang['RULES_REPLY_CAN'] : $user->lang['RULES_REPLY_CANNOT'],
      ($user->data['is_registered'] && $auth->acl_gets('f_edit', 'm_edit', $forum_id) && !$locked) ? $user->lang['RULES_EDIT_CAN'] : $user->lang['RULES_EDIT_CANNOT'],
      ($user->data['is_registered'] && $auth->acl_gets('f_delete', 'm_delete', $forum_id) && !$locked) ? $user->lang['RULES_DELETE_CAN'] : $user->lang['RULES_DELETE_CANNOT'],
   );

   if ($config['allow_attachments'])
   {
      $rules[] = ($auth->acl_get('f_attach', $forum_id) && $auth->acl_get('u_attach') && !$locked) ? $user->lang['RULES_ATTACH_CAN'] : $user->lang['RULES_ATTACH_CANNOT'];
   }

   foreach ($rules as $rule)
   {
      $template->assign_block_vars('rules', array('RULE' => $rule));
   }

   return;
}

/**
* Generate topic status
*/
function topic_status(&$topic_row, $replies, $unread_topic, &$folder_img, &$folder_alt, &$topic_type)
{
   global $user, $config;

   $folder = $folder_new = '';

   if ($topic_row['topic_status'] == ITEM_MOVED)
   {
      $topic_type = $user->lang['VIEW_TOPIC_MOVED'];
      $folder_img = 'topic_moved';
      $folder_alt = 'TOPIC_MOVED';
   }
   else
   {
      switch ($topic_row['topic_type'])
      {
         case POST_GLOBAL:
            $topic_type = $user->lang['VIEW_TOPIC_GLOBAL'];
            $folder = 'global_read';
            $folder_new = 'global_unread';
         break;

         case POST_ANNOUNCE:
            $topic_type = $user->lang['VIEW_TOPIC_ANNOUNCEMENT'];
            $folder = 'announce_read';
            $folder_new = 'announce_unread';
         break;

         case POST_STICKY:
            $topic_type = $user->lang['VIEW_TOPIC_STICKY'];
            $folder = 'sticky_read';
            $folder_new = 'sticky_unread';
         break;

         default:
            $topic_type = '';
            $folder = 'topic_read';
            $folder_new = 'topic_unread';

            // Hot topic threshold is for posts in a topic, which is replies + the first post. ;)
            if ($config['hot_threshold'] && ($replies + 1) >= $config['hot_threshold'] && $topic_row['topic_status'] != ITEM_LOCKED)
            {
               $folder .= '_hot';
               $folder_new .= '_hot';
            }
         break;
      }

      if ($topic_row['topic_status'] == ITEM_LOCKED)
      {
         $topic_type = $user->lang['VIEW_TOPIC_LOCKED'];
         $folder .= '_locked';
         $folder_new .= '_locked';
      }


      $folder_img = ($unread_topic) ? $folder_new : $folder;
      $folder_alt = ($unread_topic) ? 'NEW_POSTS' : (($topic_row['topic_status'] == ITEM_LOCKED) ? 'TOPIC_LOCKED' : 'NO_NEW_POSTS');

      // Posted image?
      if (!empty($topic_row['topic_posted']) && $topic_row['topic_posted'])
      {
         $folder_img .= '_mine';
      }
   }

   if ($topic_row['poll_start'] && $topic_row['topic_status'] != ITEM_MOVED)
   {
      $topic_type = $user->lang['VIEW_TOPIC_POLL'];
   }
}

/**
* Assign/Build custom bbcodes for display in screens supporting using of bbcodes
* The custom bbcodes buttons will be placed within the template block 'custom_codes'
*/
function display_custom_bbcodes()
{
   global $db, $template, $user;

   // Start counting from 22 for the bbcode ids (every bbcode takes two ids - opening/closing)
   $num_predefined_bbcodes = 22;

   $sql = 'SELECT bbcode_id, bbcode_tag, bbcode_helpline
      FROM ' . BBCODES_TABLE . '
      WHERE display_on_posting = 1
      ORDER BY bbcode_tag';
   $result = $db->sql_query($sql);

   $i = 0;
   while ($row = $db->sql_fetchrow($result))
   {
      // If the helpline is defined within the language file, we will use the localised version, else just use the database entry...
      if (isset($user->lang[strtoupper($row['bbcode_helpline'])]))
      {
         $row['bbcode_helpline'] = $user->lang[strtoupper($row['bbcode_helpline'])];
      }

      $template->assign_block_vars('custom_tags', array(
         'BBCODE_NAME'      => "'[{$row['bbcode_tag']}]', '[/" . str_replace('=', '', $row['bbcode_tag']) . "]'",
         'BBCODE_ID'         => $num_predefined_bbcodes + ($i * 2),
         'BBCODE_TAG'      => $row['bbcode_tag'],
         'BBCODE_HELPLINE'   => $row['bbcode_helpline'],
         'A_BBCODE_HELPLINE'   => str_replace(array('&amp;', '&quot;', "'", '&lt;', '&gt;'), array('&', '"', "\'", '<', '>'), $row['bbcode_helpline']),
      ));

      $i++;
   }
   $db->sql_freeresult($result);
}

/**
* Display reasons
*/
function display_reasons($reason_id = 0)
{
   global $db, $user, $template;

   $sql = 'SELECT *
      FROM ' . REPORTS_REASONS_TABLE . '
      ORDER BY reason_order ASC';
   $result = $db->sql_query($sql);

   while ($row = $db->sql_fetchrow($result))
   {
      // If the reason is defined within the language file, we will use the localized version, else just use the database entry...
      if (isset($user->lang['report_reasons']['TITLE'][strtoupper($row['reason_title'])]) && isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])]))
      {
         $row['reason_description'] = $user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])];
         $row['reason_title'] = $user->lang['report_reasons']['TITLE'][strtoupper($row['reason_title'])];
      }

      $template->assign_block_vars('reason', array(
         'ID'         => $row['reason_id'],
         'TITLE'         => $row['reason_title'],
         'DESCRIPTION'   => $row['reason_description'],
         'S_SELECTED'   => ($row['reason_id'] == $reason_id) ? true : false)
      );
   }
   $db->sql_freeresult($result);
}

/**
* Display user activity (action forum/topic)
*/
function display_user_activity(&$userdata)
{
   global $auth, $template, $db, $user;
   global $phpbb_root_path, $phpEx;

   // Do not display user activity for users having more than 5000 posts...
   if ($userdata['user_posts'] > 5000)
   {
      return;
   }

   $forum_ary = array();

   // Do not include those forums the user is not having read access to...
   $forum_read_ary = $auth->acl_getf('!f_read');

   foreach ($forum_read_ary as $forum_id => $not_allowed)
   {
      if ($not_allowed['f_read'])
      {
         $forum_ary[] = (int) $forum_id;
      }
   }

   $forum_ary = array_unique($forum_ary);
   $forum_sql = (sizeof($forum_ary)) ? 'AND ' . $db->sql_in_set('forum_id', $forum_ary, true) : '';

   // Obtain active forum
   $sql = 'SELECT forum_id, COUNT(post_id) AS num_posts
      FROM ' . POSTS_TABLE . '
      WHERE poster_id = ' . $userdata['user_id'] . "
         AND post_postcount = 1
         $forum_sql
      GROUP BY forum_id
      ORDER BY num_posts DESC";
   $result = $db->sql_query_limit($sql, 1);
   $active_f_row = $db->sql_fetchrow($result);
   $db->sql_freeresult($result);

   if (!empty($active_f_row))
   {
      $sql = 'SELECT forum_name
         FROM ' . FORUMS_TABLE . '
         WHERE forum_id = ' . $active_f_row['forum_id'];
      $result = $db->sql_query($sql, 3600);
      $active_f_row['forum_name'] = (string) $db->sql_fetchfield('forum_name');
      $db->sql_freeresult($result);
   }

   // Obtain active topic
   $sql = 'SELECT topic_id, COUNT(post_id) AS num_posts
      FROM ' . POSTS_TABLE . '
      WHERE poster_id = ' . $userdata['user_id'] . "
         AND post_postcount = 1
         $forum_sql
      GROUP BY topic_id
      ORDER BY num_posts DESC";
   $result = $db->sql_query_limit($sql, 1);
   $active_t_row = $db->sql_fetchrow($result);
   $db->sql_freeresult($result);

   if (!empty($active_t_row))
   {
      $sql = 'SELECT topic_title
         FROM ' . TOPICS_TABLE . '
         WHERE topic_id = ' . $active_t_row['topic_id'];
      $result = $db->sql_query($sql);
      $active_t_row['topic_title'] = (string) $db->sql_fetchfield('topic_title');
      $db->sql_freeresult($result);
   }

   $userdata['active_t_row'] = $active_t_row;
   $userdata['active_f_row'] = $active_f_row;

   $active_f_name = $active_f_id = $active_f_count = $active_f_pct = '';
   if (!empty($active_f_row['num_posts']))
   {
      $active_f_name = $active_f_row['forum_name'];
      $active_f_id = $active_f_row['forum_id'];
      $active_f_count = $active_f_row['num_posts'];
      $active_f_pct = ($userdata['user_posts']) ? ($active_f_count / $userdata['user_posts']) * 100 : 0;
   }

   $active_t_name = $active_t_id = $active_t_count = $active_t_pct = '';
   if (!empty($active_t_row['num_posts']))
   {
      $active_t_name = $active_t_row['topic_title'];
      $active_t_id = $active_t_row['topic_id'];
      $active_t_count = $active_t_row['num_posts'];
      $active_t_pct = ($userdata['user_posts']) ? ($active_t_count / $userdata['user_posts']) * 100 : 0;
   }

   $l_active_pct = ($userdata['user_id'] != ANONYMOUS && $userdata['user_id'] == $user->data['user_id']) ? $user->lang['POST_PCT_ACTIVE_OWN'] : $user->lang['POST_PCT_ACTIVE'];

   $template->assign_vars(array(
      'ACTIVE_FORUM'         => $active_f_name,
      'ACTIVE_FORUM_POSTS'   => ($active_f_count == 1) ? sprintf($user->lang['USER_POST'], 1) : sprintf($user->lang['USER_POSTS'], $active_f_count),
      'ACTIVE_FORUM_PCT'      => sprintf($l_active_pct, $active_f_pct),
      'ACTIVE_TOPIC'         => censor_text($active_t_name),
      'ACTIVE_TOPIC_POSTS'   => ($active_t_count == 1) ? sprintf($user->lang['USER_POST'], 1) : sprintf($user->lang['USER_POSTS'], $active_t_count),
      'ACTIVE_TOPIC_PCT'      => sprintf($l_active_pct, $active_t_pct),
      'U_ACTIVE_FORUM'      => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $active_f_id),
      'U_ACTIVE_TOPIC'      => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=' . $active_t_id),
      'S_SHOW_ACTIVITY'      => true)
   );
}

/**
* Topic and forum watching common code
*/
function watch_topic_forum($mode, &$s_watching, $user_id, $forum_id, $topic_id, $notify_status = 'unset', $start = 0)
{
   global $template, $db, $user, $phpEx, $start, $phpbb_root_path;

   $table_sql = ($mode == 'forum') ? FORUMS_WATCH_TABLE : TOPICS_WATCH_TABLE;
   $where_sql = ($mode == 'forum') ? 'forum_id' : 'topic_id';
   $match_id = ($mode == 'forum') ? $forum_id : $topic_id;
   $u_url = "uid={$user->data['user_id']}";
   $u_url .= ($mode == 'forum') ? '&amp;f' : '&amp;f=' . $forum_id . '&amp;t';

   // Is user watching this thread?
   if ($user_id != ANONYMOUS)
   {
      $can_watch = true;

      if ($notify_status == 'unset')
      {
         $sql = "SELECT notify_status
            FROM $table_sql
            WHERE $where_sql = $match_id
               AND user_id = $user_id";
         $result = $db->sql_query($sql);

         $notify_status = ($row = $db->sql_fetchrow($result)) ? $row['notify_status'] : NULL;
         $db->sql_freeresult($result);
      }

      if (!is_null($notify_status) && $notify_status !== '')
      {

         if (isset($_GET['unwatch']))
         {
            $uid = request_var('uid', 0);
            if ($uid != $user_id)
            {
               $redirect_url = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&amp;start=$start");
               $message = $user->lang['ERR_UNWATCHING'] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</a>');
               trigger_error($message);
            }
            if ($_GET['unwatch'] == $mode)
            {
               $is_watching = 0;

               $sql = 'DELETE FROM ' . $table_sql . "
                  WHERE $where_sql = $match_id
                     AND user_id = $user_id";
               $db->sql_query($sql);
            }

            $redirect_url = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&amp;start=$start");

            meta_refresh(3, $redirect_url);

            $message = $user->lang['NOT_WATCHING_' . strtoupper($mode)] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</a>');
            trigger_error($message);
         }
         else
         {
            $is_watching = true;

            if ($notify_status)
            {
               $sql = 'UPDATE ' . $table_sql . "
                  SET notify_status = 0
                  WHERE $where_sql = $match_id
                     AND user_id = $user_id";
               $db->sql_query($sql);
            }
         }
      }
      else
      {
         if (isset($_GET['watch']))
         {
            $token = request_var('hash', '');
            $redirect_url = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&amp;start=$start");

            if ($_GET['watch'] == $mode && check_link_hash($token, "{$mode}_$match_id"))
            {
               $is_watching = true;

               $sql = 'INSERT INTO ' . $table_sql . " (user_id, $where_sql, notify_status)
                  VALUES ($user_id, $match_id, 0)";
               $db->sql_query($sql);
               $message = $user->lang['ARE_WATCHING_' . strtoupper($mode)] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</a>');
            }
            else
            {
               $message = $user->lang['ERR_WATCHING'] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</a>');
            }

            meta_refresh(3, $redirect_url);

            trigger_error($message);
         }
         else
         {
            $is_watching = 0;
         }
      }
   }
   else
   {
      if (isset($_GET['unwatch']) && $_GET['unwatch'] == $mode)
      {
         login_box();
      }
      else
      {
         $can_watch = 0;
         $is_watching = 0;
      }
   }

   if ($can_watch)
   {
      $s_watching['link'] = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&amp;" . (($is_watching) ? 'unwatch' : 'watch') . "=$mode&amp;start=$start&amp;hash=" . generate_link_hash("{$mode}_$match_id"));
      $s_watching['title'] = $user->lang[(($is_watching) ? 'STOP' : 'START') . '_WATCHING_' . strtoupper($mode)];
      $s_watching['is_watching'] = $is_watching;
   }

   return;
}

/**
* Get user rank title and image
*
* @param int $user_rank the current stored users rank id
* @param int $user_posts the users number of posts
* @param string &$rank_title the rank title will be stored here after execution
* @param string &$rank_img the rank image as full img tag is stored here after execution
* @param string &$rank_img_src the rank image source is stored here after execution
*
* Note: since we do not want to break backwards-compatibility, this function will only properly assign ranks to guests if you call it for them with user_posts == false
*/
function get_user_rank($user_rank, $user_posts, &$rank_title, &$rank_img, &$rank_img_src)
{
   global $ranks, $config, $phpbb_root_path;

//-- mod: Prime Links -------------------------------------------------------//
   if (!function_exists('prime_links'))
   {
      global $phpEx;
      include($phpbb_root_path . 'includes/prime_links.' . $phpEx);
   }
   prime_links();
//-- end: Prime Links -------------------------------------------------------//

   if (empty($ranks))
   {
      global $cache;
      $ranks = $cache->obtain_ranks();
   }

   if (!empty($user_rank))
   {
      $rank_title = (isset($ranks['special'][$user_rank]['rank_title'])) ? $ranks['special'][$user_rank]['rank_title'] : '';
      $rank_img = (!empty($ranks['special'][$user_rank]['rank_image'])) ? '<img src="' . $phpbb_root_path . $config['ranks_path'] . '/' . $ranks['special'][$user_rank]['rank_image'] . '" alt="' . $ranks['special'][$user_rank]['rank_title'] . '" title="' . $ranks['special'][$user_rank]['rank_title'] . '" />' : '';
      $rank_img_src = (!empty($ranks['special'][$user_rank]['rank_image'])) ? $phpbb_root_path . $config['ranks_path'] . '/' . $ranks['special'][$user_rank]['rank_image'] : '';
   }
   else if ($user_posts !== false)
   {
      if (!empty($ranks['normal']))
      {
         foreach ($ranks['normal'] as $rank)
         {
            if ($user_posts >= $rank['rank_min'])
            {
               $rank_title = $rank['rank_title'];
               $rank_img = (!empty($rank['rank_image'])) ? '<img src="' . $phpbb_root_path . $config['ranks_path'] . '/' . $rank['rank_image'] . '" alt="' . $rank['rank_title'] . '" title="' . $rank['rank_title'] . '" />' : '';
               $rank_img_src = (!empty($rank['rank_image'])) ? $phpbb_root_path . $config['ranks_path'] . '/' . $rank['rank_image'] : '';
               break;
            }
         }
      }
   }
}

/**
* Get user avatar
*
* @param string $avatar Users assigned avatar name
* @param int $avatar_type Type of avatar
* @param string $avatar_width Width of users avatar
* @param string $avatar_height Height of users avatar
* @param string $alt Optional language string for alt tag within image, can be a language key or text
* @param bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP
*
* @return string Avatar image
*/
function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $alt = 'USER_AVATAR', $ignore_config = false)
{
   global $user, $config, $phpbb_root_path, $phpEx;

   if (empty($avatar) || !$avatar_type || (!$config['allow_avatar'] && !$ignore_config))
   {
      return '<img src="images/avatars/gallery/no_avatar.gif" ' . (($avatar_width) ? ' width="' . $avatar_width . '" height="' . $avatar_height . '"' : '' ) . ' alt="' . ((!empty($user->lang[$alt])) ? $user->lang[$alt] : $alt) . '" />';
   }

   $avatar_img = '';

   switch ($avatar_type)
   {
      case AVATAR_UPLOAD:
         if (!$config['allow_avatar_upload'] && !$ignore_config)
         {
            return '';
         }
         $avatar_img = $phpbb_root_path . "download/file.$phpEx?avatar=";
      break;

      case AVATAR_GALLERY:
         if (!$config['allow_avatar_local'] && !$ignore_config)
         {
            return '';
         }
         $avatar_img = $phpbb_root_path . $config['avatar_gallery_path'] . '/';
      break;

      case AVATAR_REMOTE:
         if (!$config['allow_avatar_remote'] && !$ignore_config)
         {
            return '';
         }
      break;
   }

   $avatar_img .= $avatar;
   return '<img src="' . (str_replace(' ', '%20', $avatar_img)) . '" width="' . $avatar_width . '" height="' . $avatar_height . '" alt="' . ((!empty($user->lang[$alt])) ? $user->lang[$alt] : $alt) . '" />';
}

?>
I am done with phpBB
stokerpiller
Registered User
Posts: 1934
Joined: Wed Feb 28, 2007 8:06 pm