beginnings of web status for session monitor
[freeside.git] / FS / FS / port.pm
1 package FS::port;
2
3 use strict;
4 use vars qw( @ISA );
5 use FS::Record qw( qsearchs );
6 use FS::nas;
7 use FS::session;
8
9 @ISA = qw(FS::Record);
10
11 =head1 NAME
12
13 FS::port - Object methods for port records
14
15 =head1 SYNOPSIS
16
17   use FS::port;
18
19   $record = new FS::port \%hash;
20   $record = new FS::port { 'column' => 'value' };
21
22   $error = $record->insert;
23
24   $error = $new_record->replace($old_record);
25
26   $error = $record->delete;
27
28   $error = $record->check;
29
30   $session = $port->session;
31
32 =head1 DESCRIPTION
33
34 An FS::port object represents an individual port on a NAS.  FS::port inherits
35 from FS::Record.  The following fields are currently supported:
36
37 =over 4
38
39 =item portnum - primary key
40
41 =item ip - IP address of this port
42
43 =item nasport - port number on the NAS
44
45 =item nasnum - NAS this port is on - see L<FS::nas>
46
47 =back
48
49 =head1 METHODS
50
51 =over 4
52
53 =item new HASHREF
54
55 Creates a new port.  To add the example to the database, see L<"insert">.
56
57 Note that this stores the hash reference, not a distinct copy of the hash it
58 points to.  You can ask the object for a copy with the I<hash> method.
59
60 =cut
61
62 # the new method can be inherited from FS::Record, if a table method is defined
63
64 sub table { 'port'; }
65
66 =item insert
67
68 Adds this record to the database.  If there is an error, returns the error,
69 otherwise returns false.
70
71 =cut
72
73 # the insert method can be inherited from FS::Record
74
75 =item delete
76
77 Delete this record from the database.
78
79 =cut
80
81 # the delete method can be inherited from FS::Record
82
83 =item replace OLD_RECORD
84
85 Replaces the OLD_RECORD with this one in the database.  If there is an error,
86 returns the error, otherwise returns false.
87
88 =cut
89
90 # the replace method can be inherited from FS::Record
91
92 =item check
93
94 Checks all fields to make sure this is a valid example.  If there is
95 an error, returns the error, otherwise returns false.  Called by the insert
96 and replace methods.
97
98 =cut
99
100 # the check method should currently be supplied - FS::Record contains some
101 # data checking routines
102
103 sub check {
104   my $self = shift;
105   my $error =
106     $self->ut_numbern('portnum')
107     || $self->ut_ipn('ipn')
108     || $self->ut_numbern('nasport')
109     || $self->ut_number('nasnum');
110   ;
111   return $error if $error;
112   return "Either ip or nasport must be specified"
113     unless $self->ip || $self->nasport;
114   return "Unknown nasnum"
115     unless qsearchs('nas', { 'nasnum' => $self->nasnum } );
116   ''; #no error
117 }
118
119 =item session
120
121 Returns the currently open session, or if no session is currently open, the
122 most recent session.  See L<FS::session>.
123
124 =cut
125
126
127
128 =back
129
130 =head1 VERSION
131
132 $Id: port.pm,v 1.2 2000-12-03 13:44:05 ivan Exp $
133
134 =head1 BUGS
135
136 The author forgot to customize this manpage.
137
138 =head1 SEE ALSO
139
140 L<FS::Record>, schema.html from the base documentation.
141
142 =head1 HISTORY
143
144 ivan@voicenet.com 97-jul-1
145
146 added hfields
147 ivan@sisd.com 97-nov-13
148
149 $Log: port.pm,v $
150 Revision 1.2  2000-12-03 13:44:05  ivan
151 beginnings of web status for session monitor
152
153 Revision 1.1  2000/10/27 20:18:32  ivan
154 oops, also necessary for session monitor
155
156 Revision 1.1  1999/08/04 08:03:03  ivan
157 move table subclass examples out of production directory
158
159 Revision 1.4  1998/12/29 11:59:57  ivan
160 mostly properly OO, some work still to be done with svc_ stuff
161
162 Revision 1.3  1998/11/15 04:33:00  ivan
163 updates for newest versoin
164
165 Revision 1.2  1998/11/15 03:48:49  ivan
166 update for current version
167
168
169 =cut
170
171 1;
172