POD documentation and split Manager.pm in 2 pieces because inheritance of CGI is not compatible with the use of
AutoLoader (_HTML.pm).
This commit is contained in:
parent
0761e8a7b2
commit
9cdefde06f
|
@ -46,6 +46,7 @@ example/imgs/tombs_mag.gif
|
||||||
example/lemonldap-ng-manager.js
|
example/lemonldap-ng-manager.js
|
||||||
example/index.pl
|
example/index.pl
|
||||||
lib/Lemonldap/NG/Manager.pm
|
lib/Lemonldap/NG/Manager.pm
|
||||||
|
lib/Lemonldap/NG/Manager/_HTML.pm
|
||||||
lib/Lemonldap/NG/Manager/Base.pm
|
lib/Lemonldap/NG/Manager/Base.pm
|
||||||
lib/Lemonldap/NG/Manager/Conf.pm
|
lib/Lemonldap/NG/Manager/Conf.pm
|
||||||
lib/Lemonldap/NG/Manager/Conf/DBI.pm
|
lib/Lemonldap/NG/Manager/Conf/DBI.pm
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
* manpage of Lemonldap::NG::Manager::Conf*
|
* system to alert if configuration as changed between get and update
|
||||||
|
|
||||||
|
|
|
@ -3,52 +3,50 @@ package Lemonldap::NG::Manager;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
use XML::Simple;
|
use XML::Simple;
|
||||||
|
|
||||||
#use AutoLoader qw(AUTOLOAD);
|
#use AutoLoader qw(AUTOLOAD);
|
||||||
use Lemonldap::NG::Manager::Base;
|
use Lemonldap::NG::Manager::Base;
|
||||||
use Lemonldap::NG::Manager::Conf;
|
use Lemonldap::NG::Manager::Conf;
|
||||||
|
use Lemonldap::NG::Manager::_HTML;
|
||||||
|
|
||||||
our @ISA = qw(Lemonldap::NG::Manager::Base);
|
our @ISA = qw(Lemonldap::NG::Manager::Base);
|
||||||
|
|
||||||
our $VERSION = '0.04';
|
our $VERSION = '0.1';
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my($class,$args) = @_;
|
my ( $class, $args ) = @_;
|
||||||
my $self = $class->SUPER::new();
|
my $self = $class->SUPER::new();
|
||||||
unless($args) {
|
unless ($args) {
|
||||||
print STDERR "parameters are required, I can't start so\n";
|
print STDERR "parameters are required, I can't start so\n";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
%$self = (%$self,%$args);
|
%$self = ( %$self, %$args );
|
||||||
foreach(qw(configStorage dhtmlXTreeImageLocation)) {
|
foreach (qw(configStorage dhtmlXTreeImageLocation)) {
|
||||||
unless($self->{$_}) {
|
unless ( $self->{$_} ) {
|
||||||
print STDERR qq/The "$_" parameter is required\n/;
|
print STDERR qq/The "$_" parameter is required\n/;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$self->{jsFile} ||= $self->_dir."lemonldap-ng-manager.js";
|
$self->{jsFile} ||= $self->_dir . "lemonldap-ng-manager.js";
|
||||||
unless(-r $self->{jsFile}) {
|
unless ( -r $self->{jsFile} ) {
|
||||||
print STDERR qq#Unable to read $self->{jsFile}. You have to set "jsFile" parameter to /path/to/lemonldap-ng-manager.js\n#;
|
print STDERR qq#Unable to read $self->{jsFile}. You have to set "jsFile" parameter to /path/to/lemonldap-ng-manager.js\n#;
|
||||||
}
|
}
|
||||||
if($self->param('lmQuery')) {
|
if ( $self->param('lmQuery') ) {
|
||||||
my $tmp = "print_" . $self->param('lmQuery');
|
my $tmp = "print_" . $self->param('lmQuery');
|
||||||
$self->$tmp;
|
$self->$tmp;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
my $datas;
|
my $datas;
|
||||||
if($datas = $self->param('POSTDATA')) {
|
if ( $datas = $self->param('POSTDATA') ) {
|
||||||
$self->print_upload(\$datas);
|
$self->print_upload( \$datas );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
# LOADED SUBROUTINES
|
|
||||||
# HTML, CSS and Javascripts are loaded with Autoload and exported with
|
|
||||||
# 'Cache-Control: Public'. So it as not to be loaded each time
|
|
||||||
|
|
||||||
# Subroutines to make all the work
|
# Subroutines to make all the work
|
||||||
sub doall {
|
sub doall {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
@ -61,23 +59,25 @@ sub doall {
|
||||||
# CSS and Javascript export
|
# CSS and Javascript export
|
||||||
sub print_css {
|
sub print_css {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
print $self->header_public($ENV{SCRIPT_FILENAME}, -type => 'text/css');
|
print $self->header_public( $ENV{SCRIPT_FILENAME}, -type => 'text/css' );
|
||||||
$self->css;
|
$self->css;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub print_libjs {
|
sub print_libjs {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
print $self->header_public($self->{jsFile}, -type => 'application/x-javascript');
|
print $self->header_public( $self->{jsFile},
|
||||||
|
-type => 'application/x-javascript' );
|
||||||
open F, $self->{jsFile};
|
open F, $self->{jsFile};
|
||||||
while(<F>) {
|
while (<F>) {
|
||||||
print;
|
print;
|
||||||
}
|
}
|
||||||
close F;
|
close F;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub print_lmjs {
|
sub print_lmjs {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
print $self->header_public($ENV{SCRIPT_FILENAME}, -type => 'text/javascript');
|
print $self->header_public( $ENV{SCRIPT_FILENAME},
|
||||||
|
-type => 'text/javascript' );
|
||||||
$self->javascript;
|
$self->javascript;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,16 +99,16 @@ sub print_conf {
|
||||||
|
|
||||||
sub default {
|
sub default {
|
||||||
return {
|
return {
|
||||||
cfgNum => 0,
|
cfgNum => 0,
|
||||||
ldapBase => "dc=example,dc=com",
|
ldapBase => "dc=example,dc=com",
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
sub printXmlConf {
|
sub printXmlConf {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $config = $self->config->getConf();
|
my $config = $self->config->getConf();
|
||||||
$config = $self->default unless($config);
|
$config = $self->default unless ($config);
|
||||||
my $tree = {
|
my $tree = {
|
||||||
id => '0',
|
id => '0',
|
||||||
item => {
|
item => {
|
||||||
id => 'root',
|
id => 'root',
|
||||||
|
@ -130,14 +130,15 @@ sub printXmlConf {
|
||||||
text => 'Stockage des sessions',
|
text => 'Stockage des sessions',
|
||||||
item => {
|
item => {
|
||||||
globalStorageOptions => {
|
globalStorageOptions => {
|
||||||
text => 'Paramètres du module Apache::Session',
|
text =>
|
||||||
|
'Paramètres du module Apache::Session',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
authParams => {
|
authParams => {
|
||||||
text => "Paramètres d'authentification",
|
text => "Paramètres d'authentification",
|
||||||
item => {},
|
item => {},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
groups => { text => "Groupes d'utilisateurs", },
|
groups => { text => "Groupes d'utilisateurs", },
|
||||||
|
@ -154,12 +155,33 @@ sub printXmlConf {
|
||||||
my $sessionStorage = $tree->{item}->{item}->{generalParameters}->{item}->{sessionStorage}->{item};
|
my $sessionStorage = $tree->{item}->{item}->{generalParameters}->{item}->{sessionStorage}->{item};
|
||||||
my $globalStorageOptions = $tree->{item}->{item}->{generalParameters}->{item}->{sessionStorage}->{item}->{globalStorageOptions}->{item};
|
my $globalStorageOptions = $tree->{item}->{item}->{generalParameters}->{item}->{sessionStorage}->{item}->{globalStorageOptions}->{item};
|
||||||
my $authParams = $tree->{item}->{item}->{generalParameters}->{item}->{authParams}->{item};
|
my $authParams = $tree->{item}->{item}->{generalParameters}->{item}->{authParams}->{item};
|
||||||
$authParams->{authentication} = $self->xmlField( "value", $config->{authentication} || 'ldap', "Type d'authentification" );
|
$authParams->{authentication} = $self->xmlField(
|
||||||
$authParams->{portal} = $self->xmlField( "value", $config->{portal} || 'http://portal/', "Portail" );
|
"value",
|
||||||
$authParams->{securedCookie} = $self->xmlField( "value", $config->{securedCookie} || 0, "Cookie sécurisé (SSL)" );
|
$config->{authentication} || 'ldap',
|
||||||
|
"Type d'authentification"
|
||||||
|
);
|
||||||
|
$authParams->{portal} =
|
||||||
|
$self->xmlField(
|
||||||
|
"value",
|
||||||
|
$config->{portal} || 'http://portal/',
|
||||||
|
"Portail" );
|
||||||
|
$authParams->{securedCookie} = $self->xmlField(
|
||||||
|
"value",
|
||||||
|
$config->{securedCookie} || 0,
|
||||||
|
"Cookie sécurisé (SSL)"
|
||||||
|
);
|
||||||
|
|
||||||
$generalParameters->{domain} = $self->xmlField( "value", $config->{domain} || 'example.com', 'Domaine' );
|
$generalParameters->{domain} =
|
||||||
$generalParameters->{cookieName} = $self->xmlField( "value", $config->{cookieName} || 'lemonldap', 'Nom du cookie' );
|
$self->xmlField(
|
||||||
|
"value",
|
||||||
|
$config->{domain} || 'example.com',
|
||||||
|
'Domaine'
|
||||||
|
);
|
||||||
|
$generalParameters->{cookieName} = $self->xmlField(
|
||||||
|
"value",
|
||||||
|
$config->{cookieName} || 'lemonldap',
|
||||||
|
'Nom du cookie'
|
||||||
|
);
|
||||||
|
|
||||||
$sessionStorage->{globalStorage} = $self->xmlField(
|
$sessionStorage->{globalStorage} = $self->xmlField(
|
||||||
"value",
|
"value",
|
||||||
|
@ -167,11 +189,30 @@ sub printXmlConf {
|
||||||
'Module Apache::Session'
|
'Module Apache::Session'
|
||||||
);
|
);
|
||||||
|
|
||||||
$ldapParameters->{ldapServer} = $self->xmlField( "value", $config->{ldapServer} || 'localhost', 'Serveur LDAP' );
|
$ldapParameters->{ldapServer} = $self->xmlField(
|
||||||
$ldapParameters->{ldapPort} = $self->xmlField( "value", $config->{ldapPort} || 389, 'Port du serveur LDAP' );
|
"value",
|
||||||
$ldapParameters->{ldapBase} = $self->xmlField( "value", $config->{ldapBase} || ' ', 'Base de recherche LDAP' );
|
$config->{ldapServer} || 'localhost',
|
||||||
$ldapParameters->{managerDn} = $self->xmlField( "value", $config->{managerDn} || ' ', 'Compte de connexion LDAP');
|
'Serveur LDAP' );
|
||||||
$ldapParameters->{managerPassword} = $self->xmlField( "value", $config->{managerPassword} || ' ', 'Mot de passe LDAP' );
|
$ldapParameters->{ldapPort} = $self->xmlField(
|
||||||
|
"value",
|
||||||
|
$config->{ldapPort} || 389,
|
||||||
|
'Port du serveur LDAP'
|
||||||
|
);
|
||||||
|
$ldapParameters->{ldapBase} = $self->xmlField(
|
||||||
|
"value",
|
||||||
|
$config->{ldapBase} || ' ',
|
||||||
|
'Base de recherche LDAP'
|
||||||
|
);
|
||||||
|
$ldapParameters->{managerDn} = $self->xmlField(
|
||||||
|
"value",
|
||||||
|
$config->{managerDn} || ' ',
|
||||||
|
'Compte de connexion LDAP'
|
||||||
|
);
|
||||||
|
$ldapParameters->{managerPassword} = $self->xmlField(
|
||||||
|
"value",
|
||||||
|
$config->{managerPassword} || ' ',
|
||||||
|
'Mot de passe LDAP'
|
||||||
|
);
|
||||||
|
|
||||||
if ( $config->{exportedVars} ) {
|
if ( $config->{exportedVars} ) {
|
||||||
while ( my ( $n, $att ) = each( %{ $config->{exportedVars} } ) ) {
|
while ( my ( $n, $att ) = each( %{ $config->{exportedVars} } ) ) {
|
||||||
|
@ -185,8 +226,9 @@ sub printXmlConf {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $config->{globalStorageOptions} ) {
|
if ( $config->{globalStorageOptions} ) {
|
||||||
$tree->{item}->{item}->{generalParameters}->{item}->{sessionStorage}->{item}->{globalStorageOptions}->{item} = {};
|
$tree->{item}->{item}->{generalParameters}->{item}->{sessionStorage}->{item}->{globalStorageOptions}->{item} = {};
|
||||||
$globalStorageOptions = $tree->{item}->{item}->{generalParameters}->{item}->{sessionStorage}->{item}->{globalStorageOptions}->{item};
|
$globalStorageOptions =
|
||||||
|
$tree->{item}->{item}->{generalParameters}->{item}->{sessionStorage}->{item}->{globalStorageOptions}->{item};
|
||||||
while ( my ( $n, $opt ) = each( %{ $config->{globalStorageOptions} } ) ) {
|
while ( my ( $n, $opt ) = each( %{ $config->{globalStorageOptions} } ) ) {
|
||||||
$globalStorageOptions->{$n} = $self->xmlField( "both", $opt, $n );
|
$globalStorageOptions->{$n} = $self->xmlField( "both", $opt, $n );
|
||||||
}
|
}
|
||||||
|
@ -200,8 +242,7 @@ sub printXmlConf {
|
||||||
my $virtualHost = $tree->{item}->{item}->{virtualHosts}->{item};
|
my $virtualHost = $tree->{item}->{item}->{virtualHosts}->{item};
|
||||||
while ( my ( $host, $rules ) = each( %{ $config->{locationRules} } ) ) {
|
while ( my ( $host, $rules ) = each( %{ $config->{locationRules} } ) ) {
|
||||||
$virtualHost->{$host} = $self->xmlField( "text", 'i', $host );
|
$virtualHost->{$host} = $self->xmlField( "text", 'i', $host );
|
||||||
my ( $ih, $ir ) =
|
my ( $ih, $ir ) = ( "exportedHeaders_$indice", "locationRules_$indice" );
|
||||||
( "exportedHeaders_$indice", "locationRules_$indice" );
|
|
||||||
$virtualHost->{$host}->{item} = {
|
$virtualHost->{$host}->{item} = {
|
||||||
"$ih" => { text => "Headers", },
|
"$ih" => { text => "Headers", },
|
||||||
"$ir" => { text => "Règles", },
|
"$ir" => { text => "Règles", },
|
||||||
|
@ -227,8 +268,9 @@ sub printXmlConf {
|
||||||
$groups->{$group} = $self->xmlField( 'both', $expr, $group );
|
$groups->{$group} = $self->xmlField( 'both', $expr, $group );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print XMLout( $tree,
|
print XMLout(
|
||||||
|
$tree,
|
||||||
XMLDecl => "<?xml version='1.0' encoding='iso-8859-1'?>",
|
XMLDecl => "<?xml version='1.0' encoding='iso-8859-1'?>",
|
||||||
RootName => 'tree',
|
RootName => 'tree',
|
||||||
KeyAttr => { item => 'id', username => 'name' },
|
KeyAttr => { item => 'id', username => 'name' },
|
||||||
|
@ -253,28 +295,28 @@ sub xmlField {
|
||||||
|
|
||||||
# Upload subroutines
|
# Upload subroutines
|
||||||
sub print_upload {
|
sub print_upload {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $datas = shift;
|
my $datas = shift;
|
||||||
print $self->header( -type => "text/html" );
|
print $self->header( -type => "text/html" );
|
||||||
my $tmp = $self->upload($datas);
|
my $tmp = $self->upload($datas);
|
||||||
if($tmp) {
|
if ($tmp) {
|
||||||
print $tmp;
|
print $tmp;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
print 0;
|
print 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub upload {
|
sub upload {
|
||||||
my($self, $tree) = @_;
|
my ( $self, $tree ) = @_;
|
||||||
$tree = XMLin($$tree);
|
$tree = XMLin($$tree);
|
||||||
my $config = {};
|
my $config = {};
|
||||||
while ( my ( $g, $h ) = each( %{ $tree->{groups} } ) ) {
|
while ( my ( $g, $h ) = each( %{ $tree->{groups} } ) ) {
|
||||||
next unless ( ref($h) );
|
next unless ( ref($h) );
|
||||||
$config->{groups}->{$h->{text}} = $h->{value};
|
$config->{groups}->{ $h->{text} } = $h->{value};
|
||||||
}
|
}
|
||||||
VH: while ( my ( $vh, $h ) = each( %{ $tree->{virtualHosts} } ) ) {
|
while ( my ( $vh, $h ) = each( %{ $tree->{virtualHosts} } ) ) {
|
||||||
next VH unless ( ref($h) );
|
next unless ( ref($h) );
|
||||||
my $lr;
|
my $lr;
|
||||||
my $eh;
|
my $eh;
|
||||||
foreach ( keys(%$h) ) {
|
foreach ( keys(%$h) ) {
|
||||||
|
@ -293,21 +335,31 @@ sub upload {
|
||||||
$config->{cookieName} = $tree->{generalParameters}->{cookieName}->{value};
|
$config->{cookieName} = $tree->{generalParameters}->{cookieName}->{value};
|
||||||
$config->{domain} = $tree->{generalParameters}->{domain}->{value};
|
$config->{domain} = $tree->{generalParameters}->{domain}->{value};
|
||||||
$config->{globalStorage} = $tree->{generalParameters}->{sessionStorage}->{globalStorage}->{value};
|
$config->{globalStorage} = $tree->{generalParameters}->{sessionStorage}->{globalStorage}->{value};
|
||||||
while ( my ( $v, $h ) = each( %{$tree->{generalParameters}->{sessionStorage}->{globalStorageOptions}})) {
|
while (
|
||||||
|
my ( $v, $h ) = each(
|
||||||
|
%{
|
||||||
|
$tree->{generalParameters}->{sessionStorage}->{globalStorageOptions}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
{
|
||||||
next unless ( ref($h) );
|
next unless ( ref($h) );
|
||||||
$config->{globalStorageOptions}->{$h->{text}} = $h->{value};
|
$config->{globalStorageOptions}->{ $h->{text} } = $h->{value};
|
||||||
}
|
}
|
||||||
foreach (qw(ldapBase ldapPort ldapServer managerDn managerPassword)) {
|
foreach (qw(ldapBase ldapPort ldapServer managerDn managerPassword)) {
|
||||||
$config->{$_} = $tree->{generalParameters}->{ldapParameters}->{$_}->{value};
|
$config->{$_} =
|
||||||
$config->{$_} = '' if(ref($config->{$_}));
|
$tree->{generalParameters}->{ldapParameters}->{$_}->{value};
|
||||||
$config->{$_} =~ s/^\s*(.*?)\s*/$1/;
|
$config->{$_} = '' if ( ref( $config->{$_} ) );
|
||||||
|
$config->{$_} =~ s/^\s*(.*?)\s*/$1/;
|
||||||
}
|
}
|
||||||
foreach (qw(authentication portal securedCookie)) {
|
foreach (qw(authentication portal securedCookie)) {
|
||||||
$config->{$_} = $tree->{generalParameters}->{authParams}->{$_}->{value};
|
$config->{$_} = $tree->{generalParameters}->{authParams}->{$_}->{value};
|
||||||
$config->{$_} = '' if(ref($config->{$_}));
|
$config->{$_} = '' if ( ref( $config->{$_} ) );
|
||||||
$config->{$_} =~ s/^\s*(.*?)\s*/$1/;
|
$config->{$_} =~ s/^\s*(.*?)\s*/$1/;
|
||||||
}
|
}
|
||||||
while ( my ( $v, $h ) = each( %{ $tree->{generalParameters}->{exportedVars} } ) ) {
|
while ( my ( $v, $h ) =
|
||||||
|
each( %{ $tree->{generalParameters}->{exportedVars} } ) )
|
||||||
|
{
|
||||||
next unless ( ref($h) );
|
next unless ( ref($h) );
|
||||||
$config->{exportedVars}->{$v} = $h->{value};
|
$config->{exportedVars}->{$v} = $h->{value};
|
||||||
}
|
}
|
||||||
|
@ -316,7 +368,7 @@ sub upload {
|
||||||
|
|
||||||
# Internal subroutines
|
# Internal subroutines
|
||||||
sub _dir {
|
sub _dir {
|
||||||
my $d=$ENV{SCRIPT_FILENAME};
|
my $d = $ENV{SCRIPT_FILENAME};
|
||||||
$d =~ s#[^/]*$##;
|
$d =~ s#[^/]*$##;
|
||||||
return $d;
|
return $d;
|
||||||
}
|
}
|
||||||
|
@ -324,362 +376,20 @@ sub _dir {
|
||||||
sub config {
|
sub config {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
return $self->{_config} if $self->{_config};
|
return $self->{_config} if $self->{_config};
|
||||||
$self->{_config} = Lemonldap::NG::Manager::Conf->new($self->{configStorage});
|
$self->{_config} =
|
||||||
unless($self->{_config}) {
|
Lemonldap::NG::Manager::Conf->new( $self->{configStorage} );
|
||||||
die "Configuration not loaded\n";
|
unless ( $self->{_config} ) {
|
||||||
|
die "Configuration not loaded\n";
|
||||||
}
|
}
|
||||||
return $self->{_config};
|
return $self->{_config};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*css = *Lemonldap::NG::Manager::_HTML::css;
|
||||||
|
*javascript = *Lemonldap::NG::Manager::_HTML::javascript;
|
||||||
|
*main = *Lemonldap::NG::Manager::_HTML::main;
|
||||||
|
*start_html = *Lemonldap::NG::Manager::_HTML::start_html;
|
||||||
|
|
||||||
sub css {
|
|
||||||
my $self = shift;
|
|
||||||
print <<EOT;
|
|
||||||
/* xSplitter Styles */
|
|
||||||
.clsSplitter
|
|
||||||
{
|
|
||||||
position: absolute;
|
|
||||||
overflow: hidden;
|
|
||||||
visibility: hidden;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
background: #FFF;
|
|
||||||
border: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.clsPane
|
|
||||||
{
|
|
||||||
position: absolute;
|
|
||||||
overflow: auto;
|
|
||||||
visibility: visible;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
background: #FFF;
|
|
||||||
border: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.clsDragBar
|
|
||||||
{
|
|
||||||
position: absolute;
|
|
||||||
overflow: hidden;
|
|
||||||
visibility: visible;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
background: lightgrey;
|
|
||||||
border: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Application Styles */
|
|
||||||
|
|
||||||
#xBody { overflow: visible; background-color: #FFF; }
|
|
||||||
.clsTemporaryContainer /* replace this with something like xFenster */
|
|
||||||
{
|
|
||||||
position: relative;
|
|
||||||
overflow: visible;
|
|
||||||
visibility: visible;
|
|
||||||
background: transparent;
|
|
||||||
border: none;
|
|
||||||
}
|
|
||||||
#idSplitter3 { border: 4px solid lightgrey; }
|
|
||||||
h3, p { padding: 0 0 0 6px; border: none; }
|
|
||||||
#buttons { text-align: center; }
|
|
||||||
#help { text-align: left; }
|
|
||||||
EOT
|
|
||||||
}
|
|
||||||
|
|
||||||
sub javascript {
|
|
||||||
my $self = shift;
|
|
||||||
print <<EOT;
|
|
||||||
var s3,s32;
|
|
||||||
window.onload=function(){
|
|
||||||
var w=X.clientWidth()-12;
|
|
||||||
var h=X.clientHeight()-12;
|
|
||||||
//var h=window.outerHeight;
|
|
||||||
s32=new xSplitter('idSplitter32',0,0,0,0,false,4,3*h/4,h/8,true,0);
|
|
||||||
s3=new xSplitter('idSplitter3',0,0,w,h,true,4,w/4,w/8,true,4,null,s32);
|
|
||||||
X.addEventListener(window,'resize',win_onresize,false);
|
|
||||||
document.body.style.cursor='wait';
|
|
||||||
tree=new dhtmlXTreeObject(document.getElementById('treeBox'),"100%","100%",0);
|
|
||||||
tree.setImagePath("$self->{dhtmlXTreeImageLocation}");
|
|
||||||
tree.setXMLAutoLoading("$ENV{SCRIPT_NAME}?lmQuery=conf");
|
|
||||||
tree.loadXML("$ENV{SCRIPT_NAME}?lmQuery=conf");
|
|
||||||
tree.setOnClickHandler(onNodeSelect);
|
|
||||||
window.setTimeout("document.body.style.cursor='auto'",1000);
|
|
||||||
};
|
|
||||||
|
|
||||||
function win_onresize(){
|
|
||||||
var cw=X.clientWidth();
|
|
||||||
var w=X.clientWidth()-12;
|
|
||||||
var h=X.clientHeight()-12;
|
|
||||||
s3.paint(w,h,w/4,w/5);
|
|
||||||
}
|
|
||||||
|
|
||||||
var indice=-1;
|
|
||||||
|
|
||||||
function onNodeSelect(nodeId) {
|
|
||||||
var k,v;
|
|
||||||
if(tree.getUserData(nodeId,"modif")) {
|
|
||||||
switch(tree.getUserData(nodeId,"modif")) {
|
|
||||||
case 'text':
|
|
||||||
k='valeur';
|
|
||||||
v='<input value="'+nodeId+'" onChange="tree.setItemText('+"'"+nodeId+"'"+',this.value);tree.changeItemId('+"'"+nodeId+"'"+',this.value);">';
|
|
||||||
break;
|
|
||||||
case 'both':
|
|
||||||
k='<input value="'+tree.getItemText(nodeId)+'" onChange="tree.setItemText('+"'"+nodeId+"'"+',this.value)">';
|
|
||||||
v='<textarea cols=40 rows=2 onChange="tree.setUserData('+"'"+nodeId+"'"+','+"'"+'value'+"'"+',this.value)">'+tree.getUserData(nodeId,'value')+'</textarea>';
|
|
||||||
//v='<input size=80 name="value" value="'+tree.getUserData(nodeId,'value')+'" onChange="tree.setUserData('+"'"+nodeId+"'"+','+"'"+'value'+"'"+',this.value)">';
|
|
||||||
break;
|
|
||||||
case 'value':
|
|
||||||
k=tree.getItemText(nodeId);
|
|
||||||
v='<textarea cols=40 rows=2 onChange="tree.setUserData('+"'"+nodeId+"'"+','+"'"+'value'+"'"+',this.value)">'+tree.getUserData(nodeId,'value')+'</textarea>';
|
|
||||||
//v='<input size=80 name="value" value="'+tree.getUserData(nodeId,'value')+'" onChange="tree.setUserData('+"'"+nodeId+"'"+','+"'"+'value'+"'"+',this.value)">';
|
|
||||||
}
|
|
||||||
document.getElementById('formulaire').style.display='block';
|
|
||||||
document.getElementById('name').innerHTML = k;
|
|
||||||
document.getElementById('value').innerHTML = v;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
document.getElementById('formulaire').style.display='none';
|
|
||||||
}
|
|
||||||
var but='';
|
|
||||||
if(nodeIs(nodeId,"virtualHosts")){
|
|
||||||
but+=button('Nouvel Hôte Virtuel','newVirtualHost',nodeId);
|
|
||||||
if(nodeIs(nodeId,"virtualHost")){
|
|
||||||
but+=button('Nouvelle règle','newRule',nodeId);
|
|
||||||
but+=button('Nouvel en-tête','newHeader',nodeId);
|
|
||||||
}
|
|
||||||
help('virtualHosts');
|
|
||||||
}
|
|
||||||
else if(nodeIs(nodeId,"groups")){
|
|
||||||
but+=button('Nouveau groupe','newGroup',nodeId);
|
|
||||||
help('groups');
|
|
||||||
}
|
|
||||||
else if(nodeIs(nodeId,"generalParameters")){
|
|
||||||
if(nodeIs(nodeId,"ldapParameters")){
|
|
||||||
help('ldap');
|
|
||||||
}
|
|
||||||
else if(nodeIs(nodeId,"exportedVars")){
|
|
||||||
but+=button('Nouvelle variable','newVar',nodeId);
|
|
||||||
help('vars');
|
|
||||||
}
|
|
||||||
else if(nodeIs(nodeId,'sessionStorage')){
|
|
||||||
if(nodeIs(nodeId,"globalStorageOptions")){
|
|
||||||
but+=button('Nouvelle option','newGSOpt',nodeId);
|
|
||||||
}
|
|
||||||
help('storage');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(tree.getUserData(nodeId,"modif")=='both') but+=button("Supprimer",'deleteNode',nodeId);
|
|
||||||
but+=button('Sauvegarder','saveConf');
|
|
||||||
document.getElementById('buttons').innerHTML = but;
|
|
||||||
}
|
|
||||||
|
|
||||||
function nodeIs(id,type) {
|
|
||||||
if(id==type)return 1;
|
|
||||||
if(id=="root")return 0;
|
|
||||||
var next=tree.getParentId(id);
|
|
||||||
if(type=="virtualHost" && next=="virtualHosts")return 1;
|
|
||||||
return nodeIs(next,type);
|
|
||||||
}
|
|
||||||
|
|
||||||
function vhostId(id){
|
|
||||||
var next=tree.getParentId(id);
|
|
||||||
if(next=="virtualHosts") return id;
|
|
||||||
return vhostId(next);
|
|
||||||
}
|
|
||||||
|
|
||||||
function button(text,func,nodeId){
|
|
||||||
return '<input type=button value="'+text+'" onclick="'+func+'('+"'"+nodeId+"'"+')"> ';
|
|
||||||
}
|
|
||||||
|
|
||||||
function insertNewChild(a,b,c) {
|
|
||||||
tree.insertNewChild(a,b,c);
|
|
||||||
tree.setItemColor(b,"#000000","#0000FF");
|
|
||||||
}
|
|
||||||
|
|
||||||
function newVirtualHost() {
|
|
||||||
var rep=prompt("Nouvel hôte virtuel");
|
|
||||||
if(rep) {
|
|
||||||
insertNewChild('virtualHosts',rep,rep)
|
|
||||||
tree.setUserData(rep,'modif','text');
|
|
||||||
insertNewChild(rep,rep+'_exportedHeaders','Headers');
|
|
||||||
insertNewChild(rep+'_exportedHeaders',rep+'_exportedHeaders_1','Auth-User');
|
|
||||||
tree.setUserData(rep+'_exportedHeaders_1','modif','both');
|
|
||||||
tree.setUserData(rep+'_exportedHeaders_1','value','\$uid');
|
|
||||||
insertNewChild(rep,rep+'_locationRules','Règles');
|
|
||||||
insertNewChild(rep+'_locationRules',rep+'_locationRules_default','default');
|
|
||||||
tree.setUserData(rep+'_locationRules_default','modif','value');
|
|
||||||
tree.setUserData(rep+'_locationRules_default','value','deny');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function newValue(id,text,type,value){
|
|
||||||
indice--;
|
|
||||||
insertNewChild(id,'j_'+indice,text);
|
|
||||||
tree.setUserData('j_'+indice,'modif',type);
|
|
||||||
tree.setUserData('j_'+indice,'value',value);
|
|
||||||
tree.selectItem('j_'+indice,true);
|
|
||||||
}
|
|
||||||
|
|
||||||
function newRule(id){
|
|
||||||
var lr=tree.getItemIdByIndex(vhostId(id),1);
|
|
||||||
newValue(lr,'New rule','both','deny');
|
|
||||||
}
|
|
||||||
|
|
||||||
function newHeader(id){
|
|
||||||
var eh=tree.getItemIdByIndex(vhostId(id),0);
|
|
||||||
newValue(eh,'New-Header','both','\$uid');
|
|
||||||
}
|
|
||||||
|
|
||||||
function newGroup(id){
|
|
||||||
newValue('groups','New-group','both','');
|
|
||||||
}
|
|
||||||
|
|
||||||
function newVar(id){
|
|
||||||
newValue('exportedVars','New-var','both','uid');
|
|
||||||
}
|
|
||||||
|
|
||||||
function newGSOpt(id){
|
|
||||||
newValue('globalStorageOptions','New-Opt','both','');
|
|
||||||
}
|
|
||||||
|
|
||||||
function deleteNode(id){
|
|
||||||
tree.deleteItem(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
var xhr_object = null;
|
|
||||||
|
|
||||||
if(window.XMLHttpRequest) // Firefox
|
|
||||||
xhr_object = new XMLHttpRequest();
|
|
||||||
else if(window.ActiveXObject) // Internet Explorer
|
|
||||||
xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
|
|
||||||
else { // XMLHttpRequest non supporté par le navigateur
|
|
||||||
alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest: sauvegarde impossible.");
|
|
||||||
}
|
|
||||||
|
|
||||||
function help(s){
|
|
||||||
xhr_object.open("GET", "$ENV{SCRIPT_NAME}?lmQuery=help&help="+s, true);
|
|
||||||
xhr_object.onreadystatechange = function() {
|
|
||||||
if(xhr_object.readyState == 4) document.getElementById('help').innerHTML=xhr_object.responseText;
|
|
||||||
}
|
|
||||||
xhr_object.send(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
function saveConf(){
|
|
||||||
var h=tree2txt('root');
|
|
||||||
//document.getElementById('help').innerHTML="<pre>"+h+"</pre>";
|
|
||||||
xhr_object.open("POST", "$ENV{SCRIPT_NAME}?lmQuery=upload",true);
|
|
||||||
xhr_object.setRequestHeader("Content-type", "text/xml");
|
|
||||||
xhr_object.setRequestHeader("Content-length", h.length);
|
|
||||||
xhr_object.onreadystatechange = function() {
|
|
||||||
if(xhr_object.readyState == 4){
|
|
||||||
var r=xhr_object.responseText;
|
|
||||||
if(r>0) {
|
|
||||||
tree.setItemText('root','Configuration '+r);
|
|
||||||
document.getElementById('help').innerHTML='<h3>Configuration sauvegardée sous le numéro : '+r+'</h3>';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
document.getElementById('help').innerHTML='<h3>Échec de la sauvegarde</h3>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else document.getElementById('help').innerHTML='<h3>Échec de la sauvegarde</h3>';
|
|
||||||
}
|
|
||||||
xhr_object.send(h);
|
|
||||||
}
|
|
||||||
|
|
||||||
function tree2txt(id){
|
|
||||||
var s=tree.getSubItems(id);
|
|
||||||
var c=s.split(',');
|
|
||||||
var r='<'+id+"><text>"+ec(tree.getItemText(id))+"</text>\\n";
|
|
||||||
if((!s) || s=='' || c.length==0){
|
|
||||||
r+= '<value>'+ec(tree.getUserData(id,'value'))+"</value>\\n";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
for(var i=0;i<c.length;i++){
|
|
||||||
r+=tree2txt(c[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
r+="</"+id+">\\n";
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
function ec(s){
|
|
||||||
if((!s) || s=='') return s;
|
|
||||||
return s.replace(/>/g,'>').replace(/</g,'<');
|
|
||||||
}
|
|
||||||
EOT
|
|
||||||
}
|
|
||||||
|
|
||||||
sub start_html {
|
|
||||||
my $self = shift;
|
|
||||||
my %args = @_;
|
|
||||||
$args{'-style'} = { -src => [ $args{'-style'} ] } if($args{'-style'} and !ref($args{'-style'}));
|
|
||||||
push @{$args{'-style'}->{'-src'}}, "$ENV{SCRIPT_NAME}?lmQuery=css";
|
|
||||||
$args{'-title'} ||= 'Lemonldap::NG Configuration';
|
|
||||||
$self->SUPER::start_html(%args);
|
|
||||||
}
|
|
||||||
|
|
||||||
sub main {
|
|
||||||
my $self = shift;
|
|
||||||
# Lemonldap::Manager javascripts;
|
|
||||||
print qq#<script type="text/javascript" src="$ENV{SCRIPT_NAME}?lmQuery=libjs"></script>#;
|
|
||||||
print qq#<script type="text/javascript" src="$ENV{SCRIPT_NAME}?lmQuery=lmjs"></script>#;
|
|
||||||
# HTML code
|
|
||||||
print <<EOT;
|
|
||||||
<div id='xBody'>
|
|
||||||
<div class="clsTemporaryContainer">
|
|
||||||
<div style="visibility: visible;" id="idSplitter3" class="clsSplitter">
|
|
||||||
<div style="z-index: 2;" id="gauche" class="clsPane">
|
|
||||||
<div id="treeBox" style="width:200;height:200"></div>
|
|
||||||
</div><!-- end Pane -->
|
|
||||||
|
|
||||||
<div style="overflow: hidden; z-index: 2;" id="droit" class="clsPane">
|
|
||||||
<div style="visibility: visible;" id="idSplitter32" class="clsSplitter">
|
|
||||||
<div style="z-index: 2;" id="haut" class="clsPane">
|
|
||||||
<div id="buttons"></div>
|
|
||||||
<div id="formulaire" style="display:none;">
|
|
||||||
<form onSubmit="return false">
|
|
||||||
<p></p>
|
|
||||||
<table border=1 width="100%" style="empty-cells:show;">
|
|
||||||
<tr>
|
|
||||||
<th width=200>Champ</th>
|
|
||||||
<th width=400>Valeur</th>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<div id="name"> </div>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div id="value"> </div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div><!-- end Pane -->
|
|
||||||
|
|
||||||
<div style="z-index: 2;" id="bas" class="clsPane">
|
|
||||||
<div id="help"></div>
|
|
||||||
</div><!-- end Pane -->
|
|
||||||
|
|
||||||
<div style="z-index: 1; cursor: n-resize;" id="barre2" class="clsDragBar">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div><!-- end Splitter -->
|
|
||||||
</div><!-- end Pane -->
|
|
||||||
|
|
||||||
<div style="z-index: 1; cursor: e-resize;" class="clsDragBar">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div><!-- end Splitter -->
|
|
||||||
</div><!-- end TemporaryContainer -->
|
|
||||||
</div>
|
|
||||||
EOT
|
|
||||||
}
|
|
||||||
|
|
||||||
1;
|
|
||||||
__END__
|
__END__
|
||||||
|
|
||||||
=head1 NAME
|
=head1 NAME
|
||||||
|
|
||||||
Lemonldap::NG::Manager - Perl extension for managing Lemonldap::NG Web-SSO
|
Lemonldap::NG::Manager - Perl extension for managing Lemonldap::NG Web-SSO
|
||||||
|
@ -695,8 +405,8 @@ system.
|
||||||
dirName=>"/tmp/",
|
dirName=>"/tmp/",
|
||||||
},
|
},
|
||||||
dhtmlXTreeImageLocation=> "/devel/img/",
|
dhtmlXTreeImageLocation=> "/devel/img/",
|
||||||
# uncomment this only if lemonldap-ng-manager.js is not in the same
|
# uncomment this only if lemonldap-ng-manager.js is not in the same
|
||||||
# directory than your script.
|
# directory than your script.
|
||||||
# jsFile => /path/to/lemonldap-ng-manager.js,
|
# jsFile => /path/to/lemonldap-ng-manager.js,
|
||||||
}
|
}
|
||||||
) or die "Unable to start, see Apache logs";
|
) or die "Unable to start, see Apache logs";
|
||||||
|
@ -708,7 +418,7 @@ You can also peersonalize the HTML code instead of using C<doall()>:
|
||||||
print $self->header_public;
|
print $self->header_public;
|
||||||
print $self->start_html ( # See CGI(3) for more about start_html
|
print $self->start_html ( # See CGI(3) for more about start_html
|
||||||
-style => "/location/to/my.css",
|
-style => "/location/to/my.css",
|
||||||
-title => "Example.com SSO configuration",
|
-title => "Example.com SSO configuration",
|
||||||
);
|
);
|
||||||
# optional HTML code for the top of the page
|
# optional HTML code for the top of the page
|
||||||
print "<img src=...";
|
print "<img src=...";
|
||||||
|
@ -771,12 +481,12 @@ manager use this mecanism except the configuration itself.
|
||||||
parameters to it; example;
|
parameters to it; example;
|
||||||
|
|
||||||
print start_html(-title => 'My SSO configuration',
|
print start_html(-title => 'My SSO configuration',
|
||||||
-author => 'fred@capricorn.org',
|
-author => 'fred@capricorn.org',
|
||||||
-target => '_blank',
|
-target => '_blank',
|
||||||
-meta => {'keywords'=>'pharaoh secret mummy',
|
-meta => {'keywords'=>'pharaoh secret mummy',
|
||||||
'copyright' => 'copyright 1996 King Tut'},
|
'copyright' => 'copyright 1996 King Tut'},
|
||||||
-style => {'src'=>'/styles/style1.css'},
|
-style => {'src'=>'/styles/style1.css'},
|
||||||
-BGCOLOR => 'blue');
|
-BGCOLOR => 'blue');
|
||||||
|
|
||||||
See start_html description in L<CGI> for more. Bee carefull with C<-style>
|
See start_html description in L<CGI> for more. Bee carefull with C<-style>
|
||||||
argument. You have to call it like the example above or simply like this:
|
argument. You have to call it like the example above or simply like this:
|
||||||
|
@ -810,3 +520,4 @@ it under the same terms as Perl itself, either Perl version 5.8.8 or,
|
||||||
at your option, any later version of Perl 5 you may have available.
|
at your option, any later version of Perl 5 you may have available.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ sub header {
|
||||||
sub header_public {
|
sub header_public {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $filename = shift;
|
my $filename = shift;
|
||||||
$filename ||= $ENV{SCRIPT_FILENAME});
|
$filename ||= $ENV{SCRIPT_FILENAME};
|
||||||
my @tmp = stat($filename);
|
my @tmp = stat($filename);
|
||||||
my $date = $tmp[9];
|
my $date = $tmp[9];
|
||||||
my $hd = gmtime($date);
|
my $hd = gmtime($date);
|
||||||
|
|
|
@ -4,7 +4,7 @@ use strict;
|
||||||
use Storable qw(thaw freeze);
|
use Storable qw(thaw freeze);
|
||||||
use MIME::Base64;
|
use MIME::Base64;
|
||||||
|
|
||||||
our $VERSION = 0.3;
|
our $VERSION = 0.4;
|
||||||
our @ISA;
|
our @ISA;
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
|
@ -74,3 +74,89 @@ sub getConf {
|
||||||
|
|
||||||
1;
|
1;
|
||||||
__END__
|
__END__
|
||||||
|
|
||||||
|
=head1 NAME
|
||||||
|
|
||||||
|
Lemonldap::NG::Manager::Conf - Perl extension written to manage Lemonldap::NG
|
||||||
|
Web-SSO configuration.
|
||||||
|
|
||||||
|
=head1 SYNOPSIS
|
||||||
|
|
||||||
|
use Lemonldap::NG::Manager::Conf;
|
||||||
|
my $confAccess = new Lemonldap::NG::Manager::Conf(
|
||||||
|
{
|
||||||
|
type=>'File',
|
||||||
|
dirName=>"/tmp/",
|
||||||
|
},
|
||||||
|
) or die "Unable to build Lemonldap::NG::Manager::Conf, see Apache logs";
|
||||||
|
my $config = $confAccess->getConf();
|
||||||
|
|
||||||
|
=head1 DESCRIPTION
|
||||||
|
|
||||||
|
Lemonldap::NG::Manager provides a simple interface to access to Lemonldap::NG
|
||||||
|
Web-SSO configuration. It is used by L<Lemonldap::NG::Handler>,
|
||||||
|
L<Lemonldap::NG::Portal> and L<Lemonldap::NG::Manager>
|
||||||
|
|
||||||
|
=head2 SUBROUTINES
|
||||||
|
|
||||||
|
=over
|
||||||
|
|
||||||
|
=item * B<new> (constructor): it takes different arguments depending on the
|
||||||
|
choosen type. Examples:
|
||||||
|
|
||||||
|
=over
|
||||||
|
|
||||||
|
=item * B<File>:
|
||||||
|
$confAccess = new Lemonldap::NG::Manager::Conf(
|
||||||
|
{
|
||||||
|
type => 'File',
|
||||||
|
dirName => '/var/lib/lemonldap-ng/',
|
||||||
|
});
|
||||||
|
|
||||||
|
=item * B<DBI>:
|
||||||
|
$confAccess = new Lemonldap::NG::Manager::Conf(
|
||||||
|
{
|
||||||
|
type
|
||||||
|
dbiChain => 'DBI:mysql:database=lemonldap-ng,host=1.2.3.4',
|
||||||
|
dbiUser => 'lemonldap'
|
||||||
|
dbiPassword => 'pass'
|
||||||
|
dbiTable => 'lmConfig',
|
||||||
|
});
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=item * B<getConf>: returns a hash reference to the configuration. it takes
|
||||||
|
a hash reference as first argument containing 2 optional parameters:
|
||||||
|
|
||||||
|
=over
|
||||||
|
|
||||||
|
=item * C<cfgNum => $number>: the number of the configuration wanted. If this
|
||||||
|
argument is omitted, the last configuration is returned.
|
||||||
|
|
||||||
|
=item * C<fields => [array of names]: the desired fields asked. By default,
|
||||||
|
getConf returns all (C<select * from lmConfig>).
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=item B<saveConf>: stores the Lemonldap::NG configuration passed in argument
|
||||||
|
(hash reference). it returns the number of the new configuration.
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=head1 SEE ALSO
|
||||||
|
|
||||||
|
L<Lemonldap::NG::Handler>, L<Lemonldap::NG::Portal>, L<CGI>
|
||||||
|
|
||||||
|
=head1 AUTHOR
|
||||||
|
|
||||||
|
Xavier Guimard, E<lt>x.guimard@free.frE<gt>
|
||||||
|
|
||||||
|
=head1 COPYRIGHT AND LICENSE
|
||||||
|
|
||||||
|
Copyright (C) 2006 by Xavier Guimard
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or modify
|
||||||
|
it under the same terms as Perl itself, either Perl version 5.8.8 or,
|
||||||
|
at your option, any later version of Perl 5 you may have available.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
357
modules/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/_HTML.pm
Normal file
357
modules/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/_HTML.pm
Normal file
|
@ -0,0 +1,357 @@
|
||||||
|
package Lemonldap::NG::Manager::_HTML;
|
||||||
|
|
||||||
|
# This package contains all subroutines that are provided after a
|
||||||
|
# 'header_public' call. So those functions are called only if the browser
|
||||||
|
# comes for the first time.
|
||||||
|
|
||||||
|
use AutoLoader qw(AUTOLOAD);
|
||||||
|
our $VERSION = '0.05';
|
||||||
|
|
||||||
|
1;
|
||||||
|
__END__
|
||||||
|
=pod
|
||||||
|
=cut
|
||||||
|
sub css {
|
||||||
|
print <<EOT;
|
||||||
|
/* xSplitter Styles */
|
||||||
|
.clsSplitter
|
||||||
|
{
|
||||||
|
position: absolute;
|
||||||
|
overflow: hidden;
|
||||||
|
visibility: hidden;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
background: #FFF;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.clsPane
|
||||||
|
{
|
||||||
|
position: absolute;
|
||||||
|
overflow: auto;
|
||||||
|
visibility: visible;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
background: #FFF;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.clsDragBar
|
||||||
|
{
|
||||||
|
position: absolute;
|
||||||
|
overflow: hidden;
|
||||||
|
visibility: visible;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
background: lightgrey;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Application Styles */
|
||||||
|
|
||||||
|
#xBody { overflow: visible; background-color: #FFF; }
|
||||||
|
.clsTemporaryContainer /* replace this with something like xFenster */
|
||||||
|
{
|
||||||
|
position: relative;
|
||||||
|
overflow: visible;
|
||||||
|
visibility: visible;
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
#idSplitter3 { border: 4px solid lightgrey; }
|
||||||
|
h3, p { padding: 0 0 0 6px; border: none; }
|
||||||
|
#buttons { text-align: center; }
|
||||||
|
#help { text-align: left; }
|
||||||
|
EOT
|
||||||
|
}
|
||||||
|
|
||||||
|
sub javascript {
|
||||||
|
my $self = shift;
|
||||||
|
print <<EOT;
|
||||||
|
var s3,s32;
|
||||||
|
window.onload=function(){
|
||||||
|
var w=X.clientWidth()-12;
|
||||||
|
var h=X.clientHeight()-12;
|
||||||
|
//var h=window.outerHeight;
|
||||||
|
s32=new xSplitter('idSplitter32',0,0,0,0,false,4,3*h/4,h/8,true,0);
|
||||||
|
s3=new xSplitter('idSplitter3',0,0,w,h,true,4,w/4,w/8,true,4,null,s32);
|
||||||
|
X.addEventListener(window,'resize',win_onresize,false);
|
||||||
|
document.body.style.cursor='wait';
|
||||||
|
tree=new dhtmlXTreeObject(document.getElementById('treeBox'),"100%","100%",0);
|
||||||
|
tree.setImagePath("$self->{dhtmlXTreeImageLocation}");
|
||||||
|
tree.setXMLAutoLoading("$ENV{SCRIPT_NAME}?lmQuery=conf");
|
||||||
|
tree.loadXML("$ENV{SCRIPT_NAME}?lmQuery=conf");
|
||||||
|
tree.setOnClickHandler(onNodeSelect);
|
||||||
|
window.setTimeout("document.body.style.cursor='auto'",1000);
|
||||||
|
};
|
||||||
|
|
||||||
|
function win_onresize(){
|
||||||
|
var cw=X.clientWidth();
|
||||||
|
var w=X.clientWidth()-12;
|
||||||
|
var h=X.clientHeight()-12;
|
||||||
|
s3.paint(w,h,w/4,w/5);
|
||||||
|
}
|
||||||
|
|
||||||
|
var indice=-1;
|
||||||
|
|
||||||
|
function onNodeSelect(nodeId) {
|
||||||
|
var k,v;
|
||||||
|
if(tree.getUserData(nodeId,"modif")) {
|
||||||
|
switch(tree.getUserData(nodeId,"modif")) {
|
||||||
|
case 'text':
|
||||||
|
k='valeur';
|
||||||
|
v='<input value="'+nodeId+'" onChange="tree.setItemText('+"'"+nodeId+"'"+',this.value);tree.changeItemId('+"'"+nodeId+"'"+',this.value);">';
|
||||||
|
break;
|
||||||
|
case 'both':
|
||||||
|
k='<input value="'+tree.getItemText(nodeId)+'" onChange="tree.setItemText('+"'"+nodeId+"'"+',this.value)">';
|
||||||
|
v='<textarea cols=40 rows=2 onChange="tree.setUserData('+"'"+nodeId+"'"+','+"'"+'value'+"'"+',this.value)">'+tree.getUserData(nodeId,'value')+'</textarea>';
|
||||||
|
//v='<input size=80 name="value" value="'+tree.getUserData(nodeId,'value')+'" onChange="tree.setUserData('+"'"+nodeId+"'"+','+"'"+'value'+"'"+',this.value)">';
|
||||||
|
break;
|
||||||
|
case 'value':
|
||||||
|
k=tree.getItemText(nodeId);
|
||||||
|
v='<textarea cols=40 rows=2 onChange="tree.setUserData('+"'"+nodeId+"'"+','+"'"+'value'+"'"+',this.value)">'+tree.getUserData(nodeId,'value')+'</textarea>';
|
||||||
|
//v='<input size=80 name="value" value="'+tree.getUserData(nodeId,'value')+'" onChange="tree.setUserData('+"'"+nodeId+"'"+','+"'"+'value'+"'"+',this.value)">';
|
||||||
|
}
|
||||||
|
document.getElementById('formulaire').style.display='block';
|
||||||
|
document.getElementById('name').innerHTML = k;
|
||||||
|
document.getElementById('value').innerHTML = v;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
document.getElementById('formulaire').style.display='none';
|
||||||
|
}
|
||||||
|
var but='';
|
||||||
|
if(nodeIs(nodeId,"virtualHosts")){
|
||||||
|
but+=button('Nouvel Hôte Virtuel','newVirtualHost',nodeId);
|
||||||
|
if(nodeIs(nodeId,"virtualHost")){
|
||||||
|
but+=button('Nouvelle règle','newRule',nodeId);
|
||||||
|
but+=button('Nouvel en-tête','newHeader',nodeId);
|
||||||
|
}
|
||||||
|
help('virtualHosts');
|
||||||
|
}
|
||||||
|
else if(nodeIs(nodeId,"groups")){
|
||||||
|
but+=button('Nouveau groupe','newGroup',nodeId);
|
||||||
|
help('groups');
|
||||||
|
}
|
||||||
|
else if(nodeIs(nodeId,"generalParameters")){
|
||||||
|
if(nodeIs(nodeId,"ldapParameters")){
|
||||||
|
help('ldap');
|
||||||
|
}
|
||||||
|
else if(nodeIs(nodeId,"exportedVars")){
|
||||||
|
but+=button('Nouvelle variable','newVar',nodeId);
|
||||||
|
help('vars');
|
||||||
|
}
|
||||||
|
else if(nodeIs(nodeId,'sessionStorage')){
|
||||||
|
if(nodeIs(nodeId,"globalStorageOptions")){
|
||||||
|
but+=button('Nouvelle option','newGSOpt',nodeId);
|
||||||
|
}
|
||||||
|
help('storage');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(tree.getUserData(nodeId,"modif")=='both') but+=button("Supprimer",'deleteNode',nodeId);
|
||||||
|
but+=button('Sauvegarder','saveConf');
|
||||||
|
document.getElementById('buttons').innerHTML = but;
|
||||||
|
}
|
||||||
|
|
||||||
|
function nodeIs(id,type) {
|
||||||
|
if(id==type)return 1;
|
||||||
|
if(id=="root")return 0;
|
||||||
|
var next=tree.getParentId(id);
|
||||||
|
if(type=="virtualHost" && next=="virtualHosts")return 1;
|
||||||
|
return nodeIs(next,type);
|
||||||
|
}
|
||||||
|
|
||||||
|
function vhostId(id){
|
||||||
|
var next=tree.getParentId(id);
|
||||||
|
if(next=="virtualHosts") return id;
|
||||||
|
return vhostId(next);
|
||||||
|
}
|
||||||
|
|
||||||
|
function button(text,func,nodeId){
|
||||||
|
return '<input type=button value="'+text+'" onclick="'+func+'('+"'"+nodeId+"'"+')"> ';
|
||||||
|
}
|
||||||
|
|
||||||
|
function insertNewChild(a,b,c) {
|
||||||
|
tree.insertNewChild(a,b,c);
|
||||||
|
tree.setItemColor(b,"#000000","#0000FF");
|
||||||
|
}
|
||||||
|
|
||||||
|
function newVirtualHost() {
|
||||||
|
var rep=prompt("Nouvel hôte virtuel");
|
||||||
|
if(rep) {
|
||||||
|
insertNewChild('virtualHosts',rep,rep)
|
||||||
|
tree.setUserData(rep,'modif','text');
|
||||||
|
insertNewChild(rep,rep+'_exportedHeaders','Headers');
|
||||||
|
insertNewChild(rep+'_exportedHeaders',rep+'_exportedHeaders_1','Auth-User');
|
||||||
|
tree.setUserData(rep+'_exportedHeaders_1','modif','both');
|
||||||
|
tree.setUserData(rep+'_exportedHeaders_1','value','\$uid');
|
||||||
|
insertNewChild(rep,rep+'_locationRules','Règles');
|
||||||
|
insertNewChild(rep+'_locationRules',rep+'_locationRules_default','default');
|
||||||
|
tree.setUserData(rep+'_locationRules_default','modif','value');
|
||||||
|
tree.setUserData(rep+'_locationRules_default','value','deny');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function newValue(id,text,type,value){
|
||||||
|
indice--;
|
||||||
|
insertNewChild(id,'j_'+indice,text);
|
||||||
|
tree.setUserData('j_'+indice,'modif',type);
|
||||||
|
tree.setUserData('j_'+indice,'value',value);
|
||||||
|
tree.selectItem('j_'+indice,true);
|
||||||
|
}
|
||||||
|
|
||||||
|
function newRule(id){
|
||||||
|
var lr=tree.getItemIdByIndex(vhostId(id),1);
|
||||||
|
newValue(lr,'New rule','both','deny');
|
||||||
|
}
|
||||||
|
|
||||||
|
function newHeader(id){
|
||||||
|
var eh=tree.getItemIdByIndex(vhostId(id),0);
|
||||||
|
newValue(eh,'New-Header','both','\$uid');
|
||||||
|
}
|
||||||
|
|
||||||
|
function newGroup(id){
|
||||||
|
newValue('groups','New-group','both','');
|
||||||
|
}
|
||||||
|
|
||||||
|
function newVar(id){
|
||||||
|
newValue('exportedVars','New-var','both','uid');
|
||||||
|
}
|
||||||
|
|
||||||
|
function newGSOpt(id){
|
||||||
|
newValue('globalStorageOptions','New-Opt','both','');
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteNode(id){
|
||||||
|
tree.deleteItem(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
var xhr_object = null;
|
||||||
|
|
||||||
|
if(window.XMLHttpRequest) // Firefox
|
||||||
|
xhr_object = new XMLHttpRequest();
|
||||||
|
else if(window.ActiveXObject) // Internet Explorer
|
||||||
|
xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
|
||||||
|
else { // XMLHttpRequest non supporté par le navigateur
|
||||||
|
alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest: sauvegarde impossible.");
|
||||||
|
}
|
||||||
|
|
||||||
|
function help(s){
|
||||||
|
xhr_object.open("GET", "$ENV{SCRIPT_NAME}?lmQuery=help&help="+s, true);
|
||||||
|
xhr_object.onreadystatechange = function() {
|
||||||
|
if(xhr_object.readyState == 4) document.getElementById('help').innerHTML=xhr_object.responseText;
|
||||||
|
}
|
||||||
|
xhr_object.send(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
function saveConf(){
|
||||||
|
var h=tree2txt('root');
|
||||||
|
//document.getElementById('help').innerHTML="<pre>"+h+"</pre>";
|
||||||
|
xhr_object.open("POST", "$ENV{SCRIPT_NAME}?lmQuery=upload",true);
|
||||||
|
xhr_object.setRequestHeader("Content-type", "text/xml");
|
||||||
|
xhr_object.setRequestHeader("Content-length", h.length);
|
||||||
|
xhr_object.onreadystatechange = function() {
|
||||||
|
if(xhr_object.readyState == 4){
|
||||||
|
var r=xhr_object.responseText;
|
||||||
|
if(r>0) {
|
||||||
|
tree.setItemText('root','Configuration '+r);
|
||||||
|
document.getElementById('help').innerHTML='<h3>Configuration sauvegardée sous le numéro : '+r+'</h3>';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
document.getElementById('help').innerHTML='<h3>Échec de la sauvegarde</h3>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else document.getElementById('help').innerHTML='<h3>Échec de la sauvegarde</h3>';
|
||||||
|
}
|
||||||
|
xhr_object.send(h);
|
||||||
|
}
|
||||||
|
|
||||||
|
function tree2txt(id){
|
||||||
|
var s=tree.getSubItems(id);
|
||||||
|
var c=s.split(',');
|
||||||
|
var r='<'+id+"><text>"+ec(tree.getItemText(id))+"</text>\\n";
|
||||||
|
if((!s) || s=='' || c.length==0){
|
||||||
|
r+= '<value>'+ec(tree.getUserData(id,'value'))+"</value>\\n";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for(var i=0;i<c.length;i++){
|
||||||
|
r+=tree2txt(c[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
r+="</"+id+">\\n";
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
function ec(s){
|
||||||
|
if((!s) || s=='') return s;
|
||||||
|
return s.replace(/>/g,'>').replace(/</g,'<');
|
||||||
|
}
|
||||||
|
EOT
|
||||||
|
}
|
||||||
|
|
||||||
|
sub start_html {
|
||||||
|
my $self = shift;
|
||||||
|
my %args = @_;
|
||||||
|
$args{'-style'} = { -src => [ $args{'-style'} ] } if($args{'-style'} and !ref($args{'-style'}));
|
||||||
|
push @{$args{'-style'}->{'-src'}}, "$ENV{SCRIPT_NAME}?lmQuery=css";
|
||||||
|
$args{'-title'} ||= 'Lemonldap::NG Configuration';
|
||||||
|
$self->SUPER::start_html(%args);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub main {
|
||||||
|
# Lemonldap::Manager javascripts;
|
||||||
|
print qq#<script type="text/javascript" src="$ENV{SCRIPT_NAME}?lmQuery=libjs"></script>#;
|
||||||
|
print qq#<script type="text/javascript" src="$ENV{SCRIPT_NAME}?lmQuery=lmjs"></script>#;
|
||||||
|
# HTML code
|
||||||
|
print <<EOT;
|
||||||
|
<div id='xBody'>
|
||||||
|
<div class="clsTemporaryContainer">
|
||||||
|
<div style="visibility: visible;" id="idSplitter3" class="clsSplitter">
|
||||||
|
<div style="z-index: 2;" id="gauche" class="clsPane">
|
||||||
|
<div id="treeBox" style="width:200;height:200"></div>
|
||||||
|
</div><!-- end Pane -->
|
||||||
|
|
||||||
|
<div style="overflow: hidden; z-index: 2;" id="droit" class="clsPane">
|
||||||
|
<div style="visibility: visible;" id="idSplitter32" class="clsSplitter">
|
||||||
|
<div style="z-index: 2;" id="haut" class="clsPane">
|
||||||
|
<div id="buttons"></div>
|
||||||
|
<div id="formulaire" style="display:none;">
|
||||||
|
<form onSubmit="return false">
|
||||||
|
<p></p>
|
||||||
|
<table border=1 width="100%" style="empty-cells:show;">
|
||||||
|
<tr>
|
||||||
|
<th width=200>Champ</th>
|
||||||
|
<th width=400>Valeur</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<div id="name"> </div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div id="value"> </div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div><!-- end Pane -->
|
||||||
|
|
||||||
|
<div style="z-index: 2;" id="bas" class="clsPane">
|
||||||
|
<div id="help"></div>
|
||||||
|
</div><!-- end Pane -->
|
||||||
|
|
||||||
|
<div style="z-index: 1; cursor: n-resize;" id="barre2" class="clsDragBar">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div><!-- end Splitter -->
|
||||||
|
</div><!-- end Pane -->
|
||||||
|
|
||||||
|
<div style="z-index: 1; cursor: e-resize;" class="clsDragBar">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div><!-- end Splitter -->
|
||||||
|
</div><!-- end TemporaryContainer -->
|
||||||
|
</div>
|
||||||
|
EOT
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user