How come when I try this one I get sql errors????? I read somewhere where someone said if you copy and paste you wind up with hidden code or something... so I manually input it, and STILL got sql errors..riesgo wrote:Hello,
I think this mod is neat. I modified it a bit to include more information in the marquee. Namely, to include the Category->Forum Name->Topic instead of just the Topic. It helps the user determine where it came from.
Just wanted to share in case anyone was interested. This is my first post, so hope it's okay.
Changes to index.php
Changed sql to query Category table and return the cat_title from the cat table and the forum_name fromm the forums table.
$sql = "SELECT t.topic_id, t.topic_title, t.topic_last_post_id, t.forum_
id, t.topic_type, t.topic_status, p.post_id, p.poster_id,
p.post_time, u.user_id, u.username, u.user_lastvisit,
c.cat_title,f.forum_name
FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f, " . POSTS_T
ABLE . " p, " . USERS_TABLE . " u, " . CATEGORIES_TABLE . " c
WHERE t.forum_id IN " . $auth_view_forum_sql . " AND t.topic_id = p.topic_id
AND f.forum_id = t.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.cat_id = c.cat_id
ORDER BY t.topic_last_post_id DESC";
Changed the marqueerow variable to include the cat_title and forum_name.$template->assign_block_vars('marqueerow', array(
'FOLD_URL' => $pic,
'TOPIC_TITLE' => $row[$i]["topic_title"],
'FORUM_NAME' => $row[$i]["forum_name"],
'FORUM_CAT' => $row[$i]["cat_title"],
Modified templates/subSilver/index_body.tpl
Also changed the sizes of the Category and Forum name displayed to be different so the users eyes focus on the topic first and the rest if they care about it.<td class="row2" width="352">
<span class="forumlink"><a href="{marqueerow.TOPIC_URL}" onMouseOver="do
cument.all.recent_topics.stop()" onMouseOut="document.all.recent_topics.start()"
><span class="gensmall">{marqueerow.FORUM_CAT}</span>-><span class="genmed">{marqueerow.FORUM_NAME}</span>->{marqueerow.TOPIC_TITLE}</a></span>
thanks,
--Eli
Code: Select all
<table width="100%" cellspacing="0" cellpadding="2" border="0" align="center">
<tr>
<!-- BEGIN switch_user_logged_in -->
<td><span class="gen">
{L_WELCOME_REG} {U_WELCOME_REG}<br />
</td>
<!-- END switch_user_logged_in -->
<!-- BEGIN switch_user_logged_out -->
<td><span class="gen">
{L_WELCOME_GUEST} {U_WELCOME_GUEST}<br />
</td>
<!-- END switch_user_logged_out -->
</tr>
<tr>
<td align="left" valign="bottom"><span class="gensmall">
<!-- BEGIN switch_user_logged_in -->
{LAST_VISIT_DATE}<br />
<!-- END switch_user_logged_in -->
{CURRENT_TIME}<br /></span><span class="nav"><a href="{U_INDEX}" class="nav">{L_INDEX}</a></span></td>
<td align="right" valign="bottom" class="gensmall">
<!-- BEGIN switch_user_logged_in -->
<a href="{U_SEARCH_NEW}" class="gensmall">{L_SEARCH_NEW}</a><br /><a href="{U_SEARCH_SELF}" class="gensmall">{L_SEARCH_SELF}</a><br />
<!-- END switch_user_logged_in -->
<!-- MOD: View Recent Posts v1.0.3 -->
<a href="{U_SEARCH_UNANSWERED}" class="gensmall">{L_SEARCH_UNANSWERED}</a><br />
<span class="gensmall"><form action="{S_SEARCH_ACTION}" method="POST">{L_SEARCH_TIME} <select class="gensmall" name="search_time">{S_TIME_OPTIONS}</select> <input type="submit" class="gensmall" value="{L_GO}" name="submit" /><input type="hidden" name="show_results" value="topics"><input type="hidden" name="sort_by" value="0"><input type="hidden" name="sort_dir" value="DESC"></form>
</td>
<!-- MOD: -END- -->
<table width="100%" cellpadding="3" cellspacing="1" border="0" class="forumline" height="100%">
<tr>
<td class="catHead" height="28"><a name="login"></a><span class="cattitle">{MARQUEE_TOPIC}</span></td>
</tr>
<tr>
<td class="row1" valign="top"><span class="gen">
<marquee id="recent_topics" behavior="scroll" direction="up" height="100" scrolldelay="100" scrollamount="1">
<table cellpadding="4" cellSpacing="1" width="100%">
<!-- BEGIN marqueerow -->
<tr valign="top">
<td class="row2" vAlign="center" align="middle" width="20">
<img src="{marqueerow.FOLD_URL}">
</td>
<td class="row2" width="352">
<span class="forumlink"><a href="{marqueerow.TOPIC_URL}" onMouseOver="document.all.recent_topics.stop()" onMouseOut="document.all.recent_topics.start()">{marqueerow.TOPIC_TITLE}</a></span>
<span class="gensmall"><br /></span>
</td>
<td class="row2" width="1%" nowrap>
<span class="gensmall"><a href="{marqueerow.POST_URL}" onMouseOver="document.all.recent_topics.stop()" onMouseOut="document.all.recent_topics.start()"><img src="templates/subSilver/images/icon_latest_reply.gif" border="0" title="Jump to the latest posted reply in this topic thread. Membership has privileges. Register to post messages." /></a></span>
</td>
<td class="row2" vAlign="center" align="middle" width="78">
<span class="gensmall"><a href="{marqueerow.USER_PROF}" onMouseOver="document.all.recent_topics.stop()" onMouseOut="document.all.recent_topics.start()">{marqueerow.USERNAME}</a></span>
</td>
<td class="row2" vAlign="center" noWrap align="middle" width="100">
<span class="gensmall">{marqueerow.POST_DATE}</span>
</td>
</tr>
<!-- END marqueerow -->
</table>
</marquee>
</td>
</tr>
</table>
{QUOTE}
</tr>
</table>
<table width="100%" border="0" cellpadding="2" cellspacing="1" class="forumline">
<tr>
<th height="28" width="100%" align="center">{NEWS_TITLE}</th>
</tr>
<tr>
<td height="28" align="center" class="row1"><{NEWS_STYLE} behavior="{SCROLL_BEHAVIOR}" direction="{SCROLL_ACTION}" width="{SCROLL_SIZE}" scrollamount="{SCROLL_SPEED}" ><font size="{NEWS_SIZE}" color="{NEWS_COLOR}"><{NEWS_BOLD}><{NEWS_ITAL}><{NEWS_UNDER}>{NEWS_BLOCK}</{NEWS_STYLE}></{NEWS_BOLD}></{NEWS_ITAL}></{NEWS_UNDER}></font></td>
</tr>
</table>
<table width="100%" cellpadding="2" cellspacing="1" border="0" class="forumline">
<tr>
<th colspan="2" class="thCornerL" height="25" nowrap="nowrap"> {L_FORUM} </th>
<th width="50" class="thTop" nowrap="nowrap"> {L_TOPICS} </th>
<th width="50" class="thTop" nowrap="nowrap"> {L_POSTS} </th>
<th class="thCornerR" nowrap="nowrap"> {L_LASTPOST} </th>
</tr>
<!-- BEGIN catrow -->
<tr>
<td class="catLeft" colspan="2" height="28"><span class="cattitle"><a href="{catrow.U_VIEWCAT}" class="cattitle">{catrow.CAT_DESC}</a></span></td>
<td class="rowpic" colspan="3" align="right"> </td>
</tr>
<!-- BEGIN forumrow -->
<tr>
<td class="row1" align="center" valign="middle" height="50"><img src="{catrow.forumrow.FORUM_FOLDER_IMG}" width="46" height="25" alt="{catrow.forumrow.L_FORUM_FOLDER_ALT}" title="{catrow.forumrow.L_FORUM_FOLDER_ALT}" /></td>
<td class="row1" width="100%" onMouseOver="this.style.backgroundColor='#C0D9D9'; this.style.cursor='default';" onMouseOut="this.style.backgroundColor='#EFEFEF';"><span {catrow.forumrow.FORUM_COLOR} class="forumlink"> <a href="{catrow.forumrow.U_VIEWFORUM}" {catrow.forumrow.FORUM_COLOR} class="forumlink">{catrow.forumrow.FORUM_NAME}</a><br />
</span> <span class="genmed">{catrow.forumrow.FORUM_DESC}<br />
</span><span class="gensmall">{catrow.forumrow.L_MODERATOR} {catrow.forumrow.MODERATORS}</span></td>
<td class="row2" align="center" valign="middle" height="50"><span class="gensmall">{catrow.forumrow.TOPICS}</span></td>
<td class="row2" align="center" valign="middle" height="50"><span class="gensmall">{catrow.forumrow.POSTS}</span></td>
<td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"> <span class="gensmall">{catrow.forumrow.LAST_POST}</span></td>
</tr>
<!-- END forumrow -->
<!-- END catrow -->
</table>
<table width="100%" cellspacing="0" border="0" align="center" cellpadding="2">
<tr>
<td align="left">
<!-- BEGIN switch_user_logged_in -->
<span class="gensmall"><a href="{U_MARK_READ}" class="gensmall">{L_MARK_FORUMS_READ}</a></span>
<!-- END switch_user_logged_in -->
</td>
<td align="right"><span class="gensmall">{S_TIMEZONE}</span></td>
</tr>
</table>
<table width="100%" cellpadding="3" cellspacing="1" border="0" class="forumline">
<tr>
<td class="catHead" colspan="2" height="28"><span class="cattitle"><a href="{U_VIEWONLINE}" class="cattitle">{L_WHO_IS_ONLINE}</a></span></td>
</tr>
<tr>
<td class="row1" align="center" valign="middle" rowspan="3"><img src="templates/subSilver/images/whosonline.gif" alt="{L_WHO_IS_ONLINE}" /></td>
<td class="row1" align="left" width="100%"><span class="gensmall">{TOTAL_POSTS}<br />{TOTAL_USERS}<br />{NEWEST_USER}</span>
</td>
</tr>
<!-- Start add - Last visit MOD -->
<tr>
<td class="row1" align="left"><span class="gensmall">{L_USERS_TODAY} {L_USERS_LASTHOUR}<br />{USERS_TODAY_LIST}</br></span></td>
</tr>
<!-- Start add - Last visit MOD -->
<tr>
<td class="row1" align="left"><span class="gensmall">{TOTAL_USERS_ONLINE} [ {L_WHOSONLINE_ADMIN} ] [ {L_WHOSONLINE_MOD} ]<br />{RECORD_USERS}<br />{LOGGED_IN_USER_LIST}</span></td>
</tr>
</table>
<table width="100%" cellpadding="1" cellspacing="1" border="0">
<tr>
<td align="left" valign="top"><span class="gensmall">{L_ONLINE_EXPLAIN}</span></td>
</tr>
</table>
<!-- BEGIN switch_user_logged_out -->
<form method="post" action="{S_LOGIN_ACTION}">
<table width="100%" cellpadding="3" cellspacing="1" border="0" class="forumline">
<tr>
<td class="catHead" height="28"><a name="login"></a><span class="cattitle">{L_LOGIN_LOGOUT}</span></td>
</tr>
<tr>
<td class="row1" align="center" valign="middle" height="28"><span class="gensmall">{L_USERNAME}:
<input class="post" type="text" name="username" size="10" />
{L_PASSWORD}:
<input class="post" type="password" name="password" size="10" maxlength="32" />
<!-- BEGIN switch_allow_autologin -->
{L_AUTO_LOGIN}
<input class="text" type="checkbox" name="autologin" />
<!-- END switch_allow_autologin -->
<input type="submit" class="mainoption" name="login" value="{L_LOGIN}" />
</span> </td>
</tr>
</table>
</form>
<!-- END switch_user_logged_out -->
<br clear="all" />
<table cellspacing="3" border="0" align="center" cellpadding="0">
<tr>
<td width="20" align="center"><img src="templates/subSilver/images/folder_new_big.gif" alt="{L_NEW_POSTS}"/></td>
<td><span class="gensmall">{L_NEW_POSTS}</span></td>
<td> </td>
<td width="20" align="center"><img src="templates/subSilver/images/folder_big.gif" alt="{L_NO_NEW_POSTS}" /></td>
<td><span class="gensmall">{L_NO_NEW_POSTS}</span></td>
<td> </td>
<td width="20" align="center"><img src="templates/subSilver/images/folder_locked_big.gif" alt="{L_FORUM_LOCKED}" /></td>
<td><span class="gensmall">{L_FORUM_LOCKED}</span></td>
</tr>
</table>
Code: Select all
##############################################################
## MOD Title: Latest active topics on index
## MOD Author: zparta < [email protected] > (Jens Holmqvist) http://www.hispan.se
## MOD Description: Show the latest active topics on index and the amout of topics to show is ACP changeable
## MOD Version: 1.1.9
##
## Installation Level: Easy
## Installation Time: ~1 Minutes
## Files To Edit: index.php, templates/subSilver/index_body.tpl, language/lang_english/lang_main.php, language/lang_english/lang_admin.php, admin/admin_board.php, templates/subSilver/admin/board_config_body.tpl
## Included Files: n/a
##############################################################
## For Security Purposes, Please Check: http://www.phpbb.com/mods/ for the
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code
## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered
## in our MOD-Database, located at: http://www.phpbb.com/mods/
##############################################################
## Author Notes: this works with the global announcement mod has
## different picture for different kind of topic
## and only shows topics the user is allowed to view
## Thanks to: LifeIsPain for helping me with the auth part!!
##
##############################################################
## MOD History:
##
## 2005-05-31 - Version 1.1.9
## - Fixed yet another validation error that me personaly think was uneseceray like put { and } on seperate lines :P
## - They could just have sent me a PM about this and released it anyways since it didn't interfere with the funtionality but what to do, what to do.
## 2005-05-28 - Version 1.1.8
## - Fixed a bug where the new auth array stuff wouldnt be put to the right place
## 2005-03-24 - Version 1.1.7
## - Fixed two validation errors
## 2005-03-05 - Version 1.1.6
## - Fixed a validation error
## 2005-03-01 - Version 1.1.5
## - Fixed a small bug that made topics in forums that they where only allowed to know that it existed where displayed
## - I have also tested it on a fresh install on phpBB 2.0.13 and it works like a charm
## 2004-02-17 - Version 1.1.4
## - Fixed validation problem
## 2003-12-25 - Version 1.1.3
## - Fixed categories hierarchy compability problem
## 2003-11-01 - Version 1.1.2
## - Fixed validation problem
## 2003-10-27 - Version 1.1.1
## - Fixed user profile bug
## 2003-10-20 - Version 1.1.0
## - Added amount of topics shown to be changeable by admin
## 2003-10-20 - Version 1.0.9
## - Changed the if statment to fit the coding standards
## 2003-10-15 - Version 1.0.8
## - Changed to last post in the topic instead of the first when cliking the link
## 2003-10-11 - Version 1.0.7
## - Fixed hardcoded language bug
## 2003-10-11 - Version 1.0.6
## - Fixed a minor bug with locked topics
## 2003-10-11 - Version 1.0.5
## - Fixed linkage and some mod-db compliant stuff
## 2003-08-24 - Version 1.0.4
## - Fixed the linkage
## 2003-08-23 - Version 1.0.3
## - Fixed the 10 windows issue (template problem)
## 2003-08-07 - Version 1.0.2
## - Fixed the parse error
## 2003-08-07 - Version 1.0.1
## - Fixed the bug that it didn't show the first post
## 2003-08-07 - Version 1.0.0
## - Initial release should work just fine
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################
#
#-----[ SQL ]------------------------------------------
#
INSERT INTO phpbb_config ( config_name, config_value ) VALUES ('topics_on_index', '10');
#
#-----[ OPEN ]------------------------------------------
#
language/lang_english/lang_main.php
#
#-----[ FIND ]------------------------------------------
#
?>
#
#-----[ BEFORE, ADD ]------------------------------------------
#
$lang['marquee_topic'] = 'Last %s Active Topics';
#
#-----[ OPEN ]------------------------------------------
#
language/lang_english/lang_admin.php
#
#-----[ FIND ]------------------------------------------
#
$lang['Enable_prune'] = 'Enable Forum Pruning';
#
#-----[ AFTER, ADD ]------------------------------------------
#
$lang['Topics_on_index'] = 'How many topics to show in recent active topics';
#
#-----[ OPEN ]------------------------------------------
#
admin/admin_board.php
#
#-----[ FIND ]------------------------------------------
#
"L_ENABLE_PRUNE" => $lang['Enable_prune'],
#
#-----[ AFTER, ADD ]------------------------------------------
#
"L_TOPICS_ON_INDEX" => $lang['Topics_on_index'],
#
#-----[ FIND ]------------------------------------------
#
"PRUNE_NO" => $prune_no,
#
#-----[ AFTER, ADD ]------------------------------------------
#
"TOPICS_ON_INDEX" => $new['topics_on_index'],
#
#-----[ OPEN ]------------------------------------------
#
index.php
#
#-----[ FIND ]------------------------------------------
#
//
// Start output of page
//
#
#-----[ BEFORE, ADD ]------------------------------------------
#
//
// Obtain new post information for marquee
// of new posts
//
//
// Get Viewable Forums
//
// function to merge two auth arrays to one
function array_merge_replace($array, $newValues)
{
foreach ($newValues as $key => $value)
{
if ( is_array($value) )
{
if ( !isset($array[$key]) )
{
$array[$key] = array();
}
$array[$key] = array_merge_replace($array[$key], $value);
}
else
{
if ( isset($array[$key]) && is_array($array[$key]) )
{
$array[$key][0] = $value;
}
else
{
if ( isset($array) && !is_array($array) )
{
$temp = $array;
$array = array();
$array[0] = $temp;
}
$array[$key] = $value;
}
}
}
return $array;
}
$ary = array();
$ary2 = array();
$ary = auth(AUTH_VIEW, AUTH_LIST_ALL, $userdata, $forum_data);
$ary2 = auth(AUTH_READ, AUTH_LIST_ALL, $userdata, $forum_data);
$is_auth_ary = array_merge_replace($ary, $ary2);
$auth_view_forum_sql = '';
for($i = 0; $i < $total_categories; $i++)
{
$cat_id = $category_rows[$i]['cat_id'];
$display_forums = false;
for($j = 0; $j < $total_forums; $j++)
{
if ( $is_auth_ary[$forum_data[$j]['forum_id']]['auth_view'] && $is_auth_ary[$forum_data[$j]['forum_id']]['auth_read'] && $forum_data[$j]['cat_id'] == $cat_id )
{
$display_forums = true;
$auth_view_forum_sql .= ($auth_view_forum_sql == '' ? '' : ', ' ) . $forum_data[$j]['forum_id'];
}
}
}
$auth_view_forum_sql = ($auth_view_forum_sql == '' ? '(0)' : '(' . $auth_view_forum_sql . ')');
//
// Get The Data
//
$template->assign_vars(array(
'MARQUEE_TOPIC' => str_replace("%s",$board_config['topics_on_index'],$lang['marquee_topic']) )
);
$sql = "SELECT t.topic_id, t.topic_title, t.topic_last_post_id, t.forum_id, t.topic_type, t.topic_status, p.post_id, p.poster_id,
p.post_time, u.user_id, u.username, u.user_lastvisit
FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f, " . POSTS_TABLE . " p, " . USERS_TABLE . " u
WHERE t.forum_id IN " . $auth_view_forum_sql . " AND t.topic_id = p.topic_id
AND f.forum_id = t.forum_id
AND t.topic_status <> 2
AND p.post_id = t.topic_last_post_id
AND p.poster_id = u.user_id
ORDER BY t.topic_last_post_id DESC";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not query recent posts marquee information', '', __LINE__, __FILE__, $sql);
}
if ($row = $db->sql_fetchrowset($result))
{
$db->sql_freeresult($result);
}
if( count($row) <= $board_config['topics_on_index'] )
{
$topics = count($row);
}
else
{
$topics = $board_config['topics_on_index'];
}
for($i = 0; $i < $topics; $i++)
{
$mar_title = $row[$i]["topic_title"];
$mar_url = $phpbb_root_path . 'viewtopic.'.$phpEx.'?'.POST_TOPIC_URL.'='.$row[$i]["topic_id"];
$mar_user = $row[$i]["username"];
if ( $row[$i]["topic_status"] == TOPIC_LOCKED )
{
if ( $row[$i]["post_time"] > $row[$i]["user_lastvisit"] )
{
$pic = $images['folder_locked_new'];
}
else
{
$pic = $images['folder_locked'];
}
}
else
{
if ( $row[$i]["topic_type"] == POST_GLOBAL_ANNOUNCE )
{
if ( $row[$i]["post_time"] > $row[$i]["user_lastvisit"] )
{
$pic = $images['folder_global_announce_new'];
}
else
{
$pic = $images['folder_global_announce'];
}
}
else if ( $row[$i]["topic_type"] == POST_ANNOUNCE )
{
if ( $row[$i]["post_time"] > $row[$i]["user_lastvisit"] )
{
$pic = $images['folder_announce_new'];
}
else
{
$pic = $images['folder_announce'];
}
}
else if ( $row[$i]["topic_type"] == POST_STICKY )
{
if ( $row[$i]["post_time"] > $row[$i]["user_lastvisit"] )
{
$pic = $images['folder_sticky_new'];
}
else
{
$pic = $images['folder_sticky'];
}
}
else { if ( $row[$i]["post_time"] > $userdata['user_lastvisit'] )
{
$pic = $images['folder_new']; }else{ $pic = $images['folder'];
}
}
}
$template->assign_block_vars('marqueerow', array(
'FOLD_URL' => $pic,
'TOPIC_TITLE' => $row[$i]["topic_title"],
'TOPIC_URL' => append_sid($phpbb_root_path . 'viewtopic.'.$phpEx.'?'.POST_TOPIC_URL.'='.$row[$i]["topic_id"]),
'USERNAME' => $row[$i]["username"],
'USER_PROF' => append_sid($phpbb_root_path . 'profile.'.$phpEx.'?mode=viewprofile$amp;u='.$row[$i]["user_id"]),
'POST_DATE' => create_date($board_config['default_dateformat'], $row[$i]["post_time"], $board_config['board_timezone']))
);
}
#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/index_body.tpl
#
#-----[ FIND ]------------------------------------------
#
<!-- END switch_user_logged_out -->
#
#-----[ AFTER, ADD ]------------------------------------------
#
<table width="100%" cellpadding="3" cellspacing="1" border="0" class="forumline" height="100%">
<tr>
<td class="catHead" height="28"><a name="login"></a><span class="cattitle">{MARQUEE_TOPIC}</span></td>
</tr>
<tr>
<td class="row1" valign="top"><span class="gen">
<marquee id="recent_topics" behavior="scroll" direction="up" height="100" scrolldelay="100" scrollamount="2">
<table cellpadding="4" cellSpacing="1" width="100%">
<!-- BEGIN marqueerow -->
<tr valign="top">
<td class="row2" vAlign="center" align="middle" width="20">
<img src="{marqueerow.FOLD_URL}">
</td>
<td class="row2" width="352">
<span class="forumlink"><a href="{marqueerow.TOPIC_URL}" onMouseOver="document.all.recent_topics.stop()" onMouseOut="document.all.recent_topics.start()">{marqueerow.TOPIC_TITLE}</a></span>
<span class="gensmall"><br /></span>
</td>
<td class="row2" vAlign="center" align="middle" width="78">
<span class="gensmall"><a href="{marqueerow.USER_PROF}" onMouseOver="document.all.recent_topics.stop()" onMouseOut="document.all.recent_topics.start()">{marqueerow.USERNAME}</a></span>
</td>
<td class="row2" vAlign="center" noWrap align="middle" width="100">
<span class="gensmall">{marqueerow.POST_DATE}</span>
</td>
</tr>
<!-- END marqueerow -->
</table>
</marquee>
</td>
</tr>
</table>
#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/admin/board_config_body.tpl
#
#-----[ FIND ]------------------------------------------
#
<td class="row2"><input type="radio" name="prune_enable" value="1" {PRUNE_YES} /> {L_YES} <input type="radio" name="prune_enable" value="0" {PRUNE_NO} /> {L_NO}</td>
</tr>
#
#-----[ AFTER, ADD ]------------------------------------------
#
<tr>
<td class="row1">{L_TOPICS_ON_INDEX}</td>
<td class="row2"><input class="post" type="text" name="topics_on_index" size="3" maxlength="2" value="{TOPICS_ON_INDEX}" /></td>
</tr>
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM
Code: Select all
<?php
/**
*
* @package phpBB3
* @version $Id: functions_display.php,v 1.167 2007/10/05 14:30:10 acydburn Exp $
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Display Forums
*/
function display_forums($root_data = '', $display_moderators = true, $return_moderators = false)
{
global $db, $auth, $user, $template;
global $phpbb_root_path, $phpEx, $config;
$forum_rows = $subforums = $forum_ids = $forum_ids_moderator = $forum_moderators = $active_forum_ary = array();
$parent_id = $visible_forums = 0;
$sql_from = '';
// Mark forums read?
$mark_read = request_var('mark', '');
if ($mark_read == 'all')
{
$mark_read = '';
}
if (!$root_data)
{
if ($mark_read == 'forums')
{
$mark_read = 'all';
}
$root_data = array('forum_id' => 0);
$sql_where = '';
}
else
{
$sql_where = 'left_id > ' . $root_data['left_id'] . ' AND left_id < ' . $root_data['right_id'];
}
// Display list of active topics for this category?
$show_active = (isset($root_data['forum_flags']) && ($root_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS)) ? true : false;
$sql_array = array(
'SELECT' => 'f.*',
'FROM' => array(
FORUMS_TABLE => 'f'
),
'LEFT_JOIN' => array(),
);
if ($config['load_db_lastread'] && $user->data['is_registered'])
{
$sql_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_TRACK_TABLE => 'ft'), 'ON' => 'ft.user_id = ' . $user->data['user_id'] . ' AND ft.forum_id = f.forum_id');
$sql_array['SELECT'] .= ', ft.mark_time';
}
else if ($config['load_anon_lastread'] || $user->data['is_registered'])
{
$tracking_topics = (isset($_COOKIE[$config['cookie_name'] . '_track'])) ? ((STRIP) ? stripslashes($_COOKIE[$config['cookie_name'] . '_track']) : $_COOKIE[$config['cookie_name'] . '_track']) : '';
$tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array();
if (!$user->data['is_registered'])
{
$user->data['user_lastmark'] = (isset($tracking_topics['l'])) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0;
}
}
if ($show_active)
{
$sql_array['LEFT_JOIN'][] = array(
'FROM' => array(FORUMS_ACCESS_TABLE => 'fa'),
'ON' => "fa.forum_id = f.forum_id AND fa.session_id = '" . $db->sql_escape($user->session_id) . "'"
);
$sql_array['SELECT'] .= ', fa.user_id';
}
$sql = $db->sql_build_query('SELECT', array(
'SELECT' => $sql_array['SELECT'],
'FROM' => $sql_array['FROM'],
'LEFT_JOIN' => $sql_array['LEFT_JOIN'],
'WHERE' => $sql_where,
'ORDER_BY' => 'f.left_id',
));
$result = $db->sql_query($sql);
$forum_tracking_info = array();
$branch_root_id = $root_data['forum_id'];
while ($row = $db->sql_fetchrow($result))
{
$forum_id = $row['forum_id'];
// Mark forums read?
if ($mark_read == 'forums' || $mark_read == 'all')
{
if ($auth->acl_get('f_list', $forum_id))
{
$forum_ids[] = $forum_id;
continue;
}
}
// Category with no members
if ($row['forum_type'] == FORUM_CAT && ($row['left_id'] + 1 == $row['right_id']))
{
continue;
}
// Skip branch
if (isset($right_id))
{
if ($row['left_id'] < $right_id)
{
continue;
}
unset($right_id);
}
if (!$auth->acl_get('f_list', $forum_id))
{
// if the user does not have permissions to list this forum, skip everything until next branch
$right_id = $row['right_id'];
continue;
}
$forum_ids[] = $forum_id;
if ($config['load_db_lastread'] && $user->data['is_registered'])
{
$forum_tracking_info[$forum_id] = (!empty($row['mark_time'])) ? $row['mark_time'] : $user->data['user_lastmark'];
}
else if ($config['load_anon_lastread'] || $user->data['is_registered'])
{
if (!$user->data['is_registered'])
{
$user->data['user_lastmark'] = (isset($tracking_topics['l'])) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0;
}
$forum_tracking_info[$forum_id] = (isset($tracking_topics['f'][$forum_id])) ? (int) (base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate']) : $user->data['user_lastmark'];
}
$row['forum_topics'] = ($auth->acl_get('m_approve', $forum_id)) ? $row['forum_topics_real'] : $row['forum_topics'];
// Display active topics from this forum?
if ($show_active && $row['forum_type'] == FORUM_POST && $auth->acl_get('f_read', $forum_id) && ($row['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS))
{
if (!isset($active_forum_ary['forum_topics']))
{
$active_forum_ary['forum_topics'] = 0;
}
if (!isset($active_forum_ary['forum_posts']))
{
$active_forum_ary['forum_posts'] = 0;
}
$active_forum_ary['forum_id'][] = $forum_id;
$active_forum_ary['enable_icons'][] = $row['enable_icons'];
$active_forum_ary['forum_topics'] += $row['forum_topics'];
$active_forum_ary['forum_posts'] += $row['forum_posts'];
// If this is a passworded forum we do not show active topics from it if the user is not authorised to view it...
if ($row['forum_password'] && $row['user_id'] != $user->data['user_id'])
{
$active_forum_ary['exclude_forum_id'][] = $forum_id;
}
}
//
if ($row['parent_id'] == $root_data['forum_id'] || $row['parent_id'] == $branch_root_id)
{
if ($row['forum_type'] != FORUM_CAT)
{
$forum_ids_moderator[] = (int) $forum_id;
}
// Direct child of current branch
$parent_id = $forum_id;
$forum_rows[$forum_id] = $row;
if ($row['forum_type'] == FORUM_CAT && $row['parent_id'] == $root_data['forum_id'])
{
$branch_root_id = $forum_id;
}
$forum_rows[$parent_id]['forum_id_last_post'] = $row['forum_id'];
$forum_rows[$parent_id]['orig_forum_last_post_time'] = $row['forum_last_post_time'];
}
else if ($row['forum_type'] != FORUM_CAT)
{
$subforums[$parent_id][$forum_id]['display'] = ($row['display_on_index']) ? true : false;
$subforums[$parent_id][$forum_id]['name'] = $row['forum_name'];
$subforums[$parent_id][$forum_id]['orig_forum_last_post_time'] = $row['forum_last_post_time'];
$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;
}
}
}
$db->sql_freeresult($result);
// Handle marking posts
if ($mark_read == 'forums' || $mark_read == 'all')
{
$redirect = build_url('mark');
if ($mark_read == 'all')
{
markread('all');
$message = sprintf($user->lang['RETURN_INDEX'], '<a href="' . $redirect . '">', '</a>');
}
else
{
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);
}
// Grab moderators ... if necessary
if ($display_moderators)
{
if ($return_moderators)
{
$forum_ids_moderator[] = $root_data['forum_id'];
}
get_moderators($forum_moderators, $forum_ids_moderator);
}
// Used to tell whatever we have to create a dummy category or not.
$last_catless = true;
foreach ($forum_rows as $row)
{
// Empty category
if ($row['parent_id'] == $root_data['forum_id'] && $row['forum_type'] == FORUM_CAT)
{
$template->assign_block_vars('forumrow', array(
'S_IS_CAT' => true,
'FORUM_ID' => $row['forum_id'],
'FORUM_NAME' => $row['forum_name'],
'FORUM_DESC' => generate_text_for_display($row['forum_desc'], $row['forum_desc_uid'], $row['forum_desc_bitfield'], $row['forum_desc_options']),
'FORUM_FOLDER_IMG' => '',
'FORUM_FOLDER_IMG_SRC' => '',
'FORUM_IMAGE' => ($row['forum_image']) ? '<img src="' . $phpbb_root_path . $row['forum_image'] . '" alt="' . $user->lang['FORUM_CAT'] . '" />' : '',
'FORUM_IMAGE_SRC' => ($row['forum_image']) ? $phpbb_root_path . $row['forum_image'] : '',
'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']))
);
continue;
}
$visible_forums++;
$forum_id = $row['forum_id'];
$forum_unread = (isset($forum_tracking_info[$forum_id]) && $row['orig_forum_last_post_time'] > $forum_tracking_info[$forum_id]) ? true : false;
$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_row['display'] && $subforum_row['name'])
{
$subforums_list[] = array(
'link' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $subforum_id),
'name' => $subforum_row['name'],
'unread' => $subforum_unread,
);
}
else
{
unset($subforums[$forum_id][$subforum_id]);
}
// If one subforum is unread the forum gets unread too...
if ($subforum_unread)
{
$forum_unread = true;
}
}
$l_subforums = (sizeof($subforums[$forum_id]) == 1) ? $user->lang['SUBFORUM'] . ': ' : $user->lang['SUBFORUMS'] . ': ';
$folder_image = ($forum_unread) ? 'forum_unread_subforum' : 'forum_read_subforum';
}
else
{
switch ($row['forum_type'])
{
case FORUM_POST:
$folder_image = ($forum_unread) ? 'forum_unread' : 'forum_read';
break;
case FORUM_LINK:
$folder_image = 'forum_link';
break;
}
}
// Which folder should we display?
if ($row['forum_status'] == ITEM_LOCKED)
{
$folder_image = ($forum_unread) ? 'forum_unread_locked' : 'forum_read_locked';
$folder_alt = 'FORUM_LOCKED';
}
else
{
$folder_alt = ($forum_unread) ? 'NEW_POSTS' : 'NO_NEW_POSTS';
}
// Create last post link information, if appropriate
if ($row['forum_last_post_id'])
{
$last_post_subject = $row['forum_last_post_subject'];
$last_post_title = '0'; // values: 0 and 1 //if 0 it'll take last TOPIC title
if ($last_post_title == '0')
{
$sql = 'SELECT t.topic_id, p.topic_id, t.topic_title, p.post_id, p.post_time
FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p
WHERE t.topic_id = p.topic_id
AND p.post_id = '.$row['forum_last_post_id'].'
ORDER BY p.post_time DESC';
$result = $db->sql_query($sql);
while ($row['2'] = $db->sql_fetchrow($result))
{
$last_topic_title = $row['2']['topic_title'];
$last_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=' . $row['2']['topic_id']);
}
$last_topic_title_substr = ( utf8_strlen($last_topic_title) > 30 )? (utf8_substr($last_topic_title,0,25) . '...') : ($last_topic_title);
}
else
{
$last_post_subject_substr = ( utf8_strlen($last_post_subject) > 30 )? (utf8_substr($last_post_subject,0,25) . '...') : ($last_post_subject);
}
$last_post_time = $user->format_date($row['forum_last_post_time']);
$last_post_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id_last_post'] . '&p=' . $row['forum_last_post_id']) . '#p' . $row['forum_last_post_id'];
}
else
{
$last_post_subject = $last_post_time = $last_post_url = '';
}
// Output moderator listing ... if applicable
$l_moderator = $moderators_list = '';
if ($display_moderators && !empty($forum_moderators[$forum_id]))
{
$l_moderator = (sizeof($forum_moderators[$forum_id]) == 1) ? $user->lang['MODERATOR'] : $user->lang['MODERATORS'];
$moderators_list = implode(', ', $forum_moderators[$forum_id]);
}
$l_post_click_count = ($row['forum_type'] == FORUM_LINK) ? 'CLICKS' : 'POSTS';
$post_click_count = ($row['forum_type'] != FORUM_LINK || $row['forum_flags'] & FORUM_FLAG_LINK_TRACK) ? $row['forum_posts'] : '';
$s_subforums_list = array();
foreach ($subforums_list as $subforum)
{
$s_subforums_list[] = '<a href="' . $subforum['link'] . '" class="subforum ' . (($subforum['unread']) ? 'unread' : 'read') . '">' . $subforum['name'] . '</a>';
}
$s_subforums_list = (string) implode(', ', $s_subforums_list);
$catless = ($row['parent_id'] == $root_data['forum_id']) ? true : false;
if ($row['forum_type'] != FORUM_LINK)
{
$u_viewforum = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']);
}
else
{
// If the forum is a link and we count redirects we need to visit it
// If the forum is having a password or no read access we do not expose the link, but instead handle it in viewforum
if (($row['forum_flags'] & FORUM_FLAG_LINK_TRACK) || $row['forum_password'] || !$auth->acl_get('f_read', $forum_id))
{
$u_viewforum = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']);
}
else
{
$u_viewforum = $row['forum_link'];
}
}
$template->assign_block_vars('forumrow', array(
'S_IS_CAT' => false,
'S_NO_CAT' => $catless && !$last_catless,
'S_IS_LINK' => ($row['forum_type'] == FORUM_LINK) ? true : false,
'S_UNREAD_FORUM' => $forum_unread,
'S_LOCKED_FORUM' => ($row['forum_status'] == ITEM_LOCKED) ? true : false,
'S_SUBFORUMS' => (sizeof($subforums_list)) ? true : false,
'FORUM_ID' => $row['forum_id'],
'FORUM_NAME' => $row['forum_name'],
'FORUM_DESC' => generate_text_for_display($row['forum_desc'], $row['forum_desc_uid'], $row['forum_desc_bitfield'], $row['forum_desc_options']),
'TOPICS' => $row['forum_topics'],
$l_post_click_count => $post_click_count,
'FORUM_FOLDER_IMG' => $user->img($folder_image, $folder_alt),
'FORUM_FOLDER_IMG_SRC' => $user->img($folder_image, $folder_alt, false, '', 'src'),
'FORUM_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),
'LAST_TOPIC_TITLE' => (isset($last_topic_title)) ? censor_text($last_topic_title) : '',
'LAST_TOPIC_TITLE_SUBSTR' => (isset($last_topic_title_substr)) ? censor_text($last_topic_title_substr) : '',
'LAST_POST_SUBJECT_SUBSTR' => (isset($last_post_subject_substr)) ? censor_text($last_post_subject_substr) : '',
'U_LAST_TOPIC' => (isset($last_topic_url)) ? $last_topic_url : '',
'LAST_POST_TIME' => $last_post_time,
'LAST_POSTER' => get_username_string('username', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']),
'LAST_POSTER_COLOUR' => get_username_string('colour', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']),
'LAST_POSTER_FULL' => get_username_string('full', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']),
'MODERATORS' => $moderators_list,
'SUBFORUMS' => $s_subforums_list,
'L_SUBFORUM_STR' => $l_subforums,
'L_FORUM_FOLDER_ALT' => $folder_alt,
'L_MODERATOR_STR' => $l_moderator,
'U_VIEWFORUM' => $u_viewforum,
'U_LAST_POSTER' => get_username_string('profile', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']),
'U_LAST_POST' => $last_post_url)
);
// Assign subforums loop for style authors
foreach ($subforums_list as $subforum)
{
$template->assign_block_vars('forumrow.subforum', array(
'U_SUBFORUM' => $subforum['link'],
'SUBFORUM_NAME' => $subforum['name'],
'S_UNREAD' => $subforum['unread'])
);
}
$last_catless = $catless;
}
$template->assign_vars(array(
'U_MARK_FORUMS' => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", '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' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'))
);
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;
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']))
);
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 . '&start=' . $j . '">' . $times . '</a>';
if ($times == 1 && $total_pages > 5)
{
$pagination .= ' ... ';
// Display the last three pages
$times = $total_pages - 3;
$j += ($total_pages - 4) * $per_page;
}
else if ($times < $total_pages)
{
$pagination .= '<span class="page-sep">' . $user->lang['COMMA_SEPARATOR'] . '</span>';
}
$times++;
}
}
else
{
$pagination = '';
}
return $pagination;
}
/**
* Obtain list of moderators of each forum
*/
function get_moderators(&$forum_moderators, $forum_id = false)
{
global $config, $template, $db, $phpbb_root_path, $phpEx;
// Have we disabled the display of moderators? If so, then return
// from whence we came ...
if (!$config['load_moderators'])
{
return;
}
$forum_sql = '';
if ($forum_id !== false)
{
if (!is_array($forum_id))
{
$forum_id = array($forum_id);
}
// If we don't have a forum then we can't have a moderator
if (!sizeof($forum_id))
{
return;
}
$forum_sql = 'AND m.' . $db->sql_in_set('forum_id', $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 $forum_sql",
);
$sql = $db->sql_build_query('SELECT', $sql_array);
$result = $db->sql_query($sql, 3600);
while ($row = $db->sql_fetchrow($result))
{
if (!empty($row['user_id']))
{
$forum_moderators[$row['forum_id']][] = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);
}
else
{
$forum_moderators[$row['forum_id']][] = '<a' . (($row['group_colour']) ? ' style="color:#' . $row['group_colour'] . ';"' : '') . ' href="' . append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&g=' . $row['group_id']) . '">' . (($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['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';
if ($config['hot_threshold'] && $replies >= $config['hot_threshold'] && $topic_row['topic_status'] != ITEM_LOCKED)
{
$folder .= '_hot';
$folder_new .= '_hot';
}
break;
}
if ($topic_row['topic_status'] == ITEM_LOCKED)
{
$topic_type = $user->lang['VIEW_TOPIC_LOCKED'];
$folder .= '_locked';
$folder_new .= '_locked';
}
$folder_img = ($unread_topic) ? $folder_new : $folder;
$folder_alt = ($unread_topic) ? 'NEW_POSTS' : (($topic_row['topic_status'] == ITEM_LOCKED) ? 'TOPIC_LOCKED' : 'NO_NEW_POSTS');
// Posted image?
if (!empty($topic_row['topic_posted']) && $topic_row['topic_posted'])
{
$folder_img .= '_mine';
}
}
if ($topic_row['poll_start'] && $topic_row['topic_status'] != ITEM_MOVED)
{
$topic_type = $user->lang['VIEW_TOPIC_POLL'];
}
}
/**
* Assign/Build custom bbcodes for display in screens supporting using of bbcodes
* The custom bbcodes buttons will be placed within the template block 'custom_codes'
*/
function display_custom_bbcodes()
{
global $db, $template;
// Start counting from 22 for the bbcode ids (every bbcode takes two ids - opening/closing)
$num_predefined_bbcodes = 22;
$sql = 'SELECT bbcode_id, bbcode_tag, bbcode_helpline
FROM ' . BBCODES_TABLE . '
WHERE display_on_posting = 1
ORDER BY bbcode_tag';
$result = $db->sql_query($sql);
$i = 0;
while ($row = $db->sql_fetchrow($result))
{
$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' => 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 5000 posts...
if ($userdata['user_posts'] > 5000)
{
return;
}
$forum_ary = array();
// Do not include those forums the user is not having read access to...
$forum_read_ary = $auth->acl_getf('!f_read');
foreach ($forum_read_ary as $forum_id => $not_allowed)
{
if ($not_allowed['f_read'])
{
$forum_ary[] = (int) $forum_id;
}
}
$forum_ary = array_unique($forum_ary);
$forum_sql = (sizeof($forum_ary)) ? 'AND ' . $db->sql_in_set('forum_id', $forum_ary, true) : '';
// Obtain active forum
$sql = 'SELECT forum_id, COUNT(post_id) AS num_posts
FROM ' . POSTS_TABLE . '
WHERE poster_id = ' . $userdata['user_id'] . "
AND post_postcount = 1
$forum_sql
GROUP BY forum_id
ORDER BY num_posts DESC";
$result = $db->sql_query_limit($sql, 1);
$active_f_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if (!empty($active_f_row))
{
$sql = 'SELECT forum_name
FROM ' . FORUMS_TABLE . '
WHERE forum_id = ' . $active_f_row['forum_id'];
$result = $db->sql_query($sql, 3600);
$active_f_row['forum_name'] = (string) $db->sql_fetchfield('forum_name');
$db->sql_freeresult($result);
}
// Obtain active topic
$sql = 'SELECT topic_id, COUNT(post_id) AS num_posts
FROM ' . POSTS_TABLE . '
WHERE poster_id = ' . $userdata['user_id'] . "
AND post_postcount = 1
$forum_sql
GROUP BY topic_id
ORDER BY num_posts DESC";
$result = $db->sql_query_limit($sql, 1);
$active_t_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if (!empty($active_t_row))
{
$sql = 'SELECT topic_title
FROM ' . TOPICS_TABLE . '
WHERE topic_id = ' . $active_t_row['topic_id'];
$result = $db->sql_query($sql);
$active_t_row['topic_title'] = (string) $db->sql_fetchfield('topic_title');
$db->sql_freeresult($result);
}
$userdata['active_t_row'] = $active_t_row;
$userdata['active_f_row'] = $active_f_row;
$active_f_name = $active_f_id = $active_f_count = $active_f_pct = '';
if (!empty($active_f_row['num_posts']))
{
$active_f_name = $active_f_row['forum_name'];
$active_f_id = $active_f_row['forum_id'];
$active_f_count = $active_f_row['num_posts'];
$active_f_pct = ($userdata['user_posts']) ? ($active_f_count / $userdata['user_posts']) * 100 : 0;
}
$active_t_name = $active_t_id = $active_t_count = $active_t_pct = '';
if (!empty($active_t_row['num_posts']))
{
$active_t_name = $active_t_row['topic_title'];
$active_t_id = $active_t_row['topic_id'];
$active_t_count = $active_t_row['num_posts'];
$active_t_pct = ($userdata['user_posts']) ? ($active_t_count / $userdata['user_posts']) * 100 : 0;
}
$l_active_pct = ($userdata['user_id'] != ANONYMOUS && $userdata['user_id'] == $user->data['user_id']) ? $user->lang['POST_PCT_ACTIVE_OWN'] : $user->lang['POST_PCT_ACTIVE'];
$template->assign_vars(array(
'ACTIVE_FORUM' => $active_f_name,
'ACTIVE_FORUM_POSTS' => ($active_f_count == 1) ? sprintf($user->lang['USER_POST'], 1) : sprintf($user->lang['USER_POSTS'], $active_f_count),
'ACTIVE_FORUM_PCT' => sprintf($l_active_pct, $active_f_pct),
'ACTIVE_TOPIC' => censor_text($active_t_name),
'ACTIVE_TOPIC_POSTS' => ($active_t_count == 1) ? sprintf($user->lang['USER_POST'], 1) : sprintf($user->lang['USER_POSTS'], $active_t_count),
'ACTIVE_TOPIC_PCT' => sprintf($l_active_pct, $active_t_pct),
'U_ACTIVE_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $active_f_id),
'U_ACTIVE_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=' . $active_t_id),
'S_SHOW_ACTIVITY' => true)
);
}
/**
* Topic and forum watching common code
*/
function watch_topic_forum($mode, &$s_watching, &$s_watching_img, $user_id, $forum_id, $topic_id, $notify_status = 'unset', $start = 0)
{
global $template, $db, $user, $phpEx, $start, $phpbb_root_path;
$table_sql = ($mode == 'forum') ? FORUMS_WATCH_TABLE : TOPICS_WATCH_TABLE;
$where_sql = ($mode == 'forum') ? 'forum_id' : 'topic_id';
$match_id = ($mode == 'forum') ? $forum_id : $topic_id;
$u_url = ($mode == 'forum') ? 'f' : 'f=' . $forum_id . '&t';
// Is user watching this thread?
if ($user_id != ANONYMOUS)
{
$can_watch = true;
if ($notify_status == 'unset')
{
$sql = "SELECT notify_status
FROM $table_sql
WHERE $where_sql = $match_id
AND user_id = $user_id";
$result = $db->sql_query($sql);
$notify_status = ($row = $db->sql_fetchrow($result)) ? $row['notify_status'] : NULL;
$db->sql_freeresult($result);
}
if (!is_null($notify_status) && $notify_status !== '')
{
if (isset($_GET['unwatch']))
{
if ($_GET['unwatch'] == $mode)
{
$is_watching = 0;
$sql = 'DELETE FROM ' . $table_sql . "
WHERE $where_sql = $match_id
AND user_id = $user_id";
$db->sql_query($sql);
}
$redirect_url = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&start=$start");
meta_refresh(3, $redirect_url);
$message = $user->lang['NOT_WATCHING_' . strtoupper($mode)] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</a>');
trigger_error($message);
}
else
{
$is_watching = true;
if ($notify_status)
{
$sql = 'UPDATE ' . $table_sql . "
SET notify_status = 0
WHERE $where_sql = $match_id
AND user_id = $user_id";
$db->sql_query($sql);
}
}
}
else
{
if (isset($_GET['watch']))
{
if ($_GET['watch'] == $mode)
{
$is_watching = true;
$sql = 'INSERT INTO ' . $table_sql . " (user_id, $where_sql, notify_status)
VALUES ($user_id, $match_id, 0)";
$db->sql_query($sql);
}
$redirect_url = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&start=$start");
meta_refresh(3, $redirect_url);
$message = $user->lang['ARE_WATCHING_' . strtoupper($mode)] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</a>');
trigger_error($message);
}
else
{
$is_watching = 0;
}
}
}
else
{
if (isset($_GET['unwatch']) && $_GET['unwatch'] == $mode)
{
login_box();
}
else
{
$can_watch = 0;
$is_watching = 0;
}
}
if ($can_watch)
{
$s_watching['link'] = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&" . (($is_watching) ? 'unwatch' : 'watch') . "=$mode&start=$start");
$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
*
*/
function get_user_rank($user_rank, $user_posts, &$rank_title, &$rank_img, &$rank_img_src)
{
global $ranks, $config;
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="' . $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'])) ? $config['ranks_path'] . '/' . $ranks['special'][$user_rank]['rank_image'] : '';
}
else
{
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="' . $config['ranks_path'] . '/' . $rank['rank_image'] . '" alt="' . $rank['rank_title'] . '" title="' . $rank['rank_title'] . '" />' : '';
$rank_img_src = (!empty($rank['rank_image'])) ? $config['ranks_path'] . '/' . $rank['rank_image'] : '';
break;
}
}
}
}
}
/**
* Get user avatar
*
* @param string $avatar Users assigned avatar name
* @param int $avatar_type Type of avatar
* @param string $avatar_width Width of users avatar
* @param string $avatar_height Height of users avatar
* @param string $alt Optional language string for alt tag within image, can be a language key or text
*
* @return string Avatar image
*/
function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $alt = 'USER_AVATAR')
{
global $user, $config, $phpbb_root_path, $phpEx;
if (empty($avatar) || !$avatar_type)
{
return '';
}
$avatar_img = '';
switch ($avatar_type)
{
case AVATAR_UPLOAD:
$avatar_img = $phpbb_root_path . "download/file.$phpEx?avatar=";
break;
case AVATAR_GALLERY:
$avatar_img = $phpbb_root_path . $config['avatar_gallery_path'] . '/';
break;
}
$avatar_img .= $avatar;
return '<img src="' . $avatar_img . '" width="' . $avatar_width . '" height="' . $avatar_height . '" alt="' . ((!empty($user->lang[$alt])) ? $user->lang[$alt] : $alt) . '" />';
}
?>
What I was hoping to be able to do (in order of preference) is:
1. Make the Mod show the latest topics in the forum, no matter whether they were posted in public folders, or folders that ONLY registered and logged in members can see... However, I would redirect them to register or sign on once they clicked the topic to try to read the post. I am not sure how easy this would be to do...
Good suggestion Xclavo- I will give that a shot and see how well that works.Xclavo wrote:Really you are requesting for a MOD and not so much support... anyway, all you have to do is set the permissions of each forum ( in advanced mode ) to anyone can vew, but only registerd can read. So that means guests will see new topics made, but when they click on it, they will be redirected to log in. For the threads that guests are allowed to view, set the forum permission to all can read and view. at least this is how it happens in our forums.. there should be no reason why it shooulndt work the same way for this mod.
What I was hoping to be able to do (in order of preference) is:
1. Make the Mod show the latest topics in the forum, no matter whether they were posted in public folders, or folders that ONLY registered and logged in members can see... However, I would redirect them to register or sign on once they clicked the topic to try to read the post. I am not sure how easy this would be to do...
OPENsilverstreek wrote:ok, i've tried messing with this for over an hour and can't get it right. how do make this display at the top of my index, right above last visited and view posts since last visit, but right below profile, messages and log in/out?
Code: Select all
<table width="100%" cellspacing="0" cellpadding="2" border="0" align="center">
<tr>
<td align="left" valign="bottom"><span class="gensmall">
<!-- BEGIN switch_user_logged_in -->
{LAST_VISIT_DATE}<br />
<!-- END switch_user_logged_in -->
{CURRENT_TIME}<br /></span><span class="nav"><a href="{U_INDEX}" class="nav">{L_INDEX}</a></span></td>
<td align="right" valign="bottom" class="gensmall">
<!-- BEGIN switch_user_logged_in -->
<a href="{U_SEARCH_NEW}" class="gensmall">{L_SEARCH_NEW}</a><br /><a href="{U_SEARCH_SELF}" class="gensmall">{L_SEARCH_SELF}</a><br />
<!-- END switch_user_logged_in -->
<a href="{U_SEARCH_UNANSWERED}" class="gensmall">{L_SEARCH_UNANSWERED}</a></td>
</tr>
</table>
Code: Select all
<table width="100%" cellpadding="3" cellspacing="1" border="0" class="forumline" height="100%">
<tr>
<td class="catHead" height="28"><a name="login"></a><span class="cattitle">{MARQUEE_TOPIC}</span></td>
</tr>
<tr>
<td class="row1" valign="top"><span class="gen">
<marquee id="recent_topics" behavior="scroll" direction="up" height="100" scrolldelay="100" scrollamount="2">
<table cellpadding="4" cellSpacing="1" width="100%">
<!-- BEGIN marqueerow -->
<tr valign="top">
<td class="row2" vAlign="center" align="middle" width="20">
<img src="{marqueerow.FOLD_URL}">
</td>
<td class="row2" width="352">
<span class="forumlink"><a href="{marqueerow.TOPIC_URL}" onMouseOver="document.all.recent_topics.stop()" onMouseOut="document.all.recent_topics.start()">{marqueerow.TOPIC_TITLE}</a></span>
<span class="gensmall"><br /></span>
</td>
<td class="row2" vAlign="center" align="middle" width="78">
<span class="gensmall"><a href="{marqueerow.USER_PROF}" onMouseOver="document.all.recent_topics.stop()" onMouseOut="document.all.recent_topics.start()">{marqueerow.USERNAME}</a></span>
</td>
<td class="row2" vAlign="center" noWrap align="middle" width="100">
<span class="gensmall">{marqueerow.POST_DATE}</span>
</td>
</tr>
<!-- END marqueerow -->
</table>
</marquee>
</td>
</tr>
</table>
(took out "height="100%" at the end of that line)<table width="100%" cellpadding="3" cellspacing="1" border="0" class="forumline">