This commit was manufactured by cvs2svn to create tag 'freeside_stable'.
[freeside.git] /
1 #!/usr/bin/perl -Tw
2 #
3 # process/svc_acct_sm.cgi: Add/edit a mail alias (process form)
4 #
5 # Usage: post form to:
6 #        http://server.name/path/svc_acct_sm.cgi
7 #
8 # Note: Should br run setuid root as user nobody.
9 #
10 # lots of crufty stuff from svc_acct still in here, and modifications are (unelegantly) disabled.
11 #
12 # ivan@voicenet.com 97-jan-6
13 #
14 # enabled modifications
15
16 # ivan@voicenet.com 97-may-7
17 #
18 # fixed removal of cust_svc record on modifications!
19 # ivan@voicenet.com 97-jun-5
20 #
21 # rewrite ivan@sisd.com 98-mar-15
22 #
23 # Changes to allow page to work at a relative position in server
24 #       bmccane@maxbaud.net     98-apr-3
25
26 use strict;
27 use CGI::Request;
28 use CGI::Carp qw(fatalsToBrowser);
29 use FS::UID qw(cgisuidsetup);
30 use FS::Record qw(qsearchs);
31 use FS::svc_acct_sm;
32
33 my($req)=new CGI::Request; # create form object
34 cgisuidsetup($req->cgi);
35
36 $req->param('svcnum') =~ /^(\d*)$/ or die "Illegal svcnum!";
37 my($svcnum)=$1;
38
39 my($old)=qsearchs('svc_acct_sm',{'svcnum'=>$svcnum}) if $svcnum;
40
41 #unmunge domsvc and domuid
42 $req->param('domsvc',(split(/:/, $req->param('domsvc') ))[0] );
43 $req->param('domuid',(split(/:/, $req->param('domuid') ))[0] );
44
45 my($new) = create FS::svc_acct_sm ( {
46   map {
47     ($_, scalar($req->param($_)));
48   } qw(svcnum pkgnum svcpart domuser domuid domsvc)
49 } );
50
51 my($error);
52 if ( $svcnum ) {
53   $error = $new->replace($old);
54 } else {
55   $error = $new->insert;
56   $svcnum = $new->getfield('svcnum');
57
58
59 unless ($error) {
60   $req->cgi->redirect("../../view/svc_acct_sm.cgi?$svcnum");
61 } else {
62   CGI::Base::SendHeaders(); # one guess
63   print <<END;
64 <HTML>
65   <HEAD>
66     <TITLE>Error adding/editing mail alias</TITLE>
67   </HEAD>
68   <BODY>
69     <CENTER>
70     <H4>Error adding/editing mail alias</H4>
71     </CENTER>
72     Your update did not occur because of the following error:
73     <P><B>$error</B>
74     <P>Hit the <I>Back</I> button in your web browser, correct this mistake, and submit the form again.
75   </BODY>
76 </HTML>
77 END
78
79 }
80