%# Earn cash in your spare time -- blackmail your friends <& /Edit/Elements/104Header, %ARGS, Focus => 'Name', Buttons => [ Add => "index.html?Action-Add=1", Save => "javascript:document.getElementById('mainform').submit()", Delete => 1, Copy => '', Search => '', ], Method => 'POST', Action => 'index.html', &>

<& $Tab, Text => 'Groups' &>
<& /Edit/Elements/Tabs, Name => 'Map2', Map => $ARGS{Map2}, URL => ($ARGS{URL} || '/Edit/Groups/Roles/') &>
<& Top, Item => $Item &>
<& List, Delete => 1, Item => $Item, List => $List, Begin => $Begin, ARGS => \%ARGS &>

<%INIT> my $List; my %Roles; my $Item = $RT::Nothing; if ($Group) { $Item = RT::Group->new($session{'CurrentUser'}); $Item->Load( $Group ); } if ($Action eq 'Save' and length($Name)) { if (!$Group) { $Item = RT::Group->new($session{'CurrentUser'}); $Item->CreateRoleGroup(Domain => 'RT::Group-Role', Type => 'Owner'); $Group = $Item->Id; } $Item->SetName($Name); $Item->UpdateCompany if $Item->can('UpdateCompany'); } elsif ($Action eq 'Delete') { foreach my $Id (@ListDelete) { my $item = RT::Group->new($session{'CurrentUser'}); $item->Load($Id); $item->SetDisabled(1); } $Item = $RT::Nothing; $Group = $Begin = 0; } elsif ($Action eq 'Add') { $Begin = 0; $Item = $RT::Nothing; $Item = RT::Group->new($session{'CurrentUser'}); $Item->CreateRoleGroup(Domain => 'RT::Group-Role', Type => 'Owner'); $Item->SetName('(new)'); $Group = $Item->Id; delete $ARGS{'Action-Add'}; } my $Groups = RT::Groups->new($session{'CurrentUser'}); $Groups->LimitToEnabled; $Groups->LimitToRolesForGroup(); $Groups->OrderBy( FIELD => 'Name' ); $List = $Groups->ItemsArrayRef; my $Role; <%ARGS> $Name => '' $Group => '' $Begin => 0 $Action => '' @ListDelete => () $Tab => '/Edit/Elements/Tab'