[MODDB] Quick Title Edition 1.2.0

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment!
Scam Warning
ABDev
Registered User
Posts: 905
Joined: Sun Aug 21, 2005 9:29 pm
Location: France
Name: Adrien Bonnel

[MODDB] Quick Title Edition 1.2.0

Post by ABDev »

  • Image
  • MOD Title: Quick Title Edition
  • MOD Author: ABDev < N/A > http://www.phpbb-forge.com/
  • MOD Author: PastisD < N/A > http://www.phpbb-forge.com/
  • MOD Codename: The "Age of Love" Edition
  • MOD Description: This MOD allows to create topic attributes, which can be applied by the administrators, the moderators and/or the topics authors.
    Attributes can be under the form of a short text, like [Solved by X on Y], or under the form of an image, like Image.
    The %mod% argument sends the username who applied the attribute.
    The %date% argument sends the date, when the attribute has been applied to the topic title.

    Attention, that MOD requires PHP 5.2.0 or greater.
  • MOD Version: 1.2.0
  • Installation level: Advanced
  • Installation time: 60 minutes
  • Download link: Click here
  • Changes from previous version:
    • Optimized the SQL queries for big boards
    • Revised the permissions system
    • Possibility to copy the permissions of another attribute
    • Possibility to define a default attribute per forum, whatever the user level
    • Possibility to prevent to remove topic attributes per forum, as the selected groups
    • Fixed an issue when editing the imagesets
    • Fixed an ID issue on the tables when using the extended permissions system
    • Fixed and improved some language keys
    • Updated jQuery library
    • Updated JSColor element
    • Light code reduction and installation
    • Removed the add-ons from the main archive
  • Demo:
    • N/A
  • Notes:
    • Availables languages: English / French
    • Styles compatibility: prosilver /subsilver2
  • Fix on Sunday, August 19 2012 :

    There are many databases records issues when editing forums.
    The MOD archive has been updated. Here is the manual update :
    • Replace adm/style/acp_attributes_forums.html file from your FTP by the archive one
    • Apply the following fix :

      Code: Select all

      #
      #-----[ OPEN ]------------------------------------------------
      #
      includes/acp/acp_forums.php
      #
      #-----[ FIND ]------------------------------------------------
      #
      //-- mod : quick title edition -------------------------------------------------
      //-- add
              if ( sizeof($forum_data['hide_attr']) )
              {
                  $forum_data['hide_attr'] = serialize($forum_data['hide_attr']);
              }
      //-- fin mod : quick title edition ---------------------------------------------
      #
      #-----[ REPLACE WITH ]----------------------------------------
      #
      //-- mod : quick title edition -------------------------------------------------
      //-- add
              if ( sizeof($forum_data['hide_attr']) )
              {
                  $forum_data['hide_attr'] = serialize($forum_data['hide_attr']);
              }
              else
              {
                  $forum_data['hide_attr'] = '';
              }
      //-- fin mod : quick title edition ---------------------------------------------
      #
      #-----[ SAVE/CLOSE ALL FILES ]--------------------------------
      #
      # EoM        
    Fix on Wesnesday, August 22 2012 :

    Fix and optimization of code

    Please replace the following files by the archive ones :
    • adm/style/acp_attributes.js
    • adm/style/acp_attributes_auths.html
    • includes/acp/acp_attributes.php
    Fix on Saturday, August 25 2012 :

    Fixed an issue when you access to the main page of the User Control Panel

    Apply the following fix :
    • Code: Select all

      #
      #-----[ OPEN ]------------------------------------------------
      #
      includes/ucp/ucp_main.php
      #
      #-----[ FIND ]------------------------------------------------
      #
          foreach ($topic_list as $topic_id)
      #
      #-----[ BEFORE, ADD ]-----------------------------------------
      #
      //-- mod : quick title edition -------------------------------------------------
      //-- add
                      $qte->get_users_by_topic_id($topic_list);
      //-- fin mod : quick title edition ---------------------------------------------
      #
      #-----[ FIND ]------------------------------------------------
      #
      //-- mod : quick title edition -------------------------------------------------
      //-- add
                          if ( !empty($row['topic_attr_id']) )
                          {
                              $qte->get_users_by_topic_id($row['topic_id']);
      #
      #-----[ REPLACE WITH ]----------------------------------------
      #
      //-- mod : quick title edition -------------------------------------------------
      //-- add
                          if ( !empty($row['topic_attr_id']) )
                          {
      #
      #-----[ SAVE/CLOSE ALL FILES ]--------------------------------
      #
      # EoM    
    Fix on Sunday, September 02 2012 :
    • Fixed the loss of the choice when previewing a topic
    • Added the attribute display when editing a first post, if it has one, and in the user activity on the main front of the user control panel
    • Removed the restriction of the attributs displaying in the search and sort functions, an user must be able to search and/or to sort as the attribute of his choice when he sees it
    The fact that there are more changes, you will find all the instructions in that text file : download
    The archive has been updated too.
Last edited by ABDev on Mon Sep 09, 2013 4:28 pm, edited 5 times in total.

User avatar
Jessica
Former Team Member
Posts: 4342
Joined: Sun Jul 18, 2010 2:53 pm
Location: Pennsylvania, USA
Name: Jessica
Contact:

Re: [RC] Quick Title Edition 1.2.0

Post by Jessica »

yay new version
Pro-choice, Atheist, Pro-LGBT rights
Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid. - Albert Einstein

User avatar
Jessica
Former Team Member
Posts: 4342
Joined: Sun Jul 18, 2010 2:53 pm
Location: Pennsylvania, USA
Name: Jessica
Contact:

Re: [RC] Quick Title Edition 1.2.0

Post by Jessica »

updated from 1.1.1 and got this error on the index page:

Code: Select all

Fatal error: Cannot redeclare class qte in /home/jesschen/public_html/phpBB3/includes/functions_attributes.php on line 18
I made all edits (updates) and uploaded the files...

my php version is 5.3.8 if that helps in any way
Pro-choice, Atheist, Pro-LGBT rights
Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid. - Albert Einstein

ABDev
Registered User
Posts: 905
Joined: Sun Aug 21, 2005 9:29 pm
Location: France
Name: Adrien Bonnel

Re: [RC] Quick Title Edition 1.2.0

Post by ABDev »

The add-ons I made are incompatible for the moment, it's just a question of days ;).

Could you say me the ones you installed, and I make you that quickly.

User avatar
Jessica
Former Team Member
Posts: 4342
Joined: Sun Jul 18, 2010 2:53 pm
Location: Pennsylvania, USA
Name: Jessica
Contact:

Re: [RC] Quick Title Edition 1.2.0

Post by Jessica »

I only have one add on, and that's the Latest Topic Title
Pro-choice, Atheist, Pro-LGBT rights
Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid. - Albert Einstein

ABDev
Registered User
Posts: 905
Joined: Sun Aug 21, 2005 9:29 pm
Location: France
Name: Adrien Bonnel

Re: [RC] Quick Title Edition 1.2.0

Post by ABDev »

In the includes/functions_display.php file, could you remove that :

Code: Select all

//-- mod : quick title edition -------------------------------------------------
//-- add
    if ( !class_exists('qte') )
    {
        include $phpbb_root_path . 'includes/functions_attributes.' . $phpEx;
    }
//-- fin mod : quick title edition --------------------------------------------- 
That should work.

User avatar
Jessica
Former Team Member
Posts: 4342
Joined: Sun Jul 18, 2010 2:53 pm
Location: Pennsylvania, USA
Name: Jessica
Contact:

Re: [RC] Quick Title Edition 1.2.0

Post by Jessica »

that's weird, I can't find that in my functions_display.php :/

Code: Select all

<?php
/**
*
* @package phpBB3
* @version $Id$
* @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;
//-- mod : quick title edition -------------------------------------------------
//-- add
	global $qte;
//-- fin mod : quick title edition ---------------------------------------------

//-- mod : latest topic title --------------------------------------------------
//-- add
	// let's check if the install is good !
	ltt_check_install();

	// grab icons from cache
	global $cache;

	$icons = $cache->obtain_icons();
//-- fin mod : latest topic title ----------------------------------------------

	$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'];
	}

	// Handle marking everything read
	if ($mark_read == 'all')
	{
		$redirect = build_url(array('mark', 'hash'));
		meta_refresh(3, $redirect);

		if (check_link_hash(request_var('hash', ''), 'global'))
		{
			markread('all');

			trigger_error(
				$user->lang['FORUMS_MARKED'] . '<br /><br />' .
				sprintf($user->lang['RETURN_INDEX'], '<a href="' . $redirect . '">', '</a>')
			);
		}
		else
		{
			trigger_error(sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));
		}
	}

	// 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;
		}
	}


//-- mod : latest topic title --------------------------------------------------
//-- add
	$sql_array['LEFT_JOIN'][] = array('FROM' => array(TOPICS_TABLE => 't'), 'ON' => 'f.forum_last_post_id = t.topic_last_post_id');
	        	$sql_array['SELECT'] .= ', t.topic_id, t.topic_title, t.topic_title_colour, t.icon_id, t.topic_status, t.topic_moved_id';
//-- fin mod : latest topic title ----------------------------------------------
//-- mod : quick title edition -------------------------------------------------
//-- add
	$sql_array['SELECT'] .= ', t.topic_attr_id, t.topic_attr_user, t.topic_attr_time';
//-- fin mod : quick title edition ---------------------------------------------

// Assign subforums loop for style authors
	{
		$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';
	}


	// BEGIN Topic Text Hover Mod
	if ($config['hover_active'] && !$user->data['user_text_hover'])
	{
		include($phpbb_root_path . 'includes/topic_text_hover.' . $phpEx);
		if($config['hover_show'] == TOPIC_TEXT_HOVER_LAST || $config['hover_show'] == TOPIC_TEXT_HOVER_BOTH)
		{
			$sql_array['LEFT_JOIN'][] = array(
				'FROM'	=> array(POSTS_TABLE => 'p'),
				'ON'	=> "f.forum_last_post_id = p.post_id"
			);
			$sql_array['SELECT'] .= ', p.post_text AS last_text_hover';
		}
	}
	// END Topic Text Hover Mod
	$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;
		}
	}


	include("{$phpbb_root_path}includes/mods/soft_delete.$phpEx");
	while ($row = $db->sql_fetchrow($result))
	{
		$forum_id = $row['forum_id'];
		soft_delete_update_topic_post_count($row);

		// Mark forums read?
		if ($mark_read == 'forums')
		{
			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);
		}


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

		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'];
//-- mod : forum title colour --------------------------------------------------
//-- add
			$subforums[$parent_id][$forum_id]['colour'] = $row['forum_name_colour'];
//-- fin mod : forum title colour ----------------------------------------------
			$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_id_last_post'] = $forum_id;
				// BEGIN Topic Text Hover Mod
				$forum_rows[$parent_id]['last_text_hover'] = (isset($row['last_text_hover'])) ? $row['last_text_hover'] : '';
				// END Topic Text Hover Mod
//-- mod : latest topic title --------------------------------------------------
//-- add
				$forum_rows[$parent_id]['topic_id'] = $row['topic_id'];
				$forum_rows[$parent_id]['topic_title'] = $row['topic_title'];
				$forum_rows[$parent_id]['topic_status'] = $row['topic_status'];
				$forum_rows[$parent_id]['topic_moved_id'] = $row['topic_moved_id'];
$forum_rows[$parent_id]['topic_title_colour'] = $row['topic_title_colour'];

				$forum_rows[$parent_id]['icon_id'] = '';
				if ( $row['enable_icons'] && !empty($row['icon_id']) )
				{
					$forum_rows[$parent_id]['enable_icons'] = $row['enable_icons'];
					$forum_rows[$parent_id]['icon_id'] = $row['icon_id'];
				}
//-- fin mod : latest topic title ----------------------------------------------
//-- mod : quick title edition -------------------------------------------------
//-- add
				$forum_rows[$parent_id]['topic_attr_id'] = $row['topic_attr_id'];
				$forum_rows[$parent_id]['topic_attr_user'] = $row['topic_attr_user'];
				$forum_rows[$parent_id]['topic_attr_time'] = $row['topic_attr_time'];
//-- fin mod : quick title edition ---------------------------------------------
			}
		}
	}
	$db->sql_freeresult($result);

	// Handle marking posts
	if ($mark_read == 'forums')
	{
		$redirect = build_url(array('mark', 'hash'));
		$token = request_var('hash', '');
		if (check_link_hash($token, 'global'))
			{
				// 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)
	{
//-- mod : latest topic title --------------------------------------------------
//-- add
	$template->assign_vars(array(
		'S_LTT' => $config['ltt_url'],
		'S_LTT_ICONS' => $config['ltt_icons'],
	));
//-- fin mod : latest topic title ----------------------------------------------
		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;

	// start mod view or mark unread post
	// initialize the flag $exists_unread to signal that we have already checked unreads in functions_display()
	// so that when check_unread_posts() is called in the future it can skip the sql query and give the
	// answer that there are none (this gets reset to '1' later on in functions_display() if there are unreads),
	// but do NOT initialize if the user is on viewforum since the test for unreads may give false negatives in that context
	if (!$sql_where)
	{
		global $exists_unreads;
		$exists_unreads = -1;
	}
	// end mod view or mark unread posts
	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,
				'S_THANKS_FORUM_REPUT_VIEW_COLUMN' => ($config['thanks_forum_reput_view']) ? $config['thanks_forum_reput_view_column'] : false,
				'THANKS_REPUT_GRAPHIC_WIDTH'=> sprintf('%dpx', $config['thanks_reput_level']*$config['thanks_reput_height']),
				'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,
//-- mod : forum title colour --------------------------------------------------
//-- add
						'colour'		=> $subforum_row['colour'],
//-- fin mod : forum title colour ----------------------------------------------
					);
				}
				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;
			}
		}


		// start mod view or mark unread posts
		if ($forum_unread)
		{
			// if there are any unread topics, set $exists_unreads flag to 1 so that
			// when check_unreads_flag() is called in the future it can skip the sql query
			// and give the answer that there are unread posts'
			$exists_unreads = 1;
		}
		// end mod view or mark unread posts
		// 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) ? 'UNREAD_POSTS' : 'NO_UNREAD_POSTS';
		}

		// Create last post link information, if appropriate
		if ($row['forum_last_post_id'])
		{
			$last_post_subject = $row['forum_last_post_subject'];
                // BEGIN Topic Text Hover MOD
                if(!empty($row['last_text_hover']) && $auth->acl_get('f_read', $row['forum_id']))
                {
                    // strip all bbcode
                    include($phpbb_root_path . 'includes/topic_text_hover.' . $phpEx);
                    $last_text_hover = censor_text(bbcode_strip($row['last_text_hover']));
                    if (utf8_strlen($last_text_hover) >= $config['hover_char_limit'])
                    {
                        $last_text_hover = (utf8_strlen($last_text_hover) > $config['hover_char_limit'] + 3) ? utf8_substr($last_text_hover, 0, $config['hover_char_limit']) . '...' : $last_text_hover;
                    }
                }
                else
                {
                    $last_text_hover = '';
                }
                // END Topic Text Hover MOD
			$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'] . '&t=' . $row['topic_id'] . '&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) ? number_format($row['forum_posts']) : '';

		$s_subforums_list = array();
//-- mod : forum title colour --------------------------------------------------
//-- add
		$offset = 0;
//-- fin mod : forum title colour ----------------------------------------------
		foreach ($subforums_list as $subforum)
		{
//-- mod : forum title colour --------------------------------------------------
// here we added
//	$offset
//-- modify
			$s_subforums_list[$offset] = '<a href="' . $subforum['link'] . '" class="subforum ' . (($subforum['unread']) ? 'unread' : 'read') . '" title="' . (($subforum['unread']) ? $user->lang['UNREAD_POSTS'] : $user->lang['NO_UNREAD_POSTS']) . '">' . $subforum['name'] . '</a>';
//-- add
			$s_subforums_list[$offset] = str_replace('class="subforum ' . ($subforum['unread'] ? 'unread' : 'read') . '"', ftc_style($subforum['colour'], true, $subforum['unread']), $s_subforums_list[$offset]);
			$offset++;
//-- fin mod : forum title colour ----------------------------------------------


		}
		$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'];
			}
		}
		$online_users = obtain_users_online($row['forum_id']);

		$template->assign_block_vars('forumrow', array(
			'S_IS_CAT'			=> false,
			'S_NO_CAT'			=> $catless && !$last_catless,
			'S_THANKS_FORUM_REPUT_VIEW_COLUMN' => ($config['thanks_forum_reput_view']) ? $config['thanks_forum_reput_view_column'] : false,
			'THANKS_REPUT_GRAPHIC_WIDTH'=> sprintf('%dpx', $config['thanks_reput_level']*$config['thanks_reput_height']),
			'S_IS_LINK'			=> ($row['forum_type'] == FORUM_LINK) ? true : false,
			'S_UNREAD_FORUM'	=> $forum_unread,
			'S_AUTH_READ'		=> $auth->acl_get('f_read', $row['forum_id']),
			'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']) && $row['forum_type'] == FORUM_POST) ? 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_op_only_view'] && !$auth->acl_get('f_op_only_view', $forum_id)) ? '--' : number_format($row['forum_topics']),
			$l_post_click_count		=>($row['forum_op_only_view'] && !$auth->acl_get('f_op_only_view', $forum_id)) ? '--' : $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'		=> censor_text($last_post_subject),
			// BEGIN Topic Text Hover MOD
			'LAST_TEXT_HOVER'		=> (isset($last_text_hover)) ? censor_text($last_text_hover) : '',
			'LAST_POST_IMG'			=> $user->img('icon_topic_latest'),
			// END Topic Text Hover Mod
			'LAST_POST_TIME'		=>($row['forum_op_only_view'] && !$auth->acl_get('f_op_only_view', $forum_id)) ? '--' : $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'		=>($row['forum_op_only_view'] && !$auth->acl_get('f_op_only_view', $forum_id)) ? '--' : get_username_string('full', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']),
			'MODERATORS'			=> $moderators_list,
			'SUBFORUMS'				=> $s_subforums_list,


			'L_SUBFORUM_STR'		=> $l_subforums,
			'L_MODERATOR_STR'		=> $l_moderator,
			'L_FORUM_VISIT'			=> $user->lang(($online_users['total_online'] > 1) ? 'FORUM_VISITS' : 'FORUM_VISIT', $online_users['total_online']),
			'S_USERS'				=> ($online_users['total_online'] != 0) ? true : false,   

			'U_UNAPPROVED_TOPICS'	=> ($row['forum_id_unapproved_topics']) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=unapproved_topics&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)
		);



//-- mod : forum title colour --------------------------------------------------
//-- add
		if ( !empty($row['forum_name_colour']) )
		{
			$template->alter_block_array('forumrow', array(
				'S_FORUM_NAME_COLOUR' => true,
				'FORUM_NAME_COLOUR' => ftc_style($row['forum_name_colour']),
			), true, 'change');
		}
//-- fin mod : forum title colour ----------------------------------------------


//-- mod : latest topic title --------------------------------------------------
//-- add
		$row['topic_id'] = (($row['topic_status'] == ITEM_MOVED) && !empty($row['topic_moved_id'])) ? $row['topic_moved_id'] : $row['topic_id'];

		$template->alter_block_array('forumrow', array(
			'LATEST_TOPIC_TITLE_COLOUR'   => !empty($row['topic_title_colour']) ? $row['topic_title_colour'] : '',
			'LATEST_TOPIC_TITLE_SHORT' => ltt_max_chars($row['topic_title']),
			'LATEST_TOPIC_TITLE_FULL' => censor_text($row['topic_title']),
			'U_FIRST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']),
			'U_NEWEST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id'] . '&view=unread') . '#unread',
		), true, 'change');

		if ( $row['enable_icons'] && !empty($row['icon_id']) )
		{
			$template->alter_block_array('forumrow', array(
				'TOPIC_ICON_IMG' => $icons[$row['icon_id']]['img'],
				'TOPIC_ICON_IMG_WIDTH' => $icons[$row['icon_id']]['width'],
				'TOPIC_ICON_IMG_HEIGHT' => $icons[$row['icon_id']]['height'],
			), true, 'change');
		}
//-- fin mod : latest topic title ----------------------------------------------
//-- mod : quick title edition -------------------------------------------------
//-- add
		if ( !empty($row['topic_attr_id']) )
		{
			$template->alter_block_array('forumrow', array(
				'S_TOPIC_ATTR' => true,
				'TOPIC_ATTRIBUTE' => $qte->attr_display($row['topic_attr_id'], $row['topic_attr_user'], $row['topic_attr_time']),
			), true, 'change');
		}
//-- fin mod : quick title edition ---------------------------------------------
		// 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') . '&f=' . $root_data['forum_id'] . '&mark=forums') : '',
		'S_HAS_SUBFORUM'	=> ($visible_forums) ? true : false,
		'L_SUBFORUM'		=> ($visible_forums == 1) ? $user->lang['SUBFORUM'] : $user->lang['SUBFORUMS'],
		'LAST_POST_IMG'		=>($row['forum_op_only_view'] && !$auth->acl_get('f_op_only_view', $forum_id)) ? '' : $user->img('icon_topic_latest', 'VIEW_LATEST_POST'),
		'UNAPPROVED_IMG'	=> $user->img('icon_topic_unapproved', 'TOPICS_UNAPPROVED'),
	));


//-- mod : latest topic title --------------------------------------------------
//-- add
	$template->assign_vars(array(
		'S_LTT' => $config['ltt_url'],
		'S_LTT_ICONS' => $config['ltt_icons'],
	));
//-- fin mod : latest topic title ----------------------------------------------
	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']),

		'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,
	));

//-- mod : forum title colour --------------------------------------------------
//-- add
	if ( !empty($forum_data['forum_name_colour']) )
	{
		$template->assign_vars(array(
			'S_FORUM_NAME_COLOUR' => true,
			'FORUM_NAME_COLOUR' => ftc_style($forum_data['forum_name_colour']),
		));
	}
//-- fin mod : forum title colour ----------------------------------------------

	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 . ($j == 0 ? '' : '&start=' . $j) . '">' . $times . '</a>';
			if ($times == 1 && $total_pages > 5)
			{
				$pagination .= '<span class="page-dots"> ... </span>';

				// 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&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) ? 'UNREAD_POSTS' : (($topic_row['topic_status'] == ITEM_LOCKED) ? 'TOPIC_LOCKED' : 'NO_UNREAD_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'];
	}
	// start mod tabulated survey at topic head...added definition of topic_type as survey for topics in viewforum that have surveys
	if ($topic_row['topic_survey'] && $topic_row['topic_status'] != ITEM_MOVED)
	{
		$topic_type = $user->lang['VIEW_TOPIC_SURVEY'];
	}
	// end mod tabulated survey at topic head
}

/**
* 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($abbc3 = true)
{
	global $db, $template, $user;

	// Start counting from 22 for the bbcode ids (every bbcode takes two ids - opening/closing)
	$num_predefined_bbcodes = 22;
// MOD : MSSTI ABBC3 - Start
	global $config, $mode, $abbcode;

	$abbc3 = ($abbc3 && @$config['ABBC3_UCP_MODE'] && isset($user->data['user_abbcode_mod'])) ? $user->data['user_abbcode_mod'] : $abbc3;

	$display = ($mode == 'signature' || $mode == 'sig') ? 'display_on_sig' : ($mode == 'compose' ? 'display_on_pm' : 'display_on_posting');

	if ($abbc3 && @$config['ABBC3_MOD'])
	{
		// We need to check if ABBC3 is properly initialized
		if (!class_exists('abbcode'))
		{
			global $phpbb_root_path, $phpEx;

			include($phpbb_root_path . 'includes/abbcode.' . $phpEx);
		}

		$abbcode->abbcode_init();
		$abbcode->abbcode_display($mode);

		$sql_where = " $display = 1 AND (abbcode = 0 AND bbcode_image = '')";
	}
	else
	{
		$sql_where = " $display = 1 AND abbcode = 0";

		$template->assign_vars(array('S_ABBC3_DISABLED' => true));
	}
// MOD : MSSTI ABBC3 - End

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

	$i = 0;
	while ($row = $db->sql_fetchrow($result))
	{

// MOD : MSSTI ABBC3 - Start
		if ($abbc3 && @$config['ABBC3_MOD'])
		{
			// Check phpbb permissions status
			// Check ABBC3 groups permission
			// try to make it as quicky as it can be 
			$auth_tag = preg_replace('#\=(.*)?#', '', strtoupper(trim($row['bbcode_tag'])));
			if (isset($row['bbcode_group']) && $row['bbcode_group'])
			{
				if (!$abbcode->abbcode_permissions($auth_tag, $row['bbcode_group']))
				{
					continue;
				}
			}
		}
// MOD : MSSTI ABBC3 - End
		// 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('&', '"', "'", '<', '>'), 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 x posts...
	global $config;
	if (($userdata['user_posts'] > $config['load_user_activity_limit']) && ($config['load_user_activity_limit'] != 0))
	{
		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) : '';

	$fid_m_approve = $auth->acl_getf('m_approve', true);
	$sql_m_approve = (!empty($fid_m_approve)) ? 'OR ' . $db->sql_in_set('forum_id', array_keys($fid_m_approve)) : '';

	// 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
			AND (post_approved = 1
				$sql_m_approve)
			$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'];
//-- mod : forum title colour --------------------------------------------------
//-- add
		$sql = str_replace('SELECT ', 'SELECT forum_name_colour, ', $sql);
//-- fin mod : forum title colour ----------------------------------------------
		$result = $db->sql_query($sql, 3600);

		$active_f_row['forum_name'] = (string) $db->sql_fetchfield('forum_name');

		$db->sql_freeresult($result);
	}

	// Obtain active topic
	// We need to exclude passworded forums here so we do not leak the topic title
	$forum_ary_topic = array_unique(array_merge($forum_ary, $user->get_passworded_forums()));
	$forum_sql_topic = (!empty($forum_ary_topic)) ? 'AND ' . $db->sql_in_set('forum_id', $forum_ary_topic, true) : '';

	$sql = 'SELECT topic_id, COUNT(post_id) AS num_posts
		FROM ' . POSTS_TABLE . '
		WHERE poster_id = ' . $userdata['user_id'] . "
			AND post_postcount = 1
			AND (post_approved = 1
				$sql_m_approve)
			$forum_sql_topic
		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;

//-- mod : forum title colour --------------------------------------------------
//-- delete
//-- mod : forum title colour --------------------------------------------------
//-- add
	$active_f_name_colour = '';
//-- fin mod : forum title colour ----------------------------------------------
	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;
//-- mod : forum title colour --------------------------------------------------
//-- add
		$active_f_name_colour = $active_f_row['forum_name_colour'];
//-- fin mod : forum title colour ----------------------------------------------
	}

	$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)
	);
//-- mod : forum title colour --------------------------------------------------
//-- add
	if ( !empty($active_f_name_colour) )
	{
		$template->assign_vars(array(
			'S_ACTIVE_FORUM_COLOUR' => true,
			'ACTIVE_FORUM_COLOUR' => ftc_style($active_f_name_colour),
		));
	}
//-- fin mod : forum title colour ----------------------------------------------
}

/**
* Topic and forum watching common code
*/
function watch_topic_forum($mode, &$s_watching, $user_id, $forum_id, $topic_id, $notify_status = 'unset', $start = 0, $item_title = '')
{
	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') ? '&f' : '&f=' . $forum_id . '&t';
	$is_watching = 0;

	// 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);
				$token = request_var('hash', '');

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

					$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&start=$start");
					$message = $user->lang['NOT_WATCHING_' . strtoupper($mode)] . '<br /><br />';
					$message .= sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</a>');
				meta_refresh(3, $redirect_url);
				trigger_error($message);
				}
				else
				{
					$s_hidden_fields = array(
						'uid'		=> $user->data['user_id'],
						'unwatch'	=> $mode,
						'start'		=> $start,
						'f'			=> $forum_id,
					);
					if ($mode != 'forum')
					{
						$s_hidden_fields['t'] = $topic_id;
					}

					if ($item_title == '')
					{
						$confirm_box_message = 'UNWATCH_' . strtoupper($mode);
					}
					else
					{
						$confirm_box_message = $user->lang('UNWATCH_' . strtoupper($mode) . '_DETAILED', $item_title);
					}
					confirm_box(false, $confirm_box_message, build_hidden_fields($s_hidden_fields));
				}
			}
			else
			{
				$is_watching = true;

				if ($notify_status != NOTIFY_YES)
				{
					$sql = 'UPDATE ' . $table_sql . "
						SET notify_status = " . NOTIFY_YES . "
						WHERE $where_sql = $match_id
							AND user_id = $user_id";
					$db->sql_query($sql);
				}
			}
		}
		else
		{
			if (isset($_GET['watch']))
			{
				$uid = request_var('uid', 0);
				$token = request_var('hash', '');

				if ($token && check_link_hash($token, "{$mode}_$match_id") || confirm_box(true))
				{
					if ($uid != $user_id || $_GET['watch'] != $mode)
					{
						$redirect_url = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&start=$start");
						$message = $user->lang['ERR_WATCHING'] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</a>');
						trigger_error($message);
					}

					$is_watching = true;

					$sql = 'INSERT INTO ' . $table_sql . " (user_id, $where_sql, notify_status)
						VALUES ($user_id, $match_id, " . NOTIFY_YES . ')';
					$db->sql_query($sql);

					$redirect_url = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&start=$start");
					$message = $user->lang['ARE_WATCHING_' . strtoupper($mode)] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</a>');
					meta_refresh(3, $redirect_url);
					trigger_error($message);
				}
				else
				{
					$s_hidden_fields = array(
						'uid'		=> $user->data['user_id'],
						'watch'		=> $mode,
						'start'		=> $start,
						'f'			=> $forum_id,
					);
					if ($mode != 'forum')
					{
						$s_hidden_fields['t'] = $topic_id;
				}

					$confirm_box_message = (($item_title == '') ? 'WATCH_' . strtoupper($mode) : $user->lang('WATCH_' . strtoupper($mode) . '_DETAILED', $item_title));
					confirm_box(false, $confirm_box_message, build_hidden_fields($s_hidden_fields));
				}
			}
			else
			{
				$is_watching = 0;
			}
		}
	}
	else
	{
		if ((isset($_GET['unwatch']) && $_GET['unwatch'] == $mode) || (isset($_GET['watch']) && $_GET['watch'] == $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&" . (($is_watching) ? 'unwatch' : 'watch') . "=$mode&start=$start&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;

	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's additional (normal) rank title and image if they have a special rank
*
* @param int $user_rank the current stored users rank id
* @param int $user_posts the users number of posts
* @param string &$rank_title the additional rank title will be stored here after execution, if the user has an additional rank
* @param string &$rank_img the additional rank image as full img tag is stored here after execution, if the user has an additional rank
* @param string &$rank_img_src the additional rank image source is stored here after execution, if the user has an additional rank
*
*/
function get_user_additional_rank($user_rank, $user_posts, &$rank_title, &$rank_img, &$rank_img_src)
{
	if (!empty($user_rank))
	{
		//Always pass 0 to save duplicating get_user_rank and getting the special rank back
		get_user_rank(0, $user_posts, $rank_title, $rank_img, $rank_img_src);
	}
}
/**
* 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 '';
	}

	$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) . '" />';
}

?>


EDIT: oh right I didn't seem to have added that line at all, because I recall it causing some problems.....
Pro-choice, Atheist, Pro-LGBT rights
Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid. - Albert Einstein

ABDev
Registered User
Posts: 905
Joined: Sun Aug 21, 2005 9:29 pm
Location: France
Name: Adrien Bonnel

Re: [RC] Quick Title Edition 1.2.0

Post by ABDev »

The add-on for Latest Topic Title works fine (just tested, with version 1.0.3).
What is the version of your add-on ?

Edit : Could you paste me your index.php file please ?

User avatar
Jessica
Former Team Member
Posts: 4342
Joined: Sun Jul 18, 2010 2:53 pm
Location: Pennsylvania, USA
Name: Jessica
Contact:

Re: [RC] Quick Title Edition 1.2.0

Post by Jessica »

not sure what the version is. I'll try to figure it out

okay, here's my index.php

Code: Select all

<?php
/**
*
* @package phpBB3
* @version $Id$
* @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);
// phpBB Arcade Start
$arcade_act	= strtolower(request_var('act', ''));
$arcade_do	= strtolower(request_var('do', ''));

$scoretype	= ($arcade_act == 'arcade' && $arcade_do == 'newscore') ? IBPRO_GAME : (($arcade_act == 'arcadelib') ? ARCADELIB_GAME : ((strtolower(request_var('autocom', '')) == 'arcade') ? IBPROV3_GAME : false));

if ($scoretype)
{
	define('IN_PHPBB_ARCADE', true);
	include($phpbb_root_path . 'arcade/includes/scoretype.' . $phpEx);
}
// phpBB Arcade End
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);

//-- mod : quick title edition -------------------------------------------------
//-- add
include $phpbb_root_path . 'includes/functions_attributes.' . $phpEx;
//-- fin mod : quick title edition ---------------------------------------------
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('viewforum');
// JQ Who is where / 4seven / 2012
$who_base = $config['cookie_name'] . '_base';	
setcookie("$who_base", 'base', time()+3600*24);
// JQ Who is where / 4seven / 2012
/// Begin cBB Portal
$portal->redirect('index');
// End cBB Portal







// Start Breizh Shoutbox
if (isset($config['shout_version']))
{
	if ($config['shout_enable'] && $config['shout_index'])
	{
		shout_display();
	}
}
// End Breizh Shoutbox --

// Begin Referral MOD
// Get referrer user ID
$r = request_var('r', 0);

// Let's check if the referrer is valid
if ($r > 0)
{
    $sql = 'SELECT user_id
	    FROM ' . USERS_TABLE . '
	    WHERE user_id=' . $r . '
	    AND user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')';
    $result = $db->sql_query($sql);
    $row = $db->sql_fetchrow($result);
    $db->sql_freeresult($result);

    // If the referrer is valid, set the cookie
    if (!empty($row['user_id']))
    {
        $user->set_cookie('referrer_id', $r, time()+60*60*24*365);

		header("HTTP/1.1 301 Moved Permanently"); 
        header("Location: " . generate_board_url()); 
    }
}

if (!empty($config['referral_mod_version']))
{
    $user->add_lang('mods/referral');

    if ($config['referral_contests_display'])
	{
	    // Get the last contest
        $sql = 'SELECT *
	        FROM ' . REFERRAL_CONTESTS_TABLE . '
	        ORDER BY contest_end_date DESC';
        $result = $db->sql_query_limit($sql, 1, 0);
        $row = $db->sql_fetchrow($result);

	    $template->assign_vars(array(
	        'CONTEST_DISPLAY'     => $config['referral_contests_display'],
		    'CONTEST_NAME'        => $row['contest_name'],
		    'CONTEST_DESCRIPTION' => $row['contest_description'],
		    'CONTEST_START_DATE'  => $user->format_date($row['contest_start_date']),
		    'CONTEST_END_DATE'    => $user->format_date($row['contest_end_date']),
		    'CONTEST_DURATION'    => $row['contest_duration'],
		    'CONTEST_STATUS'      => ($row['contest_end_date'] < time()) ? '<span style="color:red;">' . $user->lang['CONTEST_OVER'] . '</span>' : '<span style="color:green;">' . $user->lang['CONTEST_IN_PROGRESS'] . '</span>',
		   )
	    );
    
	    // Set some variables to use in statistics
        $contest_id         = $row['contest_id'];
        $contest_start_date = $row['contest_start_date'];
        $contest_end_date   = $row['contest_end_date'];
	    $ref_min_posts      = $row['contest_condition'];

        $db->sql_freeresult($result);

	    if ($row)
	    {
	        // Get contest statistics
	        $sql = 'SELECT * ,
		        COUNT(referrer_username) AS referrals_count
		        FROM ' . REFERRALS_TABLE . '
		        LEFT JOIN ' . USERS_TABLE . '
		        ON referral_username=username
		        WHERE referral_since
		        BETWEEN ' . $contest_start_date . ' AND ' . $contest_end_date . '
		        AND user_posts >= ' . $ref_min_posts . '
		        GROUP BY referrer_username
		        ORDER BY referrals_count DESC';
            $result = $db->sql_query_limit($sql, 3, 0);

	        $i = 1;

	        while ($row = $db->sql_fetchrow($result))
	        {
                if ($i == 1)
                {
	                $referrer_username = $row['referrer_username'];
                }

                $template->assign_block_vars('contest_stats', array(
			        'REFERRER_USERNAME' => $row['referrer_username'],
			        'REFERRALS_COUNT'   => $row['referrals_count'],
			        'CONTEST_POS'       => '<img src="' . $phpbb_root_path . 'images/contest_pos_' . $i . '.gif" alt="' . $i . '" />',
     )
);
$i++;
	        }
	        $db->sql_freeresult($result);

	        // If contest is over, save contest winner
	        if ($contest_end_date < time())
	        {
	            $sql = 'UPDATE ' . REFERRAL_CONTESTS_TABLE . '
		            SET contest_winner = "' . $referrer_username . '"
		            WHERE contest_id = ' . $contest_id;
	            $db->sql_query($sql);
	        }
	    }
    }

	// Get top 5 referrers
	if ($config['top_five_referrers'])
    {
        $sql = 'SELECT *
            FROM ' . USERS_TABLE . '
	        WHERE user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')
		    AND user_referrals >=1';
        $result = $db->sql_query_limit($sql, 5, 0);

        while ($row = $db->sql_fetchrow($result))
        {
	        $template->assign_block_vars('top_five_referrers', array(
		        'USERNAME'    => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
		        'REFERRALS'   => $row['user_referrals'],
		        )
	        );
        }
        $db->sql_freeresult($result);

	    // Set template variables
	    $template->assign_vars(array(
	        'TOP_FIVE_REFERRERS' => $config['top_five_referrers'],
		    )
        );
	}
}
// End Referral MOD
display_forums('', $config['load_moderators']);

// Set some stats, get posts count from forums data if we... hum... retrieve all forums data
$total_posts	= $config['num_posts'];
$total_topics	= $config['num_topics'];
$total_users	= $config['num_users'];

$l_total_user_s = ($total_users == 0) ? 'TOTAL_USERS_ZERO' : 'TOTAL_USERS_OTHER';
$l_total_post_s = ($total_posts == 0) ? 'TOTAL_POSTS_ZERO' : 'TOTAL_POSTS_OTHER';
$l_total_topic_s = ($total_topics == 0) ? 'TOTAL_TOPICS_ZERO' : 'TOTAL_TOPICS_OTHER';

// Grab group details for legend display
if ($auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel'))
{
	$sql = 'SELECT group_id, group_name, group_colour, group_type, group_position
		FROM ' . GROUPS_TABLE . '
		WHERE group_legend = 1
		ORDER BY group_position ASC';
}
else
{
	$sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_type, g.group_position
		FROM ' . GROUPS_TABLE . ' g
		LEFT JOIN ' . USER_GROUP_TABLE . ' ug
			ON (
				g.group_id = ug.group_id
				AND ug.user_id = ' . $user->data['user_id'] . '
				AND ug.user_pending = 0
			)
		WHERE g.group_legend = 1
			AND (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . $user->data['user_id'] . ')
		ORDER BY g.group_position ASC';
}
$result = $db->sql_query($sql);

$legend = array();
while ($row = $db->sql_fetchrow($result))
{
	$colour_text = ($row['group_colour']) ? ' style="color:#' . $row['group_colour'] . '"' : '';
	$group_name = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name'];

	if ($row['group_name'] == 'BOTS' || ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')))
	{
		$legend[] = '<span' . $colour_text . '>' . $group_name . '</span>';
	}
	else
	{
		$legend[] = '<a' . $colour_text . ' href="' . append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&g=' . $row['group_id']) . '">' . $group_name . '</a>';
	}
}
$db->sql_freeresult($result);

$legend = implode(', ', $legend);

// Generate birthday list if required ...
$birthday_list = '';
if ($config['load_birthdays'] && $config['allow_birthdays'] && $auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel'))
{
	$now = phpbb_gmgetdate(time() + $user->timezone + $user->dst);

	// Display birthdays of 29th february on 28th february in non-leap-years
	$leap_year_birthdays = '';
	if ($now['mday'] == 28 && $now['mon'] == 2 && !$user->format_date(time(), 'L'))
	{
		$leap_year_birthdays = " OR user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', 29, 2)) . "%'";
	}

	$sql = 'SELECT u.user_id, u.username, u.user_colour, u.user_birthday
		FROM ' . USERS_TABLE . ' u
		LEFT JOIN ' . BANLIST_TABLE . " b ON (u.user_id = b.ban_userid)
		WHERE (b.ban_id IS NULL
			OR b.ban_exclude = 1)
			AND (u.user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', $now['mday'], $now['mon'])) . "%' $leap_year_birthdays)
			AND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')';
//-- mod: Prime Birthdate ---------------------------------------------------//
	include($phpbb_root_path . 'includes/prime_birthdate.' . $phpEx);
	$prime_birthdate->index_inject_sql($sql);
//-- end: Prime Birthdate ---------------------------------------------------//
	$result = $db->sql_query($sql);

	while ($row = $db->sql_fetchrow($result))
	{

//-- mod: Prime Birthdate ---------------------------------------------------//
		$prime_birthdate->index_alter_birthday_list($row);
//-- end: Prime Birthdate ---------------------------------------------------//
		$birthday_list .= (($birthday_list != '') ? ', ' : '') . get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);

		if ($age = (int) substr($row['user_birthday'], -4))
		{
			$birthday_list .= ' (' . max(0, $now['year'] - $age) . ')';
		}
	}
	$db->sql_freeresult($result);
}
// Start User Statistics
if($user->data['is_registered'])
{
  $sql = 'SELECT COUNT(topic_poster) as user_topics
          FROM ' . TOPICS_TABLE . '
          WHERE topic_poster = ' . $user->data['user_id'];
  $result = $db->sql_query($sql);
  $user_topics = $db->sql_fetchrow($result);
  $db->sql_freeresult($result);

  $sql = 'SELECT r.rank_title, u.user_rank
          FROM ' . RANKS_TABLE . ' as r, ' . USERS_TABLE . ' as u
          WHERE u.user_id = ' . $user->data['user_id'] . '
            AND rank_id = u.user_rank';
  $result = $db->sql_query($sql);
  $user_rank = $db->sql_fetchrow($result);
  $db->sql_freeresult($result);

  $template->assign_vars(array(
    'US_IP'	=> $user->data['user_ip'],
    'US_REGDATE'	=> $user->format_date($user->data['user_regdate']),
    'US_ID'	=> $user->data['user_id'],
    'US_POSTS'	=> $user->data['user_posts'],
    'US_RTITLE'	=> ($user_rank['rank_title'] != '') ? $user_rank['rank_title'] : $user->lang['US_NO_RANK'],
    'US_TOPICS'	=> $user_topics['user_topics'],
  ));
}
// End User Statistics


if (!class_exists('phpbb_mods_who_was_here'))
{
	include($phpbb_root_path . 'includes/mods/who_was_here.' . $phpEx);
	phpbb_mods_who_was_here::update_session();
}
phpbb_mods_who_was_here::display();


// BEGIN MOD guests past 24 hours
if (!function_exists('obtain_guest_count_24'))
{
	include($phpbb_root_path . 'includes/functions_guests_24.' . $phpEx);
}
obtain_guest_count_24();
// END MOD guests past 24 hours

//-- mod: top five ---------------------------------------------------------//
//	include($phpbb_root_path . 'includes/top_five.' . $phpEx);
//-- end: top five ---------------------------------------------------------//

if ($config['load_birthdays'] && $config['allow_birthdays'] && ( $config['allow_birthdays_ahead'] > 0 ) )
{
	if(!function_exists('get_upcbirthdays'))
	{	
		include($phpbb_root_path . 'includes/functions_upcbirthdays.' . $phpEx);
	}
	get_upcbirthdays();
}

//-- mod: top five ---------------------------------------------------------//
	include($phpbb_root_path . 'includes/top_five.' . $phpEx);
//-- end: top five ---------------------------------------------------------//


if ( isset($config['announcement_enable']))
{
	if ( $config['announcement_show_index'] && ($config['announcement_enable'] || $config['announcement_show_birthdays_always']) )
	{
		if (!function_exists('get_announcement_data'))
		{
			include($phpbb_root_path . 'includes/functions_announcements.' . $phpEx);
		}
		get_announcement_data();
	}
}

/**
* DM Quotes Collection
*/
if ( !function_exists('get_quote') )
{
	include($phpbb_root_path . 'includes/functions_dm_qc.' . $phpEx);
}
get_quote();

/**
* Ultimate Points
*/
if (isset($config['points_name']))
{
	// Add points lang
	$user->add_lang('mods/points');

	// Generate the bank statistics
	$sql_array = array(
		'SELECT'	=> 'SUM(holding) AS total_holding, count(user_id) AS total_users',
		'FROM'		=> array(
			POINTS_BANK_TABLE => 'b',
		),
		'WHERE'		=> 'id > 0',
	);
	$sql = $db->sql_build_query('SELECT', $sql_array);
	$result = $db->sql_query($sql);
	$b_row = $db->sql_fetchrow($result);
	$bankholdings = ( $b_row['total_holding'] ) ? $b_row['total_holding'] : 0;
	$bankusers = $b_row['total_users'];

	// Create most rich users - cash and bank
	$limit = $points_values['number_show_top_points'];
	$sql_array = array(
		'SELECT'	=> 'u.user_id, u.username, u.user_colour, u.user_points, b.holding',

		'FROM'		=> array(
			USERS_TABLE  => 'u',
		),
		'LEFT_JOIN' => array(
			array(
				'FROM'	=> array(POINTS_BANK_TABLE => 'b'),
				'ON'	=> 'u.user_id = b.user_id'
			)
		),
	);
	$sql = $db->sql_build_query('SELECT', $sql_array);
	$result = $db->sql_query($sql);

	// Create a new array for the users
	$rich_users = array();

	// Create sorting array
	$rich_users_sort = array();

	// Loop all users array to escape the 0 points users
	while ($row = $db->sql_fetchrow($result))
	{
		if ($row['user_points'] > 0 || $row['holding'] > 0) //let away beggars
		{
			$total_points = $row['user_points'] + $row['holding'];
			$index = $row['user_id'];
			$rich_users[$index] = array('total_points' => $total_points, 'username' => $row['username'], 'user_colour' => $row['user_colour'], 'user_id' => $index);
			$rich_users_sort[$index] = $total_points;
		}
	}

	$db->sql_freeresult($result);

	// Sort by points desc
	arsort ($rich_users_sort);

	// Extract the user ids
	$rich_users_sort  = array_keys($rich_users_sort);

	// Create new sorted rich users array
	$rich_users_sorted = array();

	// Check, if number of users in array is below the set limit
	$new_limit = sizeof($rich_users) < $limit ? sizeof($rich_users) : $limit;

	for($i = 0; $i < $new_limit; $i++)
	{
		$rich_users_sorted[] = $rich_users[$rich_users_sort[$i]];
	}

	// Send to template
	foreach($rich_users_sorted as $var)
	{
		$template->assign_block_vars('rich_user', array(
			'USERNAME'			=> get_username_string('full', $var['user_id'], $var['username'], $var['user_colour']),
			'SUM_POINTS'		=> number_format_points($var['total_points']),
			'SUM_POINTS_NAME'	=> $config['points_name'],
		));
	}

	//Generate the points statistics
	$sql_array = array(
		'SELECT'	=> 'SUM(user_points) AS total_points',
		'FROM'		=> array(
			USERS_TABLE => 'u',
		),
		'WHERE'		=> 'user_points > 0',
	);
	$sql = $db->sql_build_query('SELECT', $sql_array);
	$result = $db->sql_query($sql);
	$b_row = $db->sql_fetchrow($result);
	$totalpoints = ( $b_row['total_points'] ) ? $b_row['total_points'] : 0;
	$lottery_time = $user->format_date(($points_values['lottery_last_draw_time'] + $points_values['lottery_draw_period']), false, true);

	// Run Lottery
	if ($points_values['lottery_draw_period'] != 0 && $points_values['lottery_last_draw_time'] + $points_values['lottery_draw_period'] - time() < 0)
	{
		if (!function_exists('run_lottery'))
		{
			include($phpbb_root_path . 'includes/points/functions_points.' . $phpEx);
		}
		if (!function_exists('send_pm'))
		{
			include($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx);
		}
		run_lottery();
	}

	$template->assign_vars(array(
		'TOTAL_BANK_USER'			=> sprintf($user->lang['POINTS_BUPOINTS_TOTAL'], $bankusers, $points_values['bank_name']),
		'TOTAL_BANK_POINTS'			=> sprintf($user->lang['POINTS_BPOINTS_TOTAL'], number_format_points($bankholdings), $config['points_name'], $points_values['bank_name']),
		'TOTAL_POINTS_USER'			=> sprintf($user->lang['POINTS_TOTAL'], number_format_points($totalpoints), $config['points_name']),
		'LOTTERY_TIME'				=> sprintf($user->lang['POINTS_LOTTERY_TIME'], $lottery_time),
		'S_DISPLAY_LOTTERY'			=> ($points_config['display_lottery_stats']) ? true : false,
		'S_DISPLAY_POINTS_STATS'	=> ($points_config['stats_enable']) ? true : false,
		'S_DISPLAY_INDEX'			=> ($points_values['number_show_top_points'] > 0) ? true : false,
	));
}



// Begin Board Clubs
$user->setup('mods/clubs_mod');
$clubs = request_var('clubs', 0);
$bc->make_tabs(0, $clubs);
// End Board Clubs



// Start DM Linkx - Check reported/unapproved
if (isset($config['dm_linkx_version']) && $auth->acl_get('a_dm_linkx_manage'))
{
	if (!function_exists('generate_unapproved') || !function_exists('generate_reported'))
	{
		include($phpbb_root_path . 'dm_linkx/functions_dm_linkx.' . $phpEx);
	}

	// Check for unapproved links
	generate_unapproved();
	// Check for reported links
	generate_reported();
}
// End DM Linkx - Check reported/unapproved

// Assign index specific vars
$template->assign_vars(array(
	'S_TAB_MENU'	=> $club_config['club_tab_menu_index'],
	'TOTAL_POSTS'	=> sprintf($user->lang[$l_total_post_s], number_format($total_posts)),
	'TOTAL_TOPICS'	=> sprintf($user->lang[$l_total_topic_s], number_format($total_topics)),
	'TOTAL_USERS'	=> sprintf($user->lang[$l_total_user_s], number_format($total_users)),
	'NEWEST_USER'	=> sprintf($user->lang['NEWEST_USER'], get_username_string('full', $config['newest_user_id'], $config['newest_username'], $config['newest_user_colour'])),

	'LEGEND'		=> $legend,
	'BIRTHDAY_LIST'	=> $birthday_list,

// MOD : Index Tabbed - Start
		'FORUM_IMG'             => $user->img('forum_read', 'NO_UNREAD_POSTS'),
		'FORUM_NEW_IMG'         => $user->img('forum_unread', 'NEW_POSTS'),
		'FORUM_UNREAD_IMG'          => $user->img('forum_unread', 'UNREAD_POSTS'),
		'FORUM_LOCKED_IMG'      => $user->img('forum_read_locked', 'NO_UNREAD_POSTS_LOCKED'),
		'FORUM_NEW_LOCKED_IMG'  => $user->img('forum_unread_locked', 'NO_NEW_POSTS_LOCKED'),
		'FORUM_UNREAD_LOCKED_IMG'   => $user->img('forum_unread_locked', 'UNREAD_POSTS_LOCKED'),
		'FORUM_LINK_IMG'      => $user->img('forum_link', 'FORUM_LINK'),
		'FORUM_NEW_SUBFORUM_IMG' => $user->img('forum_read_subforum', 'NO_NEW_POSTS'),
		'FORUM_SUBFORUM_IMG'   => $user->img('forum_unread_subforum', 'NEW_POSTS'),

		'S_LOGIN_ACTION'			=> append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'),
		'S_DISPLAY_BIRTHDAY_LIST'	=> ($config['load_birthdays']) ? true : false,

		'S_INDEXTABS'				=> (isset($config['load_indextabs'])) ? $config['load_indextabs'] : false,
		'S_MODETABS'				=> (isset($config['load_modetabs'])) ? $config['load_modetabs'] : false,
// MOD : Index Tabbed - END

	'S_LOGIN_ACTION'			=> append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'),
	'S_DISPLAY_BIRTHDAY_LIST'	=> ($config['load_birthdays']) ? true : false,

    'S_ANNOUNCE_INDEX'  => (!empty($config['announce_index'])) ? true : false,

	'U_MARK_FORUMS'		=> ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}index.$phpEx", 'hash=' . generate_link_hash('global') . '&mark=forums') : '',
	'U_MCP'				=> ($auth->acl_get('m_') || $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=front', true, $user->session_id) : '')
);
// START Global Announcements
				$user->add_lang(array('memberlist', 'viewforum'));

				$sql_from = TOPICS_TABLE . ' t ';
				$sql_select = '';

				if ($config['load_db_track'])
				{
					$sql_from .= ' LEFT JOIN ' . TOPICS_POSTED_TABLE . ' tp ON (tp.topic_id = t.topic_id
						AND tp.user_id = ' . $user->data['user_id'] . ')';
					$sql_select .= ', tp.topic_posted';
				}

				if ($config['load_db_lastread'])
				{
					$sql_from .= ' LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt ON (tt.topic_id = t.topic_id
						AND tt.user_id = ' . $user->data['user_id'] . ')';
					$sql_select .= ', tt.mark_time';
				}

				$topic_type = $user->lang['VIEW_TOPIC_GLOBAL'];
				$folder = 'global_read';
				$folder_new = 'global_unread';

				// Get cleaned up list... return only those forums not having the f_read permission
				$forum_ary = $auth->acl_getf('!f_read', true);
				$forum_ary = array_unique(array_keys($forum_ary));

				// Determine first forum the user is able to read into - for global announcement link
				$sql = 'SELECT forum_id
					FROM ' . FORUMS_TABLE . '
					WHERE forum_type = ' . FORUM_POST;

				if (sizeof($forum_ary))
				{
					$sql .= ' AND ' . $db->sql_in_set('forum_id', $forum_ary, true);
				}
				$result = $db->sql_query_limit($sql, 1);
				$g_forum_id = (int) $db->sql_fetchfield('forum_id');
				$db->sql_freeresult($result);

				$sql = "SELECT t.* $sql_select
					FROM $sql_from
					WHERE t.forum_id = 0
						AND t.topic_type = " . POST_GLOBAL . '
					ORDER BY t.topic_last_post_time DESC';

				$topic_list = $rowset = array();
				// If the user can't see any forums, he can't read any posts because fid of 0 is invalid
				if ($g_forum_id)
				{
					$result = $db->sql_query($sql);

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

				$topic_tracking_info = array();
				if ($config['load_db_lastread'] && $user->data['is_registered'])
				{
					$topic_tracking_info = get_topic_tracking(0, $topic_list, $rowset, false, $topic_list);
				}
				else
				{
					$topic_tracking_info = get_complete_topic_tracking(0, $topic_list, $topic_list);
				}

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

					$forum_id = $row['forum_id'];
					$topic_id = $row['topic_id'];

					$unread_topic = (isset($topic_tracking_info[$topic_id]) && $row['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
                    // Grab icons
                    $icons = $cache->obtain_icons();

					$folder_img = ($unread_topic) ? $folder_new : $folder;
					$folder_alt = ($unread_topic) ? 'UNREAD_POSTS' : (($row['topic_status'] == ITEM_LOCKED) ? 'TOPIC_LOCKED' : 'NO_UNREAD_POSTS');
                    $topic_link = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']);
                    $topic_views = $user->lang($row['topic_views']);
                    $topic_replies = $user->lang($row['topic_replies']);
                    $topic_last_author = get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']);
      
					if ($row['topic_status'] == ITEM_LOCKED)
					{
						$folder_img .= '_locked';
					}

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

					$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']),
						'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']),
						'TOPIC_TITLE'				=> censor_text($row['topic_title']),
						'TOPIC_TYPE'				=> $topic_type,
                        'TOPIC_LINK'                => $topic_link,
	                    'REPLIES'			        => $topic_replies,
	                    'VIEWS'				        => $topic_views,
		                'TOPIC_LAST_AUTHOR'         => $topic_last_author,
						'TOPIC_FOLDER_IMG'		=> $user->img($folder_img, $folder_alt),
						'TOPIC_FOLDER_IMG_SRC'	=> $user->img($folder_img, $folder_alt, false, '', 'src'),
                        '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'] : '',
			
						'S_USER_POSTED'		=> (!empty($row['topic_posted']) && $row['topic_posted']) ? true : false,
						'S_UNREAD'			=> $unread_topic,

						'U_TOPIC_AUTHOR'		=> get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
						'U_LAST_POST'			=> append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$g_forum_id&t=$topic_id&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_NEWEST_POST'			=> append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$g_forum_id&t=$topic_id&view=unread") . '#unread',
						'U_VIEW_TOPIC'			=> append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$g_forum_id&t=$topic_id"))
					);
//-- mod : quick title edition -------------------------------------------------
//-- add
					if ( !empty($row['topic_attr_id']) )
					{
						$template->alter_block_array('topicrow', array(
							'S_TOPIC_ATTR' => true,
							'TOPIC_ATTRIBUTE' => $qte->attr_display($row['topic_attr_id'], $row['topic_attr_user'], $row['topic_attr_time']),
						), true, 'change');
					}
//-- fin mod : quick title edition ---------------------------------------------
				}
				
