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