diff options
| author | fukachan <fukachan> | 2003-09-25 11:40:57 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2003-09-25 11:40:57 +0000 |
| commit | 2d3e485d03bbc3d5ba82871b487a8b4d964041ce (patch) | |
| tree | e3aa875a61f0b434e798b2fa604e5242c7058644 /fml | |
| parent | 267560f658d60a5670f8221a7b6f10ff70052abd (diff) | |
| download | fml8-2d3e485d03bbc3d5ba82871b487a8b4d964041ce.tar.gz fml8-2d3e485d03bbc3d5ba82871b487a8b4d964041ce.tar.bz2 fml8-2d3e485d03bbc3d5ba82871b487a8b4d964041ce.zip | |
change *::CGI:: class architecture.
FML::CGI::*Admin::Menu inherits FML::CGI::Menu.
methods in FML::Process::CGI::* returns the value by checking the
current cgi mode (admin or ml-admin).
Diffstat (limited to 'fml')
| -rw-r--r-- | fml/lib/FML/CGI/Admin/Menu.pm | 206 | ||||
| -rw-r--r-- | fml/lib/FML/CGI/MLAdmin/Menu.pm | 96 | ||||
| -rw-r--r-- | fml/lib/FML/CGI/Menu.pm | 287 | ||||
| -rw-r--r-- | fml/lib/FML/Command/Admin/newml.pm | 53 | ||||
| -rw-r--r-- | fml/lib/FML/Process/CGI/Kernel.pm | 23 | ||||
| -rw-r--r-- | fml/lib/FML/Process/CGI/Utils.pm | 149 |
6 files changed, 589 insertions, 225 deletions
diff --git a/fml/lib/FML/CGI/Admin/Menu.pm b/fml/lib/FML/CGI/Admin/Menu.pm index d1ef5882..0aba989c 100644 --- a/fml/lib/FML/CGI/Admin/Menu.pm +++ b/fml/lib/FML/CGI/Admin/Menu.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: Menu.pm,v 1.25 2003/02/16 08:33:08 fukachan Exp $ +# $FML: Menu.pm,v 1.26 2003/08/29 15:33:56 fukachan Exp $ # package FML::CGI::Admin::Menu; @@ -13,10 +13,8 @@ use Carp; use vars qw(@ISA @EXPORT @EXPORT_OK $AUTOLOAD); use CGI qw/:standard/; # load standard CGI routines -use FML::Process::CGI; -@ISA = qw(FML::Process::CGI); - -my $debug = 0; +use FML::CGI::Menu; +@ISA = qw(FML::CGI::Menu); =head1 NAME @@ -53,7 +51,10 @@ C<FML::CGI::Admin::Menu> is a subclass of C<FML::Process::CGI>. ----------------------- | | A A - FML::CGI::Admin::Menu + FML::CGI::Menu FML::CGI::Menu + | | + A A + FML::CGI::Admin::Menu FML::CGI::MLAdmin::Menu =head1 METHODS @@ -62,199 +63,6 @@ C<FML::Process::CGI> base class. This module has routines needed for the admin CGI. -=cut - - -# Descriptions: print out HTML header + body former part -# Arguments: OBJ($curproc) HASH_REF($args) -# Side Effects: none -# Return Value: none -sub html_start -{ - my ($curproc, $args) = @_; - my $config = $curproc->config(); - my $myname = $curproc->myname(); - my $domain = $curproc->ml_domain(); # must be safe (hard-coded in .cgi) - my $ml_name = $curproc->cgi_try_get_ml_name($args); # safe ok - my $title = "${ml_name}\@${domain} configuration interface"; - my $color = $config->{ cgi_main_menu_color } || '#FFFFFF'; - my $charset = $curproc->language_of_cgi_message(); - - # o.k start html - print start_html(-title => $title, - -lang => $charset, - -BGCOLOR => $color); - print "\n"; -} - - -# Descriptions: print out body latter part -# Arguments: OBJ($curproc) HASH_REF($args) -# Side Effects: none -# Return Value: none -sub html_end -{ - my ($curproc, $args) = @_; - - # o.k. end of html - print end_html; - print "\n"; -} - - -# Descriptions: main routine for CGI. -# kick off suitable FML::Command finally -# via cgi_execulte_command(). -# Arguments: OBJ($curproc) HASH_REF($args) -# Side Effects: none -# Return Value: none -sub run_cgi_main -{ - my ($curproc, $args) = @_; - my $config = $curproc->config(); - my $address = $curproc->cgi_try_get_address($args); - my $ml_name = $curproc->cgi_try_get_ml_name($args); - my $hints = $curproc->hints(); - my $pcb = $curproc->pcb(); - my $mode = 'admin'; # cgi runs under admin mode (same way as makefml) - - # specified command, we need to identify - # the command specifined in the cgi_navigation and cgi_mein. - my $navi_command = $curproc->safe_param_navi_command() || ''; - my $command = $curproc->safe_param_command() || ''; - - # updat config: $ml_name is found now (get $ml_name from CGI). - $config->set('ml_name', $ml_name); - - if ($debug) { - print "<PRE>\n"; - print "ml_name = $ml_name\n"; - print "command = $command\n"; - print "navi_command = $navi_command\n"; - print "</PRE>\n"; - } - - if (($command eq 'newml' && $ml_name) || - ($command eq 'rmml' && $ml_name)) { - print "<br>* case 1 <br>\n" if $debug; - my $command_args = { - command_mode => $mode, - comname => $command, - command => $command, - ml_name => $ml_name, - options => [ ], - argv => undef, - args => undef, - }; - - $pcb->set('cgi', 'command_args', $command_args); - $curproc->cgi_execute_command($args, $command_args); - } - elsif ($command && $address) { - print "<br>* case 2 <br>\n" if $debug; - my $ml_name = $curproc->safe_param_ml_name(); - my $command_args = { - command_mode => $mode, - comname => $command, - command => $command, - ml_name => $ml_name, - options => [ $address ], - argv => undef, - args => undef, - }; - - $pcb->set('cgi', 'command_args', $command_args); - $curproc->cgi_execute_command($args, $command_args); - } - elsif ($navi_command) { - print "<br>* case 3 <br>\n" if $debug; - - my $ml_name = $curproc->safe_param_ml_name(); - my $command_args = { - command_mode => $mode, - comname => $navi_command, - command => $navi_command, - ml_name => $ml_name, - options => [ ], - argv => undef, - args => undef, - }; - - $pcb->set('cgi', 'command_args', $command_args); - } - elsif ($command) { - print "<br>* case 4 <br>\n" if $debug; - - my $ml_name = $curproc->safe_param_ml_name(); - my $command_args = { - command_mode => $mode, - comname => $command, - command => $command, - ml_name => $ml_name, - options => [ ], - argv => undef, - args => undef, - }; - - $pcb->set('cgi', 'command_args', $command_args); - } - else { - print "<br>* case 5 <br>\n" if $debug; - - $pcb->set('cgi', 'command_args', undef); - } -} - - -# Descriptions: show menu (table based menu) -# Arguments: OBJ($curproc) HASH_REF($args) -# Side Effects: none -# Return Value: none -sub run_cgi_navigator -{ - my ($curproc, $args) = @_; - my $config = $curproc->config(); - my $action = $curproc->safe_cgi_action_name(); - my $target = '_top'; - - # 1. ML - my $ml_name = $curproc->cgi_try_get_ml_name($args); - my $ml_list = $curproc->get_ml_list($args); - my $fml_url = '<A HREF="http://www.fml.org/software/fml-devel/">fml</A>'; - print "<B>$fml_url admin menu</B>\n<BR>\n"; - - print start_form(-action=>$action, -target=>$target); - - print "mailing list:\n"; - print scrolling_list(-name => 'ml_name', - -values => $ml_list, - -default => [ $ml_name ], - -size => 5); - print "\n<BR>\n"; - - # 2. command - my $navi_command = $curproc->safe_param_navi_command() || ''; - my $command = $curproc->safe_param_command() || ''; - my $command_default = $navi_command || $command; - my $command_list = - $config->get_as_array_ref('commands_for_admin_cgi'); - - print " command:\n"; - print scrolling_list(-name => 'navi_command', - -values => $command_list, - -default => [ $command_default ], - -size => 5); - print "\n<BR>\n"; - - - # 3. submit - print submit(-name => 'submit'); - print reset(-name => 'reset'); - - print end_form; -} - - =head1 SEE ALSO L<CGI>, diff --git a/fml/lib/FML/CGI/MLAdmin/Menu.pm b/fml/lib/FML/CGI/MLAdmin/Menu.pm new file mode 100644 index 00000000..5521ad53 --- /dev/null +++ b/fml/lib/FML/CGI/MLAdmin/Menu.pm @@ -0,0 +1,96 @@ +#-*- perl -*- +# +# Copyright (C) 2002,2003 Ken'ichi Fukamachi +# All rights reserved. This program is free software; you can +# redistribute it and/or modify it under the same terms as Perl itself. +# +# $FML: Menu.pm,v 1.26 2003/08/29 15:33:56 fukachan Exp $ +# + +package FML::CGI::MLAdmin::Menu; +use strict; +use Carp; +use vars qw(@ISA @EXPORT @EXPORT_OK $AUTOLOAD); +use CGI qw/:standard/; # load standard CGI routines + +use FML::CGI::Menu; +@ISA = qw(FML::CGI::Menu); + + +=head1 NAME + +FML::CGI::MLAdmin::Menu - provides CGI controll for the specific domain + +=head1 SYNOPSIS + + $obj = new FML::CGI::MLAdmin::Menu; + $obj->prepare(); + $obj->verify_request(); + $obj->run(); + $obj->finish(); + +run() executes html_start(), run_cgi() and html_end() described below. + +See L<FML::Process::Flow> for flow details. + +=head1 DESCRIPTION + +=head2 CLASS HIERARCHY + +C<FML::CGI::MLAdmin::Menu> is a subclass of C<FML::Process::CGI>. + + FML::Process::Kernel + | + A + FML::Process::CGI::Kernel + | + A + FML::Process::CGI + | + A + ----------------------- + | | + A A + FML::CGI::Menu FML::CGI::Menu + | | + A A + FML::CGI::MLAdmin::Menu FML::CGI::MLMLAdmin::Menu + +=head1 METHODS + +Almost methods common for CGI or HTML are forwarded to +C<FML::Process::CGI> base class. + +This module has routines needed for the admin CGI. + +=head1 SEE ALSO + +L<CGI>, +L<FML::Process::CGI> +and +L<FML::Process::Flow> + +=head1 CODING STYLE + +See C<http://www.fml.org/software/FNF/> on fml coding style guide. + +=head1 AUTHOR + +Ken'ichi Fukamachi + +=head1 COPYRIGHT + +Copyright (C) 2002,2003 Ken'ichi Fukamachi + +All rights reserved. This program is free software; you can +redistribute it and/or modify it under the same terms as Perl itself. + +=head1 HISTORY + +FML::CGI::MLAdmin::Menu first appeared in fml8 mailing list driver package. +See C<http://www.fml.org/> for more details. + +=cut + + +1; diff --git a/fml/lib/FML/CGI/Menu.pm b/fml/lib/FML/CGI/Menu.pm new file mode 100644 index 00000000..a303cfc9 --- /dev/null +++ b/fml/lib/FML/CGI/Menu.pm @@ -0,0 +1,287 @@ +#-*- perl -*- +# +# Copyright (C) 2003 Ken'ichi Fukamachi +# All rights reserved. This program is free software; you can +# redistribute it and/or modify it under the same terms as Perl itself. +# +# $FML: Menu.pm,v 1.26 2003/08/29 15:33:56 fukachan Exp $ +# + +package FML::CGI::Menu; +use strict; +use Carp; +use vars qw(@ISA @EXPORT @EXPORT_OK $AUTOLOAD); +use CGI qw/:standard/; # load standard CGI routines + +use FML::Process::CGI; +@ISA = qw(FML::Process::CGI); + +my $debug = 0; + + +=head1 NAME + +FML::CGI::Menu - provides CGI controll for the specific domain + +=head1 SYNOPSIS + + $obj = new FML::CGI::Menu; + $obj->prepare(); + $obj->verify_request(); + $obj->run(); + $obj->finish(); + +run() executes html_start(), run_cgi() and html_end() described below. + +See L<FML::Process::Flow> for flow details. + +=head1 DESCRIPTION + +=head2 CLASS HIERARCHY + +C<FML::CGI::Menu> is a subclass of C<FML::Process::CGI>. + + FML::Process::Kernel + | + A + FML::Process::CGI::Kernel + | + A + FML::Process::CGI + | + A + ----------------------- + | | + A A + FML::CGI::Menu + +=head1 METHODS + +Almost methods common for CGI or HTML are forwarded to +C<FML::Process::CGI> base class. + +This module has routines needed for the admin CGI. + +=cut + + +# Descriptions: print out HTML header + body former part +# Arguments: OBJ($curproc) HASH_REF($args) +# Side Effects: none +# Return Value: none +sub html_start +{ + my ($curproc, $args) = @_; + my $config = $curproc->config(); + my $myname = $curproc->myname(); + my $domain = $curproc->cgi_var_ml_domain(); + my $ml_name = $curproc->cgi_var_ml_name(); + my $title = "${ml_name}\@${domain} configuration interface"; + my $color = $config->{ cgi_main_menu_color } || '#FFFFFF'; + my $charset = $curproc->language_of_cgi_message(); + + # o.k start html + print start_html(-title => $title, + -lang => $charset, + -BGCOLOR => $color); + print "\n"; +} + + +# Descriptions: print out body latter part +# Arguments: OBJ($curproc) HASH_REF($args) +# Side Effects: none +# Return Value: none +sub html_end +{ + my ($curproc, $args) = @_; + + # o.k. end of html + print end_html; + print "\n"; +} + + +# Descriptions: main routine for CGI. +# kick off suitable FML::Command finally +# via cgi_execulte_command(). +# Arguments: OBJ($curproc) HASH_REF($args) +# Side Effects: none +# Return Value: none +sub run_cgi_main +{ + my ($curproc, $args) = @_; + my $config = $curproc->config(); + my $address = $curproc->cgi_try_get_address(); + my $ml_name = $curproc->cgi_var_ml_name(); + my $hints = $curproc->hints(); + my $pcb = $curproc->pcb(); + my $mode = 'admin'; # cgi runs under admin mode (same way as makefml) + + # specified command, we need to identify + # the command specifined in the cgi_navigation and cgi_mein. + my $navi_command = $curproc->safe_param_navi_command() || ''; + my $command = $curproc->safe_param_command() || ''; + + # updat config: $ml_name is found now (get $ml_name from CGI). + $config->set('ml_name', $ml_name); + + if ($debug) { + print "<PRE>\n"; + print "ml_name = $ml_name\n"; + print "command = $command\n"; + print "navi_command = $navi_command\n"; + print "</PRE>\n"; + } + + if (($command eq 'newml' && $ml_name) || + ($command eq 'rmml' && $ml_name)) { + print "<br>* case 1 <br>\n" if $debug; + my $command_args = { + command_mode => $mode, + comname => $command, + command => $command, + ml_name => $ml_name, + options => [ ], + argv => undef, + args => undef, + }; + + $pcb->set('cgi', 'command_args', $command_args); + $curproc->cgi_execute_command($args, $command_args); + } + elsif ($command && $address) { + print "<br>* case 2 <br>\n" if $debug; + + my $command_args = { + command_mode => $mode, + comname => $command, + command => $command, + ml_name => $ml_name, + options => [ $address ], + argv => undef, + args => undef, + }; + + $pcb->set('cgi', 'command_args', $command_args); + $curproc->cgi_execute_command($args, $command_args); + } + elsif ($navi_command) { + print "<br>* case 3 <br>\n" if $debug; + + my $command_args = { + command_mode => $mode, + comname => $navi_command, + command => $navi_command, + ml_name => $ml_name, + options => [ ], + argv => undef, + args => undef, + }; + + $pcb->set('cgi', 'command_args', $command_args); + } + elsif ($command) { + print "<br>* case 4 <br>\n" if $debug; + + my $command_args = { + command_mode => $mode, + comname => $command, + command => $command, + ml_name => $ml_name, + options => [ ], + argv => undef, + args => undef, + }; + + $pcb->set('cgi', 'command_args', $command_args); + } + else { + print "<br>* case 5 <br>\n" if $debug; + + $pcb->set('cgi', 'command_args', undef); + } +} + + +# Descriptions: show menu (table based menu) +# Arguments: OBJ($curproc) HASH_REF($args) +# Side Effects: none +# Return Value: none +sub run_cgi_navigator +{ + my ($curproc, $args) = @_; + my $config = $curproc->config(); + my $action = $curproc->safe_cgi_action_name(); + my $target = '_top'; + + # 1. ML + my $ml_name = $curproc->cgi_var_ml_name(); + my $ml_list = $curproc->cgi_var_ml_name_list(); + my $fml_url = '<A HREF="http://www.fml.org/software/fml-devel/">fml</A>'; + print "<B>$fml_url admin menu</B>\n<BR>\n"; + + print start_form(-action=>$action, -target=>$target); + + print "mailing list:\n"; + print scrolling_list(-name => 'ml_name', + -values => $ml_list, + -default => [ $ml_name ], + -size => 5); + print "\n<BR>\n"; + + # 2. command + my $navi_command = $curproc->safe_param_navi_command() || ''; + my $command = $curproc->safe_param_command() || ''; + my $command_default = $navi_command || $command; + my $command_list = $curproc->cgi_var_available_command_list(); + + print " command:\n"; + print scrolling_list(-name => 'navi_command', + -values => $command_list, + -default => [ $command_default ], + -size => 5); + print "\n<BR>\n"; + + + # 3. submit + print submit(-name => 'submit'); + print reset(-name => 'reset'); + + print end_form; +} + + +=head1 SEE ALSO + +L<CGI>, +L<FML::Process::CGI> +and +L<FML::Process::Flow> + +=head1 CODING STYLE + +See C<http://www.fml.org/software/FNF/> on fml coding style guide. + +=head1 AUTHOR + +Ken'ichi Fukamachi + +=head1 COPYRIGHT + +Copyright (C) 2003 Ken'ichi Fukamachi + +All rights reserved. This program is free software; you can +redistribute it and/or modify it under the same terms as Perl itself. + +=head1 HISTORY + +2003/09/25: FML::CGI::Menu is derived from FML::CGI::Admin::Menu. + +FML::CGI::Menu first appeared in fml8 mailing list driver package. +See C<http://www.fml.org/> for more details. + +=cut + + +1; diff --git a/fml/lib/FML/Command/Admin/newml.pm b/fml/lib/FML/Command/Admin/newml.pm index 254b5a55..f3c9b2bc 100644 --- a/fml/lib/FML/Command/Admin/newml.pm +++ b/fml/lib/FML/Command/Admin/newml.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: newml.pm,v 1.68 2003/09/12 00:01:09 fukachan Exp $ +# $FML: newml.pm,v 1.69 2003/09/13 09:16:59 fukachan Exp $ # package FML::Command::Admin::newml; @@ -118,8 +118,10 @@ sub process # XXX we assume /etc/passwd exists for backword compatibility # XXX on all unix plathomes. if ($self->_is_mta_alias_maps_has_ml_entry($curproc, $params, $ml_name)) { - warn("$ml_name already exists (somewhere in MTA aliases)"); - return ; + unless (defined $options->{ force } ) { + warn("$ml_name already exists (somewhere in MTA aliases)"); + return ; + } } # 0. creat $ml_home_dir @@ -426,17 +428,19 @@ sub _setup_cgi_interface _install($src, $dst, $params); } - # - # 3. install admin/{menu,config,thread}.cgi - # - { - use File::Spec; - my $libexec_dir = $config->{ fml_libexec_dir }; - my $src = File::Spec->catfile($libexec_dir, 'loader'); + # + # 3. install *.cgi + # + + use File::Spec; + my $libexec_dir = $config->{ fml_libexec_dir }; + my $src = File::Spec->catfile($libexec_dir, 'loader'); + my $ml_name = $config->{ ml_name }; + my $ml_domain = $config->{ ml_domain }; + # 3.1 install admin/{menu,config,thread}.cgi + { # hints - my $ml_name = $config->{ ml_name }; - my $ml_domain = $config->{ ml_domain }; $params->{ __hints_for_fml_process__ } = qq{ \$hints = { cgi_mode => 'admin', @@ -458,9 +462,28 @@ sub _setup_cgi_interface } # - # 4. install ml-admin/ - # - # XXX-TODO: install ml-admin/ + # 3.2. install ml-admin/ + { + # hints + $params->{ __hints_for_fml_process__ } = qq{ + \$hints = { + cgi_mode => 'ml-admin', + ml_name => '$ml_name', + ml_domain => '$ml_domain', + }; + }; + + use File::Spec; + for my $dst ( + File::Spec->catfile($ml_admin_cgi_dir, 'menu.cgi'), + File::Spec->catfile($ml_admin_cgi_dir, 'config.cgi'), + File::Spec->catfile($ml_admin_cgi_dir, 'thread.cgi') + ) { + $curproc->ui_message("creating $dst"); + _install($src, $dst, $params); + chmod 0755, $dst; + } + } } diff --git a/fml/lib/FML/Process/CGI/Kernel.pm b/fml/lib/FML/Process/CGI/Kernel.pm index 016a771c..2e8a1434 100644 --- a/fml/lib/FML/Process/CGI/Kernel.pm +++ b/fml/lib/FML/Process/CGI/Kernel.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: Kernel.pm,v 1.52 2003/08/29 15:34:09 fukachan Exp $ +# $FML: Kernel.pm,v 1.53 2003/09/13 09:08:12 fukachan Exp $ # package FML::Process::CGI::Kernel; @@ -18,7 +18,8 @@ use CGI qw/:standard/; use FML::Log qw(Log LogWarn LogError); use FML::Process::Kernel; -@ISA = qw(FML::Process::Kernel); +use FML::Process::CGI::Utils; +@ISA = qw(FML::Process::CGI::Utils FML::Process::Kernel); =head1 NAME @@ -402,9 +403,9 @@ show title. sub run_cgi_title { my ($curproc, $args) = @_; - my $myname = $curproc->myname(); - my $domain = $curproc->ml_domain(); - my $ml_name = $curproc->safe_param_ml_name(); + my $myname = $curproc->cgi_var_myname(); + my $domain = $curproc->cgi_var_ml_domain(); + my $ml_name = $curproc->cgi_var_ml_name(); my $role = ''; my $title = ''; @@ -429,7 +430,7 @@ help. sub run_cgi_help { my ($curproc, $args) = @_; - my $domain = $curproc->ml_domain(); + my $domain = $curproc->cgi_var_ml_domain(); print "<B>\n"; print "<CENTER>fml CGI interface for \@$domain ML's</CENTER><BR>\n"; @@ -544,7 +545,7 @@ show options. sub run_cgi_options { my ($curproc, $args) = @_; - my $domain = $curproc->ml_domain(); + my $domain = $curproc->cgi_var_ml_domain(); my $action = $curproc->safe_cgi_action_name(); print "<P> <B> options </B>\n"; @@ -616,12 +617,12 @@ return input address after validating the input # Descriptions: return input address after validating the input -# Arguments: OBJ($curproc) HASH_REF($args) +# Arguments: OBJ($curproc) # Side Effects: longjmp() if critical error occurs. # Return Value: STR sub cgi_try_get_address { - my ($curproc, $args) = @_; + my ($curproc) = @_; my $address = ''; my $a = ''; @@ -669,12 +670,12 @@ return input address after validating the input # Descriptions: return input ml_name after validating the input -# Arguments: OBJ($curproc) HASH_REF($args) +# Arguments: OBJ($curproc) # Side Effects: longjmp() if critical error occurs. # Return Value: STR sub cgi_try_get_ml_name { - my ($curproc, $args) = @_; + my ($curproc) = @_; my $ml_name = ''; my $a = ''; diff --git a/fml/lib/FML/Process/CGI/Utils.pm b/fml/lib/FML/Process/CGI/Utils.pm new file mode 100644 index 00000000..0b4ade00 --- /dev/null +++ b/fml/lib/FML/Process/CGI/Utils.pm @@ -0,0 +1,149 @@ +#-*- perl -*- +# +# Copyright (C) 2003 Ken'ichi Fukamachi +# All rights reserved. This program is free software; you can +# redistribute it and/or modify it under the same terms as Perl itself. +# +# $FML: Utils.pm,v 1.21 2003/08/25 14:13:59 fukachan Exp $ +# + +package FML::Process::CGI::Utils; +use strict; +use vars qw(@ISA @EXPORT @EXPORT_OK $AUTOLOAD); +use Carp; + +=head1 NAME + +FML::Process::CGI::Utils - utility for FML::Process::CGI::Kernel + +=head1 SYNOPSIS + +=head1 DESCRIPTION + +=head1 METHODS + +=cut + + +# Descriptions: return $ml_name, which varies with the cgi_mode. +# Arguments: OBJ($curproc) +# Side Effects: none +# Return Value: STR +sub cgi_var_ml_name +{ + my ($curproc) = @_; + my $cgi_mode = $curproc->cgi_var_cgi_mode(); + + if ($cgi_mode eq 'admin') { + return $curproc->cgi_try_get_ml_name(); + } + else { + my $hints = $curproc->hints(); + return $hints->{ ml_name }; + } +} + + +# Descriptions: return $ml_domain defined in *.cgi programd . +# ml_domain is hard-coded, not dependent on cgi_var_cgi_mode. +# Arguments: OBJ($curproc) +# Side Effects: none +# Return Value: STR +sub cgi_var_ml_domain +{ + my ($curproc) = @_; + my $hints = $curproc->hints(); + return $hints->{ ml_domain }; +} + + +# Descriptions: return $ml_home_prefix defined in *.cgi program. +# ml_home_prefix is determined by ml_domain, +# which is hard-coded, not dependent on cgi_var_cgi_mode. +# Arguments: OBJ($curproc) +# Side Effects: none +# Return Value: STR +sub cgi_var_ml_home_prefix +{ + my ($curproc) = @_; + my $ml_domain = $curproc->cgi_var_ml_domain(); + return $curproc->ml_home_prefix( $ml_domain ); +} + + +sub cgi_var_ml_name_list +{ + my ($curproc) = @_; + my $cgi_mode = $curproc->cgi_var_cgi_mode(); + my $ml_domain = $curproc->cgi_var_ml_domain(); + + if ($cgi_mode eq 'admin') { + return $curproc->get_ml_list($ml_domain); + } + else { + my $ml_name = $curproc->cgi_var_ml_name(); + return [ $ml_name ]; + } +} + + +sub cgi_var_myname +{ + my ($curproc) = @_; + + return $curproc->myname(); +} + + +sub cgi_var_available_command_list +{ + my ($curproc) = @_; + my $config = $curproc->config(); + my $cgi_mode = $curproc->cgi_var_cgi_mode(); + + if ($cgi_mode eq 'admin') { + return $config->get_as_array_ref('commands_for_admin_cgi'); + } + else { + return $config->get_as_array_ref('commands_for_ml_admin_cgi'); + } +} + + +# Descriptions: return $mode, which is hard-coded in *.cgi program. +# Arguments: OBJ($curproc) +# Side Effects: none +# Return Value: STR +sub cgi_var_cgi_mode +{ + my ($curproc) = @_; + my $hints = $curproc->hints(); + + return $hints->{ cgi_mode }; +} + + +=head1 CODING STYLE + +See C<http://www.fml.org/software/FNF/> on fml coding style guide. + +=head1 AUTHOR + +Ken'ichi Fukamachi + +=head1 COPYRIGHT + +Copyright (C) 2003 Ken'ichi Fukamachi + +All rights reserved. This program is free software; you can +redistribute it and/or modify it under the same terms as Perl itself. + +=head1 HISTORY + +FML::Process::CGI::Utils first appeared in fml8 mailing list driver package. +See C<http://www.fml.org/> for more details. + +=cut + + +1; |
