Up coverage of addGroups to 100%.
Change tabs to spaces in group diagrams. Optimize the addGroups membership check so the expensive getGroupsIn doesn't have to take place. Add a label to the foreach.
This commit is contained in:
parent
1b3d7f0c2b
commit
8b84ae3e76
2 changed files with 32 additions and 29 deletions
|
|
@ -124,15 +124,15 @@ sub addGroups {
|
|||
my $self = shift;
|
||||
my $groups = shift;
|
||||
WebGUI::Cache->new($self->session, $self->getId)->delete;
|
||||
foreach my $gid (@{$groups}) {
|
||||
GROUP: foreach my $gid (@{$groups}) {
|
||||
next if ($gid eq '1');
|
||||
next if ($gid eq $self->getId);
|
||||
my ($isIn) = $self->session->db->quickArray("select count(*) from groupGroupings where groupId=? and inGroup=?", [$gid, $self->getId]);
|
||||
next GROUP if $isIn;
|
||||
my $group = WebGUI::Group->new($self->session, $gid);
|
||||
my $recursive = isIn($self->getId, @{$group->getGroupsIn(1)});
|
||||
unless ($isIn || $recursive) {
|
||||
$self->session->db->write("insert into groupGroupings (groupId,inGroup) values (?,?)",[$gid, $self->getId]);
|
||||
}
|
||||
next GROUP if $recursive;
|
||||
$self->session->db->write("insert into groupGroupings (groupId,inGroup) values (?,?)",[$gid, $self->getId]);
|
||||
}
|
||||
$self->clearCaches();
|
||||
return 1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue