default to a session cookie instead of setting an explicit timeout, weird timezone...
[freeside.git] / httemplate / edit / process / payment_gateway.html
index 0b7e313..157449e 100644 (file)
@@ -1,34 +1,23 @@
-%
-%
-%my $gatewaynum = $cgi->param('gatewaynum');
-%
-%my $old = qsearchs('payment_gateway',{'gatewaynum'=>$gatewaynum}) if $gatewaynum;
-%
-%my $new = new FS::payment_gateway ( {
-%  map {
-%    $_, scalar($cgi->param($_));
-%  } fields('payment_gateway')
-%} );
-%
-%my @options = split(/\r?\n/, $cgi->param('gateway_options') );
-%pop @options
-%  if scalar(@options) % 2 && $options[-1] =~ /^\s*$/;
-%my %options = @options;
-%
-%my $error;
-%if ( $gatewaynum ) {
-%  $error=$new->replace($old, \%options);
-%} else {
-%  $error=$new->insert(\%options);
-%  $gatewaynum=$new->getfield('gatewaynum');
-%}
-%
-%if ( $error ) {
-%  $cgi->param('error', $error);
-%  print $cgi->redirect(popurl(2). "payment_gateway.html?". $cgi->query_string );
-%} else { 
-%  print $cgi->redirect(popurl(3). "browse/payment_gateway.html");
-%}
-%
-%
+<% include( 'elements/process.html',
+            'table'         => 'payment_gateway',
+            'viewall_dir'   => 'browse',
+            'args_callback' => $args_callback,
+          )
+%>
+<%init>
 
+die "access denied"
+  unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+
+my $args_callback = sub {
+  my ( $cgi, $new ) = @_;
+
+  my @options = split(/\r?\n/, $cgi->param('gateway_options') );
+  pop @options
+    if scalar(@options) % 2 && $options[-1] =~ /^\s*$/;
+  @options = ( {} ) if !@options;
+  (@options)
+};
+
+
+</%init>