icradius groups (usergroup table if not radgroupreply & radgroupcheck)
+message catalogs (infrastructure, anyway)
+
Luke Pfeifer <freeside@globalli.com> contributed the "subscription" price plan.
Noment Networks, LLC <http://www.noment.com/> sponsored ICRADIUS/FreeRADIUS
-groups.
+groups, message catalogs, and signup server enhancements.
Everything else is my (Ivan Kohler <ivan@420.am>) fault.
'type' => 'checkbox',
},
+ {
+ 'key' => 'security_phrase',
+ 'section' => 'password',
+ 'description' => 'Enable the tracking of a "security phrase" with each account. Not recommended, as it is vulnerable to social engineering.',
+ 'type' => 'checkbox',
+ },
+
+ {
+ 'key' => 'locale',
+ 'section' => 'UI',
+ 'description' => 'Message locale',
+ 'type' => 'select',
+ 'select_enum' => [ qw(en_US) ],
+ },
+
);
1;
--- /dev/null
+package FS::msgcat;
+
+use strict;
+use vars qw( @ISA @EXPORT_OK $conf $locale );
+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';
+};
+
+=head1 NAME
+
+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');
+
+ #maintenance stuff
+ $record = new FS::msgcat \%hash;
+ $record = new FS::msgcat { 'column' => 'value' };
+
+ $error = $record->insert;
+
+ $error = $new_record->replace($old_record);
+
+ $error = $record->delete;
+
+ $error = $record->check;
+
+=head1 DESCRIPTION
+
+An FS::msgcat object represents an message catalog entry. FS::msgcat inherits
+from FS::Record. The following fields are currently supported:
+
+=over 4
+
+=item msgnum - primary key
+
+=item msgcode - Error code
+
+=item locale - Locale
+
+=item msg - Message
+
+=back
+
+=head1 METHODS
+
+=over 4
+
+=item new HASHREF
+
+Creates a new example. To add the example to the database, see L<"insert">.
+
+Note that this stores the hash reference, not a distinct copy of the hash it
+points to. You can ask the object for a copy with the I<hash> method.
+
+=cut
+
+# the new method can be inherited from FS::Record, if a table method is defined
+
+sub table { 'msgcat'; }
+
+=item insert
+
+Adds this record to the database. If there is an error, returns the error,
+otherwise returns false.
+
+=cut
+
+# the insert method can be inherited from FS::Record
+
+=item delete
+
+Delete this record from the database.
+
+=cut
+
+# the delete method can be inherited from FS::Record
+
+=item replace OLD_RECORD
+
+Replaces the OLD_RECORD with this one in the database. If there is an error,
+returns the error, otherwise returns false.
+
+=cut
+
+# the replace method can be inherited from FS::Record
+
+=item check
+
+Checks all fields to make sure this is a valid example. If there is
+an error, returns the error, otherwise returns false. Called by the insert
+and replace methods.
+
+=cut
+
+# the check method should currently be supplied - FS::Record contains some
+# data checking routines
+
+sub check {
+ my $self = shift;
+
+ my $error =
+ $self->ut_numbern('msgnum')
+ || $self->ut_text('msgcode')
+ || $self->ut_text('msg')
+ ;
+ return $error if $error;
+
+ $self->locale =~ /^([\w\@]+)$/ or return "illegal locale: ". $self->locale;
+ $self->locale($1);
+
+ ''; #no error
+}
+
+=back
+
+=head1 SUBROUTINES
+
+=over 4
+
+=item gettext MSGCODE
+
+Returns the full message for the supplied message code.
+
+=cut
+
+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 is a mess.
+
+=head1 SEE ALSO
+
+L<FS::Record>, schema.html from the base documentation.
+
+=cut
+
+1;
+
my $error = $self->ut_numbern('svcnum')
|| $self->ut_number('domsvc')
+ || $self->ut_textn('sec_phrase')
;
return $error if $error;
FS/radius_usergroup.pm
FS/queue.pm
FS/queue_arg.pm
+FS/msgcat.pm
t/agent.t
t/agent_type.t
t/CGI.t
t/type_pkgs.t
t/queue.t
t/queue_arg.t
+t/msgcat.t
t/UID.t
t/raddb.t
--- /dev/null
+BEGIN { $| = 1; print "1..1\n" }
+END {print "not ok 1\n" unless $loaded;}
+use FS::msgcat;
+$loaded=1;
+print "ok 1\n";
DB_USER = freeside
DB_PASSWORD=
-TEMPLATE = asp
-#TEMPLATE = mason
+#TEMPLATE = asp
+TEMPLATE = mason
ASP_GLOBAL = /usr/local/etc/freeside/asp-global
CREATE INDEX radius_usergroup1 ON radius_usergroup ( svcnum );
CREATE INDEX radius_usergroup2 ON radius_usergroup ( groupname );
+ALTER TABLE svc_acct ADD sec_phrase varchar(80) NULL;
+CREATE TABLE msgcat (
+ msgnum int primary key,
+ msgcode varchar(80) not null,
+ locale varchar(16) not null,
+ msg text not null
+);
+CREATE INDEX msgcat1 ON msgcat ( msgcode, locale );
+
Run bin/dbdef-create
Run bin/create-history-tables
Run bin/dbdef-create again
+Run bin/populate-msgcat
+
the mxmachines, nsmachines, arecords and cnamerecords configuration values have been deprecated. Use the defaultrecords configuration value instead.
New export code has landed! If you were using the icradiusmachines,
$dbh->commit or die $dbh->errstr;
+sub usage {
+ die "Usage:\n\n freeside-session-kill user\n";
+}
#!/usr/bin/perl -Tw
#
-# $Id: fs-setup,v 1.84 2002-03-22 18:56:32 ivan Exp $
+# $Id: fs-setup,v 1.85 2002-04-05 23:51:17 ivan Exp $
#to delay loading dbdef until we're ready
BEGIN { $FS::Record::setup_hack = 1; }
'svcnum', 'int', '', '',
'username', 'varchar', '', $username_len, #unique (& remove dup code)
'_password', 'varchar', '', 50, #13 for encryped pw's plus ' *SUSPENDED* (mp5 passwords can be 34)
+ 'sec_phrase', 'varchar', 'NULL', $char_d,
'popnum', 'int', 'NULL', '',
'uid', 'int', 'NULL', '',
'gid', 'int', 'NULL', '',
'index' => [ [ 'svcnum' ], [ 'groupname' ] ],
},
+ 'msgcat' => {
+ 'columns' => [
+ 'msgnum', 'int', '', '',
+ 'msgcode', 'varchar', '', $char_d,
+ 'locale', 'varchar', '', 16,
+ 'msg', 'text', '', '',
+ ],
+ 'primary_key' => 'msgnum',
+ 'unique' => [ [ 'msgcode', 'locale' ] ],
+ 'index' => [],
+ },
+
);
%tables;
--- /dev/null
+#!/usr/bin/perl
+
+use FS::UID qw(adminsuidsetup);
+use FS::msgcat;
+
+my $user = shift or die &usage;
+adminsuidsetup $user;
+
+foreach my $del_msgcat ( qsearchs('msgcat', {}) ) {
+ my $error = $del_msgcat->delete;
+ die $error if $error;
+}
+
+my %messages = messages();
+
+foreach $msgcode ( keys %messages ) {
+ foreach my $locale ( keys %{$messages{$msgcode}} ) {
+ my $msgcat = new FS::msgcat( {
+ 'msgcode' => $msgcode,
+ 'locale' => $locale,
+ });
+ my $error = $msgcat->insert;
+ die $error if $error;
+ }
+}
+
+sub messages {
+
+ # 'msgcode' => {
+ # 'en_US' => 'Message',
+ # },
+
+ (
+
+ 'msgcode' => {
+ 'en_US' => 'Message',
+ },
+
+ );
+}
+
+sub usage {
+ die "Usage:\n\n populate-msgcat user\n";
+}
+
}
sub usage {
- #die "Usage:\n\n icradius_reset user machine\n";
- die "Usage:\n\n icradius_reset user\n";
+ #die "Usage:\n\n sqlradius_reset user machine\n";
+ die "Usage:\n\n sqlradius_reset user\n";
}
=back
-=head1 VERSION
-
-$Id: table_template-svc.pm,v 1.2 2001-08-21 02:44:47 ivan Exp $
-
=head1 BUGS
The author forgot to customize this manpage.
=back
-=head1 VERSION
-
-$Id: table_template.pm,v 1.2 2000-10-27 20:15:50 ivan Exp $
-
=head1 BUGS
The author forgot to customize this manpage.
use FS::type_pkgs;
use FS::part_export;
use FS::part_export_option;
+use FS::msgcat qw(gettext geterror);
sub Script_OnStart {
$Response->AddHeader('Pragma' => 'no-cache');
use FS::type_pkgs;
use FS::part_export;
use FS::part_export_option;
+ use FS::msgcat qw(gettext geterror);
*CGI::redirect = sub {
my( $self, $location ) = @_;
print <<END;
</TABLE>
- </CENTER>
</BODY>
</HTML>
END
--- /dev/null
+<!-- mason kludge -->
+<%
+
+print header("Message catalog", menubar(
+ 'Main Menu' => $p,
+ 'Edit message catalog' => $p. "edit/msgcat.cgi",
+)), '<BR>';
+
+my $widget = new HTML::Widgets::SelectLayers(
+ 'selected_layer' => 'en_US',
+ 'options' => { 'en_US'=>'en_US' },
+ 'layer_callback' => sub {
+ my $layer = shift;
+ my $html = "<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 }
+ # qsearchs('msgcat', { 'locale' => $layer } ) ) {
+ foreach my $msgcat ( qsearchs('msgcat', { 'locale' => $layer } ) ) {
+ $html .= '<TR><TD>'. $msgcat->msgnum. '</TD>'.
+ '<TD>'. $msgcat->msgcode. '</TD>'.
+ '<TD>'. $msgcat->msg. '</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>';
+ $html;
+ },
+
+);
+
+print $widget->html;
+
+print <<END;
+ </TABLE>
+ </BODY>
+</HTML>
+END
+
+%>
<TD COLSPAN=2><A HREF="${p}edit/part_referral.cgi"><I>Add a new advertising source</I></A></TD>
</TR>
</TABLE>
- </CENTER>
</BODY>
</HTML>
END
<TD COLSPAN=5><A HREF="${p}edit/svc_acct_pop.cgi"><I>Add new Access Number</I></A></TD>
</TR>
</TABLE>
- </CENTER>
</BODY>
</HTML>
END
<li>svcnum - <a href="#cust_svc">primary key</a>
<li>username
<li>_password
+ <li>sec_phrase - security phrase
<li>popnum - <a href="#svc_acct_pop">Point of Presence</a>
<li>uid
<li>gid
<li>svcnum - <a href="#svc_acct">account</a>
<li>groupname
</ul>
+ <li><a name="msgcat" href="man/FS/msgcat.html">msgcat</a> - i18n message catalog
+ <ul>
+ <li>msgnum - primary key
+ <li>msgcode - message code
+ <li>locale - locale
+ <li>msg - Message text
+ </ul>
</ul>
</body>
CREATE INDEX radius_usergroup1 ON radius_usergroup ( svcnum );
CREATE INDEX radius_usergroup2 ON radius_usergroup ( groupname );
+CREATE TABLE msgcat (
+ msgnum int primary key,
+ msgcode varchar(80) not null,
+ locale varchar(16) not null,
+ msg text not null
+);
+CREATE INDEX msgcat1 ON msgcat ( msgcode, locale );
+
ALTER TABLE svc_acct ADD domsvc integer NOT NULL;
ALTER TABLE svc_domain ADD catchall integer NULL;
ALTER TABLE cust_main ADD referral_custnum integer NULL;
ALTER TABLE cust_refund ADD closed char(1) NULL;
ALTER TABLE cust_bill_event ADD status varchar(80);
ALTER TABLE cust_bill_event ADD statustext text NULL;
+ALTER TABLE svc_acct ADD sec_phrase varchar(80) NULL;
CREATE INDEX cust_main3 ON cust_main ( referral_custnum );
CREATE INDEX cust_credit_bill1 ON cust_credit_bill ( crednum );
CREATE INDEX cust_credit_bill2 ON cust_credit_bill ( invnum );
</TR>
END
+if ( $conf->exists('security_phrase') ) {
+ print <<END;
+ <TR><TD ALIGN="right">Security phrase</TD>
+ <TD><INPUT TYPE="text" NAME="sec_phrase" VALUE="$sec_phrase" SIZE=32>
+ (for forgotten passwords)</TD>
+ </TD>
+END
+}
+
#domain
my $domsvc = $svc_acct->domsvc || 0;
if ( $part_svc->part_svc_column('domsvc')->columnflag eq 'F' ) {
<LI><A HREF="browse/svc_acct_pop.cgi">View/Edit Access Numbers</A>
- Points of Presence
<LI><A HREF="browse/part_bill_event.cgi">View/Edit invoice events</A> - Actions for overdue invoices
+ <LI><A HREF="browse/msgcat.cgi">View/Edit message catalog</A> - Change error messages and other customizable labels.
</ul>
<BR>
</TD></TR>
print "</TR></TD>";
$password = '';
+if ( $conf->exists('security_phrase') ) {
+ my $sec_phrase = $svc_acct->sec_phrase;
+ print '<TR><TD ALIGN="right">Security phrase</TD><TD BGCOLOR="#ffffff">'.
+ $svc_acct->sec_phrase. '</TD></TR>;
+}
+
my $svc_acct_pop = qsearchs('svc_acct_pop',{'popnum'=>$svc_acct->popnum});
print "<TR><TD ALIGN=\"right\">Access number</TD>".
"<TD BGCOLOR=\"#ffffff\">". $svc_acct_pop->text. '</TD></TR>'