lemonldap-ng/modules/lemonldap-ng-manager/lib/Lemonldap/NG/Manager.pm

202 lines
5.5 KiB
Perl
Raw Normal View History

2009-12-17 20:20:17 +01:00
## @file
# Lemonldap::NG manager main file
## @class
# Lemonldap::NG manager main class
package Lemonldap::NG::Manager;
use strict;
use File::Basename;
2009-12-17 20:20:17 +01:00
use Lemonldap::NG::Handler::CGI qw(:globalStorage :locationRules); #inherits
2010-03-01 21:32:28 +01:00
use Lemonldap::NG::Common::Conf; #link protected conf Configuration
use Lemonldap::NG::Common::Conf::Constants; #inherits
2011-10-07 14:23:15 +02:00
our $VERSION = '1.2.0';
2009-12-11 19:17:00 +01:00
our @ISA = qw(
Lemonldap::NG::Handler::CGI
Lemonldap::NG::Manager::Downloader
Lemonldap::NG::Manager::Uploader
Lemonldap::NG::Manager::Request
2009-12-11 19:17:00 +01:00
Lemonldap::NG::Manager::_Struct
Lemonldap::NG::Manager::_i18n
);
2009-12-17 20:20:17 +01:00
## @cmethod Lemonldap::NG::Manager new(hashRef args)
# Class constructor.
#@param args hash reference
#@return Lemonldap::NG::Manager object
sub new {
my ( $class, $args ) = @_;
# Output UTF-8
binmode( STDOUT, ':utf8' );
# Try to load local configuration parameters
my $conf = Lemonldap::NG::Common::Conf->new( $args->{configStorage} )
or Lemonldap::NG::Handler::CGI->abort( 'Unable to get configuration',
$Lemonldap::NG::Common::Conf::msg );
if ( my $localconf = $conf->getLocalConf(MANAGERSECTION) ) {
$args->{$_} ||= $localconf->{$_} foreach ( keys %$localconf );
}
my $self = $class->SUPER::new($args)
or $class->abort( 'Unable to start ' . __PACKAGE__,
'See Apache logs for more' );
# Default values
2010-03-01 21:32:28 +01:00
$self->{managerSkin} = "default" unless defined $self->{managerSkin};
$self->{managerCss} = "accordion.css" unless defined $self->{managerCss};
$self->{managerCssTheme} = "ui-lightness"
unless defined $self->{managerCssTheme};
$self->{managerTreeAutoClose} = "true"
unless defined $self->{managerTreeAutoClose};
$self->{managerTreeJqueryCss} = "true"
unless defined $self->{managerTreeJqueryCss};
# Absolute path to the htdocs directory where is manager script.
my ( $mname, $mpath, $msuffix ) = fileparse( $ENV{SCRIPT_FILENAME} );
$self->{managerHtdocsPath} = $mpath;
# Save conf if ?data=
2010-11-01 23:32:06 +01:00
if ( my $rdata = $self->rparam('data') ) {
2009-12-11 19:17:00 +01:00
$self->lmLog( "Manager request: Save data $rdata", 'debug' );
2009-12-11 19:17:00 +01:00
require Lemonldap::NG::Manager::Uploader; #inherits
$self->confUpload($rdata);
$self->quit();
}
# File upload/download
elsif ( my $rfile = $self->rparam('file') ) {
$self->lmLog( "Manager request: File $rfile", 'debug' );
2010-03-20 18:14:28 +01:00
my @params = ('file');
if ( my $rfilename = $self->rparam('filename') ) {
push @params, ${$rfilename};
}
require Lemonldap::NG::Manager::Uploader; #inherits
$self->fileUpload(@params);
$self->quit();
2010-03-20 18:14:28 +01:00
}
# URL upload/download
elsif ( my $rurl = $self->rparam('url') ) {
$self->lmLog( "Manager request: URL $rurl", 'debug' );
require Lemonldap::NG::Manager::Uploader; #inherits
$self->urlUpload('url');
$self->quit();
}
# Reload menu
elsif ( my $menu = $self->param('menu') ) {
$self->lmLog( "Manager request: Menu reload for num $menu", 'debug' );
$self->{cfgNum} = $menu;
print $self->header( -type => 'text/html;charset=utf-8' );
print $self->menu();
$self->quit();
}
# Ask requests
elsif ( my $rreq = $self->rparam('request') ) {
$self->lmLog( "Manager request: $rreq", 'debug' );
require Lemonldap::NG::Manager::Request; #inherits
$self->request($rreq);
$self->quit();
}
# Else load conf
require Lemonldap::NG::Manager::Downloader; #inherits
2009-12-11 19:17:00 +01:00
$self->{cfgNum} =
$self->param('cfgNum')
|| $self->confObj->lastCfg()
|| 'UNAVAILABLE';
2009-12-11 19:17:00 +01:00
if ( my $p = $self->param('node') ) {
$self->lmLog( "Manager request: load node $p", 'debug' );
2009-12-11 19:17:00 +01:00
print $self->header( -type => 'text/html; charset=utf8', );
print $self->node($p);
$self->quit();
}
2009-12-30 18:02:23 +01:00
if ( $self->param('cfgAttr') ) {
$self->lmLog( "Manager request: load configuration attributes",
'debug' );
2009-12-30 21:00:54 +01:00
$self->sendCfgParams( $self->conf );
2009-12-30 18:02:23 +01:00
}
2009-12-11 19:17:00 +01:00
return $self;
}
2009-12-17 20:20:17 +01:00
## @method string menu()
# Build the tree menu.
# @return HTML string
2009-12-11 19:17:00 +01:00
sub menu {
my $self = shift;
2009-12-17 20:20:17 +01:00
require Lemonldap::NG::Manager::Downloader;
2009-12-11 19:17:00 +01:00
return
'<ul class="simpleTree">'
. $self->li( 'root', 'root' )
2010-01-04 14:28:10 +01:00
. $self->span(
id => 'root',
text => "Configuration $self->{cfgNum}",
data => $self->{cfgNum},
js => 'cfgDatas',
help => 'default'
)
2009-12-11 19:17:00 +01:00
. '<ul>'
. $self->node()
. '</ul></li></ul>';
}
1;
__END__
=head1 NAME
=encoding utf8
Lemonldap::NG::Manager - Perl extension for managing Lemonldap::NG Web-SSO
system.
=head1 SYNOPSIS
See example/index.pl
=head1 DESCRIPTION
Lemonldap::NG::Manager provides a web interface to manage Lemonldap::NG Web-SSO
system.
=head1 SEE ALSO
L<Lemonldap::NG::Handler>, L<Lemonldap::NG::Portal>, L<CGI>,
2010-10-26 08:08:16 +02:00
L<http://lemonldap-ng.org/>
=head1 AUTHOR
Xavier Guimard, E<lt>x.guimard@free.frE<gt>
=head1 BUG REPORT
Use OW2 system to report bug or ask for features:
2010-10-26 08:08:16 +02:00
L<http://jira.ow2.org>
=head1 DOWNLOAD
Lemonldap::NG is available at
L<http://forge.objectweb.org/project/showfiles.php?group_id=274>
=head1 COPYRIGHT AND LICENSE
2010-10-23 10:35:38 +02:00
Copyright (C) 2006, 2009, 2010 by Xavier Guimard
This library is free software; you can redistribute it and/or modify
2010-10-24 09:25:44 +02:00
it under the same terms as Perl itself, either Perl version 5.10.0 or,
at your option, any later version of Perl 5 you may have available.
=cut