1 頁 (共 1 頁)

[整理外掛] 垃圾桶外掛(BBC修改->會員回收功能) FOR PLUS 1.5.3

發表於 : 2006-09-09 23:22
chadav
這個外掛可以讓管理者快速將不適當的主題及文章直接丟到設定好的垃圾文章收集區內, 並在丟到回收區的同時可以針對該文章作說明, 這樣方便以後管理!!

參考來源: http://phpbb-tw.net/phpbb/viewtopic.php?t=43767

檔案下載: http://bbc.sytes.net/mods/trashcan_mod_bbc_120.zip


1. 請先下載原始的壓縮檔, 解開後把裡面的 root\templates\subsilver\images 目錄 COPY 到你的每一個佈景主題下
2. 再來以下的 CODE 已經由本人修改調整成給 PLUS 1.5.3 專用, 使用其它版本 phpBB 的請自行比較更改!!

代碼: 選擇全部

############################################################## 
## 外掛名稱: 垃圾桶外掛BBC加強版
## 外掛版本: 1.2.0 
## 外掛作者: HentaiBBC
##
## 原外掛: 垃圾桶外掛<1.0.2>
## 作者: Martinet Oaf < oafwork@hotmail.com >
## 
## 安裝難度: 簡單 
## 安裝時間: 5 分鐘 
## 
## 需要編輯的檔案: 9
## viewforum.php
## viewtopic.php
## admin/admin_board.php
## language/lang_chinese_traditional_taiwan/lang_admin.php
## language/lang_chinese_traditional_taiwan/lang_main.php 
## templates/subSilver/subSilver.cfg
## templates/subSilver/viewforum_body.tpl
## templates/subSilver/viewtopic_body.tpl
## templates/subSilver/admin/board_config_body.tpl
## 
## 附加的檔案: root/trashcan.php
## 
## 附加的圖示: root/templates/subSilver/images/icon_trash.gif
##             root/templates/subSilver/images/topic_trash.gif 
## 
############################################################## 
## 版本修改資訊:
##
## 1.0.0 功能改變部份: 1.發表主題的人,可以對回覆的文章進行回收,但不可回收管理層級會員的文章
##                     2.後台可設定哪些版面可以進行回收
##                     3.設定為垃圾桶的版面,會自動被設定為「鎖定」
##                     4.只有版主或系管可以回收主題
##
## 1.1.0 功能變更: 1.後台增加了模式選擇, 完整模式是可以回收回文的, 主題模式是只能回收主題.
##                 2.不再使用控制台頁, 改用新寫一個頁面的方面(安全性上的考量)
##
## 1.2.0 功能新增: 1.新增回收原因功能(後台有可設定是否強制輸入)
##       BUG修正:  1.版面可同時設為具回收功能的版面與垃圾桶版面
##
## PS. 1.0.0版的修改中有BUG存在, 所以不會再公佈在網路上了.
##
############################################################## 
## 在增加此外掛前, 請務必備份所有需要修改的檔案 
############################################################## 

STEP 1:
將root資料夾中的檔案複製至對應位置

##############################################################

STEP 2:
#
#-----[ SQL ]------------------------------
#
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ('trashcan_id', '-1');
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ('trashcan_forums', '');
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ('trashcan_type', '1');
INSERT INTO `phpbb_config` ( `config_name` , `config_value` ) VALUES ('trash_reason_must', '1');
ALTER TABLE `phpbb_topics` ADD `topic_trash_reason` VARCHAR( 255 ) NOT NULL;

##############################################################

STEP 3:
編輯檔案


#
#-----[ OPEN ]-----------------------------
#
viewforum.php

includes\functions_topics_list.php

#
#-----[ FIND ]-----------------------------
#
		$topic_title = ( count($orig_word) ) ? preg_replace($orig_word, $replacement_word, $topic_rowset[$i]['topic_title']) : $topic_rowset[$i]['topic_title'];

#
#-----[ AFTER, ADD ]-----------------------
#
		//trashcan_mod
		$trash_reason = ( $topic_rowset[$i]['topic_trash_reason'] != '' && $forum_id == $board_config['trashcan_id'] ) ? '<br /><span class="gensmall">' . $lang['trash_reason'] . '&nbsp;<font color="red">' . $topic_rowset[$i]['topic_trash_reason'] . '</font></span>' : '';
		//trashcan_mod

