=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/message/EmailMessageSender.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/message/EmailMessageSender.java 2014-09-29 16:33:27 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/message/EmailMessageSender.java 2014-11-08 23:03:17 +0000 @@ -55,8 +55,9 @@ { private static final Log log = LogFactory.getLog( EmailMessageSender.class ); private static final String FROM_ADDRESS = "noreply@dhis2.org"; - private static final String FROM_NAME = "DHIS 2 Message [No reply]"; - private static final String SUBJECT_PREFIX = "[DHIS 2] "; + private static final String DEFAULT_APPLICATION_TITLE = "DHIS 2"; + private static final String DEFAULT_FROM_NAME = DEFAULT_APPLICATION_TITLE + " Message [No reply]"; + private static final String DEFAULT_SUBJECT_PREFIX = "[" + DEFAULT_APPLICATION_TITLE + "] "; private static final String LB = System.getProperty( "line.separator" ); // ------------------------------------------------------------------------- @@ -116,7 +117,7 @@ try { Email email = getEmail( hostName, port, username, password, tls, from ); - email.setSubject( SUBJECT_PREFIX + subject ); + email.setSubject( customizeTitle( DEFAULT_SUBJECT_PREFIX ) + subject ); email.setMsg( text ); boolean hasRecipients = false; @@ -160,7 +161,7 @@ { Email email = new SimpleEmail(); email.setHostName( hostName ); - email.setFrom( defaultIfEmpty( sender, FROM_ADDRESS ), FROM_NAME ); + email.setFrom( defaultIfEmpty( sender, FROM_ADDRESS ), customizeTitle( DEFAULT_FROM_NAME ) ); email.setSmtpPort( port ); email.setStartTLSEnabled( tls ); @@ -171,4 +172,16 @@ return email; } + + private String customizeTitle( String s ) + { + String applicationTitle = (String) systemSettingManager.getSystemSetting( SystemSettingManager.KEY_APPLICATION_TITLE ); + + if ( applicationTitle != null && !applicationTitle.isEmpty() ) + { + s = s.replace( DEFAULT_APPLICATION_TITLE, applicationTitle ); + } + + return s; + } } === 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-10-22 23:49:18 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/DefaultSecurityService.java 2014-11-08 23:03:17 +0000 @@ -69,6 +69,8 @@ private static final String RESTORE_PATH = "/dhis-web-commons/security/"; + private static final String DEFAULT_APPLICATION_TITLE = "DHIS 2"; + private static final int INVITED_USER_PASSWORD_LENGTH = 40; private static final int RESTORE_TOKEN_LENGTH = 50; @@ -192,13 +194,20 @@ RestoreType restoreType = restoreOptions.getRestoreType(); + String applicationTitle = (String) systemSettingManager.getSystemSetting( SystemSettingManager.KEY_APPLICATION_TITLE ); + + if ( applicationTitle == null || applicationTitle.isEmpty() ) + { + applicationTitle = DEFAULT_APPLICATION_TITLE; + } + String[] result = initRestore( credentials, restoreOptions ); Set users = new HashSet<>(); users.add( credentials.getUser() ); Map vars = new HashMap<>(); - vars.put( "rootPath", rootPath ); + vars.put( "applicationTitle", applicationTitle ); vars.put( "restorePath", rootPath + RESTORE_PATH + restoreType.getAction() ); vars.put( "token", result[0] ); vars.put( "code", result[1] ); @@ -210,6 +219,8 @@ I18n i18n = i18nManager.getI18n( locale ); vars.put( "i18n" , i18n ); + rootPath = rootPath.replace( "http://", "" ).replace( "https://", "" ); + // ------------------------------------------------------------------------- // Render emails // ------------------------------------------------------------------------- @@ -219,8 +230,8 @@ 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)"; + String subject1 = i18n.getString( restoreType.getEmailSubject() ) + " " + rootPath + " (" + i18n.getString( "message" ).toLowerCase() + " 1 / 2)", + subject2 = i18n.getString( restoreType.getEmailSubject() ) + " " + rootPath + " (" + i18n.getString( "message" ).toLowerCase() + " 2 / 2)"; // ------------------------------------------------------------------------- // Send emails === 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-11-07 19:36:59 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/i18n_global.properties 2014-11-08 23:03:17 +0000 @@ -889,20 +889,24 @@ #-- 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_subject=User account restore confirmation at +email_restore_1_1st_paragraph_before_application_title=Someone, probably you, has asked us to restore your +email_restore_1_1st_paragraph_after_application_title=user account. 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_1st_paragraph_before_application_title=Someone, probably you, has asked us to restore your +email_restore_2_1st_paragraph_after_application_title=user account. 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_subject=Invitation to create user account at +email_invite_1_1st_paragraph_before_application_title=This is an invitation to create a +email_invite_1_1st_paragraph_after_application_title=user account. 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_1st_paragraph_before_application_title=This is an invitation to create a +email_invite_2_1st_paragraph_after_application_title=user account. 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. === modified 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-07-24 16:38:14 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/invite_message1.vm 2014-11-08 23:03:17 +0000 @@ -1,5 +1,6 @@ ## Email account invite message 1 of 2 -$object.i18n.getString( "email_invite_1_1st_paragraph" ) ${object.rootPath}. +$object.i18n.getString( "email_invite_1_1st_paragraph_before_application_title" ) ${object.applicationTitle} $object.i18n.getString( "email_invite_1_1st_paragraph_after_application_title" ) + $object.i18n.getString( "email_invite_1_2nd_paragraph" ) === modified 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-07-24 16:38:14 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/invite_message2.vm 2014-11-08 23:03:17 +0000 @@ -1,5 +1,6 @@ ## Email account invite message 2 of 2 -$object.i18n.getString( 'email_invite_2_1st_paragraph' ) ${object.rootPath}. +$object.i18n.getString( "email_invite_2_1st_paragraph_before_application_title" ) ${object.applicationTitle} $object.i18n.getString( "email_invite_2_1st_paragraph_after_application_title" ) + $object.i18n.getString( 'email_invite_2_2nd_paragraph' ) === modified 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 2014-07-24 16:38:14 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/restore_message1.vm 2014-11-08 23:03:17 +0000 @@ -1,5 +1,6 @@ ## Email account recovery message 1 of 2 -$object.i18n.getString( 'email_restore_1_1st_paragraph' ) ${object.rootPath}. +$object.i18n.getString( "email_restore_1_1st_paragraph_before_application_title" ) ${object.applicationTitle} $object.i18n.getString( "email_restore_1_1st_paragraph_after_application_title" ) + $object.i18n.getString( 'email_restore_1_2nd_paragraph' ) === modified 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 2014-07-24 16:38:14 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/restore_message2.vm 2014-11-08 23:03:17 +0000 @@ -1,5 +1,6 @@ ## Email account recovery message 2 of 2 -$object.i18n.getString( 'email_restore_2_1st_paragraph' ) ${object.rootPath}. +$object.i18n.getString( "email_restore_2_1st_paragraph_before_application_title" ) ${object.applicationTitle} $object.i18n.getString( "email_restore_2_1st_paragraph_after_application_title" ) + $object.i18n.getString( 'email_restore_2_2nd_paragraph' )