From 322202189759513603bd6fbde0a18ffa192160c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Oudot?= Date: Fri, 22 Jan 2010 11:25:37 +0000 Subject: [PATCH] Portal: * Use HTML templates to send fancy reset password mail, with translations * Send the new password by mail instead of diplaying it n the web page * Remove the need to configure : the value is now set with help of {DOCUMENT_ROOT} --- build/lemonldap-ng/Makefile | 14 ++-- modules/lemonldap-ng-portal/example/error.pl | 3 +- .../lemonldap-ng-portal/example/index_skin.pl | 11 +-- modules/lemonldap-ng-portal/example/mail.pl | 7 +- .../example/skins/common/mail_confirm.tpl | 11 +++ .../example/skins/common/mail_footer.tpl | 11 +++ .../example/skins/common/mail_header.tpl | 17 +++++ .../example/skins/common/mail_password.tpl | 9 +++ .../example/skins/pastel/mail.tpl | 5 -- .../example/skins/pastel/styles.css | 2 +- .../lib/Lemonldap/NG/Portal/MailReset.pm | 67 +++++++++++++++++-- .../lib/Lemonldap/NG/Portal/Menu.pm | 3 +- .../lib/Lemonldap/NG/Portal/PasswordDBDBI.pm | 4 +- .../lib/Lemonldap/NG/Portal/PasswordDBLDAP.pm | 4 +- .../lib/Lemonldap/NG/Portal/Simple.pm | 7 +- .../lib/Lemonldap/NG/Portal/_SMTP.pm | 18 +++-- .../lib/Lemonldap/NG/Portal/_i18n.pm | 10 +-- 17 files changed, 148 insertions(+), 55 deletions(-) create mode 100644 modules/lemonldap-ng-portal/example/skins/common/mail_confirm.tpl create mode 100644 modules/lemonldap-ng-portal/example/skins/common/mail_footer.tpl create mode 100644 modules/lemonldap-ng-portal/example/skins/common/mail_header.tpl create mode 100644 modules/lemonldap-ng-portal/example/skins/common/mail_password.tpl diff --git a/build/lemonldap-ng/Makefile b/build/lemonldap-ng/Makefile index f44a0266a..6000cd335 100644 --- a/build/lemonldap-ng/Makefile +++ b/build/lemonldap-ng/Makefile @@ -310,8 +310,6 @@ install_portal_site: install_conf_dir @cp -pR --remove-destination ${SRCPORTALDIR}/example/error.pl ${RPORTALDIR} @cp -pR --remove-destination ${SRCPORTALDIR}/example/mail.pl ${RPORTALDIR} @cp -pR --remove-destination ${SRCPORTALDIR}/example/apps ${RPORTALDIR} - @$(PERL) -i -pe 's#__SKINDIR__#$(PORTALDIR)/skins#; \ - s#__APPSXMLFILE__#$(CONFDIR)/apps-list.xml#;' ${RPORTALDIR}/index.pl ${RPORTALDIR}/error.pl ${RPORTALDIR}/mail.pl @cp -pR --remove-destination ${SRCPORTALDIR}/example/skins/* $(RPORTALSKINSDIR) @if [ "$(PORTALDIR)/skins/" != "$(PORTALSKINSDIR)/" ]; then \ for skin in $$(ls lemonldap-ng-portal/example/skins/); do \ @@ -546,9 +544,9 @@ debian-diff: @for i in $(PORTALSKINS); do \ $(DIFF) -x 'jquery*' lemonldap-ng-portal/example/skins/$$i /usr/share/lemonldap-ng/portal-skins/$$i; \ done ||true - @$(DIFF) -I '$$skin_dir' -I '$$appsxmlfile' lemonldap-ng-portal/example/index_skin.pl /var/lib/lemonldap-ng/portal/index.pl ||true - @$(DIFF) -I '$$skin_dir' lemonldap-ng-portal/example/error.pl /var/lib/lemonldap-ng/portal/error.pl ||true - @$(DIFF) -I '$$skin_dir' lemonldap-ng-portal/example/mail.pl /var/lib/lemonldap-ng/portal/mail.pl ||true + @$(DIFF) lemonldap-ng-portal/example/index_skin.pl /var/lib/lemonldap-ng/portal/index.pl ||true + @$(DIFF) lemonldap-ng-portal/example/error.pl /var/lib/lemonldap-ng/portal/error.pl ||true + @$(DIFF) lemonldap-ng-portal/example/mail.pl /var/lib/lemonldap-ng/portal/mail.pl ||true @# Handler @$(DIFF) lemonldap-ng-handler/lib/Lemonldap/NG/Handler /usr/share/perl5/Lemonldap/NG/Handler ||true @# Common @@ -570,9 +568,9 @@ default-diff: @$(DIFF) lemonldap-ng-portal/example/scripts/purgeCentralCache $(LMPREFIX)/bin/purgeCentralCache ||true @$(DIFF) lemonldap-ng-portal/example/scripts/buildPortalWSDL $(LMPREFIX)/bin/buildPortalWSDL ||true @$(DIFF) lemonldap-ng-portal/example/skins $(LMPREFIX)/htdocs/portal/skins ||true - @$(DIFF) -I '$$skin_dir' -I '$$appsxmlfile' lemonldap-ng-portal/example/index_skin.pl $(LMPREFIX)/htdocs/portal/index.pl ||true - @$(DIFF) -I '$$skin_dir' lemonldap-ng-portal/example/error.pl $(LMPREFIX)/htdocs/portal/error.pl ||true - @$(DIFF) -I '$$skin_dir' lemonldap-ng-portal/example/mail.pl $(LMPREFIX)/htdocs/portal/mail.pl ||true + @$(DIFF) lemonldap-ng-portal/example/index_skin.pl $(LMPREFIX)/htdocs/portal/index.pl ||true + @$(DIFF) lemonldap-ng-portal/example/error.pl $(LMPREFIX)/htdocs/portal/error.pl ||true + @$(DIFF) lemonldap-ng-portal/example/mail.pl $(LMPREFIX)/htdocs/portal/mail.pl ||true @# Handler @$(DIFF) lemonldap-ng-handler/lib/Lemonldap/NG/Handler /usr/local/share/perl/5.10.0/Lemonldap/NG/Handler ||true @$(DIFF) lemonldap-ng-handler/example/MyHandler.pm $(LMPREFIX)/handler/MyHandler.pm ||true diff --git a/modules/lemonldap-ng-portal/example/error.pl b/modules/lemonldap-ng-portal/example/error.pl index cba69cc0e..62b05cb0b 100755 --- a/modules/lemonldap-ng-portal/example/error.pl +++ b/modules/lemonldap-ng-portal/example/error.pl @@ -1,8 +1,6 @@ #!/usr/bin/perl use HTML::Template; -my $skin_dir = "__SKINDIR__"; - my $portal = Lemonldap::NG::Portal::SharedConf->new( # PORTAL CUSTOMIZATION @@ -11,6 +9,7 @@ my $portal = Lemonldap::NG::Portal::SharedConf->new( ); my $skin = $portal->{portalSkin}; +my $skin_dir = $ENV{DOCUMENT_ROOT} . "skins"; my $portal_url = $portal->{portal}; my $logout_url = "$portal_url?logout=1"; diff --git a/modules/lemonldap-ng-portal/example/index_skin.pl b/modules/lemonldap-ng-portal/example/index_skin.pl index 77a0132f6..9eafc6b37 100755 --- a/modules/lemonldap-ng-portal/example/index_skin.pl +++ b/modules/lemonldap-ng-portal/example/index_skin.pl @@ -4,11 +4,6 @@ use Lemonldap::NG::Portal::SharedConf; use HTML::Template; use strict; -# Menu configuration -my $skin_dir = "__SKINDIR__"; -my $appsxmlfile = "__APPSXMLFILE__"; -my $appsimgpath = "apps/"; - my $portal = Lemonldap::NG::Portal::SharedConf->new( { @@ -149,7 +144,7 @@ my $portal = Lemonldap::NG::Portal::SharedConf->new( # Get skin value my $skin = $portal->{portalSkin}; - +my $skin_dir = $ENV{DOCUMENT_ROOT} . "skins"; my ( $skinfile, %templateParams ); #################### @@ -180,10 +175,6 @@ if ( $portal->process() ) { my $menu = Lemonldap::NG::Portal::Menu->new( { portalObject => $portal, - apps => { - xmlfile => "$appsxmlfile", - imgpath => "$appsimgpath", - }, modules => { appslist => $portal->{portalDisplayAppslist}, password => $portal->{portalDisplayChangePassword}, diff --git a/modules/lemonldap-ng-portal/example/mail.pl b/modules/lemonldap-ng-portal/example/mail.pl index 5816209d4..b6875546e 100755 --- a/modules/lemonldap-ng-portal/example/mail.pl +++ b/modules/lemonldap-ng-portal/example/mail.pl @@ -4,12 +4,11 @@ use Lemonldap::NG::Portal::MailReset; use HTML::Template; use strict; -my $skin_dir = "__SKINDIR__"; - # Load portal module my $portal = Lemonldap::NG::Portal::MailReset->new(); my $skin = $portal->{portalSkin}; +my $skin_dir = $ENV{DOCUMENT_ROOT} . "skins"; my $portal_url = $portal->{portal}; # Process @@ -33,10 +32,6 @@ $template->param( DISPLAY_FORM => 1 ) if ( $portal->{error} == PE_MAILFORMEMPTY or ( $portal->{error} == PE_BADCREDENTIALS and !$portal->{mail_token} ) ); -# Display password if change is OK -$template->param( NEW_PASSWORD => $portal->{reset_password} ) - if ( $portal->{error} == PE_PASSWORD_OK ); - print $portal->header('text/html; charset=utf8'); print $template->output; diff --git a/modules/lemonldap-ng-portal/example/skins/common/mail_confirm.tpl b/modules/lemonldap-ng-portal/example/skins/common/mail_confirm.tpl new file mode 100644 index 000000000..346c25e7a --- /dev/null +++ b/modules/lemonldap-ng-portal/example/skins/common/mail_confirm.tpl @@ -0,0 +1,11 @@ + + +

+,
+
+ + + +

+ + diff --git a/modules/lemonldap-ng-portal/example/skins/common/mail_footer.tpl b/modules/lemonldap-ng-portal/example/skins/common/mail_footer.tpl new file mode 100644 index 000000000..bc3674412 --- /dev/null +++ b/modules/lemonldap-ng-portal/example/skins/common/mail_footer.tpl @@ -0,0 +1,11 @@ + + + + + diff --git a/modules/lemonldap-ng-portal/example/skins/common/mail_header.tpl b/modules/lemonldap-ng-portal/example/skins/common/mail_header.tpl new file mode 100644 index 000000000..3e701f857 --- /dev/null +++ b/modules/lemonldap-ng-portal/example/skins/common/mail_header.tpl @@ -0,0 +1,17 @@ +
+ + + +
diff --git a/modules/lemonldap-ng-portal/example/skins/common/mail_password.tpl b/modules/lemonldap-ng-portal/example/skins/common/mail_password.tpl new file mode 100644 index 000000000..58c5f8b02 --- /dev/null +++ b/modules/lemonldap-ng-portal/example/skins/common/mail_password.tpl @@ -0,0 +1,9 @@ + + +

+,
+
+ $password +

+ + diff --git a/modules/lemonldap-ng-portal/example/skins/pastel/mail.tpl b/modules/lemonldap-ng-portal/example/skins/pastel/mail.tpl index 0512b428f..41799b825 100644 --- a/modules/lemonldap-ng-portal/example/skins/pastel/mail.tpl +++ b/modules/lemonldap-ng-portal/example/skins/pastel/mail.tpl @@ -27,11 +27,6 @@