[MOD] 分割合并主题外挂

PHPBB2.0.X资源收集专用版,提问和建议请发到主版面
Locked
User avatar
土老耄
技术组成员
技术组成员
Posts: 1441
Joined: 2006-11-18 8:17

[MOD] 分割合并主题外挂

Post by 土老耄 » 2007-05-17 10:34

若版主/管理员想分割一个文章的回帖并且想立即合并到另外一个主题上。这个就是你想要的东西了。

官方介绍及下载:点这里

Code: Select all

############################################################## 
## MOD Title:		Split posts and merge in one step
## MOD Author: asinshesq < N/A > (Alan) N/A
## MOD Description:	Allow admin to split posts from a topic (using the regular split feature) and merge them
##			into an existing topic in a single step
##
## MOD Version:		1.0.3a
## 
## Installation Level:	Easy
## Installation Time:	5 Minutes ( 1 minute with easymod) 
##
## Files To Edit:	modcp.php
##			language/lang_english/lang_main.php
##			templates/subSilver/modcp_split.tpl
##
## Included Files:	n/a
##
## License:		http://opensource.org/licenses/gpl-license.php GNU General Public License v2
##
##############################################################
## For security purposes, please check: http://www.phpbb.com/mods/
## for the latest version of this MOD. Although MODs are checked
## before being allowed in the MODs Database there is no guarantee
## that there are no security problems within the MOD. No support
## will be given for MODs not found within the MODs Database which
## can be found at http://www.phpbb.com/mods/
############################################################## 
## Author Notes:	n/a
############################################################## 
## MOD History:
##
##  2006-5-20	- Version 1.0.3a
##		 no changes...just repacked to be validated against phpbb2.0.20
##
##  2005-5-06	- Version 1.0.3
##		 added an intval to protect against injection risk
##
##  2005-4-09	- Version 1.0.2
##		 a few more changes in textual instructions to ensure that the instructions don't wrap on monitors 
##		 with resolutions lower than 1280 accross 
##
##  2005-4-09	- Version 1.0.1
##		 a few changes in textual instructions suggested by mistakeprone (no change in functionality) 
##
##  2005-4-08	- Version 1.0.0
##		 initial version
##
############################################################## 
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
##############################################################
lang_main.php的中文翻译,如果大家不介意俺的翻译烂...下面就是... :oops:

Code: Select all

// start mod split posts and merge in one step
$lang['If_title_blank'] = '<br />(请提供新贴的主题; 若此栏目留空的话则将会与下列所显示的主题合并)';
$lang['Destination_topic'] = '合并至';
$lang['Destination_topic_format'] = '<br />(若合并至现有的主题,插入该主题ID或链接)';
// end mod split posts and merge in one step

User avatar
土老耄
技术组成员
技术组成员
Posts: 1441
Joined: 2006-11-18 8:17

Post by 土老耄 » 2007-05-17 10:40

newerby针对phpbbXS_build20070411版本的改动
newerby wrote:已经装上了,这个功能不错。要在 phpBBXS_build20070411 里使用要注意一下 Cache 的处理,在原有的代码里:

Code: Select all

					$template->assign_vars(array(
						'META' => '<meta http-equiv="refresh" content="3;url=' . "viewtopic.$phpEx?" . POST_TOPIC_URL . "=$destination_topic_id&sid=" . $userdata['session_id'] . '">')
					);

					$message = $lang['Topic_split'] . '<br /><br />' . sprintf($lang['Click_return_topic'], '<a href="' . "viewtopic.$phpEx?" . POST_TOPIC_URL . "=$destination_topic_id&sid=" . $userdata['session_id'] . '">', '</a>');
					message_die(GENERAL_MESSAGE, $message);
				}
			}
			// end mod split posts and merge in one step
message_die(GENERAL_MESSAGE, $message); 之后加上

Code: Select all

					$db->clear_cache('posts_');

否则分割合并帖子后刷新并不立刻显示出效果。
原帖子在下面
http://www.phpbbchina.com/forum/viewtopic.php?p=3212

