7 use FS::Record; # qw( qsearchs );
13 FS::msgcat - Object methods for message catalog entries
19 $record = new FS::msgcat \%hash;
20 $record = new FS::msgcat { 'column' => 'value' };
22 $error = $record->insert;
24 $error = $new_record->replace($old_record);
26 $error = $record->delete;
28 $error = $record->check;
32 An FS::msgcat object represents an message catalog entry. FS::msgcat inherits
33 from FS::Record. The following fields are currently supported:
37 =item msgnum - primary key
39 =item msgcode - Error code
47 If you just want to B<use> message catalogs, see L<FS::Msgcat>.
55 Creates a new message catalog entry. To add the message catalog entry to the
56 database, see L<"insert">.
58 Note that this stores the hash reference, not a distinct copy of the hash it
59 points to. You can ask the object for a copy with the I<hash> method.
63 # the new method can be inherited from FS::Record, if a table method is defined
65 sub table { 'msgcat'; }
69 Adds this record to the database. If there is an error, returns the error,
70 otherwise returns false.
74 # the insert method can be inherited from FS::Record
78 Delete this record from the database.
82 # the delete method can be inherited from FS::Record
84 =item replace OLD_RECORD
86 Replaces the OLD_RECORD with this one in the database. If there is an error,
87 returns the error, otherwise returns false.
91 # the replace method can be inherited from FS::Record
95 Checks all fields to make sure this is a valid message catalog entry. If there
96 is an error, returns the error, otherwise returns false. Called by the insert
101 # the check method should currently be supplied - FS::Record contains some
102 # data checking routines
108 $self->ut_numbern('msgnum')
109 || $self->ut_text('msgcode')
110 # || $self->ut_text('msg')
112 return $error if $error;
114 $self->locale =~ /^([\w\@]+)$/ or return "illegal locale: ". $self->locale;
121 sub _upgrade_data { #class method
122 my( $class, %opts) = @_;
124 #"repopulate_msgcat", false laziness w/FS::Setup::populate_msgcat
126 my %messages = _legacy_messages();
128 foreach my $msgcode ( keys %messages ) {
129 foreach my $locale ( keys %{$messages{$msgcode}} ) {
131 'msgcode' => $msgcode,
133 #'msg' => $messages{$msgcode}{$locale},
135 #my $msgcat = qsearchs('msgcat', \%msgcat);
136 my $msgcat = FS::Record::qsearchs('msgcat', \%msgcat); #wtf?
139 $msgcat = new FS::msgcat( {
141 'msg' => $messages{$msgcode}{$locale},
143 my $error = $msgcat->insert;
144 die $error if $error;
150 sub _legacy_messages {
153 # 'en_US' => 'Message',
158 'passwords_dont_match' => {
159 'en_US' => "Passwords don't match",
163 'en_US' => 'Invalid credit card number',
166 'unknown_card_type' => {
167 'en_US' => 'Unknown card type',
174 'empty_password' => {
175 'en_US' => 'Empty password',
178 'no_access_number_selected' => {
179 'en_US' => 'No access number selected',
183 'en_US' => 'Illegal (text)',
184 #'en_US' => 'Only letters, numbers, spaces, and the following punctuation symbols are permitted: ! @ # $ % & ( ) - + ; : \' " , . ? / in field',
187 'illegal_or_empty_text' => {
188 'en_US' => 'Illegal or empty (text)',
189 #'en_US' => 'Only letters, numbers, spaces, and the following punctuation symbols are permitted: ! @ # $ % & ( ) - + ; : \' " , . ? / in required field',
192 'illegal_username' => {
193 'en_US' => 'Illegal username',
196 'illegal_password' => {
197 'en_US' => 'Illegal password (',
200 'illegal_password_characters' => {
201 'en_US' => ' characters)',
204 'username_in_use' => {
205 'en_US' => 'Username in use',
208 'phonenum_in_use' => {
209 'en_US' => 'Phone number in use',
212 'illegal_email_invoice_address' => {
213 'en_US' => 'Illegal email invoice address',
217 'en_US' => 'Illegal (name)',
218 #'en_US' => 'Only letters, numbers, spaces and the following punctuation symbols are permitted: , . - \' in field',
222 'en_US' => 'Illegal (phone)',
227 'en_US' => 'Illegal (zip)',
232 'en_US' => 'Expired card',
236 'en_US' => 'Day Phone',
240 'en_US' => 'Night Phone',
243 'svc_external-id' => {
244 'en_US' => 'External ID',
247 'svc_external-title' => {
252 'en_US' => 'Driver\'s License',
256 'en_US' => 'Driver\'s License State',
259 'invalid_domain' => {
260 'en_US' => 'Invalid domain',
274 L<FS::Msgcat>, L<FS::Record>, schema.html from the base documentation.