RADIUS group enhancements, overlimit_groups changes, etc. RT13432
[freeside.git] / FS / FS / radius_group.pm
1 package FS::radius_group;
2
3 use strict;
4 use base qw( FS::Record );
5 use FS::Record qw( qsearch qsearchs );
6
7 =head1 NAME
8
9 FS::radius_group - Object methods for radius_group records
10
11 =head1 SYNOPSIS
12
13   use FS::radius_group;
14
15   $record = new FS::radius_group \%hash;
16   $record = new FS::radius_group { 'column' => 'value' };
17
18   $error = $record->insert;
19
20   $error = $new_record->replace($old_record);
21
22   $error = $record->delete;
23
24   $error = $record->check;
25
26 =head1 DESCRIPTION
27
28 An FS::radius_group object represents a RADIUS group.  FS::radius_group inherits from
29 FS::Record.  The following fields are currently supported:
30
31 =over 4
32
33 =item groupnum
34
35 primary key
36
37 =item groupname
38
39 groupname
40
41 =item description
42
43 description
44
45
46 =back
47
48 =head1 METHODS
49
50 =over 4
51
52 =item new HASHREF
53
54 Creates a new RADIUS group.  To add the RADIUS group to the database, see L<"insert">.
55
56 Note that this stores the hash reference, not a distinct copy of the hash it
57 points to.  You can ask the object for a copy with the I<hash> method.
58
59 =cut
60
61 # the new method can be inherited from FS::Record, if a table method is defined
62
63 sub table { 'radius_group'; }
64
65 =item insert
66
67 Adds this record to the database.  If there is an error, returns the error,
68 otherwise returns false.
69
70 =cut
71
72 # the insert method can be inherited from FS::Record
73
74 =item delete
75
76 Delete this record from the database.
77
78 =cut
79
80 # the delete method can be inherited from FS::Record
81
82 =item replace OLD_RECORD
83
84 Replaces the OLD_RECORD with this one in the database.  If there is an error,
85 returns the error, otherwise returns false.
86
87 =cut
88
89 # the replace method can be inherited from FS::Record
90
91 =item check
92
93 Checks all fields to make sure this is a valid RADIUS group.  If there is
94 an error, returns the error, otherwise returns false.  Called by the insert
95 and replace methods.
96
97 =cut
98
99 # the check method should currently be supplied - FS::Record contains some
100 # data checking routines
101
102 sub check {
103   my $self = shift;
104
105   my $error = 
106     $self->ut_numbern('groupnum')
107     || $self->ut_text('groupname')
108     || $self->ut_textn('description')
109   ;
110   return $error if $error;
111
112   $self->SUPER::check;
113 }
114
115 =item long_description
116
117 Returns a description for this group consisting of its description field, 
118 if any, and the RADIUS group name.
119
120 =cut
121
122 sub long_description {
123     my $self = shift;
124     $self->description ? $self->description . " (". $self->groupname . ")"
125                        : $self->groupname;
126 }
127
128 =back
129
130 =head1 BUGS
131
132 This isn't export-specific (i.e. groups are globally unique, as opposed to being
133 unique per-export).
134
135 =head1 SEE ALSO
136
137 L<FS::radius_usergroup>, L<FS::Record>, schema.html from the base documentation.
138
139 =cut
140
141 1;
142