As I said before, one thing my mods were asking from this tool, was the ability to copy selected posts to a new thread in a specified forum. Some times, they want to edit a post, but their instructions is always to keep evidence of the original post, for dispute resolution. They usually do that, by making a copy of the thread in a specific forum. But this gets stupid, if you want to edit one post in a 200 posts thread.
So I came up with an addition to this hack, which is similar to split, but doesn't remove the original posts from the original thread, it just creates a new thread with the selected posts, in a selected forum, without touching the originals. In addition, you can select if you want to end up in the new thread's forum, or return to where you were originally (so that you can edit the original post).
For those interested, here is what you need to do, to add this functionality to this hack:
1. Open inlinemod.php and find:
PHP Code:
// -------------------------------------------------------------------
default:
print_no_permission();
break;
}
}
// ###################################################################
// Thread moderation
Right above that, add:
PHP Code:
// -------------------------------------------------------------------
case 'copy':
if (!$vars['thread']['visible'] OR !$vars['thread']['visible'])
{
eval(print_standard_error('error_invalidid'));
}
if (!is_array($vars['posts']))
{
eval(print_standard_error('error_nosplitposts'));
}
if (!can_moderate($vars['thread']['forumid'], 'canmanagethreads'))
{
print_no_permission();
}
// Make sure that we've specified the split options
if (empty($_POST['do']))
{
$curforumid = $vars['thread']['forumid'];
$moveforumbits = construct_move_forums_options();
define('PRINT_TPL', 'inline_copy');
}
else
{
// Get the scoop on this new forum
$vars['newforum'] = verify_id('forum', intval($_POST['newforumid']));
$vars['newforuminfo'] = fetch_foruminfo($vars['newforum']);
if (!$vars['newforuminfo']['cancontainthreads'] OR $vars['newforuminfo']['link'])
{
eval(print_standard_error('error_moveillegalforum'));
}
// Construct notes
$vars['newnotes'] = sprintf('Thread split from threadid %1$s by %2$s on %3$s at %4$s via Moderation Tool.', $vars['threadid'], $bbuserinfo['username'], vbdate($vboptions['dateformat'], TIMENOW), vbdate($vboptions['timeformat'], TIMENOW));
$vars['newnotes'] .= ' ' . $vars['thread']['notes'];
// Create the new thread
$DB_site->query("
INSERT INTO " . TABLE_PREFIX . "thread
(
title,
lastpost,
forumid,
open,
replycount,
postusername,
postuserid,
lastposter,
dateline,
views,
iconid,
notes,
visible
)
VALUES
(
'" . addslashes(htmlspecialchars_uni($_POST['title'])) . "',
" . intval($vars['thread']['lastpost']) . ",
" . intval($vars['newforum']) . ",
" . intval($vars['thread']['open']) . ",
" . intval($vars['thread']['replycount']) . ",
'" . addslashes($vars['thread']['postusername']) . "',
" . intval($vars['thread']['postuserid']) . ",
'" . addslashes($vars['thread']['lastposter']) . "',
" . intval($vars['thread']['dateline']) . ",
0,
" . intval($vars['thread']['iconid']) . ",
'" . addslashes($vars['newnotes']) . "',
" . intval($vars['thread']['visible']) . "
)"
);
$vars['newthreadid'] = $DB_site->insert_id();
foreach($vars['posts'] as $postnumber)
{
$posts=$DB_site->query("SELECT * FROM " . TABLE_PREFIX . "post WHERE postid=$postnumber");
$pst=$DB_site->fetch_array($posts);
$DB_site->query("
INSERT INTO " . TABLE_PREFIX . "post
(
threadid,
parentid,
username,
userid,
title,
dateline,
pagetext,
allowsmilie,
showsignature,
ipaddress,
iconid,
visible,
attach,
warn_flag
)
VALUES
(
" . intval($vars[newthreadid]) . ",
" . intval($pst['parentid']) . ",
'" . addslashes($pst['username']) . "',
" . intval($pst['userid']) . ",
'" . addslashes($pst['title']) . "',
" . intval($pst['dateline']) . ",
'" . addslashes($pst['pagetext']) . "',
" . intval($pst['allowsmilie']) . ",
" . intval($pst['showsignature']) . ",
'" . addslashes($pst['ipaddress']) . "',
" . intval($pst['iconid']) . ",
" . intval($pst['visible']) . ",
" . intval($pst['attach']) . ",
" . intval($pst['warn_flag']) . "
)"
);
}
// Update counters
// #*# things like rebuild search index can go here (maybe, depeneds on MySQL fulltext imp), post count problems from switching post-counted to not (vv) forum(?)
build_thread_counters($vars['threadid']);
build_thread_counters($vars['newthreadid']);
build_forum_counters($vars['thread']['forumid']);
if ($vars['thread']['forumid'] != $vars['newforum'])
{
build_forum_counters($vars['newforum']);
}
log_moderator_action($vars['thread'], sprintf('thread copied to %1$s (inline copy)', $vars['newthreadid']));
// Done! w00t!
toss_cookies();
if ($_POST['destination']=='old')
{
$url = "showthread.php?$session[sessionurl]t=$vars[threadid]&mod=1";
}
else
{
$url = "showthread.php?$session[sessionurl]t=$vars[newthreadid]&mod=1";
}
eval(print_standard_redirect('redirect_copyposts'));
}
break;
Then create a new template called inline_copy, which shall contain the followings:
HTML Code:
<form action="inlinemod.php" method="post" name="vbform">
<input type="hidden" name="s" value="$session[sessionhash]" />
<input type="hidden" name="do" value="doproces" />
<input type="hidden" name="type" value="post" />
<input type="hidden" name="inlinemodact" value="copy" />
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
<td class="tcat">$vbphrase[copy_thread]</td>
</tr>
<!--
<tr>
<td class="thead">$vbphrase[title]: <span style="font-weight:normal">{$vars['thread']['title']}</span></td>
</tr>
-->
<tr>
<td class="panelsurround" align="center">
<div class="panel">
<div style="width:$stylevar[formwidth]" align="$stylevar[left]">
<fieldset class="fieldset">
<legend>Specify new copy thread details</legend>
<table cellpadding="0" cellspacing="$stylevar[formspacer]" border="0">
<tr>
<td>The selected post(s) will be copied into a new thread in the forum you will specify.<br>You may select the new thread title and in which forum it will be created.<p>
New thread $vbphrase[title] (old thread title shown):<br />
<input type="text" class="bginput" name="title" size="50" value="{$vars['thread']['title']}"/>
</td>
</tr>
<tr>
<td>
New thread $vbphrase[forum]:<br />
<select name="newforumid">$moveforumbits</select>
</td>
</tr>
<tr>
<td>
Where you want to go after the copy:<br />
<select name="destination"><option value="old">Where I was before</option><option value="new">Where the new thread will be created</option></select>
</td>
</tr>
</table>
</fieldset>
</div>
</div>
<div style="margin-top:$stylevar[cellpadding]px">
<input type="submit" class="button" value="$vbphrase[copy_thread]" accesskey="s" />
<input type="reset" class="button" value="$vbphrase[reset_fields]" accesskey="r" />
<input type="button" class="button" value="$vbphrase[cancel]" accesskey="c" onclick="history.back(1)" />
</div>
</td>
</tr>
</table>
</form>
Then open your SHOWTHREAD template and find:
HTML Code:
<select name="inlinemodact">
<option value="merge" selected="selected">Merge Posts</option>
<option value="delete">Soft Delete Posts</option>
<option value="split">Split Posts</option>
Right below that, add :
HTML Code:
<option value="copy">Copy Posts</option>
Finally add a phrase:
Type : Front-end redirect messages
Name: copyposts
Contents: The selected posts have been copied to a new thread, in the forum you specified.
You may want to run this query, to change an existing phrase, so that it can be used in copying as well as in splitting:
update phrase set text='You must specify some posts to split/copy from this thread.' where varname='nosplitposts'
I think this is it, I hope I am not forgetting anything.