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