communigate (phase 2): rules. RT#7514
[freeside.git] / FS / FS / cgp_rule_action.pm
1 package FS::cgp_rule_action;
2
3 use strict;
4 use base qw( FS::Record );
5 use FS::Record qw( qsearch qsearchs );
6 use FS::cgp_rule;
7
8 =head1 NAME
9
10 FS::cgp_rule_action - Object methods for cgp_rule_action records
11
12 =head1 SYNOPSIS
13
14   use FS::cgp_rule_action;
15
16   $record = new FS::cgp_rule_action \%hash;
17   $record = new FS::cgp_rule_action { '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::cgp_rule_action object represents a mail filtering action.
30 FS::cgp_rule_action inherits from FS::Record.  The following fields are
31 currently supported:
32
33 =over 4
34
35 =item ruleactionnum
36
37 primary key
38
39 =item action
40
41 action
42
43 =item params
44
45 params
46
47 =item rulenum
48
49 rulenum
50
51
52 =back
53
54 =head1 METHODS
55
56 =over 4
57
58 =item new HASHREF
59
60 Creates a new action.  To add the action to the database, see L<"insert">.
61
62 Note that this stores the hash reference, not a distinct copy of the hash it
63 points to.  You can ask the object for a copy with the I<hash> method.
64
65 =cut
66
67 # the new method can be inherited from FS::Record, if a table method is defined
68
69 sub table { 'cgp_rule_action'; }
70
71 =item insert
72
73 Adds this record to the database.  If there is an error, returns the error,
74 otherwise returns false.
75
76 =cut
77
78 # the insert method can be inherited from FS::Record
79
80 =item delete
81
82 Delete this record from the database.
83
84 =cut
85
86 # the delete method can be inherited from FS::Record
87
88 =item replace OLD_RECORD
89
90 Replaces the OLD_RECORD with this one in the database.  If there is an error,
91 returns the error, otherwise returns false.
92
93 =cut
94
95 # the replace method can be inherited from FS::Record
96
97 =item check
98
99 Checks all fields to make sure this is a valid action.  If there is
100 an error, returns the error, otherwise returns false.  Called by the insert
101 and replace methods.
102
103 =cut
104
105 # the check method should currently be supplied - FS::Record contains some
106 # data checking routines
107
108 sub check {
109   my $self = shift;
110
111   my $error = 
112     $self->ut_numbern('ruleactionnum')
113     || $self->ut_text('action')
114     || $self->ut_text('params')
115     || $self->ut_foreign_key('rulenum', 'cgp_rule', 'rulenum')
116   ;
117   return $error if $error;
118
119   $self->SUPER::check;
120 }
121
122 =back
123
124 =head1 BUGS
125
126 =head1 SEE ALSO
127
128 L<FS::Record>, schema.html from the base documentation.
129
130 =cut
131
132 1;
133