1 package FS::radius_group;
4 use base qw( FS::o2m_Common FS::Record );
5 use FS::Record qw( qsearch qsearchs );
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.
85 # I'd delete any linked attributes here but we don't really support group
86 # deletion. We would also have to delete linked records from
87 # radius_usergroup and part_svc_column...
89 =item replace OLD_RECORD
91 Replaces the OLD_RECORD with this one in the database. If there is an error,
92 returns the error, otherwise returns false.
96 # To keep these things from proliferating, we will follow the same
97 # export/noexport switches that radius_attr uses. If you _don't_ use
98 # Freeside to maintain your RADIUS group attributes, then it probably
99 # shouldn't try to rename groups either.
102 my ($self, $old) = @_;
103 $old ||= $self->replace_old;
105 my $error = $self->check;
106 return $error if $error;
108 if ( !$FS::radius_attr::noexport_hack ) {
109 foreach ( qsearch('part_export', {}) ) {
110 next if !$_->option('export_attrs',1);
111 $error = $_->export_group_replace($self, $old);
112 return $error if $error;
116 $self->SUPER::replace($old);
121 Checks all fields to make sure this is a valid RADIUS group. If there is
122 an error, returns the error, otherwise returns false. Called by the insert
127 # the check method should currently be supplied - FS::Record contains some
128 # data checking routines
134 $self->ut_numbern('groupnum')
135 || $self->ut_text('groupname')
136 || $self->ut_textn('description')
137 || $self->ut_numbern('priority')
139 return $error if $error;
144 =item long_description
146 Returns a description for this group consisting of its description field,
147 if any, and the RADIUS group name.
151 sub long_description {
153 $self->description ? $self->description . " (". $self->groupname . ")"
159 Returns all L<FS::radius_attr> objects (check and reply attributes) for
167 table => 'radius_attr',
168 hashref => {'groupnum' => $self->groupnum },
169 order_by => 'ORDER BY attrtype, attrname',
177 This isn't export-specific (i.e. groups are globally unique, as opposed to being
182 L<FS::radius_usergroup>, L<FS::Record>, schema.html from the base documentation.