1 package FS::access_user_log;
2 use base qw( FS::Record );
6 #use FS::Record qw( qsearch qsearchs );
11 FS::access_user_log - Object methods for access_user_log records
15 use FS::access_user_log;
17 $record = new FS::access_user_log \%hash;
18 $record = new FS::access_user_log { 'column' => 'value' };
20 $error = $record->insert;
22 $error = $new_record->replace($old_record);
24 $error = $record->delete;
26 $error = $record->check;
30 An FS::access_user_log object represents a backoffice web server log entry.
31 FS::access_user_log inherits from FS::Record. The following fields are
66 Creates a new log entry. To add the log entry to the database, see L<"insert">.
68 Note that this stores the hash reference, not a distinct copy of the hash it
69 points to. You can ask the object for a copy with the I<hash> method.
73 sub table { 'access_user_log'; }
75 =item insert_new_path PATH
77 Adds a log entry for PATH for the current user and timestamp.
82 my( $class, $path, $render_seconds ) = @_;
84 return '' unless defined $FS::CurrentUser::CurrentUser;
86 my $self = $class->new( {
87 'usernum' => $FS::CurrentUser::CurrentUser->usernum,
90 'render_seconds' => $render_seconds,
94 #so we can still log pages after a transaction-aborting SQL error (and then
95 # show the # error page)
96 local($FS::UID::dbh) = dbh->clone;
97 #if current transaction is aborted (if we had a way to check for it)
99 my $error = $self->insert;
100 die $error if $error;
106 Adds this record to the database. If there is an error, returns the error,
107 otherwise returns false.
111 Delete this record from the database.
113 =item replace OLD_RECORD
115 Replaces the OLD_RECORD with this one in the database. If there is an error,
116 returns the error, otherwise returns false.
120 Checks all fields to make sure this is a valid log entry. If there is
121 an error, returns the error, otherwise returns false. Called by the insert
130 $self->ut_numbern('lognum')
131 || $self->ut_foreign_key('usernum', 'access_user', 'usernum')
132 || $self->ut_text('path')
133 || $self->ut_number('_date')
134 || $self->ut_numbern('render_seconds')
135 || $self->ut_numbern('pid')
137 return $error if $error;
146 sub _upgrade_schema {
147 my ($class, %opts) = @_;
149 my $sql = 'DROP TABLE IF EXISTS h_access_user_log';
151 my $sth = dbh->prepare($sql) or die dbh->errstr;
152 $sth->execute or die $sth->errstr;