]>
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 ################################################################################
19 ################################################################################
27 sub VERSION
{(q
$Revision$ =~ /([\d.]+)\s*$/)[0] or '0.0'}
29 ################################################################################
33 use base
qw(Exporter);
34 @EXPORT = qw(get_obsolete_threads);
36 ### sub get_obsolete_threads ($) ###############################################
38 # check forum main file on obsolete threads
40 # Params: $param - hash reference
41 # (parsedThreads, adminDefault)
43 # Return: array reference containing the obsolete thread numbers
46 sub get_obsolete_threads
($) {
49 my $thread_count = keys %{$param->{parsedThreads
}};
51 my ($msg_count, $main_size, $tid, %tinfo) = (0, 0);
52 for $tid (keys %{$param->{parsedThreads
}}) {
53 my $num = @
{$param->{parsedThreads
}->{$tid}};
56 my ($age, $size) = (0, 0);
57 for (@
{$param->{parsedThreads
}->{$tid}}) {
58 $age = ($age > $_->{time}) ?
$age : $_->{time};
62 + length ($_->{subject
});
64 $size += $num * 190 + 30; # we guess a little bit ;-)
76 if ($param -> {adminDefault
} -> {Severance
} -> {severance
} eq 'instant') {
77 $sev_opt = $param -> {adminDefault
} -> {Instant
} -> {Severance
};
80 $sev_opt = $param -> {adminDefault
} -> {Severance
};
84 if ($sev_opt->{severance
} eq 'asymmetrical') {
85 @sorted = sort {$tinfo{$a}->{age
} <=> $tinfo{$b}->{age
}} keys %tinfo;
88 @sorted = sort {$a <=> $b} keys %tinfo;
95 if ($sev_opt -> {afterByte
}) {
96 while ($main_size > $sev_opt -> {afterByte
}) {
97 $main_size -= $tinfo{$sorted[$obsolete]}->{size
};
98 $msg_count -= $tinfo{$sorted[$obsolete]}->{num
};
108 if ($sev_opt -> {afterMessage
}) {
109 while ($msg_count > $sev_opt -> {afterMessage
}) {
110 $msg_count -= $tinfo{$sorted[$obsolete]}->{num
};
120 $obsolete += $thread_count - $sev_opt -> {afterThread
}
121 if ($sev_opt -> {afterThread
} and $thread_count > $sev_opt -> {afterThread
});
124 [sort {$a <=> $b} splice @sorted => 0, $obsolete];
127 # keep 'require' happy
132 ### end of Arc::Test ###########################################################
patrick-canterino.de