4 use base qw( FS::m2m_Common FS::Record );
5 use FS::Record qw( qsearch qsearchs dbh );
11 FS::nas - Object methods for nas records
17 $record = new FS::nas \%hash;
18 $record = new FS::nas { 'column' => 'value' };
20 $error = $record->insert;
22 $error = $new_record->replace($old_record);
24 $error = $record->delete;
26 $error = $record->check;
30 An FS::nas object represents a RADIUS client. FS::nas inherits from
31 FS::Record. The following fields are currently supported:
35 =item nasnum - primary key
37 =item nasname - "NAS name", i.e. IP address
39 =item shortname - short descriptive name
41 =item type - the equipment vendor
45 =item secret - the authentication secret for this client
47 =item server - virtual server name (optional)
51 =item description - a longer descriptive name
62 Creates a new NAS. To add the NAS to the database, see L<"insert">.
64 Note that this stores the hash reference, not a distinct copy of the hash it
65 points to. You can ask the object for a copy with the I<hash> method.
69 # the new method can be inherited from FS::Record, if a table method is defined
75 Adds this record to the database. If there is an error, returns the error,
76 otherwise returns false.
80 Delete this record from the database and remove all linked exports.
85 my $oldAutoCommit = $FS::UID::AutoCommit;
86 local $FS::UID::AutoCommit = 0;
90 my $error = $self->process_m2m([])
91 || $self->SUPER::delete;
98 $dbh->commit if $oldAutoCommit;
102 =item replace OLD_RECORD
104 Replaces the OLD_RECORD with this one in the database. If there is an error,
105 returns the error, otherwise returns false.
107 To change the list of linked exports, see the C<export_nas> method.
112 my $oldAutoCommit = $FS::UID::AutoCommit;
113 local $FS::UID::AutoCommit = 0;
116 my ($self, $old) = @_;
117 $old ||= qsearchs('nas', { 'nasnum' => $self->nasnum });
120 foreach my $part_export ( $self->part_export ) {
121 $error ||= $part_export->export_nas_replace($self, $old);
124 $error ||= $self->SUPER::replace($old);
131 $dbh->commit if $oldAutoCommit;
137 Checks all fields to make sure this is a valid NAS. If there is
138 an error, returns the error, otherwise returns false. Called by the insert
143 # the check method should currently be supplied - FS::Record contains some
144 # data checking routines
150 $self->ut_numbern('nasnum')
151 || $self->ut_text('nasname')
152 || $self->ut_textn('shortname')
153 || $self->ut_text('type')
154 || $self->ut_numbern('ports')
155 || $self->ut_text('secret')
156 || $self->ut_textn('server')
157 || $self->ut_textn('community')
158 || $self->ut_text('description')
160 return $error if $error;
167 Return all L<FS::part_export> objects to which this NAS is being exported.
173 map { qsearchs('part_export', { exportnum => $_->exportnum }) }
174 qsearch('export_nas', { nasnum => $self->nasnum})
183 L<FS::Record>, schema.html from the base documentation.