https://www.icyphoenix.com/viewtopic.php?f=35&t=2195
-----------------------------------
borbo
Sat 02 Jun, 2007 22:57

Exclude Forums From Recent Topics Block
-----------------------------------
Hello there....once again,,,,

Can anyboty help me mod imp_recent_topics_wide.php to exclude some forums from beeing shown on recet topics block wide in portal?

Thanks in advance!


-----------------------------------
borbo
Sun 03 Jun, 2007 04:44

Re: Exclude Forums From Recent Topics Block
-----------------------------------
After i've spent about an hour i found  how to do it and i posting the code i used if you want to check it or make a mod for this request...


file:[b]blocks_imp_recent_topics_wide.php[/b]
[code]<?php

if ( !defined('IN_PHPBB') )
{
	die("Hacking attempt");
}

if(!function_exists(imp_recent_topics_wide_block_func))
{
	function imp_recent_topics_wide_block_func()
	{
		global $template, $portal_config, $block_id, $userdata, $board_config, $db, $phpEx,$var_cache, $lang, $bbcode;
		global $html_on, $bbcode_on, $smilies_on;

		$template->_tpldata['recent_topic_row.'] = array();
		//reset($template->_tpldata['recent_topic_row.']);

		$bbcode->allow_html = $html_on;
		$bbcode->allow_bbcode = $bbcode_on;
		$bbcode->allow_smilies = $smilies_on;  
		
		$forum_data = array();
		if($portal_config['cache_enabled'])
		{
			$forum_data = $var_cache->get('forum', 90000, 'forum');
		}
		if(!$forum_data)
		{
		
			$sql = "SELECT * FROM ". FORUMS_TABLE . " ORDER BY forum_id";
		if (!$result1 = $db->sql_query($sql))
		{
			message_die(GENERAL_ERROR, 'Could not query forums information', '', __LINE__, __FILE__, $sql);
		}
		$forum_data = array();
		while( $row1 = $db->sql_fetchrow($result1) )
		{
			$forum_data[] = $row1;
		}
		if($portal_config['cache_enabled'])
			{
				$var_cache->save($forum_data, 'forum', 'forum');
			}
		}
		$is_auth_ary = array();
		$is_auth_ary = auth(AUTH_ALL, AUTH_LIST_ALL, $userdata, $forum_data);

		if( $portal_config['md_except_forum_id'] == '' )
		{
			$except_forum_id = ''start'';
		}
		else
		{
			$except_forum_id = $portal_config['md_except_forum_id'][$block_id];
		}

		for ($i = 0; $i < count($forum_data); $i++)
		{
			//if ((!$is_auth_ary[$forum_data[$i]['forum_id']]['auth_read']) || (!$is_auth_ary[$forum_data[$i]['forum_id']]['auth_view']))
			if ( !$is_auth_ary[$forum_data[$i]['forum_id']]['auth_read'] )
			{
				if ($except_forum_id == ''start'')
				{
					$except_forum_id = $forum_data[$i]['forum_id'];
				}
				else
				{
					$except_forum_id .= ',' . $forum_data[$i]['forum_id'];
				}
			}
		}

		$extra = '';

		if ($portal_config['md_show_not_forums']){
			$sql = "SELECT t.topic_id, t.topic_title, t.topic_last_post_id, t.forum_id, p.post_id, p.poster_id, p.post_time, u.user_id, u.username, f.forum_name
				FROM " . TOPICS_TABLE . " AS t, " . POSTS_TABLE . " AS p, " . USERS_TABLE . " AS u, " . FORUMS_TABLE . " AS f
				WHERE t.forum_id NOT IN (" . $except_forum_id . ")
					AND t.topic_status <> 2
					AND p.post_id = t.topic_last_post_id
					AND p.poster_id = u.user_id
					AND f.forum_id = t.forum_id
					$extra
				ORDER BY p.post_id DESC
				LIMIT " . $portal_config['md_num_recent_topics_wide'][$block_id];
		}else{
			$sql = "SELECT t.topic_id, t.topic_title, t.topic_last_post_id, t.forum_id, p.post_id, p.poster_id, p.post_time, u.user_id, u.username
				FROM " . TOPICS_TABLE . " AS t, " . POSTS_TABLE . " AS p, " . USERS_TABLE . " AS u
				WHERE t.forum_id IN (" . $except_forum_id . ")
					AND t.topic_status <> 2
					AND p.post_id = t.topic_last_post_id
					AND p.poster_id = u.user_id
					AND f.forum_id = t.forum_id
					$extra
				ORDER BY p.post_id DESC
				LIMIT " . $portal_config['md_num_recent_topics_wide'][$block_id];
		}

		if (!$result1 = $db->sql_query($sql))
		{
			message_die(GENERAL_ERROR, 'Could not query recent topics information', '', __LINE__, __FILE__, $sql);
		}
		$number_recent_topics = $db->sql_numrows($result1);
		$recent_topic_row = array();
		while ($row1 = $db->sql_fetchrow($result1))
		{
			$recent_topic_row[] = $row1;
		}

		if($portal_config['md_recent_topics_wide_style'][$block_id] == 1 )
		{
			$style_row = 'scroll';
		}else
		{
			$style_row = 'static';
		}

		$template->assign_block_vars($style_row,"");

		for ($i = 0; $i < $number_recent_topics; $i++)
		{
			$orig_word = array();
			$replacement_word = array();
			obtain_word_list($orig_word, $replacement_word);

			if ( !empty($orig_word) )
			{
				$recent_topic_row[$i]['topic_title'] = ( !empty($recent_topic_row[$i]['topic_title']) ) ? preg_replace($orig_word, $replacement_word, $recent_topic_row[$i]['topic_title']) : '';
			}
			$recent_topic_row[$i]['username'] = color_group_colorize_name($recent_topic_row[$i]['user_id']);

			$template->assign_block_vars($style_row . '.recent_topic_row', array(
				'U_FORUM' => append_sid(VIEWFORUM_MG . '?' . POST_FORUM_URL . '=' . $recent_topic_row[$i]['forum_id']),
				'L_FORUM' => $recent_topic_row[$i]['forum_name'],
				'U_TITLE' => append_sid(VIEWTOPIC_MG . '?' . POST_POST_URL . '=' . $recent_topic_row[$i]['post_id']) . '#p' .$recent_topic_row[$i]['post_id'],
				'L_TITLE' => $bbcode->parse($recent_topic_row[$i]['topic_title'], $bbcode_uid, true),
				'L_BY' => $lang['By'],
				'L_ON' => $lang['On'],
				'S_POSTER' => $recent_topic_row[$i]['username'],
				'S_POSTTIME' => create_date2($board_config['default_dateformat'], $recent_topic_row[$i]['post_time'], $board_config['board_timezone'])
				)
			);
		}
		$template->assign_vars(array(
			'BY' => $lang['by'],
			'ON' => $lang['on']
			));
	}
}

imp_recent_topics_wide_block_func();
?>[/code]


file:[b]blocks_imp_recent_topics_wide.cfg[/b]
[code]<?php

if ( !defined('IN_PHPBB') )
{
	die("Hacking attempt");
}

$block_count_variables = 4;

// array( <Field label>, <Field Info>, <Config Name>, <Options>, <Field Values>, <Control Type>, <Block>, <Default Value>);

$block_variables = array(
	array('Number of recent topics', 'number of topics displayed', 'md_num_recent_topics_wide', '', '', '1', 'recent_topics_wide', '10'),
	array('Recent Topics Style', 'choose static display or scrolling display', 'md_recent_topics_wide_style', 'Static,Scroll', '0,1', '3', 'recent_topics_wide', '1'),
	array('Recent Topic Forums', 'comma delimited', 'md_except_forum_id', '', '', '1', 'recent_topics', '1'),
	array('Show not', 'tick, if listed forums is not to be shown', 'md_show_not_forums', '', '', '4', 'recent_topics', '0')
	);
?>[/code]


I'll feel very happy and helpful if you find it usefull and add it to the customizatios....he he

Regards


