71513: Card tokenization in v4+
[freeside.git] / FS / FS / log_context.pm
1 package FS::log_context;
2
3 use strict;
4 use base qw( FS::Record );
5 use FS::Record qw( qsearch qsearchs );
6
7 my @contexts = ( qw(
8   bill_and_collect
9   FS::cust_main::Billing::bill_and_collect
10   FS::cust_main::Billing::bill
11   FS::cust_main::Billing_Realtime::realtime_bop
12   FS::cust_main::Billing_Realtime::realtime_tokenize
13   FS::cust_main::Billing_Realtime::realtime_verify_bop
14   FS::pay_batch::import_from_gateway
15   FS::part_pkg
16   FS::Misc::Geo::standardize_uscensus
17   FS::saved_search::send
18   FS::saved_search::render
19   Cron::bill
20   Cron::backup
21   Cron::upload
22   spool_upload
23   daily
24   queue
25   upgrade
26   upgrade_taxable_billpkgnum
27   freeside-paymentech-upload
28   freeside-paymentech-download
29   test
30 ) );
31
32 =head1 NAME
33
34 FS::log_context - Object methods for log_context records
35
36 =head1 SYNOPSIS
37
38   use FS::log_context;
39
40   $record = new FS::log_context \%hash;
41   $record = new FS::log_context { 'column' => 'value' };
42
43   $error = $record->insert;
44
45   $error = $new_record->replace($old_record);
46
47   $error = $record->delete;
48
49   $error = $record->check;
50
51 =head1 DESCRIPTION
52
53 An FS::log_context object represents a context tag attached to a log entry
54 (L<FS::log>).  FS::log_context inherits from FS::Record.  The following 
55 fields are currently supported:
56
57 =over 4
58
59 =item logcontextnum - primary key
60
61 =item lognum - lognum (L<FS::log> foreign key)
62
63 =item context - context
64
65 =back
66
67 =head1 METHODS
68
69 =over 4
70
71 =item new HASHREF
72
73 Creates a new context tag.  To add the example to the database, see 
74 L<"insert">.
75
76 Note that this stores the hash reference, not a distinct copy of the hash it
77 points to.  You can ask the object for a copy with the I<hash> method.
78
79 =cut
80
81 sub table { 'log_context'; }
82
83 =item insert
84
85 Adds this record to the database.  If there is an error, returns the error,
86 otherwise returns false.
87
88 =item delete
89
90 Delete this record from the database.
91
92 =item replace OLD_RECORD
93
94 Replaces the OLD_RECORD with this one in the database.  If there is an error,
95 returns the error, otherwise returns false.
96
97 =item check
98
99 Checks all fields to make sure this is a valid example.  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 sub check {
106   my $self = shift;
107
108   my $error = 
109     $self->ut_numbern('logcontextnum')
110     || $self->ut_number('lognum')
111     || $self->ut_text('context') #|| $self->ut_enum('context', \@contexts)
112   ;
113   return $error if $error;
114
115   $self->SUPER::check;
116 }
117
118 =back
119
120 =head1 CLASS METHODS
121
122 =over 4
123
124 =item contexts
125
126 Returns a list of all valid contexts.
127
128 =cut
129
130 sub contexts { @contexts }
131
132 =back
133
134 =head1 BUGS
135
136 =head1 SEE ALSO
137
138 L<FS::Log>, L<FS::Record>, schema.html from the base documentation.
139
140 =cut
141
142 1;
143