package FS::radius_group;
use strict;
-use base qw( FS::Record );
+use base qw( FS::o2m_Common FS::Record );
use FS::Record qw( qsearch qsearchs );
+use FS::radius_attr;
=head1 NAME
description
+=item priority
+
+priority - for export
+
=back
=cut
-# the delete method can be inherited from FS::Record
+# I'd delete any linked attributes here but we don't really support group
+# deletion. We would also have to delete linked records from
+# radius_usergroup and part_svc_column...
=item replace OLD_RECORD
=cut
-# the replace method can be inherited from FS::Record
+# To keep these things from proliferating, we will follow the same
+# export/noexport switches that radius_attr uses. If you _don't_ use
+# Freeside to maintain your RADIUS group attributes, then it probably
+# shouldn't try to rename groups either.
+
+sub replace {
+ my ($self, $old) = @_;
+ $old ||= $self->replace_old;
+
+ my $error = $self->check;
+ return $error if $error;
+
+ if ( !$FS::radius_attr::noexport_hack ) {
+ foreach ( qsearch('part_export', {}) ) {
+ next if !$_->option('export_attrs',1);
+ $error = $_->export_group_replace($self, $old);
+ return $error if $error;
+ }
+ }
+
+ $self->SUPER::replace($old);
+}
=item check
$self->ut_numbern('groupnum')
|| $self->ut_text('groupname')
|| $self->ut_textn('description')
+ || $self->ut_numbern('priority')
;
return $error if $error;
$self->SUPER::check;
}
+=item long_description
+
+Returns a description for this group consisting of its description field,
+if any, and the RADIUS group name.
+
+=cut
+
+sub long_description {
+ my $self = shift;
+ $self->description ? $self->description . " (". $self->groupname . ")"
+ : $self->groupname;
+}
+
+=item radius_attr
+
+Returns all L<FS::radius_attr> objects (check and reply attributes) for
+this group.
+
+=cut
+
+sub radius_attr {
+ my $self = shift;
+ qsearch({
+ table => 'radius_attr',
+ hashref => {'groupnum' => $self->groupnum },
+ order_by => 'ORDER BY attrtype, attrname',
+ })
+}
+
=back
=head1 BUGS