diff options
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/Msgcat.pm | 98 | ||||
-rw-r--r-- | FS/FS/Record.pm | 9 | ||||
-rw-r--r-- | FS/FS/cust_main.pm | 2 | ||||
-rw-r--r-- | FS/FS/cust_main_invoice.pm | 4 | ||||
-rw-r--r-- | FS/FS/msgcat.pm | 70 | ||||
-rw-r--r-- | FS/FS/part_export.pm | 116 | ||||
-rw-r--r-- | FS/FS/svc_acct.pm | 2 | ||||
-rw-r--r-- | FS/MANIFEST | 4 | ||||
-rw-r--r-- | FS/t/Msgcat.t | 5 |
9 files changed, 234 insertions, 76 deletions
diff --git a/FS/FS/Msgcat.pm b/FS/FS/Msgcat.pm new file mode 100644 index 000000000..625743dc0 --- /dev/null +++ b/FS/FS/Msgcat.pm @@ -0,0 +1,98 @@ +package FS::Msgcat; + +use strict; +use vars qw( @ISA @EXPORT_OK $conf $locale $debug ); +use Exporter; +use FS::UID; +#use FS::Record qw( qsearchs ); # wtf? won't import... +use FS::Record; +use FS::Conf; +use FS::msgcat; + +@ISA = qw(Exporter); +@EXPORT_OK = qw( gettext geterror ); + +$FS::UID::callback{'Msgcat'} = sub { + $conf = new FS::Conf; + $locale = $conf->config('locale') || 'en_US'; + $debug = $conf->exists('show-msgcat-codes') +}; + +=head1 NAME + +FS::Msgcat - Message catalog functions + +=head1 SYNOPSIS + + use FS::Msgcat qw(gettext geterror); + + #simple interface for retreiving messages... + $message = gettext('msgcode'); + #or errors (includes the error code) + $message = geterror('msgcode'); + +=head1 DESCRIPTION + +FS::Msgcat provides functions to use the message catalog. If you want to +maintain the message catalog database, see L<FS::msgcat> instead. + +=head1 SUBROUTINES + +=over 4 + +=item gettext MSGCODE + +Returns the full message for the supplied message code. + +=cut + +sub gettext { + $debug ? geterror(@_) : _gettext(@_); +} + +sub _gettext { + my $msgcode = shift; + my $msgcat = FS::Record::qsearchs('msgcat', { + 'msgcode' => $msgcode, + 'locale' => $locale + } ); + if ( $msgcat ) { + $msgcat->msg; + } else { + warn "WARNING: message for msgcode $msgcode in locale $locale not found"; + $msgcode; + } + +} + +=item geterror MSGCODE + +Returns the full message for the supplied message code, including the message +code. + +=cut + +sub geterror { + my $msgcode = shift; + my $msg = _gettext($msgcode); + if ( $msg eq $msgcode ) { + "Error code $msgcode (message for locale $locale not found)"; + } else { + "$msg (error code $msgcode)"; + } +} + +=back + +=head1 BUGS + +i18n/l10n, eek + +=head1 SEE ALSO + +L<FS::msgcat>, L<FS::Record>, schema.html from the base documentation. + +=cut + +1; + diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index 978ea72e7..cb42b266c 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -12,7 +12,7 @@ use DBI qw(:sql_types); use DBIx::DBSchema 0.19; use FS::UID qw(dbh checkruid getotaker datasrc driver_name); use FS::SearchCache; -use FS::msgcat qw(gettext); +use FS::Msgcat qw(gettext); @ISA = qw(Exporter); @EXPORT_OK = qw(dbh fields hfields qsearch qsearchs dbdef jsearch); @@ -572,7 +572,7 @@ sub delete { $h_sth->execute or return $h_sth->errstr if $h_sth; dbh->commit or croak dbh->errstr if $FS::UID::AutoCommit; - #no need to needlessly destoy the data either + #no need to needlessly destoy the data either (causes problems actually) #undef $self; #no need to keep object! ''; @@ -825,9 +825,12 @@ false. sub ut_text { my($self,$field)=@_; + warn "msgcat ". \&msgcat. "\n"; + warn "notexist ". \¬exist. "\n"; + warn "AUTOLOAD ". \&AUTOLOAD. "\n"; $self->getfield($field) =~ /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/]+)$/ or return gettext('illegal_or_empty_text'). " $field: ". - $self->getfield($field); + $self->getfield($field); $self->setfield($field,$1); ''; } diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index e1a51732f..fd1ccd772 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -26,7 +26,7 @@ use FS::queue; use FS::part_pkg; use FS::part_bill_event; use FS::cust_bill_event; -use FS::msgcat qw(gettext); +use FS::Msgcat qw(gettext); @ISA = qw( FS::Record ); diff --git a/FS/FS/cust_main_invoice.pm b/FS/FS/cust_main_invoice.pm index b82e2e732..a5533a088 100644 --- a/FS/FS/cust_main_invoice.pm +++ b/FS/FS/cust_main_invoice.pm @@ -7,7 +7,7 @@ use FS::Record qw( qsearchs ); use FS::Conf; use FS::cust_main; use FS::svc_acct; -use FS::msgcat qw(gettext); +use FS::Msgcat qw(gettext); @ISA = qw( FS::Record ); @@ -170,7 +170,7 @@ sub address { =head1 VERSION -$Id: cust_main_invoice.pm,v 1.11 2002-04-10 13:42:48 ivan Exp $ +$Id: cust_main_invoice.pm,v 1.12 2002-04-12 13:22:02 ivan Exp $ =head1 BUGS diff --git a/FS/FS/msgcat.pm b/FS/FS/msgcat.pm index 3eca14b83..fa10d34fa 100644 --- a/FS/FS/msgcat.pm +++ b/FS/FS/msgcat.pm @@ -1,20 +1,12 @@ package FS::msgcat; use strict; -use vars qw( @ISA @EXPORT_OK $conf $locale $debug ); +use vars qw( @ISA ); use Exporter; use FS::UID; use FS::Record qw( qsearchs ); -use FS::Conf; @ISA = qw(FS::Record); -@EXPORT_OK = qw( gettext geterror ); - -$FS::UID::callback{'msgcat'} = sub { - $conf = new FS::Conf; - $locale = $conf->config('locale') || 'en_US'; - $debug = $conf->exists('show-msgcat-codes') -}; =head1 NAME @@ -22,14 +14,8 @@ FS::msgcat - Object methods for message catalog entries =head1 SYNOPSIS - use FS::msgcat qw(gettext); - - #simple interface for retreiving messages... - $message = gettext('msgcode'); - #or errors (includes the error code) - $message = geterror('msgcode'); + use FS::msgcat; - #maintenance stuff $record = new FS::msgcat \%hash; $record = new FS::msgcat { 'column' => 'value' }; @@ -58,6 +44,8 @@ from FS::Record. The following fields are currently supported: =back +If you just want to B<use> message catalogs, see L<FS::Msgcat>. + =head1 METHODS =over 4 @@ -130,61 +118,13 @@ sub check { =back -=head1 SUBROUTINES - -=over 4 - -=item gettext MSGCODE - -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, - 'locale' => $locale - } ); - if ( $msgcat ) { - $msgcat->msg; - } else { - warn "WARNING: message for msgcode $msgcode in locale $locale not found"; - $msgcode; - } - -} - -=item geterror MSGCODE - -Returns the full message for the supplied message code, including the message -code. - -=cut - -sub geterror { - my $msgcode = shift; - my $msg = _gettext($msgcode); - if ( $msg eq $msgcode ) { - "Error code $msgcode (message for locale $locale not found)"; - } else { - "$msg (error code $msgcode)"; - } -} - -=back - =head1 BUGS i18n/l10n, eek =head1 SEE ALSO -L<FS::Record>, schema.html from the base documentation. +L<FS::Msgcat>, L<FS::Record>, schema.html from the base documentation. =cut diff --git a/FS/FS/part_export.pm b/FS/FS/part_export.pm index 8af413b1d..835f5318f 100644 --- a/FS/FS/part_export.pm +++ b/FS/FS/part_export.pm @@ -1,13 +1,15 @@ package FS::part_export; use strict; -use vars qw( @ISA ); +use vars qw( @ISA @EXPORT_OK %exports ); +use Exporter; use FS::Record qw( qsearch qsearchs dbh ); use FS::part_svc; use FS::part_export_option; use FS::export_svc; @ISA = qw(FS::Record); +@EXPORT_OK = qw(export_info); =head1 NAME @@ -428,10 +430,118 @@ sub _export_delete { =back +=head1 SUBROUTINES + +=over 4 + +=item export_info [ SVCDB ] + +Returns a hash reference of the exports for the given I<svcdb>, or if no +I<svcdb> is specified, for all exports. The keys of the hash are +I<exporttype>s and the values are again hash references containing information +on the export: + + 'desc' => 'Description', + 'options' => { + 'option' => { label=>'Option Label' }, + 'option2' => { label=>'Another label' }, + }, + 'nodomain' => 'Y', #or '' + 'notes' => 'Additional notes', + +=cut + +sub export_info { + #warn $_[0]; + return $exports{$_[0]} if @_; + #{ map { %{$exports{$_}} } keys %exports }; + my $r = { map { %{$exports{$_}} } keys %exports }; +} + +=item exporttype2svcdb EXPORTTYPE + +Returns the applicable I<svcdb> for an I<exporttype>. + +=cut + +sub exporttype2svcdb { + my $exporttype = $_[0]; + foreach my $svcdb ( keys %exports ) { + return $svcdb if grep { $exporttype eq $_ } keys %{$exports{$svcdb}}; + } + ''; +} + +%exports = ( + 'svc_acct' => { + 'sysvshell' => { + 'desc' => + 'Batch export of /etc/passwd and /etc/shadow files (Linux/SysV)', + 'options' => {}, + }, + 'bsdshell' => { + 'desc' => + 'Batch export of /etc/passwd and /etc/master.passwd files (BSD)', + 'options' => {}, + }, +# 'nis' => { +# 'desc' => +# 'Batch export of /etc/global/passwd and /etc/global/shadow for NIS ', +# 'options' => {}, +# }, + 'bsdshell' => { + 'desc' => + 'Batch export of /etc/passwd and /etc/master.passwd files (BSD)', + 'options' => {}, + }, + 'textradius' => { + 'desc' => 'Batch export of a text /etc/raddb/users file (Livingston, Cistron)', + }, + 'sqlradius' => { + 'desc' => 'Real-time export to SQL-backed RADIUS (ICRADIUS, FreeRADIUS)', + 'options' => { + 'datasrc' => { label=>'DBI data source' }, + 'username' => { label=>'Database username' }, + 'password' => { label=>'Database password' }, + }, + 'nodomain' => 'Y', + 'notes' => 'Not specifying datasrc will export to the freeside database? (no... notes on MySQL replication, DBI::Proxy, etc., from Conf.pm && export.html etc., reset with bin/sqlradius_reset', + }, + 'cyrus' => { + 'desc' => 'Real-time export to Cyrus IMAP server', + }, + 'cp' => { + 'desc' => 'Real-time export to Critical Path Account Provisioning Protocol', + }, + 'infostreet' => { + 'desc' => 'Real-time export to InfoStreet streetSmartAPI', + 'options' => { + 'url' => { label=>'XML-RPC Access URL', }, + 'login' => { label=>'InfoStreet login', }, + 'password' => { label=>'InfoStreet password', }, + 'groupID' => { label=>'InfoStreet groupID', }, + }, + 'nodomain' => 'Y', + 'notes' => 'Real-time export to <a href="http://www.infostreet.com/">InfoStreet</a> streetSmartAPI. Requires installation of <a href="http://search.cpan.org/search?dist=Frontier-Client">Frontier::Client</a> from CPAN.', + } + }, + + 'svc_domain' => {}, + + 'svc_acct_sm' => {}, + + 'svc_forward' => {}, + + 'svc_www' => {}, + +); + +=back + =head1 NEW EXPORT CLASSES -Should be added to httemplate/edit/part_export.cgi and a module should -be FS/FS/part_export/ (an example may be found in eg/export_template.pm) +Should be added to the %export hash here, and a module should be added in +FS/FS/part_export/ (an example may be found in eg/export_template.pm) =head1 BUGS diff --git a/FS/FS/svc_acct.pm b/FS/FS/svc_acct.pm index 030ffbe19..38e24c110 100644 --- a/FS/FS/svc_acct.pm +++ b/FS/FS/svc_acct.pm @@ -28,7 +28,7 @@ use FS::svc_domain; use FS::raddb; use FS::queue; use FS::radius_usergroup; -use FS::msgcat qw(gettext); +use FS::Msgcat qw(gettext); @ISA = qw( FS::svc_Common ); diff --git a/FS/MANIFEST b/FS/MANIFEST index 440c75565..1c90dfc0e 100644 --- a/FS/MANIFEST +++ b/FS/MANIFEST @@ -27,6 +27,7 @@ FS/UI/CGI.pm FS/UI/Gtk.pm FS/UI/agent.pm FS/UID.pm +FS/Msgcat.pm FS/agent.pm FS/agent_type.pm FS/cust_bill.pm @@ -80,6 +81,8 @@ t/CGI.t t/Conf.t t/ConfItem.t t/Record.t +t/UID.t +t/Msgcat.t t/cust_bill.t t/cust_bill_event.t t/cust_bill_pay.t @@ -124,5 +127,4 @@ t/type_pkgs.t t/queue.t t/queue_arg.t t/msgcat.t -t/UID.t t/raddb.t diff --git a/FS/t/Msgcat.t b/FS/t/Msgcat.t new file mode 100644 index 000000000..29e71b33c --- /dev/null +++ b/FS/t/Msgcat.t @@ -0,0 +1,5 @@ +BEGIN { $| = 1; print "1..1\n" } +END {print "not ok 1\n" unless $loaded;} +use FS::Msgcat; +$loaded=1; +print "ok 1\n"; |