]>
git.p6c8.net - selfforum.git/blob - selfforum-cgi/shared/Arc/Test.pm
3 ################################################################################
5 # File: shared/Arc/Test.pm #
7 # Authors: André Malo <nd@o3media.de> #
9 # Description: check on obsolete threads #
11 ################################################################################
18 ################################################################################
26 sub VERSION
{(q
$Revision$ =~ /([\d.]+)\s*$/)[0] or '0.0'}
28 ################################################################################
32 use base
qw(Exporter);
33 @EXPORT = qw(get_obsolete_threads);
35 ### sub get_obsolete_threads ($) ###############################################
37 # check forum main file on obsolete threads
39 # Params: $param - hash reference
40 # (parsedThreads, adminDefault)
42 # Return: array reference containing the obsolete thread numbers
45 sub get_obsolete_threads
($) {
48 my $thread_count = keys %{$param->{parsedThreads
}};
50 my ($msg_count, $main_size, $tid, %tinfo) = (0, 0);
51 for $tid (keys %{$param->{parsedThreads
}}) {
52 my $num = @
{$param->{parsedThreads
}->{$tid}};
55 my ($age, $size) = (0, 0);
56 for (@
{$param->{parsedThreads
}->{$tid}}) {
57 $age = ($age > $_->{time}) ?
$age : $_->{time};
61 + length ($_->{subject
});
63 $size += $num * 190 + 30; # we guess a little bit ;-)
75 if ($param -> {adminDefault
} -> {Severance
} -> {severance
} eq 'instant') {
76 $sev_opt = $param -> {adminDefault
} -> {Instant
} -> {Severance
};
79 $sev_opt = $param -> {adminDefault
} -> {Severance
};
83 if ($sev_opt->{severance
} eq 'asymmetrical') {
84 @sorted = sort {$tinfo{$a}->{age
} <=> $tinfo{$b}->{age
}} keys %tinfo;
87 @sorted = sort {$a <=> $b} keys %tinfo;
94 if ($sev_opt -> {afterByte
}) {
95 while ($main_size > $sev_opt -> {afterByte
}) {
96 $main_size -= $tinfo{$sorted[$obsolete]}->{size
};
97 $msg_count -= $tinfo{$sorted[$obsolete]}->{num
};
107 if ($sev_opt -> {afterMessage
}) {
108 while ($msg_count > $sev_opt -> {afterMessage
}) {
109 $msg_count -= $tinfo{$sorted[$obsolete]}->{num
};
119 $obsolete += $thread_count - $sev_opt -> {afterThread
}
120 if ($sev_opt -> {afterThread
} and $thread_count > $sev_opt -> {afterThread
});
123 [sort {$a <=> $b} splice @sorted => 0, $obsolete];
126 # keep 'require' happy
131 ### end of Arc::Test ###########################################################
patrick-canterino.de