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