From b6fce85c041b6694bed86b7c233e47e256e9b76b Mon Sep 17 00:00:00 2001 From: JT Smith Date: Sun, 2 May 2004 15:31:04 +0000 Subject: [PATCH] adding clarity --- lib/WebGUI/Grouping.pm | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/lib/WebGUI/Grouping.pm b/lib/WebGUI/Grouping.pm index f36503939..bd87697c1 100755 --- a/lib/WebGUI/Grouping.pm +++ b/lib/WebGUI/Grouping.pm @@ -256,23 +256,26 @@ A boolean value to determine whether the method should return the groups directl =cut + sub getGroupsInGroup { - return undef unless $_[0]; - my $groups = WebGUI::SQL->buildArrayRef("select groupId from groupGroupings where inGroup=$_[0]"); - if ($_[1]) { - my $loopCount = $_[2]++ || 1; - if ($loopCount > 99) { - WebGUI::ErrorHandler::fatalError("Endless recursive loop detected while determinating". - " groups in group.\nRequested groupId: ".$_[0]."\nGroups in that group: ".join(",",@$groups)); - } - my @groupsOfGroups = @$groups; - foreach my $group (@$groups) { - my $gog = getGroupsInGroup($group,1,$loopCount); - push(@groupsOfGroups, @$gog); - } - return \@groupsOfGroups; - } - return $groups; + my $groupId = shift; + my $isRecursive = shift; + my $loopCount = shift; + my $groups = WebGUI::SQL->buildArrayRef("select groupId from groupGroupings where inGroup=$groupId"); + if ($isRecursive) { + $loopCount++; + if ($loopCount > 99) { + WebGUI::ErrorHandler::fatalError("Endless recursive loop detected while determining". + " groups in group.\nRequested groupId: ".$groupId."\nGroups in that group: ".join(",",@$groups)); + } + my @groupsOfGroups = @$groups; + foreach my $group (@$groups) { + my $gog = getGroupsInGroup($group,1,$loopCount); + push(@groupsOfGroups, @$gog); + } + return \@groupsOfGroups; + } + return $groups; }