Add a new method called getAllGroupsFor, which recursively returns ALL groups

that a group belongs to.  This is required to properly uncache group settings
for groups with more than 2 levels of hierarchy.

Add 7 tests to verify the working of the new method.

Fix a typo in the POD for Operation/Group.pm
This commit is contained in:
Colin Kuskie 2006-05-26 16:43:47 +00:00
parent 174e3df9ef
commit 7100d1df41
3 changed files with 31 additions and 4 deletions

View file

@ -211,14 +211,14 @@ sub autoDelete {
=head2 clearCaches ( )
Clears caches for this group.
Clears all caches for this group and any ancestor groups of the group.
=cut
sub clearCaches {
my $self = shift;
##Clear my cache and the cache of all groups above me.
my $groups = $self->getGroupsFor();
my $groups = $self->getAllGroupsFor();
foreach my $group ( $self->getId, @{ $groups } ) {
WebGUI::Cache->new($self->session, $group)->delete;
}
@ -615,6 +615,25 @@ sub get {
#-------------------------------------------------------------------
=head2 getAllGroupsFor ( )
Returns an array reference containing a list of all groups this group is in, recursively.
=cut
sub getAllGroupsFor {
my $self = shift;
my $groups = $self->getGroupsFor();
foreach my $gid (@{ $groups }) {
push @{ $groups }, @{ WebGUI::Group->new($self->session, $gid)->getAllGroupsFor() };
}
my %unique = map { $_ => 1 } @{ $groups };
$groups = [ keys %unique ];
return $groups;
}
#-------------------------------------------------------------------
=head2 getGroupsFor ( )

View file

@ -238,7 +238,7 @@ sub www_deleteGroupGrouping {
Deletes a set of users from a set of groups. Only Admins may perform this function.
The user and group lists are expected to
be found in form fields names uid and gid, respectively. Visitors are not allowed to
perform this operation, and the
perform this operation.
=cut