fixed "randomness" to only include CS's that are not empty. Returning an random CS that was empty would throw an error.

This commit is contained in:
Frank Dillon 2006-09-07 20:47:13 +00:00
parent adb099dcea
commit 71d6a3bd28

View file

@ -93,6 +93,23 @@ sub process {
$session->errorHandler->warn('Error: no Collaboration Systems found with current parameters. Check parameters of macro on page '.$session->asset->get('url'));
return '';
}
#Trim off any CS's that have no threads
my @llist = ();
foreach my $csid (@{$lineage}) {
my $cs = undef;
# Get random thread in that CS:
$cs = WebGUI::Asset->new($session,$csid,'WebGUI::Asset::Wobject::Collaboration');
my $threads = $cs->getLineage(['children'],{includeOnlyClasses => ['WebGUI::Asset::Post::Thread']});
push(@llist,$csid) if (scalar(@{$threads}) > 0);
}
$lineage = \@llist;
unless ( scalar(@{$lineage}) ) {
$session->errorHandler->warn('Error: no Collaboration Systems found have any threads to display.'.$session->asset->get('url'));
return '';
}
# Try to get a random thread that the user can see:
my $randomThread = _getRandomThread($session, $lineage);