backup the schema for tables we don't need the data from. RT#85959
[freeside.git] / FS / FS / log_email.pm
1 package FS::log_email;
2
3 use strict;
4 use base qw( FS::Record );
5 use FS::Record qw( qsearch qsearchs dbdef );
6 use FS::UID qw( dbh driver_name );
7
8 =head1 NAME
9
10 FS::log_email - Object methods for log email records
11
12 =head1 SYNOPSIS
13
14   use FS::log_email;
15
16   $record = new FS::log_email \%hash;
17   $record = new FS::log_email { 'column' => 'value' };
18
19   $error = $record->insert;
20
21   $error = $new_record->replace($old_record);
22
23   $error = $record->delete;
24
25   $error = $record->check;
26
27 =head1 DESCRIPTION
28
29 An FS::log object represents the conditions for sending an email
30 when a log entry is created.  FS::log inherits from FS::Record.  
31 The following fields are currently supported:
32
33 =over 4
34
35 =item logemailnum - primary key
36
37 =item context - the context that will trigger the email (all contexts if unspecified)
38
39 =item min_level - the minimum log level that will trigger the email (all levels if unspecified)
40
41 =item msgnum - the msg_template that will be used to send the email
42
43 =item to_addr - who the email will be sent to (in addition to any bcc on the template)
44
45 =item context_height - number of context stack levels to match against 
46 (0 or null matches against full stack, 1 only matches lowest level context, 2 matches lowest two levels, etc.)
47
48 =back
49
50 =head1 METHODS
51
52 =over 4
53
54 =item new HASHREF
55
56 Creates a new log_email entry.
57
58 =cut
59
60 sub table { 'log_email'; }
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 =item delete
68
69 Delete this record from the database.
70
71 =item replace OLD_RECORD
72
73 Replaces the OLD_RECORD with this one in the database.  If there is an error,
74 returns the error, otherwise returns false.
75
76 =item check
77
78 Checks all fields to make sure this is a valid record.  If there is
79 an error, returns the error, otherwise returns false.  Called by the insert
80 and replace methods.
81
82 =cut
83
84 sub check {
85   my $self = shift;
86
87   my $error = 
88     $self->ut_numbern('logemailnum')
89     || $self->ut_textn('context') # not validating against list of contexts in log_context,
90                                   # because not even log_context check currently does so
91     || $self->ut_number('min_level')
92     || $self->ut_foreign_key('msgnum', 'msg_template', 'msgnum')
93     || $self->ut_textn('to_addr')
94     || $self->ut_numbern('context_height')
95   ;
96   return $error if $error;
97
98   $self->SUPER::check;
99 }
100
101 =back
102
103 =head1 BUGS
104
105 =head1 SEE ALSO
106
107 L<FS::Record>, schema.html from the base documentation.
108
109 =cut
110
111 1;
112