%# The right half of the brain controls the left half of the body. This %# means that only left handed people are in their right mind. <& /Edit/Elements/PopHeader &>
<& /Edit/Elements/ListButtons &>
<&|/l&>Groups:
  <&|/l&>Create:
<& /Edit/Elements/PopFooter &> <%INIT> my $Object = $RT::System; my $List = $session{GroupRightList}; my $OffList = $session{GroupRightOffList}; if ($Queue) { $Object = RT::Queue->new($session{'CurrentUser'}); $Object->Load($Queue) || Abort(loc("Couldn't load queue [_1]",$Queue)); } elsif ($Group) { $Object = RT::Group->new($session{'CurrentUser'}); $Object->Load($Group) || Abort(loc("Couldn't load group [_1]",$Group)); } elsif ($Report) { require RTx::Report; $Object = RTx::Report->new($session{'CurrentUser'}); $Object->Load($Report) || Abort(loc("Couldn't load group [_1]",$Report)); } elsif (length($Report)) { require RTx::Reports; $Object = $RTx::Reports; } if ($Action eq 'Add') { @$OffList = grep { my $id = $_->Id; my $ok = (grep { $_ == $id } @Off); push @$List, $_ if $ok; !$ok; } @$OffList; } elsif ($Action eq 'AddAll') { push @$List, @$OffList; @$OffList = (); } elsif ($Action eq 'Delete') { @$List = grep { my $id = $_->Id; my $ok = (grep { $_ == $id } @On); push @$OffList, $_ if $ok; !$ok; } @$List; } elsif ($Action eq 'DeleteAll') { push @$OffList, @$List; @$List = (); } elsif ($Action eq 'Commit') { # two-phase: first, clean all people's right in OffList # next, add at least rudimentary rights to List. my $right = ( ($Object == $RT::System) ? 'ModifySelf' : (ref($Object) =~ /Queue/) ? 'SeeQueue' : (ref($Object) =~ /Report/) ? 'SeeReport' : 'AdminGroup' ); foreach my $item (@$OffList) { my $ACLObj = RT::ACL->new($session{'CurrentUser'}); $ACLObj->LimitToObject( $Object ); $ACLObj->LimitToPrincipal( Id => $item->PrincipalId ); foreach my $ace (@{$ACLObj->ItemsArrayRef}) { $ace->Delete; } } foreach my $item (@$List) { my $ace = RT::ACE->new( $session{CurrentUser} ); $ace->Create( RightName => $right, Object => $Object, PrincipalType => 'Group', PrincipalId => $item->PrincipalId, ); } $m->print(""); $m->abort; } @$OffList = ( map { $_->[0] } sort { $a->[1] cmp $b->[1] } map { [ $_ => $_->Name ] } @$OffList ); @$List = ( map { $_->[0] } sort { $a->[1] cmp $b->[1] } map { [ $_ => $_->Name ] } grep { $_->Name } @$List ); $session{GroupRightList} = $List; $session{GroupRightOffList} = $OffList; <%ARGS> $Show => '' $Queue => 0 $Group => 0 $Report => undef $Action => '' $Begin => 0 @On => () @Off => ()