#
#-----[ FIND ]-----------------------------
#
			'TOPIC_TITLE' => $topic_title,

#
#-----[ AFTER, ADD ]-----------------------
#
			//trashcan_mod
			'TOPIC_TRASH_REASON' => $trash_reason,
			//trashcan_mod

#
#-----[ OPEN ]-----------------------------
#
viewtopic.php

#
#-----[ FIND ]-----------------------------
#
$sql = "SELECT t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, t.topic_type, t.topic_vote, t.topic_last_post_id, f.forum_name, f.forum_status, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_edit, f.auth_delete, f.auth_sticky, f.auth_announce, f.auth_pollcreate, f.auth_vote, f.auth_attachments" . $count_sql . "

#
#-----[ IN-LINE, FIND ]--------------------
#
t.topic_last_post_id

#
#-----[ IN-LINE AFTER, ADD ]---------------
#
, t.topic_poster, t.topic_first_post_id

#
#-----[ FIND ]-----------------------------
#
$sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_regdate, u.user_msnm, u.user_viewemail, u.user_rank, u.user_sig, u.user_sig_bbcode_uid, u.user_avatar, u.user_avatar_type, u.user_allowavatar, u.user_allowsmile, p.*,  pt.post_text, pt.post_subject, pt.bbcode_uid

#
#-----[ IN-LINE, FIND ]--------------------
#
u.user_id

#
#-----[ IN-LINE AFTER, ADD ]---------------
#
, u.user_level

#
#-----[ FIND ]-----------------------------
#
if ( $is_auth['auth_mod'] )

#
#-----[ BEFORE, ADD ]-----------------------
#
	//Martinet Trashcan Mod
	if( $board_config['trashcan_id'] != -1 && $forum_id != $board_config['trashcan_id'] )
	{
		if( $is_auth['auth_mod'] || ($userdata['user_id'] == $forum_topic_data['topic_poster'] && in_array($forum_id, explode(',', $board_config['trashcan_forums']))) )
		{
			$topic_mod .= "<a href=\"trashcan.$phpEx?mode=trash&type=topic&" . POST_TOPIC_URL . "=$topic_id&sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_mod_trashcan'] . '" alt="' . $lang['Trash_topic'] . '" title="' . $lang['Trash_topic'] . '" border="0" /></a>&nbsp;&nbsp;';
		}
	}
	//Martinet Trashcan Mod End

#
#-----[ FIND ]------------------------------
#
	if ( $is_auth['auth_mod'] )

#
#-----[ BEFORE, ADD ]-----------------------
#
	//Martinet Trashcan Mod
	$trash_img ='';
	if( $board_config['trashcan_id'] != -1 && $forum_id != $board_config['trashcan_id'] )
	{
		if( $is_auth['auth_mod'] || ($userdata['user_id'] == $forum_topic_data['topic_poster'] && $postrow[$i]['user_level'] < 1 && in_array($forum_id, explode(',', $board_config['trashcan_forums']))) )
		{
			if( $board_config['trashcan_type'] && $postrow[$i]['post_id'] != $forum_topic_data['topic_first_post_id'] )
			{
				$temp_url = "trashcan.$phpEx?mode=trash&type=post&" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&" . POST_FORUM_URL . "=" . $forum_id . "&sid=" . $userdata['session_id'];				
				$trash_img = '<a href="' . $temp_url .'"><img src="' . $images['icon_trash'] .'" alt="' . $lang['MARTINET_TRASHCAN_THROW'] . '" title="' . $lang['MARTINET_TRASHCAN_THROW'] . '" border="0" /></a>';
			}
			else if ( !$board_config['trashcan_type'] && $postrow[$i]['post_id'] == $forum_topic_data['topic_first_post_id'])
			{
				$temp_url = "trashcan.$phpEx?mode=trash&" . POST_TOPIC_URL . "=$topic_id&sid=" . $userdata['session_id'];				
				$trash_img = '<a href="' . $temp_url .'"><img src="' . $images['icon_trash'] .'" alt="' . $lang['Trash_topic'] . '" title="' . $lang['Trash_topic'] . '" border="0" /></a>';
			}
		}
	}
	//Martinet Trashcan Mod End

