## @file # Lemonldap::NG manager main file ## @class # Lemonldap::NG manager main class package Lemonldap::NG::Manager; use strict; use Lemonldap::NG::Handler::CGI qw(:globalStorage :locationRules); #inherits use Lemonldap::NG::Manager::Help; #inherits use Lemonldap::NG::Common::Conf; #link protected conf Configuration use Lemonldap::NG::Common::Conf::Constants; #inherits our $VERSION = '0.93'; our @ISA = qw( Lemonldap::NG::Handler::CGI Lemonldap::NG::Manager::Downloader Lemonldap::NG::Manager::Uploader Lemonldap::NG::Manager::_Struct Lemonldap::NG::Manager::_i18n ); ## @cmethod Lemonldap::NG::Manager new(hashRef args) # Class constructor. #@param args hash reference #@return Lemonldap::NG::Manager object sub new { my ( $class, $args ) = @_; # 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 $self->{managerSkin} = "default" unless defined $self->{managerSkin}; $self->{managerCss} = "accordion.css" unless defined $self->{managerCss}; $self->{managerTreeAutoClose} = "true" unless defined $self->{managerTreeAutoClose}; $self->{managerTreeJqueryCss} = "true" unless defined $self->{managerTreeJqueryCss}; # Display help if ?help= if ( $self->param('help') ) { print $self->header_public( $ENV{SCRIPT_FILENAME}, -type => 'text/html; charset=utf8' ); &Lemonldap::NG::Manager::Help::import( $self->{language} ); my $chap = $self->param('help'); eval { no strict "refs"; &{"help_$chap"} }; $self->quit(); } # Save conf if ?data= elsif ( my $rdata = $self->rparam('data') ) { require Lemonldap::NG::Manager::Uploader; #inherits $self->confUpload($rdata); $self->quit(); } # File upload/download elsif ( my $rfile = $self->rparam('file') ) { require Lemonldap::NG::Manager::Uploader; #inherits my $result = $self->fileUpload('file'); my %headers = ( -type => 'text/html', -Content_Length => length($result) ); if ( my $rfilename = $self->rparam('filename') ) { $headers{-type} = 'application/octet-stream'; $headers{-attachment} = ${$rfilename}; $result =~ s/{.*"content":"(.*)"}$/$1/g; } print $self->header(%headers).$result; $self->quit(); } # Else load conf require Lemonldap::NG::Manager::Downloader; #inherits $self->{cfgNum} = $self->param('cfgNum') || $self->confObj->lastCfg() || 'UNAVAILABLE'; if ( my $p = $self->param('node') ) { print $self->header( -type => 'text/html; charset=utf8', ); print $self->node($p); $self->quit(); } if ( $self->param('cfgAttr') ) { $self->sendCfgParams( $self->conf ); } return $self; } ## @method string menu() # Build the tree menu. # @return HTML string sub menu { my $self = shift; require Lemonldap::NG::Manager::Downloader; return '