代碼: 選擇全部
########################################################
## 外掛名稱: 主題類型分區劃 (資料庫版 by Martinet)
## 外掛版本: 2.0.0
## 外掛原作者: 炎之虛空(御津闇慈)
## 外掛強化者: 炎之虛空(御津闇慈) <http://imoml.phpbb-tw.com/>
## 外掛資料庫化 : Martinet Oaf <oafwork@hotmail.com>
##
## 外掛描述: 這個外掛可以讓管理員在控制台中指定各個討論版發表主題的主題類型 ,
## 讓會員不會在版面上使用到錯誤的主題類型
## 並且新增?#91;"主題分類功能"
##
## 安裝難度: 簡單
## 安裝時間: 5 分鐘
##
## 需要編輯的檔案: 9
## viewforum.php
## posting.php
## template/你的風格/posting_body.tpl
## includes/constants.php
## admin/admin_forums.php
## template/你的風格/viewforum_body.tpl
## template/你的風格/admin/forum_edit_body.tpl
## language/你的語言/lang_admin.php
## language/你的語言/lang_main.php
##
## 附?#91;的檔案: n/a
##
## 附?#91;的圖示: n/a
##
##############################################################
## 在增?#91;此外掛前, 請務必備份所有需要修改的檔案
##############################################################
由於有些是中途改出來的 , 若有錯誤請通知我修改一下^^
#
#-----[ ADD SQL ]------------------------------------------
#
ALTER TABLE `phpbb_forums` ADD `forum_topictypes` VARCHAR( 255 ) DEFAULT '' NOT NULL
#
#-----[ OPEN ]------------------------------------------
#
posting.php
#
#-----[ FIND ]------------------------------------------
#
//
// Include page header
//
#
#-----[ BEFORE, ADD ]------------------------------------------
#
//Topic type mod
$topictypes = explode(",",$post_info['forum_topictypes']);
$ttopions = '';
foreach ($topictypes as $topictype)
{
$ttoptions .= '<option value="' . $topictype . '">' . $topictype . "</option>
";
}
$template->assign_vars(array(
'L_TOPIC_TYPES_EXPLAIN' => $lang['topic_types_explain'],
'TOPIC_TYPES'
=> $ttoptions)
);
//沒主題類型的時候關閉
if($post_info['forum_topictypes']!='')
{
$template->assign_block_vars('switch_topictypes', array());
}
//Topic type mod end
#
#-----[ OPEN ]------------------------------------------
#
viewforum.php
#
#-----[ FIND ]------------------------------------------
#
$select_topic_days .= '</select>';
#
#-----[ AFTER, ADD ]------------------------------------------
#
//types
if($forum_row['forum_topictypes'] != '')
{
if ( empty($HTTP_POST_VARS['types']) || empty($HTTP_GET_VARS['types']) )
{
$types_id = ( !empty($HTTP_POST_VARS['types']) ) ? $HTTP_POST_VARS['types'] : $HTTP_GET_VARS['types'];
$topictypes = explode(",",$forum_row['forum_topictypes']);
$types = $topictypes[$types_id].'%';
$sql = "SELECT COUNT(t.topic_id) AS forum_topics
FROM " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p
WHERE t.forum_id = $forum_id
AND p.post_id = t.topic_last_post_id
AND t.topic_title LIKE '$types'
$limit_topics_time";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain limited topics count information', '', __LINE__, __FILE__, $sql);
}
$row = $db->sql_fetchrow($result);
$topics_count = ( $row['forum_topics'] ) ? $row['forum_topics'] : 1;
$limit_topic_types = "AND t.topic_title LIKE '$types'";
if ( !empty($HTTP_POST_VARS['types']) )
{
$start = 0;
}
}
$topictypes = explode(",",$forum_row['forum_topictypes']);
$select_topic_types = '<table border="0" cellpadding="1" cellspacing="1" width="75%" class="forumline"><tr><td class="row1" colspan="2" height="20"><b><a href="' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=" . $forum_id) . '">'.$lang['All_Topics'].'</a>';
for($i=0;$i<count($topictypes);$i++)
{
$select_topic_types .= '|<a href="' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=" . $forum_id . "&start=0&" . POST_TYEPS_URL . "=".$i) . '">' . $topictypes[$i] . "</a>";
}
$select_topic_types .='</b></td></tr></table>';
}
//types
#
#-----[ FIND ]------------------------------------------
#
$sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_time, p.post_username
FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . USERS_TABLE . " u2
WHERE t.forum_id = $forum_id
AND t.topic_poster = u.user_id
AND p.post_id = t.topic_last_post_id
AND p.poster_id = u2.user_id
#
#-----[ AFTER, ADD ]------------------------------------------
#
$limit_topic_types
#
#-----[ FIND ]------------------------------------------
#
$sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_username, p2.post_username AS post_username2, p2.post_time
FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2, " . USERS_TABLE . " u2
WHERE t.forum_id = $forum_id
AND t.topic_poster = u.user_id
AND p.post_id = t.topic_first_post_id
AND p2.post_id = t.topic_last_post_id
AND u2.user_id = p2.poster_id
AND t.topic_type <> " . POST_ANNOUNCE . "
$limit_topics_time
#
#-----[ AFTER, ADD ]------------------------------------------
#
$limit_topic_types
#
#-----[ FIND ]------------------------------------------
#
'FOLDER_ANNOUNCE_NEW_IMG' => $images['folder_announce_new'],
#
#-----[ AFTER, ADD ]------------------------------------------
#
'TYPES' => $select_topic_types,
#
#-----[ OPEN ]------------------------------------------
#
includes/constants.php
#
#-----[ FIND ]------------------------------------------
#
define('POST_FORUM_URL', 'f');
#
#-----[ AFTER, ADD ]------------------------------------------
#
define('POST_TYEPS_URL', 'types');
#
#-----[ OPEN ]------------------------------------------
#
admin/admin_forums.php
#
#-----[ FIND ]------------------------------------------
#
$forumstatus = $row['forum_status'];
#
#-----[ AFTER, ADD ]------------------------------------------
#
$forum_topictypes = $row['forum_topictypes'];
找到
$forumstatus = FORUM_UNLOCKED;
$forum_id = '';
$prune_enabled = '';
#
#-----[ AFTER, ADD ]------------------------------------------
#
$forum_topictypes = '';
#
#-----[ FIND ]------------------------------------------
#
'S_PRUNE_ENABLED' => $prune_enabled,
#
#-----[ AFTER, ADD ]------------------------------------------
#
'S_FORUM_TOPICTYPES' => $forum_topictypes,
#
#-----[ FIND ]------------------------------------------
#
'L_DAYS' => $lang['Days'],
#
#-----[ AFTER, ADD ]------------------------------------------
#
'L_FORUM_TOPICTYPES' => $lang['Forum_topictypes'],
#
#-----[ FIND ]------------------------------------------
#
$sql = "INSERT INTO " . FORUMS_TABLE . " (forum_id, forum_name, cat_id, forum_desc, forum_order, forum_status, prune_enable" . $field_sql . ")
VALUES ('" . $next_id . "', '" . str_replace("\'", "''", $HTTP_POST_VARS['forumname']) . "', " . intval($HTTP_POST_VARS[POST_CAT_URL]) . ", '" . str_replace("\'", "''", $HTTP_POST_VARS['forumdesc']) . "', $next_order, " . intval($HTTP_POST_VARS['forumstatus']) . ", " . intval($HTTP_POST_VARS['prune_enable']) . $value_sql . ")";
#
#-----[ IN-LINE FIND ]------------------------------------------
#
prune_enable
#
#-----[ IN-LINE, AFTER, ADD ]------------------------------------------
#
, forum_topictypes
#
#-----[ IN-LINE FIND ]------------------------------------------
#
$value_sql
#
#-----[ IN-LINE BEFORE, ADD ]------------------------------------------
#
",'".str_replace("\'", "''", $HTTP_POST_VARS['topictypes'])."'".
#
#-----[ FIND ]------------------------------------------
#
$sql = "UPDATE " . FORUMS_TABLE . "
SET forum_name = '" . str_replace("\'", "''", $HTTP_POST_VARS['forumname']) . "', cat_id = " . intval($HTTP_POST_VARS[POST_CAT_URL]) . ", forum_desc = '" . str_replace("\'", "''", $HTTP_POST_VARS['forumdesc']) . "', forum_status = " . intval($HTTP_POST_VARS['forumstatus']) . ", prune_enable = " . intval($HTTP_POST_VARS['prune_enable']) . "
WHERE forum_id = " . intval($HTTP_POST_VARS[POST_FORUM_URL]);
#
#-----[ IN-LINE FIND ]------------------------------------------
#
prune_enable = " . intval($HTTP_POST_VARS['prune_enable']) . "
#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#
,forum_topictypes = '".str_replace("\'", "''", $HTTP_POST_VARS['topictypes'])."'
#
#-----[ OPEN ]------------------------------------------
#
template/你的風格/posting_body.tpl
#
#-----[ FIND ]------------------------------------------
#
<!-- END switch_privmsg -->
\n<tr>
<td class="row1" width="22%"><span class="gen"><b>{L_SUBJECT}</b></span></td>
<td class="row2" width="78%"> <span class="gen">
#
#-----[ AFTER, ADD ]------------------------------------------
#
<!-- TopicTypes Mod -->
<!-- BEGIN switch_topictypes -->
<select onchange="document.post.subject.focus(); document.post.subject.value = this.options[this.selectedIndex].value + document.post.subject.value;">
<option selected value="">{L_TOPIC_TYPES_EXPLAIN}</option>
{TOPIC_TYPES}
</select>
<!-- END switch_topictypes -->
<!-- End Mod -->
#
#-----[ OPEN ]------------------------------------------
#
template/你的風格/viewforum_body.tpl
#
#-----[ FIND ]------------------------------------------
#
<table border="0" cellpadding="4" cellspacing="1" width="100%" class="forumline">
#
#-----[ BEFORE, ADD ]------------------------------------------
#
{TYPES}
#
#-----[ OPEN ]------------------------------------------
#
template/你的風格/admin/forum_edit_body.tpl
#
#-----[ FIND ]------------------------------------------
#
<tr>
<td class="row1">{L_FORUM_NAME}</td>
<td class="row2"><input type="text" size="25" name="forumname" value="{FORUM_NAME}" class="post" /></td>
</tr>
#
#-----[ AFTER, ADD ]------------------------------------------
#
<tr>
<td class="row1">{L_FORUM_TOPICTYPES}</td>
<td class="row2"><input type="text" size="45" name="topictypes" value="{S_FORUM_TOPICTYPES}" class="post" /></td>
</tr>
#
#-----[ OPEN ]------------------------------------------
#
language/你的語言/lang_admin.php
#
#-----[ FIND ]------------------------------------------
#
//
// That's all Folks!
#
#-----[ BEFORE, ADD ]------------------------------------------
#
$lang['Forum_topictypes'] = '這個版面的主題類型';
#
#-----[ OPEN ]------------------------------------------
#
language/你的語言/lang_main.php
#
#-----[ FIND ]------------------------------------------
#
//
// That's all Folks!
#
#-----[ BEFORE, ADD ]------------------------------------------
#
$lang['topic_types_explain'] = '主題類型';
$lang['All_Topics'] = '所有主題';
###############EOM 存檔結束##############