fix TeleAPI import (what kind of crack was Christopher smoking that he couldn't fix...
[freeside.git] / FS / FS / radius_attr.pm
index b4c6e70..1b7df2e 100644 (file)
@@ -1,9 +1,11 @@
 package FS::radius_attr;
 package FS::radius_attr;
+use base qw( FS::Record );
 
 use strict;
 
 use strict;
-use base qw( FS::Record );
-use FS::Record qw( qsearch qsearchs );
 use vars qw( $noexport_hack );
 use vars qw( $noexport_hack );
+use FS::Record qw( qsearch dbh );
+
+$noexport_hack = 0;
 
 =head1 NAME
 
 
 =head1 NAME
 
@@ -52,7 +54,7 @@ currently supported:
 
 =item new HASHREF
 
 
 =item new HASHREF
 
-Creates a new example.  To add the example to the database, see L<"insert">.
+Creates a new record.  To add the record to the database, see L<"insert">.
 
 Note that this stores the hash reference, not a distinct copy of the hash it
 points to.  You can ask the object for a copy with the I<hash> method.
 
 Note that this stores the hash reference, not a distinct copy of the hash it
 points to.  You can ask the object for a copy with the I<hash> method.
@@ -143,7 +145,7 @@ sub replace {
 
 =item check
 
 
 =item check
 
-Checks all fields to make sure this is a valid example.  If there is
+Checks all fields to make sure this is a valid record.  If there is
 an error, returns the error, otherwise returns false.  Called by the insert
 and replace methods.
 
 an error, returns the error, otherwise returns false.  Called by the insert
 and replace methods.
 
@@ -174,13 +176,6 @@ sub check {
 
 Returns the L<FS::radius_group> object to which this attribute applies.
 
 
 Returns the L<FS::radius_group> object to which this attribute applies.
 
-=cut
-
-sub radius_group {
-  my $self = shift;
-  qsearchs('radius_group', { 'groupnum' => $self->groupnum });
-}
-
 =back
 
 =head1 CLASS METHODS
 =back
 
 =head1 CLASS METHODS
@@ -195,7 +190,7 @@ check or R for reply.
 =cut
 
 my %ops = (
 =cut
 
 my %ops = (
-  C => [ '==', ':=', '+=', '!=', '>', '>=', '<', '<=', '=~', '!~', '=*', '!*' ],
+  C => [ '=', '==', ':=', '+=', '!=', '>', '>=', '<', '<=', '=~', '!~', '=*', '!*' ],
   R => [ '=', ':=', '+=' ],
 );
 
   R => [ '=', ':=', '+=' ],
 );
 
@@ -207,6 +202,21 @@ sub ops {
 
 =back
 
 
 =back
 
+=cut
+
+sub _upgrade_schema {
+  my ($class, %opts) = @_;
+
+  my $sql = '
+    DELETE FROM radius_attr WHERE NOT EXISTS
+      ( SELECT 1 FROM radius_group WHERE radius_group.groupnum = radius_attr.groupnum )
+  ';
+
+  my $sth = dbh->prepare($sql) or die dbh->errstr;
+  $sth->execute or die $sth->errstr;
+  '';
+}
+
 =head1 BUGS
 
 =head1 SEE ALSO
 =head1 BUGS
 
 =head1 SEE ALSO