]>
git.p6c8.net - selfforum.git/blob - selfforum-cgi/shared/Arc/Test.pm
aacc92eec7be63e73706f0383e6424ebf21bbbb3
3 ################################################################################
5 # File: shared/Arc/Test.pm #
7 # Authors: Andre Malo <nd@o3media.de>, 2001-04-27 #
9 # Description: check on obsolete threads #
11 ################################################################################
19 ################################################################################
23 $VERSION = do { my @r =(q
$Revision$ =~ /\d+/g); sprintf "%d."."%02d" x
$#r, @r };
25 ################################################################################
29 use base
qw(Exporter);
30 @EXPORT = qw(get_obsolete_threads);
32 ### sub get_obsolete_threads ($) ###############################################
34 # check forum main file on obsolete threads
36 # Params: $param - hash reference
37 # (parsedThreads, adminDefault)
39 # Return: array reference containing the obsolete thread numbers
42 sub get_obsolete_threads
($) {
45 my $thread_count = keys %{$param->{parsedThreads
}};
47 my ($msg_count, $main_size, $tid, %tinfo) = (0, 0);
48 for $tid (keys %{$param->{parsedThreads
}}) {
49 my $num = @
{$param->{parsedThreads
}->{$tid}};
52 my ($age, $size) = (0, 0);
53 for (@
{$param->{parsedThreads
}->{$tid}}) {
54 $age = ($age > $_->{time}) ?
$age : $_->{time};
58 + length ($_->{subject
});
60 $size += $num * 190 + 30; # we guess a little bit ;-)
72 if ($param -> {adminDefault
} -> {Severance
} -> {severance
} eq 'instant') {
73 $sev_opt = $param -> {adminDefault
} -> {Instant
} -> {Severance
};
76 $sev_opt = $param -> {adminDefault
} -> {Severance
};
80 if ($sev_opt->{severance
} eq 'asymmetrical') {
81 @sorted = sort {$tinfo{$a}->{age
} <=> $tinfo{$b}->{age
}} keys %tinfo;
84 @sorted = sort {$a <=> $b} keys %tinfo;
91 if ($sev_opt -> {afterByte
}) {
92 while ($main_size > $sev_opt -> {afterByte
}) {
93 $main_size -= $tinfo{$sorted[$obsolete]}->{size
};
94 $msg_count -= $tinfo{$sorted[$obsolete]}->{num
};
104 if ($sev_opt -> {afterMessage
}) {
105 while ($msg_count > $sev_opt -> {afterMessage
}) {
106 $msg_count -= $tinfo{$sorted[$obsolete]}->{num
};
116 $obsolete += $thread_count - $sev_opt -> {afterThread
}
117 if ($sev_opt -> {afterThread
} and $thread_count > $sev_opt -> {afterThread
});
120 [sort {$a <=> $b} splice @sorted => 0, $obsolete];
123 # keep 'require' happy
128 ### end of Arc::Test ###########################################################
patrick-canterino.de