<%doc> Modify the settings of a filter rule group, or create a new one. \ <%ARGS> $id => undef $Create => undef $Name => undef $SetEnabled => undef $Enabled => undef $Delete => undef $ConfirmDelete => undef \ <%INIT> unless ( $session{'CurrentUser'} ->HasRight( Object => $RT::System, Right => 'SuperUser' ) ) { Abort( loc('This feature is only available to system administrators.') ); } my ( $Title, @Results, $Disabled, $EnabledChecked ); my $Object = RT::FilterRuleGroup->new( $session{'CurrentUser'} ); $Object->Load($id) if ( $id && $id ne 'new' ); @Results = (); if ( $Delete && not $ConfirmDelete ) { push @Results, loc('Not deleted - confirmation box not checked'); } elsif ( $Delete && $ConfirmDelete ) { my ( $ok, $msg ) = $Object->Delete(); push @Results, $msg; if ($ok) { $Create = 1; $id = 'new'; delete $ARGS{'id'}; $Object = RT::FilterRuleGroup->new( $session{'CurrentUser'} ); } } if ($SetEnabled) { $Disabled = $ARGS{'Disabled'} = $Enabled ? 0 : 1; } $EnabledChecked = 'checked="checked"'; if ( not $Create ) { if ( defined $id && $id eq 'new' ) { my ( $ok, $msg ) = $Object->Create( Name => $Name, Disabled => $Disabled ); if ( not $ok ) { $Create = 1; # Create failed, so bring us back to step 1 } push @Results, $msg; } else { $Object->Load($id) || $Object->Load($Name) || Abort( loc( "Couldn't load filter rule group '[_1]'", $Name ) ); } } if ( $Object->id && not $Create ) { $Title = loc( 'Configuration for filter rule group [_1]', $Object->Name ); my @Attributes = qw(Name CanMatchQueues CanTransferQueues CanUseGroups Disabled); foreach my $ListAttribute ( 'CanMatchQueues', 'CanTransferQueues', 'CanUseGroups' ) { my @ValueList = $Object->$ListAttribute; if ( $ARGS{ 'Add' . $ListAttribute } ) { push @ValueList, $ARGS{ 'Add' . $ListAttribute } if ( not grep { $_ eq $ARGS{ 'Add' . $ListAttribute } } @ValueList ); } if ( $ARGS{ 'Remove' . $ListAttribute } ) { foreach my $Value ( @{ ref $ARGS{ 'Remove' . $ListAttribute } ? $ARGS{ 'Remove' . $ListAttribute } : [ $ARGS{ 'Remove' . $ListAttribute } ] } ) { @ValueList = grep { $_ ne $Value } @ValueList; } } $ARGS{$ListAttribute} = join( ',', @ValueList ); } push @Results, UpdateRecordObject( AttributesRef => \@Attributes, Object => $Object, ARGSRef => \%ARGS ); $Disabled = $ARGS{'Disabled'} = $Enabled ? 0 : 1; $EnabledChecked = "" if $Object->Disabled; } else { $Title = loc('Create a filter rule group'); } # This code does automatic redirection if any updates happen. MaybeRedirectForResults( Actions => \@Results, Arguments => { id => $Object->id }, ) if $Object->id; \ <& /Admin/Elements/Header, Title => $Title &> <& /Elements/Tabs &> <& /Elements/ListActions, actions => \@Results &>

\ \ \ % if (not $Create) { \ \ \ \ \ \ \ \ \ % } \ \ \
<&|/l&>Name:
<&|/l&>Queues to allow in match rules:<& /Elements/SelectObject, ObjectType => 'Queue', CheckRight => 'SeeQueue', ShowAll => 1, Name => 'AddCanMatchQueues' &>\ \ % my ($Collection, $Count); % $Collection = $Object->CanMatchQueuesObj; % $Count = 0; % while (my $Item = $Collection->Next) { % $Count++;
% } % if ($Count > 0) {

<&|/l&>(Check box to delete)

\ % }
<&|/l&>Queues to allow as transfer destinations:<& /Elements/SelectObject, ObjectType => 'Queue', CheckRight => 'SeeQueue', ShowAll => 1, Name => 'AddCanTransferQueues' &>\ \ % $Collection = $Object->CanTransferQueuesObj; % $Count = 0; % while (my $Item = $Collection->Next) { % $Count++;
% } % if ($Count > 0) {

<&|/l&>(Check box to delete)

\ % }
<&|/l&>Groups to allow in rule actions:\ \ % $Collection = $Object->CanUseGroupsObj; % $Count = 0; % while (my $Item = $Collection->Next) { % $Count++;
% } % if ($Count > 0) {

<&|/l&>(Check box to delete)

\ % }
/>
\ \

\ % if ( $Create ) { <& /Elements/Submit, Label => loc('Create') &> % } else { <& /Elements/Submit, Label => loc('Save Changes') &> % }
% if ( not $Create ) {

<&|/l&>Check this box to confirm
% }