1 package FS::radius_group;
4 use base qw( FS::o2m_Common FS::Record );
5 use FS::Record qw( qsearch qsearchs dbh );
10 FS::radius_group - Object methods for radius_group records
16 $record = new FS::radius_group \%hash;
17 $record = new FS::radius_group { 'column' => 'value' };
19 $error = $record->insert;
21 $error = $new_record->replace($old_record);
23 $error = $record->delete;
25 $error = $record->check;
29 An FS::radius_group object represents a RADIUS group. FS::radius_group inherits from
30 FS::Record. The following fields are currently supported:
59 Creates a new RADIUS group. To add the RADIUS group to the database, see L<"insert">.
61 Note that this stores the hash reference, not a distinct copy of the hash it
62 points to. You can ask the object for a copy with the I<hash> method.
66 # the new method can be inherited from FS::Record, if a table method is defined
68 sub table { 'radius_group'; }
72 Adds this record to the database. If there is an error, returns the error,
73 otherwise returns false.
77 # the insert method can be inherited from FS::Record
81 Delete this record from the database.
86 # okay, I guess we support it now
88 local $SIG{HUP} = 'IGNORE';
89 local $SIG{INT} = 'IGNORE';
90 local $SIG{QUIT} = 'IGNORE';
91 local $SIG{TERM} = 'IGNORE';
92 local $SIG{TSTP} = 'IGNORE';
93 local $SIG{PIPE} = 'IGNORE';
95 my $oldAutoCommit = $FS::UID::AutoCommit;
96 local $FS::UID::AutoCommit = 0;
99 my $groupnum = $self->groupnum;
100 my $error = $self->process_o2m(
101 'table' => 'radius_usergroup',
102 'num_col' => 'groupnum',
103 'fields' => ['groupnum'], # just delete them
105 ) || $self->SUPER::delete(@_);
108 $dbh->rollback if $oldAutoCommit;
112 foreach my $part_svc_column (
113 qsearch('part_svc_column', { columnname => 'usergroup' })
115 my $new_values = join(',',
116 grep { $_ != $groupnum } split(',', $part_svc_column->columnvalue)
118 next if $new_values eq $part_svc_column->columnvalue;
119 $part_svc_column->set(columnvalue => $new_values);
120 $error = $part_svc_column->replace;
122 $dbh->rollback if $oldAutoCommit;
130 =item replace OLD_RECORD
132 Replaces the OLD_RECORD with this one in the database. If there is an error,
133 returns the error, otherwise returns false.
137 # To keep these things from proliferating, we will follow the same
138 # export/noexport switches that radius_attr uses. If you _don't_ use
139 # Freeside to maintain your RADIUS group attributes, then it probably
140 # shouldn't try to rename groups either.
143 my ($self, $old) = @_;
144 $old ||= $self->replace_old;
146 my $error = $self->check;
147 return $error if $error;
149 if ( !$FS::radius_attr::noexport_hack ) {
150 foreach ( qsearch('part_export', {}) ) {
151 next if !$_->option('export_attrs',1);
152 $error = $_->export_group_replace($self, $old);
153 return $error if $error;
157 $self->SUPER::replace($old);
162 Checks all fields to make sure this is a valid RADIUS group. If there is
163 an error, returns the error, otherwise returns false. Called by the insert
168 # the check method should currently be supplied - FS::Record contains some
169 # data checking routines
175 $self->ut_numbern('groupnum')
176 || $self->ut_text('groupname')
177 || $self->ut_textn('description')
178 || $self->ut_numbern('priority')
180 return $error if $error;
185 =item long_description
187 Returns a description for this group consisting of its description field,
188 if any, and the RADIUS group name.
192 sub long_description {
194 $self->description ? $self->description . " (". $self->groupname . ")"
200 Returns all L<FS::radius_attr> objects (check and reply attributes) for
208 table => 'radius_attr',
209 hashref => {'groupnum' => $self->groupnum },
210 order_by => 'ORDER BY attrtype, attrname',
218 This isn't export-specific (i.e. groups are globally unique, as opposed to being
223 L<FS::radius_usergroup>, L<FS::Record>, schema.html from the base documentation.