// END Global Announcements

include($phpbb_root_path . 'includes/functions_activity_stats.' . $phpEx);
activity_mod();

// Start DM Linkx
if (isset($config['dm_linkx_version']))
{
	$user->add_lang('mods/dm_linkx');

	$sql = 'SELECT COUNT(linkx_id) AS number_linkxs
		FROM ' . DM_LINKX_TABLE . '
		WHERE linkx_approval = 1';
	$result = $db->sql_query($sql);
	$row = $db->sql_fetchrow($result);

	$sql2 = 'SELECT *
		FROM ' . DM_LINKX_TABLE . '
		WHERE linkx_approval = 1
		ORDER BY linkx_counter DESC LIMIT 5';
	$result2 = $db->sql_query($sql2);

	while ( $row2 = $db->sql_fetchrow($result2) )
	{	
		$template->assign_block_vars('linkxline', array(
			'LINKX_COUNTER' => sprintf($user->lang['DM_LINKX_LINKX_COUNTER'], $row2['linkx_counter']),
			'TITEL'			=> '<a href="' . $row2['linkx_link'] . '" onclick="window.open(this.href); return false" title="{' . $row2['linkx_title'] . '}"><strong>' . $row2['linkx_title'] . '</strong></a>',
		));  
	}
	$db->sql_freeresult($result);

	$template->assign_vars(array(
		'S_LINKX_EXIST'	=> true,
		'NUMBER_LINKXS'	=> sprintf($user->lang['DM_LINKX_TOTAL_LINKXS'], $row['number_linkxs']),
	));
}
// End DM Linkx
// Output page
page_header($user->lang['INDEX']);

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

