communigate provisioning phase 2: Account:Settings: RulesAllowed, RPOPAllowed, MailTo...
[freeside.git] / FS / FS / nas.pm
index 873c9bc..97b0ea1 100644 (file)
@@ -2,8 +2,8 @@ package FS::nas;
 
 use strict;
 use vars qw( @ISA );
 
 use strict;
 use vars qw( @ISA );
-use FS::Record qw();
-#use FS::Record qw( qsearch qsearchs );
+use FS::Record qw(qsearchs); #qsearch);
+use FS::UID qw( dbh );
 
 @ISA = qw(FS::Record);
 
 
 @ISA = qw(FS::Record);
 
@@ -98,7 +98,7 @@ returns the error, otherwise returns false.
 
 =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 NAS.  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.
 
@@ -114,28 +114,31 @@ sub check {
     || $self->ut_text('nas')
     || $self->ut_ip('nasip')
     || $self->ut_domain('nasfqdn')
     || $self->ut_text('nas')
     || $self->ut_ip('nasip')
     || $self->ut_domain('nasfqdn')
-    || $self->ut_numbern('last');
+    || $self->ut_numbern('last')
+    || $self->SUPER::check
+    ;
 }
 
 }
 
-=sub heartbeat TIMESTAMP
+=item heartbeat TIMESTAMP
 
 Updates the timestamp for this nas
 
 =cut
 
 sub heartbeat {
 
 Updates the timestamp for this nas
 
 =cut
 
 sub heartbeat {
-  warn "warning: heartbeat unimplemented!"
+  my($self, $timestamp) = @_;
+  my $dbh = dbh;
+  my $sth =
+    $dbh->prepare("UPDATE nas SET last = ? WHERE nasnum = ? AND last < ?");
+  $sth->execute($timestamp, $self->nasnum, $timestamp) or die $sth->errstr;
+  $self->last($timestamp);
 }
 
 =back
 
 }
 
 =back
 
-=head1 VERSION
-
-$Id: nas.pm,v 1.2 2000-11-07 15:00:37 ivan Exp $
-
 =head1 BUGS
 
 =head1 BUGS
 
-The author forgot to customize this manpage.
+heartbeat method uses SQL directly and doesn't update history tables.
 
 =head1 SEE ALSO
 
 
 =head1 SEE ALSO