=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/i18n/I18nManager.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/i18n/I18nManager.java 2014-07-06 17:12:17 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/i18n/I18nManager.java 2014-07-24 16:46:51 +0000 @@ -42,6 +42,8 @@ { String ID = I18nManager.class.getName(); + I18n getI18n( Locale locale ); + I18n getI18n( Class clazz ); I18n getI18n( Class clazz, Locale locale ); === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/i18n/ui/DefaultI18nManager.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/i18n/ui/DefaultI18nManager.java 2014-07-06 17:12:17 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/i18n/ui/DefaultI18nManager.java 2014-07-24 16:46:51 +0000 @@ -68,6 +68,12 @@ // ------------------------------------------------------------------------- @Override + public I18n getI18n( Locale locale ) + { + return new I18n( getGlobalResourceBundle( locale ), null ); + } + + @Override public I18n getI18n( Class clazz ) { return new I18n( getGlobalResourceBundle(), getSpecificResourceBundle( clazz.getName() ) ); === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/DefaultSecurityService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/DefaultSecurityService.java 2014-05-24 18:16:41 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/DefaultSecurityService.java 2014-07-24 16:51:56 +0000 @@ -33,6 +33,9 @@ import org.hisp.dhis.acl.AclService; import org.hisp.dhis.common.CodeGenerator; import org.hisp.dhis.common.IdentifiableObject; +import org.hisp.dhis.i18n.I18n; +import org.hisp.dhis.i18n.I18nManager; +import org.hisp.dhis.i18n.locale.LocaleManager; import org.hisp.dhis.message.MessageSender; import org.hisp.dhis.period.Cal; import org.hisp.dhis.setting.SystemSettingManager; @@ -43,12 +46,14 @@ import org.hisp.dhis.user.UserAuthorityGroup; import org.hisp.dhis.user.UserCredentials; import org.hisp.dhis.user.UserService; +import org.hisp.dhis.user.UserSettingService; import org.springframework.beans.factory.annotation.Autowired; import java.util.Arrays; import java.util.Date; import java.util.HashMap; import java.util.HashSet; +import java.util.Locale; import java.util.Map; import java.util.Set; @@ -100,6 +105,13 @@ this.systemSettingManager = systemSettingManager; } + private I18nManager i18nManager; + + public void setI18nManager( I18nManager i18nManager ) + { + this.i18nManager = i18nManager; + } + @Autowired private CurrentUserService currentUserService; @@ -171,18 +183,37 @@ Set users = new HashSet(); users.add( credentials.getUser() ); - Map vars = new HashMap(); + Map vars = new HashMap(); vars.put( "rootPath", rootPath ); vars.put( "restorePath", rootPath + RESTORE_PATH + restoreType.getAction() ); vars.put( "token", result[0] ); vars.put( "code", result[1] ); vars.put( "username", credentials.getUsername() ); - String text1 = new VelocityManager().render( vars, restoreType.getEmailTemplate() + "1" ); - String text2 = new VelocityManager().render( vars, restoreType.getEmailTemplate() + "2" ); - - emailMessageSender.sendMessage( restoreType.getEmailSubject() + " (message 1 of 2)", text1, null, users, true ); - emailMessageSender.sendMessage( restoreType.getEmailSubject() + " (message 2 of 2)", text2, null, users, true ); + User user = credentials.getUser(); + Locale locale = (Locale) userService.getUserSettingValue( user, UserSettingService.KEY_UI_LOCALE, LocaleManager.DHIS_STANDARD_LOCALE ); + + I18n i18n = i18nManager.getI18n( locale ); + vars.put( "i18n" , i18n ); + + // ------------------------------------------------------------------------- + // Render emails + // ------------------------------------------------------------------------- + + VelocityManager vm = new VelocityManager(); + + String text1 = vm.render( vars, restoreType.getEmailTemplate() + "1" ), + text2 = vm.render( vars, restoreType.getEmailTemplate() + "2" ); + + String subject1 = i18n.getString( restoreType.getEmailSubject() ) + " (" + i18n.getString( "message" ).toLowerCase() + " 1 / 2)", + subject2 = i18n.getString( restoreType.getEmailSubject() ) + " (" + i18n.getString( "message" ).toLowerCase() + " 2 / 2)"; + + // ------------------------------------------------------------------------- + // Send emails + // ------------------------------------------------------------------------- + + emailMessageSender.sendMessage( subject1, text1, null, users, true ); + emailMessageSender.sendMessage( subject2, text2, null, users, true ); return true; } === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/RestoreType.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/RestoreType.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/RestoreType.java 2014-07-24 16:38:14 +0000 @@ -37,8 +37,8 @@ public enum RestoreType { - RECOVER_PASSWORD( Calendar.HOUR_OF_DAY, 1, "restore_message", "User account restore confirmation", "restore.action" ), - INVITE( Calendar.MONTH, 3, "invite_message", "Create DHIS 2 user account invitation", "invite.action" ); + RECOVER_PASSWORD( Calendar.HOUR_OF_DAY, 1, "restore_message", "email_restore_subject", "restore.action" ), + INVITE( Calendar.MONTH, 3, "invite_message", "email_invite_subject", "invite.action" ); /** * Type of Calendar interval before the restore expires. === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/security.xml' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/security.xml 2013-08-13 07:18:45 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/security.xml 2014-07-16 17:07:46 +0000 @@ -19,5 +19,6 @@ + === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/i18n_global.properties' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/i18n_global.properties 2014-07-23 12:49:57 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/i18n_global.properties 2014-07-25 15:15:14 +0000 @@ -862,3 +862,37 @@ thai=Thai iso8601=ISO 8601 coptic=Coptic + +#-- Restore emails ------------------------------------------------------------# + +email_restore_subject=User account restore confirmation +email_restore_1_1st_paragraph=Someone, probably you, have asked us to restore your user account at +email_restore_1_2nd_paragraph=You have been sent two emails, where this is the first one. Please follow the \ + link below. In the next step you will be asked to enter a code which has been \ + sent to you in the other email. +email_restore_1_3rd_paragraph=You must complete the restore process within 1 hour. If you take no action, your \ + account will not be restored. If you did not request this restore, please disregard \ + this message. +email_restore_2_1st_paragraph=Someone, probably you, have asked us to restore your user account at +email_restore_2_2nd_paragraph=You have been sent two emails, where this is the second one. Please read the \ + first email and follow the instructions. Please use the code below to complete \ + the new account form. +email_restore_2_3rd_paragraph=You must complete the restore process within 1 hour. If you take no action, your \ + account will not be restored. If you did not request this restore, please disregard \ + this message. + +#-- Invite emails -------------------------------------------------------------# + +email_invite_subject=Create user account invitation +email_invite_1_1st_paragraph=This is an invitation to create a user account on the DHIS 2 system at +email_invite_1_2nd_paragraph=You have been sent two emails, where this is the first one. Please follow the \ + link below. In the next step you will be asked to enter a code which has been \ + sent to you in the other email. +email_invite_1_3rd_paragraph=You must respond to this invitation within 3 months. If you take no action, \ + the invitation will expire at that time. +email_invite_2_1st_paragraph=This is an invitation to create a user account on the DHIS 2 system at +email_invite_2_2nd_paragraph=You have been sent two emails, where this is the second one. Please read the \ + first email and follow the instructions. Please use the code below to complete \ + the new account form. +email_invite_2_3rd_paragraph=You must respond to this invitation within 3 months. If you take no action, \ + the invitation will expire at that time. === removed file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/invite_message1.vm' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/invite_message1.vm 2014-01-17 03:48:57 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/invite_message1.vm 1970-01-01 00:00:00 +0000 @@ -1,11 +0,0 @@ -This is an invitation to create a user account on the DHIS 2 system at ${object.rootPath}. -You have been sent two emails, where this is the first one. Please follow the -link below. In the next step you will be asked to enter a code which has been -sent to you in the other email. - - -${object.restorePath}?username=${object.username}&token=${object.token} - - -You must respond to this invitation within 3 months. If you take no action, -the invitation will expire at that time. === added file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/invite_message1.vm' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/invite_message1.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/invite_message1.vm 2014-07-24 16:38:14 +0000 @@ -0,0 +1,9 @@ +## Email account invite message 1 of 2 +$object.i18n.getString( "email_invite_1_1st_paragraph" ) ${object.rootPath}. +$object.i18n.getString( "email_invite_1_2nd_paragraph" ) + + +${object.restorePath}?username=${object.username}&token=${object.token} + + +$object.i18n.getString( "email_invite_1_3rd_paragraph" ) \ No newline at end of file === added file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/invite_message2.vm' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/invite_message2.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/invite_message2.vm 2014-07-24 16:38:14 +0000 @@ -0,0 +1,9 @@ +## Email account invite message 2 of 2 +$object.i18n.getString( 'email_invite_2_1st_paragraph' ) ${object.rootPath}. +$object.i18n.getString( 'email_invite_2_2nd_paragraph' ) + + +${object.code} + + +$object.i18n.getString( 'email_invite_2_3rd_paragraph' ) === removed file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/invite_message2.vm' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/invite_message2.vm 2014-01-23 15:04:07 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/invite_message2.vm 1970-01-01 00:00:00 +0000 @@ -1,11 +0,0 @@ -This is an invitation to create a user account on the DHIS 2 system at ${object.rootPath}. -You have been sent two emails, where this is the second one. Please read the -first email and follow the instructions. Please use the code below to complete -the new account form. - - -${object.code} - - -You must respond to this invitation within 3 months. If you take no action, -the invitation will expire at that time. === added file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/restore_message1.vm' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/restore_message1.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/restore_message1.vm 2014-07-24 16:38:14 +0000 @@ -0,0 +1,9 @@ +## Email account recovery message 1 of 2 +$object.i18n.getString( 'email_restore_1_1st_paragraph' ) ${object.rootPath}. +$object.i18n.getString( 'email_restore_1_2nd_paragraph' ) + + +${object.restorePath}?username=${object.username}&token=${object.token} + + +$object.i18n.getString( 'email_restore_1_3rd_paragraph' ) === removed file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/restore_message1.vm' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/restore_message1.vm 2012-10-30 06:50:49 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/restore_message1.vm 1970-01-01 00:00:00 +0000 @@ -1,12 +0,0 @@ -Someone, probably you, have asked us to restore your user account at ${object.rootPath}. -You have been sent two emails, where this is the first one. Please follow the -link below. In the next step you will be asked to enter a code which has been -sent to you in the other email. - - -${object.restorePath}?username=${object.username}&token=${object.token} - - -You must complete the restore process within 1 hour. If you take no action, your -account will not be restored. If you did not request this restore, please disregard -this message. === removed file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/restore_message2.vm' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/restore_message2.vm 2012-10-30 06:50:49 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/restore_message2.vm 1970-01-01 00:00:00 +0000 @@ -1,12 +0,0 @@ -Someone, probably you, have asked us to restore your user account at ${object.rootPath}. -You have been sent two emails, where this is the second one. Please read the -first email and follow the instructions. If you already have done so, please -use the code below to complete the account restore form. - - -${object.code} - - -You must complete the restore process within 1 hour. If you take no action, your -account will not be restored. If you did not request this restore, please disregard -this message. \ No newline at end of file === added file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/restore_message2.vm' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/restore_message2.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/restore_message2.vm 2014-07-24 16:38:14 +0000 @@ -0,0 +1,9 @@ +## Email account recovery message 2 of 2 +$object.i18n.getString( 'email_restore_2_1st_paragraph' ) ${object.rootPath}. +$object.i18n.getString( 'email_restore_2_2nd_paragraph' ) + + +${object.code} + + +$object.i18n.getString( 'email_restore_2_3rd_paragraph' ) \ No newline at end of file