summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjeff <jeff>2007-06-08 17:38:04 +0000
committerjeff <jeff>2007-06-08 17:38:04 +0000
commit328063222f1b7c55d509704ccbe481bd98538bde (patch)
tree982beda7a482c3ac70f401ccb8d50c93571a6cc2
parent688b5ddabd230aa7577e8199f1ffebe3ae0b12e3 (diff)
prevent multiple additions to usergroup table (work around #1606)
-rw-r--r--FS/FS/part_export/sqlradius.pm7
1 files changed, 7 insertions, 0 deletions
diff --git a/FS/FS/part_export/sqlradius.pm b/FS/FS/part_export/sqlradius.pm
index 139f4001f..114ca0b1f 100644
--- a/FS/FS/part_export/sqlradius.pm
+++ b/FS/FS/part_export/sqlradius.pm
@@ -374,10 +374,17 @@ sub sqlradius_usergroup_insert { #subroutine, not method
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;
}