default to a session cookie instead of setting an explicit timeout, weird timezone...
[freeside.git] / httemplate / edit / process / svc_domain.cgi
1 %if ($error) {
2 %  $cgi->param('error', $error);
3 <% $cgi->redirect(popurl(2). "svc_domain.cgi?". $cgi->query_string ) %>
4 %} else {
5 <% $cgi->redirect(popurl(3). "view/svc_domain.cgi?$svcnum") %>
6 %}
7 <%init>
8
9 die "access denied"
10   unless $FS::CurrentUser::CurrentUser->access_right('Provision customer service'); #something else more specific?
11
12 #remove this to actually test the domains!
13 $FS::svc_domain::whois_hack = 1;
14
15 $cgi->param('svcnum') =~ /^(\d*)$/ or die "Illegal svcnum!";
16 my $svcnum = $1;
17
18 #unmunge cgp_accessmodes (falze laziness-ish w/part_svc.pm::process & svc_acct)
19 unless ( $cgi->param('cgp_accessmodes') ) {
20   $cgi->param('cgp_accessmodes', 
21     join(' ',
22       sort map { /^cgp_accessmodes_([\w\/]+)$/ or die "no way"; $1; }
23                grep $cgi->param($_),
24                     grep /^cgp_accessmodes_([\w\/]+)$/,
25                          $cgi->param()
26         )
27   );
28 }
29
30 #unmunge acct_def_cgp_accessmodes (falze laziness-ahoy)
31 unless ( $cgi->param('acct_def_cgp_accessmodes') ) {
32   $cgi->param('acct_def_cgp_accessmodes', 
33     join(' ',
34       sort map { /^acct_def_cgp_accessmodes_([\w\/]+)$/ or die "no way"; $1; }
35                grep $cgi->param($_),
36                     grep /^acct_def_cgp_accessmodes_([\w\/]+)$/,
37                          $cgi->param()
38         )
39   );
40 }
41
42 my $new = new FS::svc_domain ( {
43   map {
44     $_, scalar($cgi->param($_));
45   #} qw(svcnum pkgnum svcpart domain action)
46   } ( fields('svc_domain'), qw( pkgnum svcpart action ) )
47 } );
48
49 # trim leading and trailing whitespace to avoid errors caused by pasting into UI
50 my $domain = $new->domain;
51 $domain =~ s/^\s+|\s+$//g;
52 $new->domain($domain);
53
54 my $error = '';
55 if ($cgi->param('svcnum')) {
56   $error  = $new->replace();
57 } else {
58   $error  = $new->insert;
59   $svcnum = $new->svcnum;
60 }
61
62 </%init>