Skip to content

Commit

Permalink
SAK-32015 notifySiteImportConfirmation template is not internationali…
Browse files Browse the repository at this point in the history
  • Loading branch information
annuelo authored and ottenhoff committed Jan 6, 2017
1 parent 5eb3bed commit e2275e8
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ public EmailTemplate getEmailTemplate(String key, Locale locale) {
search.addRestriction( new Restriction("locale", locale.toString()) );
et = dao.findOneBySearch(EmailTemplate.class, search);
if (et == null) {
search = new Search("key", key);
search.addRestriction( new Restriction("locale", locale.getLanguage()) );
et = dao.findOneBySearch(EmailTemplate.class, search);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.sakaiproject.sitemanage.api;

import java.util.List;
import java.util.Locale;

import org.sakaiproject.user.api.User;
import org.sakaiproject.site.api.Site;
Expand Down Expand Up @@ -104,8 +105,9 @@ public String notifyCourseRequestSupport(String requestEmail, String serverName,
/**
* Notifies user when the course site import completed
* @param toEmail
* @param locale
* @param siteId
* @param siteTitle
*/
public void notifySiteImportCompleted(String toEmail, String siteId, String siteTitle);
public void notifySiteImportCompleted(String toEmail, Locale locale, String siteId, String siteTitle);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,20 @@ ${institution}
<locale>en</locale>
<version>1</version>
</emailTemplate>
<emailTemplate>
<subject>${localSakaiName} Importación del sitio completada para "${worksiteName}"</subject>
<message>El proceso de importación que usted comenzó para el sitio "${worksiteName}" ha sido completado.

Por favor, visite el sitio para ver los materiales importados:

${linkToWorksite}

Atentamente,

Los Administradores de ${localSakaiName}
${institution}
</message>
<locale>es</locale>
<version>1</version>
</emailTemplate>
</emailTemplates>
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ private String emailTemplateServiceSend(String templateName, Locale locale, User
return null;
}

public void notifySiteImportCompleted(String toEmail, String siteId, String siteTitle){
public void notifySiteImportCompleted(String toEmail, Locale locale, String siteId, String siteTitle){
if(toEmail != null && !"".equals(toEmail)){

// Create the map of replacement values
Expand All @@ -439,7 +439,7 @@ public void notifySiteImportCompleted(String toEmail, String siteId, String site
// Use the email template service to send the email
String headerTo = toEmail;
String replyTo = toEmail;
emailTemplateServiceSend(SITE_IMPORT_EMAIL_TEMPLATE_KEY, Locale.ENGLISH, userDirectoryService.getCurrentUser(), getSetupRequestEmailAddress(),
emailTemplateServiceSend(SITE_IMPORT_EMAIL_TEMPLATE_KEY, locale, userDirectoryService.getCurrentUser(), getSetupRequestEmailAddress(),
toEmail, headerTo, replyTo, replacementValues);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ private String getSetupRequestEmailAddress() {
return from;
}

public void notifySiteImportCompleted(String toEmail, String siteId, String siteTitle){
public void notifySiteImportCompleted(String toEmail, Locale locale, String siteId, String siteTitle){
if(toEmail != null && !"".equals(toEmail)){
String headerTo = toEmail;
String replyTo = toEmail;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@
import org.sakaiproject.tool.api.ToolSession;
import org.sakaiproject.tool.cover.SessionManager;
import org.sakaiproject.tool.cover.ToolManager;
import org.sakaiproject.user.api.PreferencesService;
import org.sakaiproject.user.api.User;
import org.sakaiproject.user.api.UserNotDefinedException;
import org.sakaiproject.user.cover.UserDirectoryService;
Expand Down Expand Up @@ -232,6 +233,8 @@ public class SiteAction extends PagedResourceActionII {
.get(org.sakaiproject.sitemanage.api.UserNotificationProvider.class);

private static ShortenedUrlService shortenedUrlService = (ShortenedUrlService) ComponentManager.get(ShortenedUrlService.class);

private PreferencesService preferencesService = (PreferencesService)ComponentManager.get(PreferencesService.class);

private static final String SITE_MODE_SITESETUP = "sitesetup";

Expand Down Expand Up @@ -9460,6 +9463,8 @@ private void actionForTemplate(String direction, int index,
final List existingTools = originalToolIds((List<String>) state.getAttribute(STATE_TOOL_REGISTRATION_SELECTED_LIST), state);

final String userEmail = UserDirectoryService.getCurrentUser().getEmail();
String userId = UserDirectoryService.getCurrentUser().getId();
final Locale locale = preferencesService.getLocale(userId);
final Session session = SessionManager.getCurrentSession();
final ToolSession toolSession = SessionManager.getCurrentToolSession();
final String siteId = existingSite.getId();
Expand All @@ -9473,7 +9478,7 @@ public void run() {
EventTrackingService.post(EventTrackingService.newEvent(SiteService.EVENT_SITE_IMPORT_START, existingSite.getReference(), false));
importToolIntoSite(existingTools, importTools, existingSite);
if (ServerConfigurationService.getBoolean(SAK_PROP_IMPORT_NOTIFICATION, true)) {
userNotificationProvider.notifySiteImportCompleted(userEmail, existingSite.getId(), existingSite.getTitle());
userNotificationProvider.notifySiteImportCompleted(userEmail, locale, existingSite.getId(), existingSite.getTitle());
}
EventTrackingService.post(EventTrackingService.newEvent(SiteService.EVENT_SITE_IMPORT_END, existingSite.getReference(), false));
} catch (IdUnusedException e) {
Expand Down Expand Up @@ -9535,6 +9540,8 @@ public void run() {
final List existingTools = originalToolIds((List<String>) state.getAttribute(STATE_TOOL_REGISTRATION_SELECTED_LIST), state);

final String userEmail = UserDirectoryService.getCurrentUser().getEmail();
String userId = UserDirectoryService.getCurrentUser().getId();
final Locale locale = preferencesService.getLocale(userId);
final Session session = SessionManager.getCurrentSession();
final ToolSession toolSession = SessionManager.getCurrentToolSession();
final String siteId = existingSite.getId();
Expand All @@ -9549,7 +9556,7 @@ public void run() {
// Remove all old contents before importing contents from new site
importToolIntoSiteMigrate(existingTools, importTools, existingSite);
if (ServerConfigurationService.getBoolean(SAK_PROP_IMPORT_NOTIFICATION, true)) {
userNotificationProvider.notifySiteImportCompleted(userEmail, existingSite.getId(), existingSite.getTitle());
userNotificationProvider.notifySiteImportCompleted(userEmail, locale, existingSite.getId(), existingSite.getTitle());
}
EventTrackingService.post(EventTrackingService.newEvent(SiteService.EVENT_SITE_IMPORT_END, existingSite.getReference(), false));
} catch (IdUnusedException e) {
Expand Down

0 comments on commit e2275e8

Please sign in to comment.