5 use FS::Record qw( qsearchs );
12 FS::session - Object methods for session records
18 $record = new FS::session \%hash;
19 $record = new FS::session {
22 'login' => $timestamp,
23 'logout' => $timestamp,
26 $error = $record->insert;
28 $error = $new_record->replace($old_record);
30 $error = $record->delete;
32 $error = $record->check;
36 An FS::session object represents an user login session. FS::session inherits
37 from FS::Record. The following fields are currently supported:
41 =item sessionnum - primary key
43 =item portnum - NAS port for this session - see L<FS::port>
45 =item svcnum - User for this session - see L<FS::svc_acct>
47 =item login - timestamp indicating the beginning of this user session.
49 =item logout - timestamp indicating the end of this user session. May be null,
50 which indicates a currently open session.
60 Creates a new example. To add the example to the database, see L<"insert">.
62 Note that this stores the hash reference, not a distinct copy of the hash it
63 points to. You can ask the object for a copy with the I<hash> method.
67 # the new method can be inherited from FS::Record, if a table method is defined
69 sub table { 'session'; }
73 Adds this record to the database. If there is an error, returns the error,
74 otherwise returns false. If the `login' field is empty, it is replaced with
83 local $SIG{HUP} = 'IGNORE';
84 local $SIG{INT} = 'IGNORE';
85 local $SIG{QUIT} = 'IGNORE';
86 local $SIG{TERM} = 'IGNORE';
87 local $SIG{TSTP} = 'IGNORE';
88 local $SIG{PIPE} = 'IGNORE';
90 $error = $self->check;
91 return $error if $error;
93 $self->setfield('login', time()) unless $self->getfield('login');
95 $error = $self->SUPER::insert;
96 return $error if $error;
98 #session-starting callback!
106 Delete this record from the database.
110 # the delete method can be inherited from FS::Record
112 =item replace OLD_RECORD
114 Replaces the OLD_RECORD with this one in the database. If there is an error,
115 returns the error, otherwise returns false. If the `logout' field is empty,
116 it is replaced with the current time.
124 local $SIG{HUP} = 'IGNORE';
125 local $SIG{INT} = 'IGNORE';
126 local $SIG{QUIT} = 'IGNORE';
127 local $SIG{TERM} = 'IGNORE';
128 local $SIG{TSTP} = 'IGNORE';
129 local $SIG{PIPE} = 'IGNORE';
131 $error = $self->check;
132 return $error if $error;
134 $self->setfield('logout', time()) unless $self->getfield('logout');
136 $error = $self->SUPER::replace;
137 return $error if $error;
139 #session-ending callback!
146 Checks all fields to make sure this is a valid example. If there is
147 an error, returns the error, otherwise returns false. Called by the insert
152 # the check method should currently be supplied - FS::Record contains some
153 # data checking routines
158 $self->ut_numbern('sessionnum')
159 || $self->ut_number('portnum')
160 || $self->ut_number('svcnum')
161 || $self->ut_numbern('login')
162 || $self->ut_numbern('logout')
164 return $error if $error;
165 return "Unknown svcnum"
166 unless qsearchs('svc_acct', { 'svcnum' => $self->svcnum } );
174 $Id: session.pm,v 1.1 2000-10-27 20:18:32 ivan Exp $
178 The author forgot to customize this manpage.
182 L<FS::Record>, schema.html from the base documentation.