& /Admin/Elements/Header, Title => $title &> <& /Elements/Tabs &> <& /Elements/ListActions, actions => \@results &> <&| /Widgets/TitleBox, title => '', class => 'formtools-admin-description ms-auto me-auto' &>
<&|/l&>Forms are shown to users on a page in the RT Self Service interface. Below you can manage how the form details will appear to end users.&>
&> <%init> use Digest::MD5 'md5_hex'; # Handle id getting submitted twice and becoming an array my @id = ( ref $id eq 'ARRAY' ) ? @{$id} : ($id); $id = $id[0]; Abort("No form id found") unless $id; my $form_attribute = RT::Attribute->new($session{'CurrentUser'}); my ($ok, $msg) = $form_attribute->Load($id); unless ( $ok ) { Abort("Unable to load form with id $id"); } my $form = $form_attribute->Content; my ($title, @results); $title = loc("Description for form [_1]", $form_attribute->Description); if ( $ARGS{'SubmitDescription'} ) { Abort( loc('Permission Denied') ) unless $session{'CurrentUser'}->HasRight( Object => $RT::System, Right => 'AdminForm' ); if ( ( $form->{'form-description'} // '' ) ne $ARGS{'FormDescription'} ) { $form->{'form-description'} = $ARGS{'FormDescription'}; my ( $ret, $msg ) = $form_attribute->SetContent($form); if ($ret) { push @results, loc('Updated description'); } else { push @results, loc( "Could not update description: [_1]", $msg ); } } } my ($current_form_icon) = RT::Extension::FormTools::LoadFormIcon( $session{'CurrentUser'}, $form_attribute->Id ); if ( my $file_hash = _UploadedFile( 'FormUploadIcon' ) ) { my ($form_icon, $msg) = RT::Extension::FormTools::LoadFormIcon( $session{'CurrentUser'}, $form_attribute->Id ); if ( $form_icon ) { # Delete the existing icon my ( $del_ok, $del_msg ) = $form_icon->Delete; RT->Logger->error("Unable to delete icon attribute id $ok, $del_msg") unless $del_ok; } my $new_form_icon = RT::Attribute->new( $session{CurrentUser} ); ( $ok, $msg ) = $new_form_icon->Create( Name => "FormTools Icon", Description => "Icon for " . $form_attribute->Description, Object => $form_attribute, Content => { type => $file_hash->{ContentType}, data => $file_hash->{LargeContent}, hash => md5_hex($file_hash->{LargeContent}), }, ); push @results, loc("Unable to set form icon") unless $ok; RT->Logger->error("Unable to set form icon: $msg") unless $ok; } MaybeRedirectForResults( Actions => \@results, Arguments => { id => $id, FormDescription => $ARGS{'FormDescription'} }, ); %init> <%args> $id => undef %args>