summaryrefslogtreecommitdiff
path: root/httemplate/misc/process/link.cgi
diff options
context:
space:
mode:
authorivan <ivan>2004-04-05 14:06:04 +0000
committerivan <ivan>2004-04-05 14:06:04 +0000
commit8ed2714fc50607081d7ac4edf0b17e23902dabba (patch)
treebc595c8af1cf1a2f01ce7e64de8b09cb58242f86 /httemplate/misc/process/link.cgi
parent65615896de6e2474953722ea25122174b151d289 (diff)
add a domain pulldown to svc_acct linking, closes: Bug#277 / prevent "stealing" services with link unless you set legacy_link-steal config option, closes: Bug#321
Diffstat (limited to 'httemplate/misc/process/link.cgi')
-rwxr-xr-xhttemplate/misc/process/link.cgi27
1 files changed, 18 insertions, 9 deletions
diff --git a/httemplate/misc/process/link.cgi b/httemplate/misc/process/link.cgi
index 8b71b893d..32a5360d9 100755
--- a/httemplate/misc/process/link.cgi
+++ b/httemplate/misc/process/link.cgi
@@ -12,8 +12,12 @@ unless ( $svcnum ) {
my $svcdb = $part_svc->getfield('svcdb');
$cgi->param('link_field') =~ /^(\w+)$/;
my $link_field = $1;
+ my %search = ( $link_field => $cgi->param('link_value') );
+ if ( $cgi->param('link_field2') =~ /^(\w+)$/ ) {
+ $search{$1} = $cgi->param('link_value2');
+ }
my $svc_x = ( grep { $_->cust_svc->svcpart == $svcpart }
- qsearch( $svcdb, { $link_field => $cgi->param('link_value') })
+ qsearch( $svcdb, \%search )
)[0];
eidiot("$link_field not found!") unless $svc_x;
$svcnum = $svc_x->svcnum;
@@ -21,19 +25,24 @@ unless ( $svcnum ) {
my $old = qsearchs('cust_svc',{'svcnum'=>$svcnum});
die "svcnum not found!" unless $old;
-#die "svcnum $svcnum already linked to package ". $old->pkgnum if $old->pkgnum;
-my $new = new FS::cust_svc ({
- 'svcnum' => $svcnum,
- 'pkgnum' => $pkgnum,
- 'svcpart' => $svcpart,
-});
+my $conf = new FS::Conf;
+my($error, $new);
+if ( $old->pkgnum && ! $conf->exists('legacy_link-steal') ) {
+ $error = "svcnum $svcnum already linked to package ". $old->pkgnum;
+} else {
+ $new = new FS::cust_svc ({
+ 'svcnum' => $svcnum,
+ 'pkgnum' => $pkgnum,
+ 'svcpart' => $svcpart,
+ });
-my $error = $new->replace($old);
+ $error = $new->replace($old);
+}
unless ($error) {
#no errors, so let's view this customer.
my $custnum = $new->cust_pkg->custnum;
- print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum"
+ print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum".
"#cust_pkg$pkgnum" );
} else {
%>