page_footer();

?>
Pro-choice, Atheist, Pro-LGBT rights
Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid. - Albert Einstein

ABDev
Registered User
Posts: 905
Joined: Sun Aug 21, 2005 9:29 pm
Location: France
Name: Adrien Bonnel

Re: [RC] Quick Title Edition 1.2.0

Post by ABDev »

Could you remove that line of your index.php file, please ?

Code: Select all

//-- mod : quick title edition -------------------------------------------------
//-- add
include $phpbb_root_path . 'includes/functions_attributes.' . $phpEx;
//-- fin mod : quick title edition --------------------------------------------- 

User avatar
Jessica
Former Team Member
Posts: 4342
Joined: Sun Jul 18, 2010 2:53 pm
Location: Pennsylvania, USA
Name: Jessica
Contact:

Re: [RC] Quick Title Edition 1.2.0

Post by Jessica »

thanks, that fixed it
Pro-choice, Atheist, Pro-LGBT rights
Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid. - Albert Einstein

User avatar
tbackoff
Former Team Member
Posts: 7022
Joined: Thu Jun 04, 2009 1:41 am
Location: cheerleading practice
Name: Tabitha Backoff

Re: [RC] Quick Title Edition 1.2.0

Post by tbackoff »

Hi ABDev,

I haven't got around to testing it yet, but was this feature request addressed? If not, that's fine. Thanks for the hard work.
Flying is the second best thrill to cheerleaders; being caught is the first.

