Commit b972c10a authored by Clément OUDOT's avatar Clément OUDOT
Browse files

Use configuration parameters for portal customization

parent 9ac349e4
......@@ -2,12 +2,16 @@
use Lemonldap::NG::Portal::Error;
use HTML::Template;
my $skin = "pastel";
my $skin_dir = "__SKINDIR__";
my $skin_dir = "/usr/local/lemonldap-ng/htdocs/portal/skins";
my $portal = Lemonldap::NG::Portal::Error->new();
my $portal = Lemonldap::NG::Portal::SharedConf->new(
# PORTAL CUSTOMIZATION
# Skin
#portalSkin => 'pastel',
);
my $portal_url = $portal->getPortal;
my $skin = $portal->{portalSkin};
my $portal_url = $portal->{portal};
my $logout_url = "$portal_url?logout=1";
my $template = HTML::Template->new(
......
......@@ -4,18 +4,9 @@ use Lemonldap::NG::Portal::SharedConf;
use HTML::Template;
# Menu configuration
my $skin = "pastel";
my $skin_dir = "__SKINDIR__";
my $skin_dir = "__SKINDIR__";
my $appsxmlfile = "__APPSXMLFILE__";
my $appsimgpath = "apps/";
my $user_attr = "_user";
# Menu configuration
use constant USER_CAN_CHANGE_PASSWORD => 1;
use constant REQUIRE_OLDPASSWORD => 0;
use constant DISPLAY_LOGOUT => 1;
use constant AUTOCOMPLETE => "on";
use constant DISPLAY_RESETPASSWORD => "1";
my $portal = Lemonldap::NG::Portal::SharedConf->new(
{
......@@ -34,6 +25,21 @@ my $portal = Lemonldap::NG::Portal::SharedConf->new(
# Note that YOU HAVE TO SET configStorage here if you've declared this
# portal as SOAP configuration server in the manager
# PORTAL CUSTOMIZATION
# Skin
#portalSkin => 'pastel',
# Modules displayed
#portalDisplayLogout => 1,
#portalDisplayResetPassword => 1,
#portalDisplayChangePassword => 1,
#portalDisplayAppslist => 1,
# Allow password autocompletion (passwords stored in user web browsers)
#portalAutocomplete => "on",
# Require the old password when changing password
#portalRequireOldPassword => 1,
# Attribute displayed as connected user
#portalUserAttr => "mail",
# LOG
# By default, all is logged in Apache file. To log user actions by
# syslog, just set syslog facility here:
......@@ -138,6 +144,9 @@ my $portal = Lemonldap::NG::Portal::SharedConf->new(
}
);
# Get skin value
my $skin = $portal->{portalSkin};
if ( $portal->process() ) {
# HTML::Template object creation
......@@ -158,15 +167,15 @@ if ( $portal->process() ) {
imgpath => "$appsimgpath",
},
modules => {
appslist => 1,
password => USER_CAN_CHANGE_PASSWORD,
logout => DISPLAY_LOGOUT,
appslist => $portal->{portalDisplayAppslist},
password => $portal->{portalDisplayChangePassword},
logout => $portal->{portalDisplayLogout},
},
}
);
$template->param( AUTH_USER => $portal->{sessionInfo}->{$user_attr} );
$template->param( AUTOCOMPLETE => AUTOCOMPLETE );
$template->param( AUTH_USER => $portal->{sessionInfo}->{ $portal->{portalUserAttr} } );
$template->param( AUTOCOMPLETE => $portal->{portalAutocomplete} );
$template->param( SKIN => $skin );
$template->param( AUTH_ERROR => $menu->error );
$template->param( AUTH_ERROR_TYPE => $menu->error_type );
......@@ -175,7 +184,7 @@ if ( $portal->process() ) {
$template->param( DISPLAY_LOGOUT => $menu->displayModule("logout") );
$template->param( DISPLAY_TAB => $menu->displayTab );
$template->param( LOGOUT_URL => "$ENV{SCRIPT_NAME}?logout=1" );
$template->param( REQUIRE_OLDPASSWORD => REQUIRE_OLDPASSWORD );
$template->param( REQUIRE_OLDPASSWORD => $portal->{portalRequireOldPassword} );
if ( $menu->displayModule("appslist") ) {
$template->param( APPSLIST_MENU => $menu->appslistMenu );
$template->param( APPSLIST_DESC => $menu->appslistDescription );
......@@ -216,11 +225,11 @@ else {
$template->param( AUTH_ERROR_TYPE => $portal->error_type );
$template->param( AUTH_URL => $portal->get_url );
$template->param( LOGIN => $portal->get_user );
$template->param( AUTOCOMPLETE => AUTOCOMPLETE );
$template->param( AUTOCOMPLETE => $portal->{portalAutocomplete} );
$template->param( SKIN => $skin );
if (
USER_CAN_CHANGE_PASSWORD
$portal->{portalDisplayChangePassword}
and ( $portal->{error} == PE_PP_CHANGE_AFTER_RESET
or $portal->{error} == PE_PP_MUST_SUPPLY_OLD_PASSWORD
or $portal->{error} == PE_PP_INSUFFICIENT_PASSWORD_QUALITY
......@@ -236,7 +245,7 @@ else {
}
else {
$template->param( DISPLAY_FORM => 1 );
$template->param( DISPLAY_RESETPASSWORD => $DISPLAY_RESETPASSWORD );
$template->param( DISPLAY_RESETPASSWORD => $portal->{portalDisplayResetPassword} );
}
print $portal->header('text/html; charset=utf-8');
......
package Lemonldap::NG::Portal::Error;
use strict;
use Lemonldap::NG::Portal::SharedConf qw(:all);
our $VERSION = '0.01';
use base ('Lemonldap::NG::Portal::SharedConf');
*EXPORT_OK = *Lemonldap::NG::Portal::SharedConf::EXPORT_OK;
*EXPORT_TAGS = *Lemonldap::NG::Portal::SharedConf::EXPORT_TAGS;
*EXPORT = *Lemonldap::NG::Portal::SharedConf::EXPORT;
# getPortal
# Return portal URL from configuration
sub getPortal {
my $self = shift;
# Return portal
return $self->{portal};
}
1;
__END__
=head1 NAME
Lemonldap::NG::Portal::Error - Simple error page
=head1 SYNOPSIS
#!/usr/bin/perl
use Lemonldap::NG::Portal::Error;
my $portal = Lemonldap::NG::Portal::Error->new(
{
configStorage => {
type => 'File',
dirName => '/opt/lemonldap-ng/conf/',
},
});
my $portal_url = $portal->getPortal;
my $logout_url = "$portal_url?logout=1";
print $portal->header('text/html; charset=utf8');
print $portal->star_html('Error');
print "...":
print "<a href=$portal_url>Go to portal</a>";
print "<a href=$logout_url>Logout</a>";
print $portal->end_html;
=head1 DESCRIPTION
Create a simple portal to display an error page.
=head1 METHODS
=head2 getPortal
Return the portal URL that was configured.
=head1 SEE ALSO
L<Lemonldap::NG::SharedConf>, L<Lemonldap::NG::Handler>,
http://wiki.lemonldap.objectweb.org/xwiki/bin/view/NG/Presentation
=head1 AUTHOR
Clement OUDOT E<lt>clement@oodo.netE<gt> E<lt>coudot@linagora.comE<gt>
=head1 BUG REPORT
Use OW2 system to report bug or ask for features:
L<http://forge.objectweb.org/tracker/?group_id=274>
=head1 DOWNLOAD
Lemonldap::NG is available at
L<http://forge.objectweb.org/project/showfiles.php?group_id=274>
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2007 by Xavier Guimard E<lt>x.guimard@free.frE<gt>
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.4 or,
at your option, any later version of Perl 5 you may have available.
=cut
......@@ -237,7 +237,15 @@ sub setDefaultValues {
my $self = shift;
$self->{whatToTrace} ||= 'uid';
$self->{whatToTrace} =~ s/^\$//;
$self->{httpOnly} = 1 unless ( defined( $self->{httpOnly} ) );
$self->{httpOnly} = 1 unless ( defined ( $self->{httpOnly} ) );
$self->{portalSkin} ||= 'pastel';
$self->{portalDisplayLogout} = 1 unless ( defined ( $self->{portalDisplayLogout} ) );
$self->{portalDisplayResetPassword} = 1 unless ( defined ( $self->{portalDisplayResetPassword} ) );
$self->{portalDisplayChangePassword} = 1 unless ( defined ( $self->{portalDisplayChangePassword} ) );
$self->{portalDisplayAppslist} = 1 unless ( defined ( $self->{portalDisplayAppslist} ) );
$self->{portalAutocomplete} ||= "off";
$self->{portalRequireOldPassword} = 1 unless ( defined ( $self->{portalRequireOldPassword} ) );
$self->{portalUserAttr} ||= "_user";
}
=begin WSDL
......
Supports Markdown
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