summaryrefslogtreecommitdiff
path: root/httemplate/config
diff options
context:
space:
mode:
authorjeff <jeff>2010-06-23 08:37:46 +0000
committerjeff <jeff>2010-06-23 08:37:46 +0000
commit06d46a675063e8a299345c9a2313ac29b9025d74 (patch)
treea68d2e84e38a26835501390cfa8a27b6085f9b72 /httemplate/config
parent371fb0b94d70c2f0c783b68350ac13e4e94cb3b9 (diff)
add config variables to position invoice addresses in envelope windows RT8384
Diffstat (limited to 'httemplate/config')
-rw-r--r--httemplate/config/config-process.cgi41
1 files changed, 41 insertions, 0 deletions
diff --git a/httemplate/config/config-process.cgi b/httemplate/config/config-process.cgi
index 876c54c..c2b11b8 100644
--- a/httemplate/config/config-process.cgi
+++ b/httemplate/config/config-process.cgi
@@ -1,3 +1,30 @@
+%if ( scalar(@error) ) {
+%
+% my $url = popurl(1)."config.cgi";
+% if ( length($cgi->query_string) > 1920 ) { #stupid IE 2083 URL limit
+%
+% 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("$url?redirect=$session") %>
+%
+% } else {
+%
+<% $cgi->redirect("$url?". $cgi->query_string ) %>
+%
+% }
+%
+%} else {
<% header('Configuration set') %>
<SCRIPT TYPE="text/javascript">
% my $n = 0;
@@ -61,6 +88,7 @@
</SCRIPT>
</BODY>
</HTML>
+%}
<%once>
#false laziness w/config-view.cgi
my %namecol = (
@@ -94,6 +122,7 @@ my $agentnum = $cgi->param('agentnum');
my $key = $cgi->param('key');
my $i = $confitems{$key};
+my @error = ();
my @touch = ();
my @delete = ();
my $n = 0;
@@ -103,6 +132,8 @@ foreach my $type ( ref($i->type) ? @{$i->type} : $i->type ) {
if ( $cgi->param($i->key.$n) ne '' ) {
my $value = $cgi->param($i->key.$n);
$value =~ s/\r\n/\n/g; #browsers?
+ my $error = &{$i->validate}($value, $n) if $i->validate;
+ push @error, $error if $error;
$conf->set($i->key, $value, $agentnum);
} else {
$conf->delete($i->key, $agentnum);
@@ -110,6 +141,8 @@ foreach my $type ( ref($i->type) ? @{$i->type} : $i->type ) {
} elsif ( $type eq 'binary' || $type eq 'image' ) {
if ( defined($cgi->param($i->key.$n)) && $cgi->param($i->key.$n) ) {
my $fh = $cgi->upload($i->key.$n);
+ my $error = &{$i->validate}($fh, $n) if $i->validate;
+ push @error, $error if $error;
if (defined($fh)) {
local $/;
$conf->set_binary($i->key, <$fh>, $agentnum);
@@ -129,12 +162,16 @@ foreach my $type ( ref($i->type) ? @{$i->type} : $i->type ) {
|| $i->multiple )
) {
if ( scalar(@{[ $cgi->param($i->key.$n) ]}) ) {
+ my $error = &{$i->validate}([ $cgi->param($i->key.$n) ], $n) if $i->validate;
+ push @error, $error if $error;
$conf->set($i->key, join("\n", @{[ $cgi->param($i->key.$n) ]} ), $agentnum);
} else {
$conf->delete($i->key, $agentnum);
}
} elsif ( $type =~ /^(text|select(-(sub|part_svc|part_pkg|pkg_class))?)$/ ) {
if ( $cgi->param($i->key.$n) ne '' ) {
+ my $error = &{$i->validate}($cgi->param($i->key.$n), $n) if $i->validate;
+ push @error, $error if $error;
$conf->set($i->key, $cgi->param($i->key.$n), $agentnum);
} else {
$conf->delete($i->key, $agentnum);
@@ -146,4 +183,8 @@ foreach my $type ( ref($i->type) ? @{$i->type} : $i->type ) {
$conf->touch($_, $agentnum) foreach @touch;
$conf->delete($_, $agentnum) foreach @delete;
+if (scalar(@error)) {
+ $cgi->param('error', join(' ', @error));
+}
+
</%init>