ABDev
Registered User
Posts: 905
Joined: Sun Aug 21, 2005 9:29 pm
Location: France
Name: Adrien Bonnel

Re: [RC] Quick Title Edition 1.2.0

Post by ABDev »

Hi t_backoff,
I had forgotten your request, sorry :oops:.
For the moment, it has not been implemented. But I have noted it and I will integrate in the next minor version ;).

PS : I'm currently working on the RC2 of "Moderator Messages".

User avatar
Ephemeraboy
Registered User
Posts: 331
Joined: Tue Dec 29, 2009 4:25 pm
Location: Bandung Kota Hujan
Name: Bernando Bona Tius Sianipar
Contact:

Re: [RC] Quick Title Edition 1.2.0

Post by Ephemeraboy »

yey
new version
thanks AbDev
it was so quick from 1.1 to 1.2
My diary, my notepad, and my life on
http://www.bonatius.com
My online shop at
http://www.nefara.com

ABDev
Registered User
Posts: 905
Joined: Sun Aug 21, 2005 9:29 pm
Location: France
Name: Adrien Bonnel

Re: [RC] Quick Title Edition 1.2.0

Post by ABDev »

It's because we are going to offer soon a new big feature for this MOD ;).
So, we had to make a new release quickly.

Locked

Return to “[3.0.x] MODs in Development”