delete fees, RT#81713
[freeside.git] / FS / FS / conf.pm
1 package FS::conf;
2
3 use strict;
4 use vars qw( @ISA );
5 use FS::Record;
6 use FS::Locales;
7
8 @ISA = qw(FS::Record);
9
10 =head1 NAME
11
12 FS::conf - Object methods for conf records
13
14 =head1 SYNOPSIS
15
16   use FS::conf;
17
18   $record = new FS::conf \%hash;
19   $record = new FS::conf { '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::conf object represents a configuration value.  FS::conf inherits from
32 FS::Record.  The following fields are currently supported:
33
34 =over 4
35
36 =item confnum - primary key
37
38 =item agentnum - the agent to which this configuration value applies
39
40 =item name - the name of the configuration value
41
42 =item value - the configuration value
43
44
45 =back
46
47 =head1 METHODS
48
49 =over 4
50
51 =item new HASHREF
52
53 Creates a new configuration value.  To add the example to the database, see L<"insert">.
54
55 Note that this stores the hash reference, not a distinct copy of the hash it
56 points to.  You can ask the object for a copy with the I<hash> method.
57
58 =cut
59
60 sub table { 'conf'; }
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 =item delete
70
71 Delete this record from the database.
72
73 =cut
74
75 =item replace OLD_RECORD
76
77 Replaces the OLD_RECORD with this one in the database.  If there is an error,
78 returns the error, otherwise returns false.
79
80 =cut
81
82 =item check
83
84 Checks all fields to make sure this is a valid configuration value.  If there is
85 an error, returns the error, otherwise returns false.  Called by the insert
86 and replace methods.
87
88 =cut
89
90 sub check {
91   my $self = shift;
92
93   my $error = 
94     $self->ut_numbern('confnum')
95     || $self->ut_foreign_keyn('agentnum', 'agent', 'agentnum')
96     || $self->ut_text('name')
97     || $self->ut_anything('value')
98     || $self->ut_enum('locale', [ '', FS::Locales->locales ])
99   ;
100   return $error if $error;
101
102   $self->SUPER::check;
103 }
104
105 =back
106
107 =head1 BUGS
108
109 =head1 SEE ALSO
110
111 L<FS::Record>, schema.html from the base documentation.
112
113 =cut
114
115 1;
116