<& /Admin/Elements/Header, Title => loc("Admin FormTools Groups") &> <& /Elements/Tabs &> <& /Elements/ListActions, actions => \@results &> <&| /Widgets/TitleBox, title => '', class => 'container formtools-admin-select' &>
% my $i = 0; % for my $group ( @groups ) { % ++$i; % }
<&|/l&>Name <&|/l&>Description <&|/l&>Enabled
<% $group->{name} %> <% $group->{description} |n %>
{disabled} ? '' : 'checked="checked"' %> />
/>
<%init> my @results; my $groups = RT::Attributes->new( $session{'CurrentUser'} ); $groups->Limit( FIELD => 'Name', VALUE => 'FormTools Group' ); my @unsorted_groups; if ( $Submit ) { while ( my $group = $groups->Next ) { my $id = $group->Id; my $content = $group->Content; my $name = $group->Description; my $changed; if ( $ARGS{"enable-form-group-$id"} ) { if ( $content->{disabled} ) { $content->{disabled} = 0; $changed = 1; } } else { if ( !$content->{disabled} ) { $content->{disabled} = 1; $changed = 1; } } if ( $changed ) { my ( $ret, $msg ) = $group->SetContent($content); if ($ret) { if ( $content->{disabled} ) { push @results, loc('Disabled [_1]', $name); } else { push @results, loc('Enabled [_1]', $name); } } else { if ( $content->{disabled} ) { push @results, loc( "Couldn't disable [_1]: [_2]", $name, $msg ); } else { push @results, loc( "Couldn't enable [_1]: [_2]", $name, $msg ); } } } } } if ( @results ) { MaybeRedirectForResults( Actions => \@results, Path => '/Admin/FormTools/Groups/index.html', Arguments => { FindDisabledFormGroups => $FindDisabledFormGroups }, ); } while ( my $group = $groups->Next ) { my $content = $group->Content; next if ! $FindDisabledFormGroups && $content->{disabled}; push @unsorted_groups, { id => $group->id, name => $group->Description, description => $content->{description}, disabled => $content->{disabled}, }; } my @groups = sort { lc $a->{name} cmp lc $b->{name} } @unsorted_groups; $m->callback( CallbackName => 'Initial', FormsRef => \@groups, ARGSRef => \%ARGS ); <%args> $Submit => undef $FindDisabledFormGroups => undef