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 link_table => 'export_nas',
92 target_table => 'part_export',
94 ) || $self->SUPER::delete;
101 $dbh->commit if $oldAutoCommit;
105 =item replace OLD_RECORD
107 Replaces the OLD_RECORD with this one in the database. If there is an error,
108 returns the error, otherwise returns false.
110 To change the list of linked exports, see the C<export_nas> method.
115 my $oldAutoCommit = $FS::UID::AutoCommit;
116 local $FS::UID::AutoCommit = 0;
119 my ($self, $old) = @_;
120 $old ||= qsearchs('nas', { 'nasnum' => $self->nasnum });
123 foreach my $part_export ( $self->part_export ) {
124 $error ||= $part_export->export_nas_replace($self, $old);
127 $error ||= $self->SUPER::replace($old);
134 $dbh->commit if $oldAutoCommit;
140 Checks all fields to make sure this is a valid NAS. If there is
141 an error, returns the error, otherwise returns false. Called by the insert
146 # the check method should currently be supplied - FS::Record contains some
147 # data checking routines
153 $self->ut_numbern('nasnum')
154 || $self->ut_text('nasname')
155 || $self->ut_textn('shortname')
156 || $self->ut_text('type')
157 || $self->ut_numbern('ports')
158 || $self->ut_text('secret')
159 || $self->ut_textn('server')
160 || $self->ut_textn('community')
161 || $self->ut_text('description')
163 return $error if $error;
170 Return all L<FS::part_export> objects to which this NAS is being exported.
176 map { qsearchs('part_export', { exportnum => $_->exportnum }) }
177 qsearch('export_nas', { nasnum => $self->nasnum})
186 L<FS::Record>, schema.html from the base documentation.