大家请放心安装。若有问题请找newerby算账....嘻嘻嘻嘻! :lol:

newerby
论坛管理员
论坛管理员
Posts: 1293
Joined: 2006-11-10 2:20

Post by newerby » 2007-05-17 11:22

但在树型模式下查看主题列表和帖子里的更新依然有问题,这个还是请老大来解决好了。 :?
土老耄 wrote: 原帖子在下面
http://www.phpbbchina.com/forum/viewtopic.php?p=3212

大家请放心安装。若有问题请找newerby算账....嘻嘻嘻嘻! :lol:

User avatar
土老耄
技术组成员
技术组成员
Posts: 1441
Joined: 2006-11-18 8:17

Post by 土老耄 » 2007-05-17 12:23

俺装了在俺的测试论坛上。直接装的下载的那个,没有装你说的那些。测试也没有问题啊!

http://demo.web4chinese.com/xs070411

版主:土老耄
登陆:password

你来试试?

不过刚才发现了一个很有意思的东西就是....

俺分割了昨天的帖子之后,分割成功了,但在昨天今天的外挂上显示“今天” 但发贴的日子还是昨天。。。哈哈哈! :D

newerby
论坛管理员
论坛管理员
Posts: 1293
Joined: 2006-11-10 2:20

Post by newerby » 2007-05-17 12:44

我已经在你那里试看了,确实有更新显示不正常的问题。

