1 package FS::access_user_session;
4 use base qw( FS::Record );
5 use FS::Record qw( qsearchs ); # qsearch );
10 FS::access_user_session - Object methods for access_user_session records
14 use FS::access_user_session;
16 $record = new FS::access_user_session \%hash;
17 $record = new FS::access_user_session { 'column' => 'value' };
19 $error = $record->insert;
21 $error = $new_record->replace($old_record);
23 $error = $record->delete;
25 $error = $record->check;
29 An FS::access_user_session object represents a backoffice web session.
30 FS::access_user_session inherits from FS::Record. The following fields are
45 Employee (see L<FS::access_user>)
49 Session start timestamp
53 Last session activity timestamp
63 Creates a new session. To add the session to the database, see L<"insert">.
65 Note that this stores the hash reference, not a distinct copy of the hash it
66 points to. You can ask the object for a copy with the I<hash> method.
70 # the new method can be inherited from FS::Record, if a table method is defined
72 sub table { 'access_user_session'; }
76 Adds this record to the database. If there is an error, returns the error,
77 otherwise returns false.
81 Delete this record from the database.
83 =item replace OLD_RECORD
85 Replaces the OLD_RECORD with this one in the database. If there is an error,
86 returns the error, otherwise returns false.
90 Checks all fields to make sure this is a valid session. If there is
91 an error, returns the error, otherwise returns false. Called by the insert
100 $self->ut_numbern('sessionnum')
101 || $self->ut_text('sessionkey')
102 || $self->ut_foreign_key('usernum', 'access_user', 'usernum')
103 || $self->ut_number('start_date')
104 || $self->ut_numbern('last_date')
106 return $error if $error;
108 $self->last_date( $self->start_date ) unless $self->last_date;
115 Returns the employee (see L<FS::access_user>) for this session.
121 qsearchs('access_user', { 'usernum' => $self->usernum });
124 =item touch_last_date
128 sub touch_last_date {
130 my $old_last_date = $self->last_date;
131 $self->last_date(time);
132 return if $old_last_date >= $self->last_date;
133 my $error = $self->replace;
134 die $error if $error;
143 my $error = $self->delete;
144 die $error if $error;
153 L<FS::Record>, schema.html from the base documentation.