% if ( keys %error ) { % foreach my $pkgpart (keys %error) { % # stuff all the errors back into $cgi % $cgi->param("error$pkgpart", $error{$pkgpart}); % } % my $session = int(rand(4294967296)); #XXX % my $pref = new FS::access_user_pref({ % 'usernum' => $FS::CurrentUser::CurrentUser->usernum, % 'prefname' => "redirect$session", % 'prefvalue' => $cgi->query_string, % 'expiration' => time + 3600, #1h? 1m? % }); % my $pref_error = $pref->insert; % if ( $pref_error ) { % die "FATAL: couldn't even set redirect cookie: $pref_error". % " attempting to set redirect$session to ". $cgi->query_string."\n"; % } <% $cgi->redirect($fsurl.'browse/part_pkg-fcc.html?redirect='.$session) %> % } else { <% $cgi->redirect($dest) %> % } <%init> my $curuser = $FS::CurrentUser::CurrentUser; my $edit_acl = $curuser->access_right('Edit FCC report configuration'); my $global_edit_acl = $curuser->access_right('Edit FCC report configuration for all agents'); die "access denied" unless $edit_acl or $global_edit_acl; # non-atomic; report errors but allow successful changes to go through # not that I even know how you'd get an error doing this my %error; foreach my $param ($cgi->param) { $param =~ /^pkgpart(\d+)$/ or next; my $pkgpart = $1; my $part_pkg = FS::part_pkg->by_key($pkgpart); my $hashref = decode_json( $cgi->param($param) ); my $error = $part_pkg->set_fcc_options($hashref); $error{$pkgpart} = $error if $error; } my $dest = $fsurl.'browse/part_pkg-fcc.html?'; foreach (qw(classnum maxrecords offset)) { if ( $cgi->param($_) =~ /^(\d+)$/ ) { $dest .= "$_=$1;"; } } if ( $cgi->param('jump') =~ /^pkgpart(\d+)$/ ) { $dest .= "#$1"; }