diff options
-rw-r--r-- | FS/FS/Conf.pm | 6 | ||||
-rw-r--r-- | FS/FS/msgcat.pm | 11 | ||||
-rwxr-xr-x | bin/populate-msgcat | 25 | ||||
-rw-r--r-- | conf/show-msgcat-codes | 0 | ||||
-rwxr-xr-x | fs_signup/FS-SignupClient/cgi/signup.cgi | 17 | ||||
-rwxr-xr-x | fs_signup/fs_signup_server | 5 | ||||
-rwxr-xr-x | httemplate/browse/msgcat.cgi | 4 | ||||
-rw-r--r-- | httemplate/docs/install.html | 5 | ||||
-rwxr-xr-x | httemplate/edit/msgcat.cgi | 57 | ||||
-rw-r--r-- | httemplate/edit/process/msgcat.cgi | 19 |
10 files changed, 134 insertions, 15 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index b39c8217d..6e588208a 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -873,6 +873,12 @@ httemplate/docs/config.html 'select_enum' => [ qw(CARD PREPAY BILL COMP) ], }, + { + 'key' => 'show-msgcat-codes', + 'section' => 'UI', + 'description' => 'Show msgcat codes in error messages. Turn this option on before reporting errors to the mailing list.', + 'type' => 'checkbox', + }, ); diff --git a/FS/FS/msgcat.pm b/FS/FS/msgcat.pm index 53a7aeee6..3eca14b83 100644 --- a/FS/FS/msgcat.pm +++ b/FS/FS/msgcat.pm @@ -1,7 +1,7 @@ package FS::msgcat; use strict; -use vars qw( @ISA @EXPORT_OK $conf $locale ); +use vars qw( @ISA @EXPORT_OK $conf $locale $debug ); use Exporter; use FS::UID; use FS::Record qw( qsearchs ); @@ -13,6 +13,7 @@ use FS::Conf; $FS::UID::callback{'msgcat'} = sub { $conf = new FS::Conf; $locale = $conf->config('locale') || 'en_US'; + $debug = $conf->exists('show-msgcat-codes') }; =head1 NAME @@ -140,6 +141,10 @@ Returns the full message for the supplied message code. =cut sub gettext { + $debug ? geterror(@_) : _gettext(@_); +} + +sub _gettext { my $msgcode = shift; my $msgcat = qsearchs('msgcat', { 'msgcode' => $msgcode, @@ -163,7 +168,7 @@ code. sub geterror { my $msgcode = shift; - my $msg = gettext($msgcode); + my $msg = _gettext($msgcode); if ( $msg eq $msgcode ) { "Error code $msgcode (message for locale $locale not found)"; } else { @@ -175,7 +180,7 @@ sub geterror { =head1 BUGS -i18n/l10n is a mess. +i18n/l10n, eek =head1 SEE ALSO diff --git a/bin/populate-msgcat b/bin/populate-msgcat index fa88732ce..51f04c10f 100755 --- a/bin/populate-msgcat +++ b/bin/populate-msgcat @@ -1,23 +1,26 @@ -#!/usr/bin/perl +#!/usr/bin/perl -Tw +use strict; use FS::UID qw(adminsuidsetup); +use FS::Record qw(qsearch); use FS::msgcat; my $user = shift or die &usage; adminsuidsetup $user; -foreach my $del_msgcat ( qsearchs('msgcat', {}) ) { +foreach my $del_msgcat ( qsearch('msgcat', {}) ) { my $error = $del_msgcat->delete; die $error if $error; } my %messages = messages(); -foreach $msgcode ( keys %messages ) { +foreach my $msgcode ( keys %messages ) { foreach my $locale ( keys %{$messages{$msgcode}} ) { my $msgcat = new FS::msgcat( { 'msgcode' => $msgcode, 'locale' => $locale, + 'msg' => $messages{$msgcode}{$locale}, }); my $error = $msgcat->insert; die $error if $error; @@ -32,8 +35,20 @@ sub messages { ( - 'msgcode' => { - 'en_US' => 'Message', + 'passwords_dont_match' => { + 'en_US' => "Passwords don't match", + }, + + 'invalid_card' => { + 'en_US' => 'Invalid credit card number', + }, + + 'unknown_card_type' => { + 'en_US' => 'Unknown card type', + }, + + 'not_a' => { + 'en_US' => 'Not a ', }, ); diff --git a/conf/show-msgcat-codes b/conf/show-msgcat-codes new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/conf/show-msgcat-codes diff --git a/fs_signup/FS-SignupClient/cgi/signup.cgi b/fs_signup/FS-SignupClient/cgi/signup.cgi index 7cf4230e6..46621d1e8 100755 --- a/fs_signup/FS-SignupClient/cgi/signup.cgi +++ b/fs_signup/FS-SignupClient/cgi/signup.cgi @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: signup.cgi,v 1.18 2002-04-07 00:00:40 ivan Exp $ +# $Id: signup.cgi,v 1.19 2002-04-07 05:56:08 ivan Exp $ use strict; use vars qw( @payby $cgi $locales $packages $pops $init_data $error @@ -120,15 +120,22 @@ if ( defined $cgi->param('magic') ) { $error = ''; if ( $cgi->param('_password') ne $cgi->param('_password2') ) { - $error = "Passwords don't match"; #msgcat + $error = $init_data->{msgcat}{passwords_dont_match}; #msgcat $password = ''; $password2 = ''; } else { $password2 = $cgi->param('_password2'); - if ( $payby eq 'CARD' && $cgi->param('CARD_type') - && cardtype($payinfo) ne $cgi->param('CARD_type') ) { - $error = 'Not an '. $cgi->param('CARD_type'). '| - is: |'. cardtype($payinfo). '|'; #msgcat + if ( $payby eq 'CARD' && $cgi->param('CARD_type') ) { + $payinfo =~ s/\D//g; + + $payinfo =~ /^(\d{13,16})$/ + or $error ||= $init_data->{msgcat}{invalid_card}; #. $self->payinfo; + $payinfo = $1; + validate($payinfo) + or $error ||= $init_data->{msgcat}{invalid_card}; #. $self->payinfo; + cardtype($payinfo) eq $cgi->param('CARD_type') + or $error ||= $init_data->{msgcat}{not_a}. $cgi->param('CARD_type'); } $error ||= new_customer ( { diff --git a/fs_signup/fs_signup_server b/fs_signup/fs_signup_server index b902d9ff4..f3030e9ae 100755 --- a/fs_signup/fs_signup_server +++ b/fs_signup/fs_signup_server @@ -13,6 +13,7 @@ use FS::Conf; use FS::Record qw( qsearch qsearchs ); use FS::cust_main_county; use FS::cust_main; +use FS::msgcat qw(gettext); use vars qw( $opt $Debug ); @@ -67,6 +68,10 @@ while (1) { 'payby' => [ $conf->config('signup_server-payby') ], + 'msgcat' => { map { $_=>gettext($_) } qw( + passwords_dont_match invalid_card unknown_card_type not_a + ) } + }; warn "[fs_signup_server] Sending init data...\n" if $Debug; diff --git a/httemplate/browse/msgcat.cgi b/httemplate/browse/msgcat.cgi index 5dab5cfc9..774473b36 100755 --- a/httemplate/browse/msgcat.cgi +++ b/httemplate/browse/msgcat.cgi @@ -18,8 +18,8 @@ my $widget = new HTML::Widgets::SelectLayers( $html .= '</TR>'; #foreach my $msgcat ( sort { $a->msgcode cmp $b->msgcode } - # qsearchs('msgcat', { 'locale' => $layer } ) ) { - foreach my $msgcat ( qsearchs('msgcat', { 'locale' => $layer } ) ) { + # qsearch('msgcat', { 'locale' => $layer } ) ) { + foreach my $msgcat ( qsearch('msgcat', { 'locale' => $layer } ) ) { $html .= '<TR><TD>'. $msgcat->msgnum. '</TD>'. '<TD>'. $msgcat->msgcode. '</TD>'. '<TD>'. $msgcat->msg. '</TD>'; diff --git a/httemplate/docs/install.html b/httemplate/docs/install.html index 2ad75b15e..4870c7db7 100644 --- a/httemplate/docs/install.html +++ b/httemplate/docs/install.html @@ -181,6 +181,11 @@ $ <a href="man/bin/freeside-adduser.html">freeside-adduser</a> -h /usr/local/etc $ su freeside $ bin/fs-setup <b>username</b> </pre> + <li>As the freeside UNIX user, run <tt>bin/populate-msgcat <b>username</b></tt> to populate the message catalog, passing the username of a Freeside user you created above: +<pre> +$ su freeside +$ bin/populate-msgcat <b>username</b> +</pre> <li><tt>freeside-queued</tt> was installed with the Perl modules. Start it now and ensure that is run upon system startup. <li>Now proceed to the initial <a href="admin.html">administration</a> of your installation. </ul> diff --git a/httemplate/edit/msgcat.cgi b/httemplate/edit/msgcat.cgi new file mode 100755 index 000000000..5d256c05b --- /dev/null +++ b/httemplate/edit/msgcat.cgi @@ -0,0 +1,57 @@ +<!-- mason kludge --> +<% + +print header("Message catalog", menubar( +# 'Main Menu' => $p, +)), '<BR>'; + +print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !. $cgi->param('error') + if $cgi->param('error'); + +my $widget = new HTML::Widgets::SelectLayers( + 'selected_layer' => 'en_US', + 'options' => { 'en_US'=>'en_US' }, + 'form_action' => 'process/msgcat.cgi', + 'layer_callback' => sub { + my $layer = shift; + my $html = qq!<INPUT TYPE="hidden" NAME="locale" VALUE="$layer">!. + "<BR>Messages for locale $layer<BR>". table(). + "<TR><TH COLSPAN=2>Code</TH>". + "<TH>Message</TH>"; + $html .= "<TH>en_US Message</TH>" unless $layer eq 'en_US'; + $html .= '</TR>'; + + #foreach my $msgcat ( sort { $a->msgcode cmp $b->msgcode } + # qsearch('msgcat', { 'locale' => $layer } ) ) { + foreach my $msgcat ( qsearch('msgcat', { 'locale' => $layer } ) ) { + $html .= + '<TR><TD>'. $msgcat->msgnum. '</TD><TD>'. $msgcat->msgcode. '</TD>'. + '<TD><INPUT TYPE="text" SIZE=32 '. + qq! NAME="!. $msgcat->msgnum. '" '. + qq!VALUE="!. $msgcat->msg. qq!"></TD>!; + unless ( $layer eq 'en_US' ) { + my $en_msgcat = qsearchs('msgcat', { + 'locale' => 'en_US', + 'msgcode' => $msgcat->msgcode, + } ); + $html .= '<TD>'. $en_msgcat->msg. '</TD>'; + } + $html .= '</TR>'; + } + + $html .= '</TABLE><BR><INPUT TYPE="submit" VALUE="Apply changes">'; + + $html; + }, + +); + +print $widget->html; + +print <<END; + </TABLE> + </BODY> +</HTML> +END + +%> diff --git a/httemplate/edit/process/msgcat.cgi b/httemplate/edit/process/msgcat.cgi new file mode 100644 index 000000000..ab30f06b5 --- /dev/null +++ b/httemplate/edit/process/msgcat.cgi @@ -0,0 +1,19 @@ +<% + +my $error; +foreach my $param ( grep { /^\d+$/ } $cgi->param ) { + my $old = qsearchs('msgcat', { msgnum=>$param } ); + my $new = new FS::msgcat { $old->hash }; + $new->msg($cgi->param($param)); + $error = $new->replace($old); + last if $error; +} + +if ( $error ) { + $cgi->param('error',$error); + print $cgi->redirect($p. "msgcat.cgi?". $cgi->query_string ); +} else { + print $cgi->redirect(popurl(3). "browse/msgcat.cgi"); +} + +%> |