delete fees, RT#81713
[freeside.git] / FS / FS / access_user_page_pref.pm
1 package FS::access_user_page_pref;
2 use base qw( FS::Record );
3
4 use strict;
5 use FS::Record qw( qsearch qsearchs );
6
7 sub table { 'access_user_page_pref'; }
8
9 =head1 NAME
10
11 FS::access_user_page_pref - Object methods for access_user_page_pref records
12
13 =head1 SYNOPSIS
14
15   use FS::access_user_page_pref;
16
17   $record = new FS::access_user_page_pref \%hash;
18   $record = new FS::access_user_page_pref { '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::access_user_page_pref object represents a per-page user interface
31 preference.  FS::access_user_page_pref inherits from FS::Record.  The
32 following fields are currently supported:
33
34 =over 4
35
36 =item prefnum
37
38 primary key
39
40 =item usernum
41
42 The user who has this preference, a L<FS::access_user> foreign key.
43
44 =item path
45
46 The path of the page where the preference is set, relative to the Mason
47 document root.
48
49 =item tablenum
50
51 For view and edit pages (which show one record at a time), the record primary
52 key that the preference applies to.
53
54 =item _date
55
56 The date the preference was created.
57
58 =item prefname
59
60 The name of the preference, as defined by the page.
61
62 =item prefvalue
63
64 The value (a free-text field).
65
66 =back
67
68 =head1 METHODS
69
70 =over 4
71
72 =item new HASHREF
73
74 Creates a new preference.  To add the preference to the database, see
75 L<"insert">.
76
77 =item insert
78
79 Adds this record to the database.  If there is an error, returns the error,
80 otherwise returns false.
81
82 =item delete
83
84 Delete this record from the database.
85
86 =item replace OLD_RECORD
87
88 Replaces the OLD_RECORD with this one in the database.  If there is an error,
89 returns the error, otherwise returns false.
90
91 =item check
92
93 Checks all fields to make sure this is a valid preference.  If there is
94 an error, returns the error, otherwise returns false.  Called by the insert
95 and replace methods.
96
97 =cut
98
99 sub check {
100   my $self = shift;
101
102   $self->set('_date', time) unless $self->get('_date');
103
104   my $error = 
105     $self->ut_numbern('prefnum')
106     || $self->ut_number('usernum')
107     || $self->ut_foreign_key('usernum', 'access_user', 'usernum')
108     || $self->ut_text('path')
109     || $self->ut_numbern('tablenum')
110     || $self->ut_numbern('_date')
111     || $self->ut_text('prefname')
112     || $self->ut_text('prefvalue')
113   ;
114   return $error if $error;
115
116   $self->SUPER::check;
117 }
118
119 =back
120
121 =head1 SEE ALSO
122
123 L<FS::Record>
124
125 =cut
126
127 1;
128