X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fmisc%2Fqueue.cgi;h=5dee29b88741db78c2f3bca840f17ddf381cead0;hp=7370aabe15bc9432b98f6217692206a4d08b5932;hb=11bbf29de447fe39e9d7155fe280a0df70fa8c3c;hpb=c8cccb4a92adceb943c635fe62dad0d034462ce0 diff --git a/httemplate/misc/queue.cgi b/httemplate/misc/queue.cgi index 7370aabe1..5dee29b88 100644 --- a/httemplate/misc/queue.cgi +++ b/httemplate/misc/queue.cgi @@ -1,48 +1,49 @@ -% -% -%$cgi->param('action') =~ /^(new|del|(retry|remove) selected)$/ -% or die "Illegal action"; -%my $action = $1; -% -%my $job; -%if ( $action eq 'new' || $action eq 'del' ) { -% $cgi->param('jobnum') =~ /^(\d+)$/ or die "Illegal jobnum"; -% my $jobnum = $1; -% $job = qsearchs('queue', { 'jobnum' => $1 }) -% or die "unknown jobnum $jobnum - ". -% "it probably completed normally or was removed by another user"; -%} -% -%if ( $action eq 'new' ) { -% my %hash = $job->hash; -% $hash{'status'} = 'new'; -% $hash{'statustext'} = ''; -% my $new = new FS::queue \%hash; -% my $error = $new->replace($job); -% die $error if $error; -%} elsif ( $action eq 'del' ) { -% my $error = $job->delete; -% die $error if $error; -%} elsif ( $action =~ /^(retry|remove) selected$/ ) { -% foreach my $jobnum ( -% map { /^jobnum(\d+)$/; $1; } grep /^jobnum\d+$/, $cgi->param -% ) { -% my $job = qsearchs('queue', { 'jobnum' => $jobnum }); -% if ( $action eq 'retry selected' && $job ) { #new -% my %hash = $job->hash; -% $hash{'status'} = 'new'; -% $hash{'statustext'} = ''; -% my $new = new FS::queue \%hash; -% my $error = $new->replace($job); -% die $error if $error; -% } elsif ( $action eq 'remove selected' && $job ) { #del -% my $error = $job->delete; -% die $error if $error; -% } -% } -%} -% -%print $cgi->redirect(popurl(2). "search/queue.html"); -% -% +<% $cgi->redirect(popurl(2). "search/queue.html") %> +<%init> +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Job queue'); + +$cgi->param('action') =~ /^(new|del|(retry|remove) selected)$/ + or die "Illegal action"; +my $action = $1; + +my $job; +if ( $action eq 'new' || $action eq 'del' ) { + $cgi->param('jobnum') =~ /^(\d+)$/ or die "Illegal jobnum"; + my $jobnum = $1; + $job = qsearchs('queue', { 'jobnum' => $1 }) + or die "unknown jobnum $jobnum - ". + "it probably completed normally or was removed by another user"; +} + +if ( $action eq 'new' ) { + my %hash = $job->hash; + $hash{'status'} = 'new'; + $hash{'statustext'} = ''; + my $new = new FS::queue \%hash; + my $error = $new->replace($job); + die $error if $error; +} elsif ( $action eq 'del' ) { + my $error = $job->delete; + die $error if $error; +} elsif ( $action =~ /^(retry|remove) selected$/ ) { + foreach my $jobnum ( + map { /^jobnum(\d+)$/; $1; } grep /^jobnum\d+$/, $cgi->param + ) { + my $job = qsearchs('queue', { 'jobnum' => $jobnum }); + if ( $action eq 'retry selected' && $job ) { #new + my %hash = $job->hash; + $hash{'status'} = 'new'; + $hash{'statustext'} = ''; + my $new = new FS::queue \%hash; + my $error = $new->replace($job); + die $error if $error; + } elsif ( $action eq 'remove selected' && $job ) { #del + my $error = $job->delete; + die $error if $error; + } + } +} + +