]>
git.p6c8.net - selfforum.git/blob - selfforum-cgi/shared/Arc/Test.pm
6851912d315370a10445523448906b928965e148
3 ################################################################################
5 # File: shared/Arc/Test.pm #
7 # Authors: Andre Malo <nd@o3media.de>, 2001-04-27 #
9 # Description: check on obsolete threads #
11 ################################################################################
15 ################################################################################
19 use base
qw(Exporter);
20 @Arc::Test
::EXPORT
= qw(get_obsolete_threads);
22 ### sub get_obsolete_threads ($) ###############################################
24 # check forum main file on obsolete threads
26 # Params: $param - hash reference
27 # (parsedThreads, adminDefault)
29 # Return: array reference containing the obsolete thread numbers
32 sub get_obsolete_threads
($) {
35 my $thread_count = keys %{$param->{parsedThreads
}};
37 my ($msg_count, $main_size, $tid, %tinfo) = (0, 0);
38 for $tid (keys %{$param->{parsedThreads
}}) {
39 my $num = @
{$param->{parsedThreads
}->{$tid}};
42 my ($age, $size) = (0, 0);
43 for (@
{$param->{parsedThreads
}->{$tid}}) {
44 $age = ($age > $_->{time}) ?
$age : $_->{time};
48 + length ($_->{subject
});
50 $size += $num * 190 + 30; # we guess a little bit ;-)
62 if ($param -> {adminDefault
} -> {Severance
} -> {severance
} eq 'instant') {
63 $sev_opt = $param -> {adminDefault
} -> {Instant
} -> {Severance
};
66 $sev_opt = $param -> {adminDefault
} -> {Severance
};
70 if ($sev_opt->{severance
} eq 'asymmetrical') {
71 @sorted = sort {$tinfo{$a}->{age
} <=> $tinfo{$b}->{age
}} keys %tinfo;
74 @sorted = sort {$a <=> $b} keys %tinfo;
81 if ($sev_opt -> {afterByte
}) {
82 while ($main_size > $sev_opt -> {afterByte
}) {
83 $main_size -= $tinfo{$sorted[$obsolete]}->{size
};
84 $msg_count -= $tinfo{$sorted[$obsolete]}->{num
};
94 if ($sev_opt -> {afterMessage
}) {
95 while ($msg_count > $sev_opt -> {afterMessage
}) {
96 $msg_count -= $tinfo{$sorted[$obsolete]}->{num
};
106 $obsolete += $thread_count - $sev_opt -> {afterThread
}
107 if ($sev_opt -> {afterThread
} and $thread_count > $sev_opt -> {afterThread
});
110 [sort {$a <=> $b} splice @sorted => 0, $obsolete];
118 ### end of Arc::Test ###########################################################
patrick-canterino.de