summaryrefslogtreecommitdiff
path: root/FS/FS
diff options
context:
space:
mode:
authorivan <ivan>2002-04-12 13:22:03 +0000
committerivan <ivan>2002-04-12 13:22:03 +0000
commite6ea57971831f25d682d97a0ba508c39b66ecd8b (patch)
treebdf395ca96a3eca52e9f4974c8bc289cbc0fe4ed /FS/FS
parenta7c1b602f88c177db34477ed4cdc1f72603f8995 (diff)
- should finish off the part_svc -> part_export s/one-to-many/many-to-many/
transition (closes: Bug#375) - fixes a nasty export scoping bug with message catalogs, whew
Diffstat (limited to 'FS/FS')
-rw-r--r--FS/FS/Msgcat.pm98
-rw-r--r--FS/FS/Record.pm9
-rw-r--r--FS/FS/cust_main.pm2
-rw-r--r--FS/FS/cust_main_invoice.pm4
-rw-r--r--FS/FS/msgcat.pm70
-rw-r--r--FS/FS/part_export.pm116
-rw-r--r--FS/FS/svc_acct.pm2
7 files changed, 226 insertions, 75 deletions
diff --git a/FS/FS/Msgcat.pm b/FS/FS/Msgcat.pm
new file mode 100644
index 0000000..625743d
--- /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 978ea72..cb42b26 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 ". \&notexist. "\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 e1a5173..fd1ccd7 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 b82e2e7..a5533a0 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 3eca14b..fa10d34 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 8af413b..835f531 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 030ffbe..38e24c1 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 );