1 package FS::access_user_session;
2 use base qw( FS::Record );
8 FS::access_user_session - Object methods for access_user_session records
12 use FS::access_user_session;
14 $record = new FS::access_user_session \%hash;
15 $record = new FS::access_user_session { 'column' => 'value' };
17 $error = $record->insert;
19 $error = $new_record->replace($old_record);
21 $error = $record->delete;
23 $error = $record->check;
27 An FS::access_user_session object represents a backoffice web session.
28 FS::access_user_session inherits from FS::Record. The following fields are
43 Employee (see L<FS::access_user>)
47 Session start timestamp
51 Last session activity timestamp
61 Creates a new session. To add the session to the database, see L<"insert">.
63 Note that this stores the hash reference, not a distinct copy of the hash it
64 points to. You can ask the object for a copy with the I<hash> method.
68 # the new method can be inherited from FS::Record, if a table method is defined
70 sub table { 'access_user_session'; }
74 Adds this record to the database. If there is an error, returns the error,
75 otherwise returns false.
79 Delete this record from the database.
81 =item replace OLD_RECORD
83 Replaces the OLD_RECORD with this one in the database. If there is an error,
84 returns the error, otherwise returns false.
88 Checks all fields to make sure this is a valid session. If there is
89 an error, returns the error, otherwise returns false. Called by the insert
98 $self->ut_numbern('sessionnum')
99 || $self->ut_text('sessionkey')
100 || $self->ut_foreign_key('usernum', 'access_user', 'usernum')
101 || $self->ut_number('start_date')
102 || $self->ut_numbern('last_date')
104 return $error if $error;
106 $self->last_date( $self->start_date ) unless $self->last_date;
113 Returns the employee (see L<FS::access_user>) for this session.
115 =item touch_last_date
119 sub touch_last_date {
121 my $old_last_date = $self->last_date;
122 $self->last_date(time);
123 return if $old_last_date >= $self->last_date;
124 my $error = $self->replace;
125 die $error if $error;
134 my $error = $self->delete;
135 die $error if $error;
144 L<FS::Record>, schema.html from the base documentation.