improved_move_threads.mod
1.0
Provides useful information to a user about where a thread was moved to and who it was moved by where the thread used to reside (with a link to the threads new location). Users no longer have to search the entire forum for their moved threads. Email notifications are also updated after a thread is moved.
DaveB
http://www.davesworldzone.com
Sources/MoveThread.pl
fopen(FILE, "$boardsdir/$currentboard.txt") || &fatal_error("$txt{'23'} $currentboard.txt");
@threads = ;
fclose(FILE);
fopen(FILE, "$datadir/$thread.txt") || &fatal_error("$txt{'23'} $thread.txt");
@messages = ;
fclose(FILE);
fopen(FILE, "$boardsdir/$currentboard.txt") || &fatal_error("$txt{'23'} $currentboard.txt");
@oldthreads = ;
fclose(FILE);
$threads[$yyThreadPosition] = '';
#$threads[$yyThreadPosition] = '';
fopen(FILE, ">$boardsdir/$currentboard.txt", 1) || &fatal_error("$txt{'23'} $currentboard.txt");
print FILE @threads;
fclose(FILE);
unless( $checknum ) {
unless( $checknum ) {
--$threadcount;
$messagecount -= $mobileposts;
if( $checknum == 1 ) {
$_ = $threads[1];
#--$threadcount;
$messagecount -= $mreplies;
if( $checknum == 1 ) {
$_ = $oldthreads[1];
&BoardCountSet( $currentboard, $threadcount, $messagecount, $lastposttime, $lastposter );
#######################################
## DaveB's Improved Move Mod v1.0 ##
#######################################
$newthreadid = time;
$i=0;
if (-e "$datadir/$newthreadid.txt") {
while (-e "$datadir/$newthreadid$i.txt") { ++$i; }
$newthreadid="$newthreadid$i";
}
fopen(FILE, "$boardsdir/$toboard.txt") || &fatal_error("209 $txt{'106'}: $txt{'23'} $boardsdir/$toboard.txt");
@boardlist = ;
fclose(FILE);
fopen(FILE, "$boardsdir/$currentboard.txt") || &fatal_error("$txt{'23'} $currentboard.txt");
@oldthreads2 = ;
fclose(FILE);
chomp $oldthreads2[$yyThreadPosition];
@newthreadinfo = split(/\|/, $oldthreads2[$yyThreadPosition]);
$newthreadinfo[0] = "$newthreadid";
$oldthreads2[$yyThreadPosition] = join("|", @newthreadinfo)."\n";
fopen(FILE, ">$boardsdir/$toboard.txt", 1) || &fatal_error("210 $txt{'106'}: $txt{'23'} $toboard.txt");
print FILE qq~$oldthreads2[$yyThreadPosition]~;
print FILE @boardlist;
fclose(FILE);
opendir (MMD,$datadir) || &fatal_error("$fatxt{'19'} $datadir!");
@files = readdir(MMD);
closedir(MMD);
foreach $files(@files) {
if ($files =~ /\A$thread\.(.+)/igo) {
fopen(FILE, "$datadir/$thread.$1");
@fileinfo = ;
fclose(FILE);
fopen(FILE, ">$datadir/$newthreadid.$1");
print FILE @fileinfo;
fclose(FILE);
if ($1 eq 'mail' && -e "$datadir/$thread.mail") { unlink("$datadir/$thread.mail"); }
}
}
fopen(FILE, "$boardsdir/$toboard.dat", 1) || &fatal_error("210 $txt{'106'}: $txt{'23'} $toboard.dat");
@toboardinfo = ;
fclose(FILE);
chomp $oldthreads[$yyThreadPosition];
chomp $toboardinfo[0];
@oldthreadlock = split(/\|/, $oldthreads[$yyThreadPosition]);
$oldthreadlock[1] = "Moved: ".$oldthreadlock[1]; #changes subject in message index to "Moved: Subject"
$oldthreadlock[8] = "1";
$oldthreadlock[5] = "0";
$oldthreads[$yyThreadPosition] = join("|", @oldthreadlock)."\n";
fopen(FILE, "$memberdir/$username.dat", 1) || &fatal_error("210 $txt{'106'}: $txt{'23'} $username.dat");
@userinfo = ;
fclose(FILE);
chomp $userinfo[1];
chomp $messages[0];
@movedthread = split(/\|/, $messages[0]);
$movedthread[8] = "This thread has been moved to [link=$scripturl?board=$toboard&action=display&num=$newthreadid&start=0]"."$toboardinfo[0]"."[/link] by $userinfo[1]";
$movedpost = join("|", @movedthread);
fopen(FILE, ">$boardsdir/$currentboard.txt", 1) || &fatal_error("210 $txt{'106'}: $txt{'23'} $currentboard.txt");
print FILE @oldthreads;
fclose(FILE);
fopen(FILE, ">$datadir/$thread.txt") || &fatal_error("$txt{'23'} $thread.txt");
print FILE "$movedpost\n";
fclose(FILE);
#######################################
## /DaveB's Improved Move Mod v1.0 ##
#######################################
$threads[$a] = "$yyThreadLine\n$threads[$a]";
&BoardCountSet( $toboard, $threadcount, $messagecount, $lastposttime, $lastposter );
fopen(FILE, ">$boardsdir/$toboard.txt", 1) || &fatal_error("$txt{'23'} $toboard.txt");
print FILE @threads;
fclose(FILE);
$threads[$a] = "$yyThreadLine\n$threads[$a]";
&BoardCountSet( $toboard, $threadcount, $messagecount, $lastposttime, $lastposter );
$yySetLocation = qq~$scripturl?board=$toboard&action=display&num=$thread&start=0~;
$yySetLocation = qq~$scripturl?board=$toboard&action=display&num=$newthreadid&start=0~;
Sources/Subs.pl
$message =~ s~\[url\]\s*(.+?)\s*\[/url\]~$1~isg;
$message =~ s~\[link\]www\.\s*(.+?)\s*\[/link\]~www.$1~isg;
$message =~ s~\[link=\s*(\w+\://.+?)\](.+?)\s*\[/link\]~$2~isg;
$message =~ s~\[link=\s*(.+?)\]\s*(.+?)\s*\[/link\]~$2~isg;
$message =~ s~\[link\]\s*(.+?)\s*\[/link\]~$1~isg;