fix TeleAPI import (what kind of crack was Christopher smoking that he couldn't fix...
[freeside.git] / FS / FS / access_user_log.pm
index 9e7f7a0..552dd2a 100644 (file)
@@ -2,6 +2,7 @@ package FS::access_user_log;
 use base qw( FS::Record );
 
 use strict;
+use FS::UID qw( dbh );
 #use FS::Record qw( qsearch qsearchs );
 use FS::CurrentUser;
 
@@ -48,6 +49,11 @@ path
 
 _date
 
+=item render_seconds
+
+=back
+
+=item pid
 
 =back
 
@@ -73,16 +79,23 @@ Adds a log entry for PATH for the current user and timestamp.
 =cut
 
 sub insert_new_path {
-  my( $class, $path ) = @_;
+  my( $class, $path, $render_seconds ) = @_;
 
   return '' unless defined $FS::CurrentUser::CurrentUser;
 
   my $self = $class->new( {
-    'usernum' => $FS::CurrentUser::CurrentUser->usernum,
-    'path'    => $path,
-    '_date'   => time,
+    'usernum'        => $FS::CurrentUser::CurrentUser->usernum,
+    'path'           => $path,
+    '_date'          => time,
+    'render_seconds' => $render_seconds,
+    'pid'            => $$,
   } );
 
+  #so we can still log pages after a transaction-aborting SQL error (and then
+  # show the # error page)
+  local($FS::UID::dbh) = dbh->clone;
+    #if current transaction is aborted (if we had a way to check for it)
+
   my $error = $self->insert;
   die $error if $error;
 
@@ -118,6 +131,8 @@ sub check {
     || $self->ut_foreign_key('usernum', 'access_user', 'usernum')
     || $self->ut_text('path')
     || $self->ut_number('_date')
+    || $self->ut_numbern('render_seconds')
+    || $self->ut_numbern('pid')
   ;
   return $error if $error;
 
@@ -126,6 +141,17 @@ sub check {
 
 =back
 
+=cut
+
+sub _upgrade_schema {
+  my ($class, %opts) = @_;
+
+  my $sql = 'DROP TABLE IF EXISTS h_access_user_log';
+
+  my $sth = dbh->prepare($sql) or die dbh->errstr;
+  $sth->execute or die $sth->errstr;
+}
+
 =head1 BUGS
 
 =head1 SEE ALSO