From 95424e487a7b913b7b421c17e39b554eb8c90eda Mon Sep 17 00:00:00 2001 From: Xavier Guimard Date: Fri, 30 Oct 2009 17:27:36 +0000 Subject: [PATCH] * New manager in progress * Strange problem with Net::LDAP in mpm-worker environment (not fixed) * Clean lock files when using Apache::Session::File --- .../example/experimental.pl | 263 ++++++++++-------- .../example/images/manager.js | 17 +- .../example/scripts/purgeCentralCache | 7 + .../lib/Lemonldap/NG/Portal/_LDAP.pm | 2 +- 4 files changed, 170 insertions(+), 119 deletions(-) diff --git a/modules/lemonldap-ng-manager/example/experimental.pl b/modules/lemonldap-ng-manager/example/experimental.pl index ba1078afd..6d6d5be5f 100755 --- a/modules/lemonldap-ng-manager/example/experimental.pl +++ b/modules/lemonldap-ng-manager/example/experimental.pl @@ -42,12 +42,7 @@ $h->doall(); package Lemonldap::NG::Manager::Experimental; use strict; -use MIME::Base64; use Lemonldap::NG::Handler::CGI qw(:globalStorage :locationRules); -use Lemonldap::NG::Common::Conf::Constants; #inherits -use Lemonldap::NG::Common::Safelib; #link protected safe Safe object - -#require Lemonldap::NG::Manager::_Struct; #inherits our $VERSION = '0.1'; our ( $stylesheet, $parser ); @@ -56,8 +51,7 @@ our @ISA; BEGIN { require Lemonldap::NG::Manager::Help; #inherits *process = *doall; - @ISA = - qw(Lemonldap::NG::Handler::CGI Lemonldap::NG::Manager::_Struct Lemonldap::NG::Manager::Uploader); + @ISA = qw(Lemonldap::NG::Handler::CGI Lemonldap::NG::Manager::Downloader Lemonldap::NG::Manager::Uploader Lemonldap::NG::Manager::_Struct); } sub new { @@ -99,11 +93,18 @@ sub doall { $self->confUpload($rdata); $self->quit(); } + elsif ( my $id = $self->param('newNode') ) { + print $self->header( -type => 'text/html; charset=utf8', ); + print '
  • test
  • '; + exit; + } + #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', ); $self->node($p); } else { @@ -114,8 +115,125 @@ sub doall { } } +## @method protected void start() +# Display HTTP and HTML headers. +sub start { + my $self = shift; + print $self->header( -type => 'text/html; charset=utf8', ); + print $self->start_html( + -title => shift || 'Lemonldap::NG Manager', + -encoding => 'utf8', + -script => [ + { + -language => 'JavaScript1.2', + + #-src => "lemonldap-ng-manager.js", + -src => "$self->{imagePath}/xlib.js", + }, + { + -language => 'JavaScript1.2', + -src => $self->{jqueryUri} || 'jquery.js', + }, + { + -language => 'JavaScript1.2', + -src => "$self->{imagePath}/tree.js", + }, + { + -language => 'JavaScript1.2', + -code => "var scriptname='$ENV{SCRIPT_NAME}';" + . "var imagepath='$self->{imagePath}';", + }, + { + -language => 'JavaScript1.2', + -src => "$self->{imagePath}/manager.js", + }, + ], + -style => { + -src => [ + "$self->{imagePath}/manager.css", + ( $self->{personnalCss} ? $self->{personnalCss} : () ) + ], + }, + ); +} + +sub window { + my ( $self, $root, $data ) = @_; + print '
    +
    +
    + Lemonldap::NG
     
      ' + . $self->li( 'root', 'root' ) + . $self->span( 'root', $root, $data, '', 'default' ) . '
        '; +} + +## @method protected void end() +# Display the end of HTML page. +sub end { + my $self = shift; + print << "EOF"; +
    +
    +
    +
    +
    +

    Lemonldap::NG Manager

    +
    + +
    +
    +
    + Default +
    + + + + + +
    +
    +
    +
    +
    +
    +
    +   +
    +
    +
    +
    +
    +
    +
    +EOF + print $self->end_html(); +} + +package Lemonldap::NG::Manager::Downloader; + +use Lemonldap::NG::Common::Conf::Constants; #inherits +use Lemonldap::NG::Common::Safelib; #link protected safe Safe object +use MIME::Base64; +# TODO use Data::Dumper; +#require Lemonldap::NG::Manager::_Struct; #inherits + sub node { my ( $self, $node ) = @_; $node =~ s/^\///; @@ -371,113 +489,6 @@ sub li { return "
  • " : ">" ); } -## @method protected void start() -# Display HTTP and HTML headers. -sub start { - my $self = shift; - print $self->header( -type => 'text/html; charset=utf8', ); - print $self->start_html( - -title => shift || 'Lemonldap::NG Manager', - -encoding => 'utf8', - -script => [ - { - -language => 'JavaScript1.2', - - #-src => "lemonldap-ng-manager.js", - -src => "$self->{imagePath}/xlib.js", - }, - { - -language => 'JavaScript1.2', - -src => $self->{jqueryUri} || 'jquery.js', - }, - { - -language => 'JavaScript1.2', - -src => "$self->{imagePath}/tree.js", - }, - { - -language => 'JavaScript1.2', - -code => "var scriptname='$ENV{SCRIPT_NAME}';" - . "var imagepath='$self->{imagePath}';", - }, - { - -language => 'JavaScript1.2', - -src => "$self->{imagePath}/manager.js", - }, - ], - -style => { - -src => [ - "$self->{imagePath}/manager.css", - ( $self->{personnalCss} ? $self->{personnalCss} : () ) - ], - }, - ); -} - -sub window { - my ( $self, $root, $data ) = @_; - print '
    -
    -
    - Lemonldap::NG
     
      ' - . $self->li( 'root', 'root' ) - . $self->span( 'root', $root, $data, '', 'default' ) . '
        '; -} - -## @method protected void end() -# Display the end of HTML page. -sub end { - my $self = shift; - print << 'EOF'; -
    -
    -
    -
    -
    -

    Lemonldap::NG Manager

    -
    - -
    -
    - Default -
    - - - - - -
    -
    -
    -
    -
    -
    -
    -   -
    -
    -
    -
    -
    -
    -
    -EOF - print $self->end_html(); -} - 1; package Lemonldap::NG::Manager::_Struct; @@ -705,7 +716,28 @@ sub testStruct { } sub defaultConf { - return { userDB => 'LDAP', }; + return { + userDB => 'LDAP', + ldapServer => 'localhost', + }; +} + +sub newNode { + virtualHost => { + '*' => { + exportedHeaders => {'Auth-User' => '$uid'}, + locationRules => {'default' => 'deny'}, + } + }, + groups => { + 'NewGroup' => '0', + }, + macro => { + 'NewMacro' => '', + }, + globalStorageOptions => { + 'NewOption' => '', + }, } 1; @@ -716,6 +748,7 @@ use strict; use XML::LibXML; use XML::LibXSLT; use MIME::Base64; +# TODO use Data::Dumper; our $VERSION = '0.1'; diff --git a/modules/lemonldap-ng-manager/example/images/manager.js b/modules/lemonldap-ng-manager/example/images/manager.js index 615651600..5211efdfe 100644 --- a/modules/lemonldap-ng-manager/example/images/manager.js +++ b/modules/lemonldap-ng-manager/example/images/manager.js @@ -1,5 +1,5 @@ +var simpleTreeCollection; $(document).ready(function(){ -var simpleTreeCollection simpleTreeCollection = $(".simpleTree").simpleTree({ autoclose: false, drag: false, @@ -88,9 +88,20 @@ function securedCookieValues(id){ } function rules(id){ currentId=id; - //display('btext',$('#'+id).parent().parent); + var t=lmtext(id); + if(t=='default'){$('#rulKey').attr('readonly','readonly')} + else{$('#rulKey').attr('readonly','')} $('#rulKey').attr('value',lmtext(id)); $('#rulValue').attr('value',lmdata(id)); display('rules',lmtext(lmparent(id))); } - +function newKey(){ + //alert(currentId); + $.get(scriptname,{'newNode':currentId},function(data,t){ + var obj = $('#'+currentId).parent().parent(); + $('#'+currentId).after(data); + $('li.line,li.line-last',obj).remove(); + simpleTreeCollection[0].setTreeNodes($('#'+currentId).parent().parent(),false); + }); + return false; +} diff --git a/modules/lemonldap-ng-portal/example/scripts/purgeCentralCache b/modules/lemonldap-ng-portal/example/scripts/purgeCentralCache index 90af75096..17b9295a9 100755 --- a/modules/lemonldap-ng-portal/example/scripts/purgeCentralCache +++ b/modules/lemonldap-ng-portal/example/scripts/purgeCentralCache @@ -40,5 +40,12 @@ for my $id (@t) { tied(%h)->delete; } +if ( $tmp =~ /^Apache::Session::(?:Browseable::)?File$/i ) { + require Apache::Session::Lock::File; + my $l = new Apache::Session::Lock::File; + $l->clean( $conf->{globalStorageOptions}->{LockDirectory}, + $conf->{timeout} ); +} + 1; diff --git a/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/_LDAP.pm b/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/_LDAP.pm index 8967bc746..b3b2201dd 100644 --- a/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/_LDAP.pm +++ b/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/_LDAP.pm @@ -5,7 +5,7 @@ # LDAP common functions package Lemonldap::NG::Portal::_LDAP; -require Net::LDAP; #inherits +use Net::LDAP; #inherits use Exporter; use base qw(Exporter Net::LDAP); use Lemonldap::NG::Portal::Simple;