Commit b30f5a8e authored by Xavier Guimard's avatar Xavier Guimard

LEMONLDAP::NG : Javascript correction ('z' was added sometimes on rules)

parent 74fce152
......@@ -2,7 +2,7 @@ lemonldap-ng (0.8.2.4) unstable; urgency=low
* Bug in manager javascript.
-- Xavier Guimard <x.guimard@free.fr> Mon, 18 Jun 2007 22:28:53 +0200
-- Xavier Guimard <x.guimard@free.fr> Tue, 19 Jun 2007 22:25:10 +0200
lemonldap-ng (0.8.2.3) unstable; urgency=low
......
Revision history for Perl extension Lemonldap::NG::Manager.
0.71 Mon jun 18 22:24:33 2007
0.71 Mon jun 19 22:22:33 2007
- Bug in javascript : a 'z' is added in regexp
0.7 Tue jun 12 22:20:54 2007
......
......@@ -16,7 +16,7 @@ use MIME::Base64;
our @ISA = qw(Lemonldap::NG::Manager::Base);
our $VERSION = '0.71';
our $VERSION = '0.72';
sub new {
my ( $class, $args ) = @_;
......@@ -146,6 +146,7 @@ sub buildTree {
my $self = shift;
my $config = $self->config->getConf( @_ );
$config = $self->default unless ($config);
my $indice = 1;
my $tree = {
id => '0',
item => {
......@@ -237,7 +238,8 @@ sub buildTree {
if ( $config->{exportedVars} ) {
while ( my ( $n, $att ) = each( %{ $config->{exportedVars} } ) ) {
$exportedVars->{$n} = $self->xmlField( "both", $att, $n );
$exportedVars->{"ev_$indice"} = $self->xmlField( "both", $att, $n );
$indice++;
}
}
else {
......@@ -264,22 +266,24 @@ sub buildTree {
my $virtualHost = $tree->{item}->{item}->{virtualHosts}->{item};
# TODO: split locationRules into 2 arrays
while ( my ( $host, $rules ) = each( %{ $config->{locationRules} } ) ) {
$virtualHost->{$host} = $self->xmlField( "text", 'i', $host );
my $vh_id = "vh_$indice";
$indice++;
$virtualHost->{$vh_id} = $self->xmlField( "text", 'i', $host );
my ( $ih, $ir ) =
( "exportedHeaders_$indice", "locationRules_$indice" );
$virtualHost->{$host}->{item} = {
$virtualHost->{$vh_id}->{item} = {
"$ih" => { text => &txt_httpHeaders, },
"$ir" => { text => &txt_locationRules, },
};
while ( my ( $reg, $expr ) = each(%$rules) ) {
my $type = ( $reg eq 'default' ) ? 'value' : 'both';
$virtualHost->{$host}->{item}->{$ir}->{item}->{"r_$indice"} =
$virtualHost->{$vh_id}->{item}->{$ir}->{item}->{"r_$indice"} =
$self->xmlField( $type, $expr, $reg );
$indice++;
}
my $headers = $config->{exportedHeaders}->{$host};
while ( my ( $h, $expr ) = each(%$headers) ) {
$virtualHost->{$host}->{item}->{$ih}->{item}->{"h_$indice"} =
$virtualHost->{$vh_id}->{item}->{$ih}->{item}->{"h_$indice"} =
$self->xmlField( "both", $expr, $h );
$indice++;
}
......@@ -289,14 +293,16 @@ sub buildTree {
$tree->{item}->{item}->{groups}->{item} = {};
my $groups = $tree->{item}->{item}->{groups}->{item};
while ( my ( $group, $expr ) = each( %{ $config->{groups} } ) ) {
$groups->{$group} = $self->xmlField( 'both', $expr, $group );
$groups->{"g_$indice"} = $self->xmlField( 'both', $expr, $group );
$indice++;
}
}
if ( $config->{macros} and %{ $config->{macros} } ) {
$tree->{item}->{item}->{generalParameters}->{item}->{macros}->{item} = {};
my $macros = $tree->{item}->{item}->{generalParameters}->{item}->{macros}->{item};
while ( my ( $macro, $expr ) = each( %{ $config->{macros} } ) ) {
$macros->{$macro} = $self->xmlField( 'both', $expr, $macro );
$macros->{"m_$indice"} = $self->xmlField( 'both', $expr, $macro );
$indice++;
}
}
return $tree;
......@@ -350,7 +356,7 @@ sub tree2conf {
$config->{groups}->{ $h->{text} } = $h->{value};
}
# Load virtualHosts
while ( my ( $vh, $h ) = each( %{ $tree->{virtualHosts} } ) ) {
while ( my ( $k, $h ) = each( %{ $tree->{virtualHosts} } ) ) {
next unless ( ref($h) );
my $lr;
my $eh;
......@@ -358,6 +364,7 @@ sub tree2conf {
$lr = $h->{$_} if ( $_ =~ /locationRules/ );
$eh = $h->{$_} if ( $_ =~ /exportedHeaders/ );
}
my $vh = $h->{text};
# TODO: split locationRules into 2 arrays
LR: foreach my $r ( values(%$lr) ) {
next LR unless ( ref($r) );
......@@ -431,7 +438,7 @@ sub checkConf {
print STDERR "$k is not authorized in macro names. Change it!\n";
return 0;
}
if( $k !~ /^\w+$/ ) {
if( $k !~ /^[a-zA-Z]\w*$/ ) {
print STDERR "$k is not a valid macro name\n";
return 0;
}
......@@ -458,7 +465,7 @@ sub checkConf {
}
# Test rules
while( my($vh, $rules) = each( %{ $config->{locationRules} } ) ) {
unless( $vh =~ /^[-\w\.]+$/ ) {
unless( $vh =~ /^\w[-\w\.]*$/ ) {
print STDERR "$vh is not a valid virtual host name\n";
return 0;
}
......@@ -482,7 +489,7 @@ sub checkConf {
}
# Test exported headers
while( my($vh, $headers) = each( %{ $config->{exportedHeaders} } ) ) {
unless( $vh =~ /^[-\w\.]+$/ ) {
unless( $vh =~ /^\w[-\w\.]*$/ ) {
print STDERR "$vh is not a valid virtual host name\n";
return 0;
}
......
......@@ -5,8 +5,6 @@ no strict 'refs';
use Data::Dumper;
use Lemonldap::NG::Manager::Conf::Constants;
$Data::Dumper::Indent = 0;
$Data::Dumper::Varname = "data";
our $VERSION = 0.5;
our @ISA;
......@@ -42,6 +40,8 @@ sub saveConf {
return CONFIG_WAS_CHANGED if( $conf->{cfgNum} != $self->lastCfg or $self->isLocked );
$self->lock or return DATABASE_LOCKED;
my $fields;
local $Data::Dumper::Indent = 0;
local $Data::Dumper::Varname = "data";
while ( my ( $k, $v ) = each(%$conf) ) {
if ( ref($v) ) {
$fields->{$k} = Dumper($v);
......
......@@ -8,7 +8,7 @@ use AutoLoader qw(AUTOLOAD);
require Lemonldap::NG::Manager::_i18n;
use Lemonldap::NG::Manager::Conf::Constants;
our $VERSION = '0.29';
our $VERSION = '0.28';
# TODO: Delete buttons in headers and rules if 'read-only'
......@@ -120,7 +120,7 @@ function win_onresize(){
s3.paint(w,h,w/4,w/5);
}
var indice=-1;
var indice=1;
function onNodeSelect(nodeId) {
var k,v;
......@@ -128,17 +128,15 @@ function onNodeSelect(nodeId) {
switch(tree.getUserData(nodeId,"modif")) {
case 'text':
k='valeur';
v='<input value="'+nodeId+'" onChange="var tmp=this.value.replace(/^([^a-z])/i,\\'z\$1\\');tmp=tmp.replace(/^([a-zA-Z0-9_\\.\\-]*).*\$/,\\'\$1\\');tree.setItemText('+"'"+nodeId+"'"+',tmp);tree.changeItemId('+"'"+nodeId+"'"+',tmp);this.value=tmp">';
v='<input value="'+tree.getItemText(nodeId)+'" onChange="tree.setItemText('+"'"+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)">';
v='<textarea cols=50 rows=5 onChange="tree.setUserData('+"'"+nodeId+"'"+','+"'"+'value'+"'"+',this.value)">'+tree.getUserData(nodeId,'value')+'</textarea>';
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)">';
v='<textarea cols=50 rows=5 onChange="tree.setUserData('+"'"+nodeId+"'"+','+"'"+'value'+"'"+',this.value)">'+tree.getUserData(nodeId,'value')+'</textarea>';
break;
case 'ro':
k=tree.getItemText(nodeId);
......@@ -233,9 +231,11 @@ function button(text,func,nodeId){
return '<input type=button value="'+text+'" onclick="'+func+'('+"'"+nodeId+"'"+')"> &nbsp; ';
}
function insertNewChild(a,b,c) {
tree.insertNewChild(a,b,c);
tree.setItemColor(b,"\#000000","\#0000FF");
function insertNewChild(a,c) {
indice++;
tree.insertNewChild(a,'js_'+indice,c);
tree.setItemColor('js_'+indice,"\#000000","\#0000FF");
return 'js_'+indice;
}
function newVirtualHost() {
......@@ -245,16 +245,21 @@ function newVirtualHost() {
alert('$text{invalidVirtualHostName}');
return 0;
}
insertNewChild('virtualHosts',rep,rep)
tree.setUserData(rep,'modif','text');
insertNewChild(rep,rep+'_exportedHeaders','$text{httpHeaders}');
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','$text{locationRules}');
insertNewChild(rep+'_locationRules',rep+'_locationRules_default','default');
tree.setUserData(rep+'_locationRules_default','modif','value');
tree.setUserData(rep+'_locationRules_default','value','deny');
var tmp=insertNewChild('virtualHosts',rep)
tree.setUserData(tmp,'modif','text');
//var tmp_eh=insertNewChild(tmp,'$text{httpHeaders}');
var tmp_eh=tmp+'_exportedHeaders';
tree.insertNewChild(tmp,tmp_eh,'$text{httpHeaders}');
tree.setItemColor(tmp_eh,"\#000000","\#0000FF");
var tmp_eh1=insertNewChild(tmp_eh,'Auth-User');
tree.setUserData(tmp_eh1,'modif','both');
tree.setUserData(tmp_eh1,'value','\$uid');
var tmp_lr=tmp+'_locationRules';
tree.insertNewChild(tmp,tmp_lr,'$text{locationRules}');
tree.setItemColor(tmp_lr,"\#000000","\#0000FF");
var tmp_lr1=insertNewChild(tmp_lr,'default');
tree.setUserData(tmp_lr1,'modif','value');
tree.setUserData(tmp_lr1,'value','deny');
}
}
......@@ -264,11 +269,10 @@ function deleteVirtualHost(id) {
}
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);
var tmp=insertNewChild(id,text);
tree.setUserData(tmp,'modif',type);
tree.setUserData(tmp,'value',value);
tree.selectItem(tmp,true);
}
function newRule(id){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment