[freeside-commits] freeside/FS/FS/part_export sqlradius.pm, 1.25, 1.25.2.1

Jeff Finucane,420,, jeff at wavetail.420.am
Fri Jun 8 10:38:06 PDT 2007


Update of /home/cvs/cvsroot/freeside/FS/FS/part_export
In directory wavetail:/tmp/cvs-serv31357

Modified Files:
      Tag: FREESIDE_1_7_BRANCH
	sqlradius.pm 
Log Message:
prevent multiple additions to usergroup table (work around #1606)

Index: sqlradius.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_export/sqlradius.pm,v
retrieving revision 1.25
retrieving revision 1.25.2.1
diff -u -d -r1.25 -r1.25.2.1
--- sqlradius.pm	8 Feb 2007 22:54:19 -0000	1.25
+++ sqlradius.pm	8 Jun 2007 17:38:04 -0000	1.25.2.1
@@ -374,10 +374,17 @@
   my $dbh = sqlradius_connect(shift, shift, shift);
   my( $username, @groups ) = @_;
 
+  my $s_sth = $dbh->prepare(
+    "SELECT COUNT(*) FROM usergroup WHERE UserName = ? AND GroupName = ?"
+  ) or die $dbh->errstr;
+
   my $sth = $dbh->prepare( 
     "INSERT INTO usergroup ( UserName, GroupName ) VALUES ( ?, ? )"
   ) or die $dbh->errstr;
+
   foreach my $group ( @groups ) {
+    $s_sth->execute( $username, $group ) or die $s_sth->errstr;
+    next if $s_sth->fetchrow_arrayref->[0];
     $sth->execute( $username, $group )
       or die "can't insert into groupname table: ". $sth->errstr;
   }



More information about the freeside-commits mailing list