[BETA] Attached Forums Pro
Verfasst: 06.02.2005 15:02
Code: Alles auswählen
##############################################################
## MOD Title: Attached Forums MOD Pro
## MOD Authors: kratzer54847 < alternativ3322@web.de > (Johny Jesewski) http://www.plauderclub.de/
## harishankar < v.harishankar@gmail.com > (V. Harishankar)
## MOD Description: Adds the ability to create subforums via attach forums to each other
## MOD Version: 0.0.1 alpha
##
## Installation Level: Easy
## Installation Time: 10 Minutes
## Files To Edit: admin/admin_forums.php, index.php, viewforum.php, templates/subSilver/admin/forum_edit_body.tpl, templates/subSilver/index_body.tpl, templates/subSilver/viewforum_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 Mod adds the ability to create subforums via attach forums to each other.
##
##############################################################
## MOD History:
##
## 2005-02-06 - Version 0.1.0 Alpha
## - Initial Release of Attached Forums MOD Pro(harishankar/kratzer54847)
##
##
## 2005-12-25 - Version 0.0.1 Alpha
## - Initial Release of Attached Forums MOD(harishankar)
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################
#
#-----[ SQL ]------------------------------------------
#
ALTER TABLE phpbb_forums ADD attached_forum_id MEDIUMINT( 8 ) DEFAULT -1 NOT NULL;
#
#-----[ OPEN ]------------------------------------------
#
admin_forums.php
#
#-----[ FIND ]------------------------------------------
#
$forumstatus = $row['forum_status'];
#
#-----[ AFTER, ADD ]----------------------------------
#
$forum_attached_id = $row['attached_forum_id'];
#
#-----[ FIND ]------------------------------------------
#
'S_PRUNE_ENABLED' => $prune_enabled,
#
#-----[ AFTER, ADD ]----------------------------------
#
'S_ATTACHED_FORUM_ID' => $forum_attached_id,
#
#-----[ FIND ]------------------------------------------
#
'L_CATEGORY' => $lang['Category'],
#
#-----[ AFTER, ADD ]----------------------------------
#
'L_ATTACHED_FORUM' => $lang['Attached_Field_Title'] ,
'L_ATTACHED_DESC' => $lang['Attached_Description'],
#
#-----[ FIND ]------------------------------------------
#
$sql = "INSERT INTO " . FORUMS_TABLE . "
#
#-----[ IN-LINE, FIND ]------------------------------------------
#
cat_id,
#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#
attached_forum_id,
#
#-----[ IN-LINE, FIND ]------------------------------------------
#
" . intval($HTTP_POST_VARS[POST_CAT_URL]) .",
#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#
" . intval($HTTP_POST_VARS['attached_forum_id']) . ",
#
#-----[ FIND ]------------------------------------------
#
$sql = "UPDATE " . FORUMS_TABLE . "
#
#-----[ IN-LINE, FIND ]------------------------------------------
#
cat_id = " . intval($HTTP_POST_VARS[POST_CAT_URL]) . ",
#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#
attached_forum_id = " . intval($HTTP_POST_VARS['attached_forum_id']) . ",
#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/admin/forum_edit_body.tpl
#
#-----[ FIND ]------------------------------------------
#
<tr>
<td class="row1">{L_CATEGORY}</td>
<td class="row2"><select name="c">{S_CAT_LIST}</select></td>
</tr>
#
#-----[ AFTER, ADD ]----------------------------------
#
<tr>
<td class="row1">{L_ATTACHED_FORUM}</td>
<td class="row2"><input type="text" name="attached_forum_id" value="{S_ATTACHED_FORUM_ID}" class="post" /><br />{L_ATTACHED_DESC}</td>
</tr>
#
#-----[ OPEN ]------------------------------------------
#
index.php
#
#-----[ FIND ]------------------------------------------
#
$forum_id = $forum_data[$j]['forum_id'];
#
#-----[ AFTER, ADD ]----------------------------------
#
$attached_id = $forum_data[$j]['attached_forum_id'];
#
#-----[ FIND ]------------------------------------------
#
if ( $is_auth_ary[$forum_id]['auth_view'] )
#
#-----[ REPLACE WITH ]------------------------------------------
#
if ( $is_auth_ary[$forum_id]['auth_view'] && $attached_id == -1 )
{
$sql = "SELECT forum_name, forum_id FROM " . FORUMS_TABLE . "
WHERE attached_forum_id = " . $forum_id ;
$result = $db->sql_query($sql);
$list_of_attached = '';
if (!$result)
{
message_die(GENERAL_ERROR, 'Could not get attached forums.', '', __LINE__, __FILE__, $sql);
}
$count_attached = $db->sql_numrows ($result);
if ($count_attached == 1)
{
$list_of_attached = $lang['Attached_forum'] . ': ';
}
else if ($count_attached > 1)
{
$list_of_attached = $lang['Attached_forums'] . ': ';
}
if ($count_attached != 0)
{
$row = $db->sql_fetchrow ($result);
do
{
if ($row)
{
$url_row2 = '<a href="' . append_sid ('viewforum.php?f=' . $row['forum_id'] ) . '">' . $row['forum_name'] . '</a>' ;
$list_of_attached = $list_of_attached . $url_row2 ;
}
$row = $db->sql_fetchrow ($result);
if ( $row )
{
$list_of_attached = $list_of_attached . ', ';
}
}
while ($row);
$list_of_attached = $list_of_attached . '<br />' ;
}
$db->sql_freeresult ($result);
#
#-----[ FIND ]------------------------------------------
#
'LAST_POST' => $last_post,
#
#-----[ AFTER, ADD ]------------------------------------------
#
'ATTACHED_FORUMS_LIST' => $list_of_attached,
#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/index_body.tpl
#
#-----[ FIND ]------------------------------------------
#
{catrow.forumrow.MODERATORS}</span>
#
#-----[ AFTER, ADD ]------------------------------------------
#
<br /><span class="genmed">{catrow.forumrow.ATTACHED_FORUMS_LIST}</span>
#
#-----[ OPEN ]------------------------------------------
#
viewforum.php
#
#-----[ FIND ]------------------------------------------
#
//
// End header
//
#
#-----[ AFTER, ADD ]------------------------------------------
#
$sql = "SELECT *
FROM " . FORUMS_TABLE . "
WHERE attached_forum_id = $forum_id";
$result = $db->sql_query ($sql);
if (! $result )
{
message_die ('Could not gather attached forum info', __LINE__, __FILE__, $sql2);
}
if ($db->sql_numrows ($result) != 0)
{
if ($db->sql_numrows ($result) == 1)
{
$attached_forum_title = $lang['Attached_forum'];
}
else
{
$attached_forum_title = $lang['Attached_forums'];
}
$template->assign_block_vars ('switch_attached_list', array(
'L_ATTACHED_FORUM' => $attached_forum_title,
'L_ATTACHED_TOPICS' => $lang['Topics'],
'L_ATTACHED_POSTS' => $lang['Posts'],
'L_LAST_POST' => $lang['Last_Post']
));
while ( $row = $db->sql_fetchrow ($result) )
{
$attach_forum_name = '<a href="' . append_sid('viewforum.php?f=' . $row['forum_id']) . '">' . $row['forum_name'] . '</a>' ;
$attach_forum_desc = '<br />' . $row['forum_desc'];
$attach_forum_topics = $row['forum_topics'];
$attach_forum_posts = $row['forum_posts'];
$attach_forum_id = $row['forum_id'];
$attach_forum_last_post = $lang['No_Posts'];
if( $row['forum_posts'] != '0' )
{
$sql3 = "SELECT *
FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u
WHERE p.post_id = '$row[forum_last_post_id]'
AND u.user_id = p.poster_id";
$result3 = $db->sql_query ($sql3);
while ( $row3 = $db->sql_fetchrow ($result3) )
{
$attach_forum_last_post = create_date($board_config['default_dateformat'], $row3['post_time'], $board_config['board_timezone']) . '<br />' . '<a href="' . append_sid('profile.$phpEx?mode=viewprofile&u=' . $row3[user_id]) . '">' . $row3[username] . '</a><a href="' . append_sid('viewtopic.php?p=' . $row3[post_id]) . '"><img src=' . $images['icon_latest_reply'] . ' border=0 hspace=3></a>';
}
}
//
// Forum Moderators
//
$sqlm = "SELECT u.user_id, u.username
FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g, " . USERS_TABLE . " u
WHERE aa.forum_id = $attach_forum_id
AND aa.auth_mod = " . TRUE . "
AND g.group_single_user = 1
AND ug.group_id = aa.group_id
AND g.group_id = aa.group_id
AND u.user_id = ug.user_id
GROUP BY u.user_id, u.username
ORDER BY u.user_id";
if ( !($resultm = $db->sql_query($sqlm)) )
{
message_die(GENERAL_ERROR, 'Could not query forum moderator information', '', __LINE__, __FILE__, $sql);
}
$moderators = array();
while( $rowm = $db->sql_fetchrow($resultm) )
{
$moderators[] = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $rowm['user_id']) . '">' . $rowm['username'] . '</a>';
}
$sqlg = "SELECT g.group_id, g.group_name
FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g
WHERE aa.forum_id = $attach_forum_id
AND aa.auth_mod = " . TRUE . "
AND g.group_single_user = 0
AND g.group_type <> ". GROUP_HIDDEN ."
AND ug.group_id = aa.group_id
AND g.group_id = aa.group_id
GROUP BY g.group_id, g.group_name
ORDER BY g.group_id";
if ( !($resultg = $db->sql_query($sqlg)) )
{
message_die(GENERAL_ERROR, 'Could not query forum moderator information', '', __LINE__, __FILE__, $sqlg);
}
while( $rowg = $db->sql_fetchrow($resultg) )
{
$moderators[] = '<a href="' . append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=" . $rowg['group_id']) . '">' . $rowg['group_name'] . '</a>';
}
$l_moderators = ( count($moderators) == 1 ) ? $lang['Moderator'] : $lang['Moderators'];
$forum_moderators = ( count($moderators) ) ? implode(', ', $moderators) : $lang['None'];
unset($moderators);
//
// Attached Forums Tree
//
$sqlsub = "SELECT forum_name, forum_id
FROM " . FORUMS_TABLE . "
WHERE attached_forum_id = '$attach_forum_id'";
$subforums = array();
if ( !($resultsub = $db->sql_query($sqlsub)) )
{
message_die(GENERAL_ERROR, 'Could not query subforums information', '', __LINE__, __FILE__, $sqlsub);
}
while( $rowsub = $db->sql_fetchrow($resultsub) )
{
$subforums[] = '<a href="' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=" . $rowsub['forum_id']) . '">' . $rowsub['forum_name'] . '</a>';
}
$l_subforums = ( count($subforums) == 1 ) ? $lang['Attached_forum'] : $lang['Attached_forums'];
$forum_subforums = ( count($subforums) ) ? implode(', ', $subforums) : $lang['None'];
unset($subforums);
$last_post_id = $row['forum_last_post_id'];
$folder_img = $images['forum_fol'];
$l_folder_alt = $lang['No_new_posts'];
$tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) : '';
$template->assign_block_vars ('switch_attached_list.switch_attached_present', array(
'FORUM_NAME' => $attach_forum_name,
'FORUM_DESC' => $attach_forum_desc,
'TOPICS' => $attach_forum_topics,
'POSTS' => $attach_forum_posts,
'LAST_POST' => $attach_forum_last_post,
'L_MODERATORS' => $l_moderators,
'MODERATORS' => $forum_moderators,
'SUBFORUMS' => $forum_subforums,
'L_SUBFORUMS' => $l_subforums,
'FOLDER_IMG' => $folder_img,
'FOLDER_ALT' => $l_folder_alt
));
}
}
$db->sql_freeresult ($result);
#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/viewforum_body.tpl
#
#-----[ FIND ]------------------------------------------
#
<td align="right" valign="bottom" class="nav" nowrap="nowrap"><span class="gensmall"><a href="{U_MARK_READ}">{L_MARK_TOPICS_READ}</a></span></td>
</tr>
</table>
#
#-----[ AFTER, ADD ]------------------------------------------
#
<!-- BEGIN switch_attached_list -->
<table width="100%" border="0" cellpadding="4" cellspacing="1" width="100%" class="forumline">
<tr>
<th colspan="2" class="thCornerL" height="15" nowrap="nowrap"> {switch_attached_list.L_ATTACHED_FORUM} </th>
<th width="50" class="thTop" nowrap="nowrap"> {switch_attached_list.L_ATTACHED_TOPICS} </th>
<th width="50" class="thTop" nowrap="nowrap"> {switch_attached_list.L_ATTACHED_POSTS} </th>
<th class="thCornerR" nowrap="nowrap"> {switch_attached_list.L_LAST_POST} </th>
</tr>
<!-- BEGIN switch_attached_present -->
<tr>
<td class="row1" align="center"><img src="{FOLDER_IMG}" alt="{L_FOLDER_ALT}"></td>
<td class="row1" width="75%"><span class="forumlink">{switch_attached_list.switch_attached_present.FORUM_NAME}</span><span class="genmed">{switch_attached_list.switch_attached_present.FORUM_DESC}
<br>{switch_attached_list.switch_attached_present.L_MODERATORS}: {switch_attached_list.switch_attached_present.MODERATORS}
<br>{switch_attached_list.switch_attached_present.L_SUBFORUMS}: {switch_attached_list.switch_attached_present.SUBFORUMS}
</span></td>
<td class="row2" align="center" valign="middle"><span class="gensmall">{switch_attached_list.switch_attached_present.TOPICS}</span></td>
<td class="row2" align="center" valign="middle"><span class="gensmall">{switch_attached_list.switch_attached_present.POSTS}</span></td>
<td class="row2" align="center" valign="middle"><span class="gensmall">{switch_attached_list.switch_attached_present.LAST_POST}</span></td>
</tr>
<!-- END switch_attached_present -->
</table>
<br />
<!-- END switch_attached_list -->
#
#-----[ OPEN ]------------------------------------------
#
language/lang_english/lang_main.php
#
#-----[ FIND ]------------------------------------------
#
//
// That's all, Folks!
// -------------------------------------------------
#
#-----[ BEFORE, ADD ]------------------------------------------
#
$lang['Attached_forum'] = 'Attached Forum';
$lang['Attached_forums'] = 'Attached Forums';
#
#-----[ OPEN ]------------------------------------------
#
language/lang_english/lang_admin.php
#
#-----[ FIND ]------------------------------------------
#
//
// That's all, Folks!
// -------------------------------------------------
#
#-----[ BEFORE, ADD ]------------------------------------------
#
$lang['Attached_Field_Title'] = 'Attached to forum';
$lang['Attached_Description'] = "This field has been added by Harishankar's attached forums mod. If you wish this forum to be a pseudo sub-forum or attached to another forum, then enter the id of the forum you wish to attach it to. For regular (normal) forums, leave this value as -1";
#
#-----[ SAVE & CLOSE ALL FILES ]------------------------------------------
#
# EoM