5 use FS::Record qw( qsearchs qsearch dbh );
8 @ISA = qw( FS::Record FS::m2m_Common );
12 FS::router - Object methods for router records
18 $record = new FS::router \%hash;
19 $record = new FS::router { 'column' => 'value' };
21 $error = $record->insert;
23 $error = $new_record->replace($old_record);
25 $error = $record->delete;
27 $error = $record->check;
31 An FS::router record describes a broadband router, such as a DSLAM or a wireless
32 access point. FS::router inherits from FS::Record. The following
33 fields are currently supported:
37 =item routernum - primary key
39 =item routername - descriptive name for the router
41 =item svcnum - svcnum of the owning FS::svc_broadband, if appropriate
43 =item manual_addr - set to 'Y' to allow services linked to this router
44 to have any IP address, rather than one in an address block belonging
55 Create a new record. To add the record to the database, see "insert".
59 sub table { 'router'; }
63 Adds this record to the database. If there is an error, returns the error,
64 otherwise returns false.
68 Deletes this record from the database. If there is an error, returns the
69 error, otherwise returns false.
71 =item replace OLD_RECORD
73 Replaces OLD_RECORD with this one in the database. If there is an error,
74 returns the error, otherwise returns false.
78 Checks all fields to make sure this is a valid record. If there is an error,
79 returns the error, otherwise returns false. Called by the insert and replace
88 $self->ut_numbern('routernum')
89 || $self->ut_text('routername')
90 || $self->ut_enum('manual_addr', [ '', 'Y' ])
91 || $self->ut_agentnum_acl('agentnum', 'Broadband global configuration')
93 return $error if $error;
100 Deletes this router if and only if no address blocks (see L<FS::addr_block>)
101 are currently allocated to it.
108 return 'Router has address blocks allocated to it' if $self->addr_block;
110 local $SIG{HUP} = 'IGNORE';
111 local $SIG{INT} = 'IGNORE';
112 local $SIG{QUIT} = 'IGNORE';
113 local $SIG{TERM} = 'IGNORE';
114 local $SIG{TSTP} = 'IGNORE';
115 local $SIG{PIPE} = 'IGNORE';
117 my $oldAutoCommit = $FS::UID::AutoCommit;
118 local $FS::UID::AutoCommit = 0;
121 my $error = $self->SUPER::delete;
123 $dbh->rollback if $oldAutoCommit;
127 $dbh->commit or die $dbh->errstr if $oldAutoCommit;
133 Returns a list of FS::addr_block objects (address blocks) associated
136 =item auto_addr_block
138 Returns a list of address blocks on which auto-assignment of IP addresses
145 return qsearch('addr_block', { routernum => $self->routernum });
148 sub auto_addr_block {
150 return () if $self->manual_addr;
151 return qsearch('addr_block', { routernum => $self->routernum,
152 manual_flag => '' });
155 =item part_svc_router
157 Returns a list of FS::part_svc_router objects associated with this
158 object. This is unlikely to be useful for any purpose other than retrieving
159 the associated FS::part_svc objects. See below.
163 sub part_svc_router {
165 return qsearch('part_svc_router', { routernum => $self->routernum });
170 Returns a list of FS::part_svc objects associated with this object.
176 return map { qsearchs('part_svc', { svcpart => $_->svcpart }) }
177 $self->part_svc_router;
182 Returns the agent associated with this router, if any.
187 qsearchs('agent', { 'agentnum' => shift->agentnum });
194 FS::svc_broadband, FS::router, FS::addr_block, FS::part_svc,
195 schema.html from the base documentation.