Configuration datas

environments/ppa-mbqj77/deployments/1
Xavier Guimard 16 years ago
parent ee62c967b9
commit 7d83901ffb
  1. 37
      modules/lemonldap-ng-common/scripts/convertConfig
  2. 1
      modules/lemonldap-ng-manager/example/skins/default/manager.css
  3. 16
      modules/lemonldap-ng-manager/example/skins/default/manager.js
  4. 12
      modules/lemonldap-ng-manager/example/skins/default/manager.tpl
  5. 15
      modules/lemonldap-ng-manager/lib/Lemonldap/NG/Manager.pm
  6. 18
      modules/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Downloader.pm
  7. 10
      modules/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Uploader.pm

@ -5,15 +5,21 @@ use Getopt::Long;
use Lemonldap::NG::Common::Conf;
my %opts;
my $result =
GetOptions( \%opts, 'help|h', 'current|c=s', 'new|n=s', 'latest|l' );
my $result = GetOptions( \%opts, 'help|h', 'current|c=s', 'new|n=s', 'latest|l',
'force|f' );
if ( $opts{help} or not( $opts{current} and $opts{new} ) ) {
print STDERR
"Usage: $0 --current=/current/lemonldap-ng.ini --new=/new/lemonldap-ng.ini\n";
print STDERR "# other parameters:
print STDERR "
## Lemonldap::NG configuration converter ##
Usage: $0 --current=/current/lemonldap-ng.ini --new=/new/lemonldap-ng.ini
other parameters:
--latest -l
convert only last configuration
--force -f
continue even if an error occurs
";
exit 1;
}
@ -30,7 +36,7 @@ foreach ( $opts{current}, $opts{new} ) {
}
my $old = Lemonldap::NG::Common::Conf->new(
{
confFile => $opts{current},
confFile => $opts{current},
noCache => 1,
}
);
@ -41,7 +47,7 @@ unless ($old) {
}
my $new = Lemonldap::NG::Common::Conf->new(
{
confFile => $opts{new},
confFile => $opts{new},
force => 1,
noCache => 1,
cfgNumFixed => 1,
@ -63,15 +69,22 @@ foreach (@available) {
my $conf = $old->getConf( { cfgNum => $_ } );
eval {
delete $conf->{reVHosts};
delete $conf->{cipher};
delete $conf->{cipher};
};
unless ($conf) {
print STDERR
"\nFailed to get conf $_ : $Lemonldap::NG::Common::Conf::msg\n";
next if ( $opts{force} );
exit 6;
}
print "Conf $conf->{cfgNum}:";
my $r = $new->saveConf($conf);
print( $r ? "stored" : "failed: $Lemonldap::NG::Common::Conf::msg" );
print "\n";
if ( my $r = $new->saveConf($conf) ) {
print "Conf $conf->{cfgNum} stored\n";
next;
}
print STDERR
"Unable to store configuration $conf->{cfgNum}: $Lemonldap::NG::Common::Conf::msg";
next if ( $opts{force} );
exit 7;
}
exit 0;

@ -151,6 +151,7 @@ input
.simpleTree .root
{
cursor:default;
margin-left:-16px;
background: url(root.gif) no-repeat 16px 0;
}

@ -114,7 +114,8 @@ function vhost(id){
$('#bdelvh').show();
}
function cfgDatas(id){
display('cfgDatas');
display('cfgDatas','');
getCfgAttributes();
}
function delvh(id){
if(confirm("Are you sure ?")){alert(id);$('#'+id).remove();}
@ -204,6 +205,7 @@ function newVh(name){
$('>span',s).attr('name',name).attr('help','default').attr('id','text_'+vhId);
});
}
var cfgAttrDone=0;
function uploadConf(f){
if(!(f==1))f=0;
$.ajax({
@ -226,7 +228,8 @@ function uploadConf(f){
setlmtext('li_cm9vdA2',tmp);
setlmdata('li_cm9vdA2',data.result.cfgNum);
$('#cfgNum').text(data.result.cfgNum);
setCfgAttributes(data.result.attributes);
setCfgAttributes(data.cfgDatas);
cfgAttrDone++;
}
if(typeof(data.warnings)!='undefined'){
for(m in data.warnings){
@ -241,15 +244,16 @@ function uploadConf(f){
}
});
}
var cfgAttrDone;
function getCfgAttributes() {
if(cfgAttrDone>0)return;
$.ajax({
type:"POST",
url:scriptname,
data:{cfgNum:lmdata('li_cm9vdA2'),attr:1},
data:{cfgNum:lmdata('li_cm9vdA2'),cfgAttr:1},
dataType:'json',
success:function(data){
setCfgAttributes(data);
cfgAttrDone++;
},
error:function(xhr, ajaxOptions, thrownError){
setCfgAttributes({cfgAuthor:'unknown',cfgAuthorIP:'unknown',cfgDate:'unknown'});
@ -257,6 +261,10 @@ function getCfgAttributes() {
});
}
function setCfgAttributes(data){
var t = new Array('cfgAuthor','cfgAuthorIP','cfgDate');
for(i in t){
$('#'+t[i]).text(data[t[i]]);
}
}
/* Warning, it's not a real base64 */
function myB64(s) {

@ -99,12 +99,12 @@ var scriptname='<TMPL_VAR NAME="SCRIPT_NAME">';var imagepath='<TMPL_VAR NAME="DI
</div>
<!-- Configuration datas -->
<div id="cfgDatas" class="hidden">
<ul>
<li><lang en="Configuration number" fr="Numéro de configuration"/>&nbsp;:<span id="cfgNum"><TMPL_VAR NAME="CFGNUM"></span></li>
<li><lang en="Author" fr="Auteur">&nbsp;:<span id="cfgAuthor"></span></li>
<li><lang en="IP Address" fr="Adresse IP">&nbsp;:<span id="cfgAuthorIP"></span></li>
<li><lang en="Date" fr="Date">&nbsp;:<span id="cfgDate"></span></li>
<div id="content_cfgDatas" class="hidden">
<ul style="text-align:left;">
<li><lang en="Configuration number" fr="Numéro de configuration"/>&nbsp;: <span id="cfgNum"><TMPL_VAR NAME="CFGNUM"></span></li>
<li><lang en="Author" fr="Auteur"/>&nbsp;: <span id="cfgAuthor"></span></li>
<li><lang en="IP Address" fr="Adresse IP"/>&nbsp;: <span id="cfgAuthorIP"></span></li>
<li><lang en="Date" fr="Date"/>&nbsp;: <span id="cfgDate"></span></li>
</ul>
</div>

@ -58,18 +58,7 @@ sub new {
$self->quit();
}
if ( $self->param('cfgAttr') ) {
my @buf;
foreach(qw(cfgAuthor cfgAuthorIP cfgDate)){
my $tmp = $self->conf()->{$_} || 'anonymous';
$tmp =~ s/'/\\'/g;
push @buf, "$_:'$tmp'";
}
$_ = '{'.join(',',@buf).'}';
print $self->header(
-type => 'application/json',
-Content_Length => length($_)
) . $_;
$self->sendCfgParams( $self->conf );
}
return $self;
}
@ -84,7 +73,7 @@ sub menu {
'<ul class="simpleTree">'
. $self->li( 'root', 'root' )
. $self->span( 'root', "Configuration $self->{cfgNum}",
$self->{cfgNum}, 'cfgDatas' )
$self->{cfgNum}, 'cfgDatas', 'default' )
. '<ul>'
. $self->node()
. '</ul></li></ul>';

@ -287,6 +287,24 @@ sub corresp {
return $h, $help, $js;
}
## @method protected void sendCfgParams(hashref h)
# Send Author, IP, and date from a Lemonldap::NG::Conf
sub sendCfgParams {
my ( $self, $h ) = @_;
my @buf;
foreach (qw(cfgAuthor cfgAuthorIP cfgDate)) {
my $tmp = $h->{$_} || 'anonymous';
$tmp =~ s/'/\\'/g;
push @buf, "$_:'$tmp'";
}
$_ = '{' . join( ',', @buf ) . '}';
print $self->header(
-type => 'application/json',
-Content_Length => length($_)
) . $_;
$self->quit();
}
## @method protected hashref conf()
# If configuration is not in memory, calls
# Lemonldap::NG::Common::Conf::getConf() and returns it.

@ -125,6 +125,11 @@ sub confUpload {
}
}
# Author attributes
$newConf->{cfgAuthor} = $ENV{AUTH_USER} || 'anonymous';
$newConf->{cfgAuthorIP} = $ENV{REMOTE_ADDR};
$newConf->{cfgDate} = time();
#print STDERR Dumper( $newConf, $errors );
if ( $errors->{errors} ) {
$errors->{result}->{cfgNum} = 0;
@ -147,6 +152,11 @@ sub confUpload {
}->{ $errors->{result}->{cfgNum} }
)
);
$errors->{cfgDatas} = {
cfgAuthor => $newConf->{cfgAuthor},
cfgAuthorIP => $newConf->{cfgAuthorIP},
cfgDate => $newConf->{cfgDate}
};
if ( $errors->{result}->{cfgNum} == CONFIG_WAS_CHANGED
or $errors->{result}->{cfgNum} == DATABASE_LOCKED )
{

Loading…
Cancel
Save