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