freeside/httemplate/misc/process link.cgi,1.8,1.9

ivan ivan at pouncequick.420.am
Mon Apr 5 07:06:10 PDT 2004


Update of /home/cvs/cvsroot/freeside/httemplate/misc/process
In directory pouncequick:/tmp/cvs-serv4561/httemplate/misc/process

Modified Files:
	link.cgi 
Log Message:
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

Index: link.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/misc/process/link.cgi,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- link.cgi	22 Mar 2004 11:05:58 -0000	1.8
+++ link.cgi	5 Apr 2004 14:06:04 -0000	1.9
@@ -12,8 +12,12 @@
   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 @@
 
 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 {
 %>




More information about the freeside-commits mailing list