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
53 =item svcnum - the L<FS::svc_broadband> record that 'owns' this device
63 Creates a new NAS. To add the NAS to the database, see L<"insert">.
65 Note that this stores the hash reference, not a distinct copy of the hash it
66 points to. You can ask the object for a copy with the I<hash> method.
70 # the new method can be inherited from FS::Record, if a table method is defined
76 Adds this record to the database. If there is an error, returns the error,
77 otherwise returns false.
81 Delete this record from the database and remove all linked exports.
86 my $oldAutoCommit = $FS::UID::AutoCommit;
87 local $FS::UID::AutoCommit = 0;
91 my $error = $self->process_m2m(
92 link_table => 'export_nas',
93 target_table => 'part_export',
95 ) || $self->SUPER::delete;
98 $dbh->rollback if $oldAutoCommit;
102 $dbh->commit if $oldAutoCommit;
106 =item replace OLD_RECORD
108 Replaces the OLD_RECORD with this one in the database. If there is an error,
109 returns the error, otherwise returns false.
111 To change the list of linked exports, see the C<export_nas> method.
116 my $oldAutoCommit = $FS::UID::AutoCommit;
117 local $FS::UID::AutoCommit = 0;
120 my ($self, $old) = @_;
121 $old ||= qsearchs('nas', { 'nasnum' => $self->nasnum });
124 foreach my $part_export ( $self->part_export ) {
125 $error ||= $part_export->export_nas_replace($self, $old);
128 $error ||= $self->SUPER::replace($old);
135 $dbh->commit if $oldAutoCommit;
141 Checks all fields to make sure this is a valid NAS. If there is
142 an error, returns the error, otherwise returns false. Called by the insert
147 # the check method should currently be supplied - FS::Record contains some
148 # data checking routines
154 $self->ut_numbern('nasnum')
155 || $self->ut_text('nasname')
156 || $self->ut_textn('shortname')
157 || $self->ut_text('type')
158 || $self->ut_numbern('ports')
159 || $self->ut_text('secret')
160 || $self->ut_textn('server')
161 || $self->ut_textn('community')
162 || $self->ut_text('description')
163 || $self->ut_foreign_keyn('svcnum', 'svc_broadband', 'svcnum')
165 return $error if $error;
172 Return all L<FS::part_export> objects to which this NAS is being exported.
178 map { qsearchs('part_export', { exportnum => $_->exportnum }) }
179 qsearch('export_nas', { nasnum => $self->nasnum})
188 L<FS::Record>, schema.html from the base documentation.