我在那里发了两个主题帖子,分别为 test Tree UP 和 test Tree D,跟帖的内容开头分别是 UP1、UP2和D1、D2。我现在已经执行了把 D2 回帖分割合并到 test Tree UP 主题的动作,你分别在树型和平板模式下看就知道问题了。 :(

User avatar
土老耄
技术组成员
技术组成员
Posts: 1441
Joined: 2006-11-18 8:17

Post by 土老耄 » 2007-05-17 13:58

newerby wrote:我已经在你那里试看了,确实有更新显示不正常的问题。

我在那里发了两个主题帖子,分别为 test Tree UP 和 test Tree D,跟帖的内容开头分别是 UP1、UP2和D1、D2。我现在已经执行了把 D2 回帖分割合并到 test Tree UP 主题的动作,你分别在树型和平板模式下看就知道问题了。 :(
嗯。终于看到了。D2在平板论坛上的显示是在UP1上面(也就是2楼) 但在树型论坛里面D2却消失了!

然后...俺再试着分割...然后合并...结果分着分着...然后合着合着....出现了这个情况!


Could not find children post for Threaded View.

DEBUG MODE

SQL Error : 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY p.post_time ASC' at line 6

SELECT p.post_id FROM 070411_posts p, 070411_posts p2 WHERE p.topic_id = 35 AND p.parent_id = p2.post_id AND p2.post_id = ORDER BY p.post_time ASC

Line : 1520
File : functions.php

靠!

俺不再研究了,先将俺的xs070411样板论坛还原再说! :?

newerby
论坛管理员
论坛管理员
Posts: 1293
Joined: 2006-11-10 2:20

Post by newerby » 2007-05-18 10:23

那得等 IOsetting 老大来查看是什么原因了,因为涉及到了树型部分。    :cry:

User avatar
IOsetting
论坛管理员
论坛管理员
Posts: 3647
Joined: 2006-10-17 1:48

Post by IOsetting » 2007-05-24 10:12

MOD中需要修改的部分:
打开MOD文档, 找到

Code: Select all

// now, get forum id for destination topic
$sql = "SELECT forum_id
FROM " . TOPICS_TABLE . "
替换为

Code: Select all

// now, get forum id for destination topic
$sql = "SELECT forum_id, topic_first_post_id
FROM " . TOPICS_TABLE . "
找到

Code: Select all

$destination_forum_id = $row['forum_id'];
在后面添加

Code: Select all

$destination_parent_id = $row['topic_first_post_id'];
找到

Code: Select all

$sql = 	"UPDATE " . POSTS_TABLE . "
SET topic_id = $destination_topic_id, forum_id = $destination_forum_id
替换为

Code: Select all

$sql = 	"UPDATE " . POSTS_TABLE . "
SET topic_id = $destination_topic_id, forum_id = $destination_forum_id, parent_id = $destination_parent_id
... 二位帮我测试一下吧 :)

:oops: 不好意思中间漏了一行很重要的代码, 现在已经补上. 重新编一个树形主题测试一下, 谢谢
Last edited by IOsetting on 2007-05-24 23:14, edited 1 time in total.

User avatar
土老耄
技术组成员
技术组成员
Posts: 1441
Joined: 2006-11-18 8:17

Post by 土老耄 » 2007-05-24 12:36

首先在树型论坛模式发主贴和跟贴如图一

Image

测试一(单独分割)
将1...5...1 即:viewtopic.php?p=132切割,然后另外加上新主题“1...5...1及以下回帖分割”
点击分割按钮后显示“选择的文章已经成功地分割”,查看本主题,1...5...1已经不在1...5的帖
子下了,然后再查看viewforum,发现新主题“1...5...1及以下回帖分割”以及它的跟贴。

Image

分割成功!



测试二(分割同时作合并)
将1...3...1即:viewtopic.php?p=137切割,然后在新主题栏目中“1...3...1 under 1...4”
Destination topic中放入:http://demo.web4chinese.com/xs070411/vi ... .php?p=117
然后点击分割按钮后显示“选择的文章已经成功地分割”...查看viewforum发现分割成功但是没有
合并到1...4下,

Image

分割成功但合并失败!


测试三 (强行合并)

选择主题“1...3...1 under 1...4”后什么都不选,然后强行在Destination topic中放入:
http://demo.web4chinese.com/xs070411/vi ... .php?p=117 然后点击分割按钮...

出现
Could not find children post for Threaded View.

DEBUG MODE

SQL Error : 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY p.post_time ASC' at line 6

SELECT p.post_id FROM 070411_posts p, 070411_posts p2 WHERE p.topic_id = 42 AND p.parent_id = p2.post_id AND p2.post_id = ORDER BY p.post_time ASC

Line : 1520
File : functions.php
强行合并失败

不知道上面的操作,尤其是将切割帖子之后合并时的连接viewtopic.php?p=xxx这个有没有用错。
曾经用过viewtopic.p=xxx&t=yy,尝试合并到主贴低下,但出现下面的错误
Could not update posts table

DEBUG MODE

SQL Error : 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE post_id IN (139, 139)' at line 3

UPDATE 070411_posts SET topic_id = 41, forum_id = 1, parent_id = WHERE post_id IN (139, 139)

Line : 1037
File : modcp.php

User avatar
IOsetting
论坛管理员
论坛管理员
Posts: 3647
Joined: 2006-10-17 1:48

Post by IOsetting » 2007-05-24 23:15

前面的修改漏了些东西, 老土再帮忙试试吧 :)

newerby
论坛管理员
论坛管理员
Posts: 1293
Joined: 2006-11-10 2:20

Post by newerby » 2007-05-25 9:22

修改了还是有些不大对劲的地方,回头再说一下测试细节。 :?

User avatar
土老耄
技术组成员
技术组成员
Posts: 1441
Joined: 2006-11-18 8:17

Post by 土老耄 » 2007-05-25 13:17

匆忙的用树型论坛试了一下:

将主题"1...5...3" 切割后合并在 "1...3...1 under 1...4" 下面。

在1...5...3 viewtopic 的显示下如图:

Image

在1...3...1 under 1...4 viewtopic 的显示下如图:

Image

似乎在树型的viewtopic中成功了....


但是在树型的viewforum的显示却是:

Image

转到平板模式的viewtopic中也没有显示1...5...3的跟贴。另外,用平板模式在1...5...1的主题下,也看不到1...5...3的内容了。
newerby wrote:修改了还是有些不大对劲的地方,回头再说一下测试细节。 :?
不知道newerby还有没有其他的补充?

Locked