#
#-----[ FIND ]------------------------------
#
		'DELETE' => $delpost,

#
#-----[ AFTER, ADD ]------------------------
#
		//Martinet Trashcan Mod
		'TRASH_IMG'=>$trash_img,
		//Martinet Trashcan Mod End

#
#-----[ OPEN ]------------------------------
#
admin/admin_board.php

#
#-----[ FINE ]------------------------------
#
		if( isset($_POST['submit']) )
		{

#
#-----[ BEFORE, ADD ]------------------------
#
		//Martinet Trashcan Mod
		if( $config_name == 'trashcan_forums' )
		{
			$new[$config_name] = ( isset($_POST[$config_name]) ) ? implode(',', $_POST[$config_name]) : $default_config[$config_name];
		}
		if( isset($_POST['submit']) && $config_name == 'trashcan_id' )
		{
			if( $default_config[$config_name] != -1 )
			{
				$forum_id = $default_config[$config_name];
				$sql = "UPDATE " . FORUMS_TABLE . " SET forum_status = " . FORUM_UNLOCKED . " WHERE forum_id = $forum_id";
				$db->sql_query($sql);
			}
			
			$forum_id = $_POST[$config_name];
			if( $forum_id != -1 )
			{
				//1.2.0
				if( in_array($forum_id, $_POST['trashcan_forums']) )
				{
					message_die(GENERAL_MESSAGE, $lang['Repeat_select']);
				}
				//1.2.0

				$sql = "UPDATE " . FORUMS_TABLE . " SET forum_status = " . FORUM_LOCKED . " WHERE forum_id = $forum_id";
				$db->sql_query($sql);
			}
		}
		//Martinet Trashcan Mod End

#
#-----[ FINE ]------------------------------
#
$smtp_no = ( !$new['smtp_delivery'] ) ? "checked=\"checked\"" : "";

#
#-----[ AFTER, ADD ]------------------------
#
//Martinet Trashcan Mod
$trashcan_type1 = ( $new['trashcan_type'] ) ? "checked=\"checked\"" : "";
$trashcan_type2 = ( !$new['trashcan_type'] ) ? "checked=\"checked\"" : "";
$trash_reason_must_yes = ( $new['trash_reason_must'] ) ? "checked=\"checked\"" : "";//1.2.0
$trash_reason_must_no = !( $new['trash_reason_must'] ) ? "checked=\"checked\"" : "";//1.2.0
$sql = "SELECT forum_id ,forum_name  FROM " . FORUMS_TABLE ;
if(!$result = $db->sql_query($sql))
        message_die(CRITICAL_ERROR ,"Failed quering Forums table", "", __LINE__, __FILE__, $sql);
$trashcan_select = '<select name="trashcan_id" class="post"><option value="-1">'.$lang['MARTINET_TRASHCAN_DISABLE'];
while($f = $db->sql_fetchrow($result))
{
        $selected = '';
        if($f['forum_id'] == $new['trashcan_id'])
                $selected = 'selected';
        $trashcan_select .= '<option value="'.$f['forum_id'].'" '.$selected.' >'.$f['forum_name'];
}
$trashcan_select .= '</select>';

$trashcan_forums = explode(',', $new['trashcan_forums']);
$trashcan_forum_option = '';
$sql = "SELECT c.cat_id, c.cat_title, c.cat_order
	FROM " . CATEGORIES_TABLE . " c 
	ORDER BY c.cat_order";
if( !($result = $db->sql_query($sql)) )
{
	message_die(GENERAL_ERROR, 'Could not query categories list', '', __LINE__, __FILE__, $sql);
}
$cat_row = $db->sql_fetchrowset($result);
$cat_rownum = $db->sql_numrows($result);
$db->sql_freeresult($result);
for($i=0;$i<$cat_rownum;$i++)
{
	$trashcan_forum_option .= '<option value=""></option>';
	$trashcan_forum_option .= '<option value="">' . $cat_row[$i]['cat_title'] . '</option>';
	$trashcan_forum_option .= '<option value="">--------------------</option>';
	
	$sql = "SELECT * FROM " . FORUMS_TABLE . " WHERE cat_id = " . $cat_row[$i]['cat_id'] . " ORDER BY forum_order";
	$result = $db->sql_query($sql);
	while($row = $db->sql_fetchrow($result) )
	{
		$trashcan_forum_option .= '<option value="' . $row['forum_id'] . '" ' . ( (in_array($row['forum_id'], $trashcan_forums)) ? 'selected="selected"' : '' ) . '>' . $row['forum_name'] . '</option>';	
	}
}
//Martinet Trashcan Mod End

#
#-----[ FINE ]------------------------------
#
	"L_FLOOD_INTERVAL" => $lang['Flood_Interval'],

#
#-----[ BEFORE, ADD ]-----------------------
#
	//Martinet Trashcan Mod
	"L_TRASHCAN_MOD" => $lang['trashcan_mod'],
	"L_TRASHCAN_FORUMS" => $lang['trashcan_forums'],
	"L_TRASHCAN_ID" => $lang['trashcan_id'],
	"L_TRASHCAN_ID_EXPLAIN" => $lang['trashcan_id_explain'],
	"TRASHCAN_ID" => $trashcan_select,
	"TRASHCAN_FORUMS" => $trashcan_forum_option,
	"L_TRASHCAN_MOD_TYPE" => $lang['trashcan_mod_type'],
	"L_FULL_MOD" => $lang['Full_mod'],
	"L_TOPIC_MOD" => $lang['Topic_mod'],
	"FULL_MOD" => $trashcan_type1,
	"TOPIC_MOD" => $trashcan_type2,
	"L_TRASH_REASON" => $lang['Trash_reason_must'],
	"REASON_YES" => $trash_reason_must_yes,
	"REASON_NO" => $trash_reason_must_no,
	//Martinet Trashcan Mod End

#
#-----[ OPEN ]------------------------------
#
language/lang_chinese_traditional_taiwan/lang_admin.php

#
#-----[ FIND ]------------------------------
#
//
// That's all Folks!

#
#-----[ BEFORE, ADD ]-----------------------
#
//Martinet Trashcan Mod
$lang['trashcan_mod'] = '垃圾桶功能';
$lang['trashcan_mod_explain'] = '選擇你允許的垃圾桶功能版面<br />並選擇要開啟該功能的版面,使用 [CTRL + 滑鼠] 點選版區,指定的版區將讓會員在瀏覽主題時即擁有此功能。';
$lang['trashcan_id'] = '選擇做為垃圾桶的版面';
$lang['trashcan_forums'] = '選擇具有此功能的版面';
$lang['MARTINET_TRASHCAN_DISABLE'] = '停用垃圾桶版面';
$lang['trashcan_mod_type'] = '垃圾桶功能模式選擇';
$lang['Full_mod'] = '完整模式';
$lang['Topic_mod'] = '主題回收模式';
//1.2.0
$lang['Trash_reason_must'] = '強制輸入回收原因';
$lang['Repeat_select'] = '回收功能版面不可包含垃圾桶版面';
//Martinet Trashcan Mod End

#
#-----[ OPEN ]------------------------------
#
language/lang_chinese_traditional_taiwan/lang_main.php

#
#-----[ FIND ]------------------------------
#
//
// That's all Folks!

#
#-----[ BEFORE, ADD ]-----------------------
#
//Martinet Trashcan Mod
$lang['MARTINET_TRASHCAN_CANNOTFINDFORUM'] = "無法找到指定的垃圾桶版面,請通知系統管理員修改垃圾桶 ID 至正確版面位置";
$lang['MARTINET_TRASHCAN_CONFIRMTRASH'] = "你確定要把這個主題丟到垃圾桶裡嗎?";
$lang['MARTINET_TRASHCAN_CONFIRMTRASH_POST'] = "你確定要把這篇文章丟到垃圾桶裡嗎?";
$lang['MARTINET_TRASHCAN_THROW'] = "丟到垃圾(違規)文章集中區";
$lang['Trash_topic'] = '回收主題';
$lang['MARTINET_TRASHCAN_CANCEL'] = "取消";
$lang['MARTINET_trash_from'] = "[違規]本文章是從<%s>分割出來的";
$lang['Cannot_trash'] = '你沒有回收這篇文章的權力';
$lang['Cannot_trash_topic'] = '你沒有回收這篇主題的權力';
$lang['Cannot_trash_in_forum'] = '該文章所屬版面沒有會員回收功能';
$lang['Cannot_trash_topic_in_forum'] = '該主題所屬版面沒有會員回收功能';
$lang['Topics_trashed'] = '選擇的主題已被回收';
$lang['No_Topics_trashed'] = '沒有主題被回收';
$lang['Post_trashed'] = '選擇的文章已被回收';
//1.2.0
$lang['trash_topic_title'] = '[違規主題]%s, 回收人:%s';
$lang['trash_reason'] = '回收原因:';
$lang['trash_reson_default'] = '常用原因:';
$lang['No_any_trash_reason'] = '必須輸入回收原因';
//以下為預設原因, 使用方式如下所示, 請自行依1,2,3,...的順序增加, trash_0那一項請不要做變更
$lang['trash_0'] = '請選擇';
$lang['trash_1'] = '無意義灌水文';
$lang['trash_2'] = '內容違反版規';
$lang['trash_3'] = '人身攻擊文章';
//Martinet Trashcan Mod End

#
#-----[ OPEN ]------------------------------
#
templates/fisubSilver/fisubSilver.cfg

#
#-----[ FIND ]------------------------------
#
$images['voting_graphic'][4] = "$current_template_images/voting_bar.gif";

#
#-----[ AFTER, ADD ]------------------------
#
//Martinet Trashcan Mod
$images['icon_trash'] = "$current_template_images/icon_trash.gif";
$images['topic_mod_trashcan'] = "$current_template_images/topic_trash.gif";
//Martinet Trashcan Mod End

#
#-----[ OPEN ]------------------------------
#

templates/fisubSilver/topics_list_box.tpl

#
#-----[ FIND ]------------------------------
#
<!-- END switch_topic_desc -->

#
#-----[ IN-LINE FIND ]---------------------
#
-->

#
#-----[ IN-LINE AFTER, ADD ]----------------
#
<span class="topictitle">{topics_list_box.row.TOPIC_TRASH_REASON}</span>

#
#-----[ OPEN ]------------------------------
#
templates/fisubSilver/viewtopic_body.tpl

#
#-----[ FIND ]------------------------------
#
{postrow.DELETE_IMG}

#
#-----[ IN-LINE BEFORE, ADD ]---------------
#
 {postrow.TRASH_IMG}

#
#-----[ OPEN ]------------------------------
#
templates/fisubSilver/admin/board_config_body.tpl

#
#-----[ FIND ]------------------------------
#
<tr> 
<td class="row1">{L_FLOOD_INTERVAL} <br />

#
#-----[ BEFORE, ADD ]-----------------------
#
<!-- Martinet Trashcan Mod -->
<tr>
<td class="row1">{L_TRASHCAN_MOD}<br /><span class="gensmall">{L_TRASHCAN_ID_EXPLAIN}</span></td>
<td class="row2"><span class="gen">{L_TRASHCAN_ID}<br />{TRASHCAN_ID}<br /><br />
{L_TRASHCAN_FORUMS}<br /><select name="trashcan_forums[]" multiple="multiple" size="10">{TRASHCAN_FORUMS}</select><br /><br />
{L_TRASHCAN_MOD_TYPE}<br /><input type="radio"  name="trashcan_type" value="1" {FULL_MOD} />{L_FULL_MOD}&nbsp;&nbsp;<input type="radio"  name="trashcan_type" value="0" {TOPIC_MOD} />{L_TOPIC_MOD}
<br /><br />
{L_TRASH_REASON}<input type="radio"  name="trash_reason_must" value="1" {REASON_YES} />{L_YES}&nbsp;&nbsp;<input type="radio"  name="trashcan_type" value="0" {REASON_NO} />{L_NO}
</span></td>
</tr>
<!-- Martinet Trashcan Mod -->

#
#-----[ SAVE/CLOSE ALL FILES ]---------------
#
#EoM