diff --git a/config/alfresco/templates/email/invite_user_email.ftl b/config/alfresco/templates/email/invite_user_email.ftl index 82a26ae8e6..a73b48964b 100644 --- a/config/alfresco/templates/email/invite_user_email.ftl +++ b/config/alfresco/templates/email/invite_user_email.ftl @@ -6,8 +6,8 @@ You can view the space through the Alfresco client: <#assign ref=space.nodeRef> <#assign workspace=ref[0..ref?index_of("://")-1]> <#assign storenode=ref[ref?index_of("://")+3..]> -http://${url.context}/alfresco/navigate/browse/${workspace}/${storenode} +${url.serverPath}/alfresco/navigate/browse/${workspace}/${storenode} Regards -Alfresco \ No newline at end of file +Alfresco diff --git a/config/alfresco/templates/email/notify_user_email.ftl b/config/alfresco/templates/email/notify_user_email.ftl index 94091d0753..fbe83fc922 100644 --- a/config/alfresco/templates/email/notify_user_email.ftl +++ b/config/alfresco/templates/email/notify_user_email.ftl @@ -1,14 +1,14 @@ A new document '${document.name}', is available in the '${space.name}' space, it was added by ${person.properties.firstName}<#if person.properties.lastName?exists> ${person.properties.lastName}. You can view it through this link: -http://${url.context}/alfresco${document.url} +${url.serverPath}/alfresco${document.url} Or through the Alfresco client: <#assign ref=space.nodeRef> <#assign workspace=ref[0..ref?index_of("://")-1]> <#assign storenode=ref[ref?index_of("://")+3..]> -http://${url.context}/alfresco/navigate/browse/${workspace}/${storenode} +${url.serverPath}/alfresco/navigate/browse/${workspace}/${storenode} Regards -Alfresco \ No newline at end of file +Alfresco diff --git a/source/java/org/alfresco/web/app/Application.java b/source/java/org/alfresco/web/app/Application.java index 88ef90b479..21379fb8eb 100644 --- a/source/java/org/alfresco/web/app/Application.java +++ b/source/java/org/alfresco/web/app/Application.java @@ -86,6 +86,8 @@ public class Application private static String spaceTemplatesFolderName; private static String contentTemplatesFolderName; private static String emailTemplatesFolderName; + private static String inviteEmailTemplatesFolderName; + private static String notifyEmailTemplatesFolderName; private static String rssTemplatesFolderName; private static String savedSearchesFolderName; private static String scriptsFolderName; @@ -432,6 +434,38 @@ public class Application } /** + * @return Returns the Invite Email Templates folder name + */ + public static String getInviteEmailTemplatesFolderName(ServletContext context) + { + return getInviteEmailTemplatesFolderName(WebApplicationContextUtils.getRequiredWebApplicationContext(context)); + } + + /** + * @return Returns the Invite Email Templates folder name + */ + public static String getInviteEmailTemplatesFolderName(FacesContext context) + { + return getInviteEmailTemplatesFolderName(FacesContextUtils.getRequiredWebApplicationContext(context)); + } + + /** + * @return Returns the Notify Email Templates folder name + */ + public static String getNotifyEmailTemplatesFolderName(ServletContext context) + { + return getNotifyEmailTemplatesFolderName(WebApplicationContextUtils.getRequiredWebApplicationContext(context)); + } + + /** + * @return Returns the Notify Email Templates folder name + */ + public static String getNotifyEmailTemplatesFolderName(FacesContext context) + { + return getNotifyEmailTemplatesFolderName(FacesContextUtils.getRequiredWebApplicationContext(context)); + } + + /** * @return Returns the Email templates folder name */ public static String getEmailTemplatesFolderName(ServletContext context) @@ -995,6 +1029,42 @@ public class Application } /** + * Returns the Invite Email Templates folder name + * + * @param context The spring context + * @return The invite email folder name + */ + private static String getInviteEmailTemplatesFolderName(WebApplicationContext context) + { + if (inviteEmailTemplatesFolderName == null) + { + ImporterBootstrap bootstrap = (ImporterBootstrap) context.getBean(BEAN_IMPORTER_BOOTSTRAP); + Properties configuration = bootstrap.getConfiguration(); + inviteEmailTemplatesFolderName = configuration.getProperty("spaces.templates.email.invite1.childname"); + } + + return inviteEmailTemplatesFolderName; + } + + /** + * Returns the Notify Email Templates folder name + * + * @param context The spring context + * @return The notify email folder name + */ + private static String getNotifyEmailTemplatesFolderName(WebApplicationContext context) + { + if (notifyEmailTemplatesFolderName == null) + { + ImporterBootstrap bootstrap = (ImporterBootstrap) context.getBean(BEAN_IMPORTER_BOOTSTRAP); + Properties configuration = bootstrap.getConfiguration(); + notifyEmailTemplatesFolderName = configuration.getProperty("spaces.templates.email.notify.childname"); + } + + return notifyEmailTemplatesFolderName; + } + + /** * Returns the RSS Templates folder name * * @param context The spring context diff --git a/source/java/org/alfresco/web/bean/TemplateMailHelperBean.java b/source/java/org/alfresco/web/bean/TemplateMailHelperBean.java index 8515c4d3a1..ef3a061475 100644 --- a/source/java/org/alfresco/web/bean/TemplateMailHelperBean.java +++ b/source/java/org/alfresco/web/bean/TemplateMailHelperBean.java @@ -149,6 +149,17 @@ public class TemplateMailHelperBean implements Serializable // object to allow client urls to be generated in emails model.put("url", new BaseTemplateContentServlet.URLHelper(fc)); + model.put("document", node); + if (nodeService.getType(node).equals(ContentModel.TYPE_CONTENT)) + { + NodeRef parentNodeRef = nodeService.getParentAssocs(node).get(0).getParentRef(); + if (parentNodeRef == null) + { + throw new IllegalArgumentException("Parent folder doesn't exists for node: " + node); + } + model.put("space", parentNodeRef); + } + body = services.getTemplateService().processTemplate("freemarker", templateRef.toString(), model); } this.finalBody = body; diff --git a/source/java/org/alfresco/web/bean/content/InviteContentUsersWizard.java b/source/java/org/alfresco/web/bean/content/InviteContentUsersWizard.java index 55118cb0af..455b5e4435 100644 --- a/source/java/org/alfresco/web/bean/content/InviteContentUsersWizard.java +++ b/source/java/org/alfresco/web/bean/content/InviteContentUsersWizard.java @@ -26,6 +26,9 @@ package org.alfresco.web.bean.content; import java.util.Set; +import javax.faces.context.FacesContext; + +import org.alfresco.web.app.Application; import org.alfresco.web.bean.repository.Node; import org.alfresco.web.bean.wizard.BaseInviteUsersWizard; @@ -57,4 +60,15 @@ public class InviteContentUsersWizard extends BaseInviteUsersWizard { return this.browseBean.getDocument(); } + + @Override + protected String getEmailTemplateXPath() + { + FacesContext fc = FacesContext.getCurrentInstance(); + String xpath = Application.getRootPath(fc) + "/" + + Application.getGlossaryFolderName(fc) + "/" + + Application.getEmailTemplatesFolderName(fc) + "/" + + Application.getNotifyEmailTemplatesFolderName(fc) + "//*"; + return xpath; + } } diff --git a/source/java/org/alfresco/web/bean/spaces/InviteSpaceUsersWizard.java b/source/java/org/alfresco/web/bean/spaces/InviteSpaceUsersWizard.java index ae4075af56..6821135c19 100644 --- a/source/java/org/alfresco/web/bean/spaces/InviteSpaceUsersWizard.java +++ b/source/java/org/alfresco/web/bean/spaces/InviteSpaceUsersWizard.java @@ -26,6 +26,9 @@ package org.alfresco.web.bean.spaces; import java.util.Set; +import javax.faces.context.FacesContext; + +import org.alfresco.web.app.Application; import org.alfresco.web.bean.repository.Node; import org.alfresco.web.bean.wizard.BaseInviteUsersWizard; @@ -57,4 +60,15 @@ public class InviteSpaceUsersWizard extends BaseInviteUsersWizard { return this.browseBean.getActionSpace(); } + + @Override + protected String getEmailTemplateXPath() + { + FacesContext fc = FacesContext.getCurrentInstance(); + String xpath = Application.getRootPath(fc) + "/" + + Application.getGlossaryFolderName(fc) + "/" + + Application.getEmailTemplatesFolderName(fc) + "/" + + Application.getInviteEmailTemplatesFolderName(fc) + "//*"; + return xpath; + } } diff --git a/source/java/org/alfresco/web/bean/wcm/InviteWebsiteUsersWizard.java b/source/java/org/alfresco/web/bean/wcm/InviteWebsiteUsersWizard.java index fb3fb752ff..c61b36a69a 100644 --- a/source/java/org/alfresco/web/bean/wcm/InviteWebsiteUsersWizard.java +++ b/source/java/org/alfresco/web/bean/wcm/InviteWebsiteUsersWizard.java @@ -215,4 +215,15 @@ public class InviteWebsiteUsersWizard extends BaseInviteUsersWizard { this.standalone = editMode; } + + @Override + protected String getEmailTemplateXPath() + { + FacesContext fc = FacesContext.getCurrentInstance(); + String xpath = Application.getRootPath(fc) + "/" + + Application.getGlossaryFolderName(fc) + "/" + + Application.getEmailTemplatesFolderName(fc) + "/" + + Application.getInviteEmailTemplatesFolderName(fc) + "//*"; + return xpath; + } } diff --git a/source/java/org/alfresco/web/bean/wizard/BaseInviteUsersWizard.java b/source/java/org/alfresco/web/bean/wizard/BaseInviteUsersWizard.java index 2e35e45294..dda6dc71f2 100644 --- a/source/java/org/alfresco/web/bean/wizard/BaseInviteUsersWizard.java +++ b/source/java/org/alfresco/web/bean/wizard/BaseInviteUsersWizard.java @@ -45,6 +45,8 @@ import javax.transaction.UserTransaction; import org.alfresco.model.ContentModel; import org.alfresco.repo.search.impl.lucene.LuceneQueryParser; +import org.alfresco.repo.security.permissions.AccessDeniedException; +import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.search.LimitBy; import org.alfresco.service.cmr.search.ResultSet; @@ -60,6 +62,8 @@ import org.alfresco.web.bean.TemplateMailHelperBean; import org.alfresco.web.bean.repository.Node; import org.alfresco.web.bean.repository.Repository; import org.alfresco.web.bean.repository.User; +import org.alfresco.web.data.IDataContainer; +import org.alfresco.web.data.QuickSort; import org.alfresco.web.ui.common.SortableSelectItem; import org.alfresco.web.ui.common.Utils; import org.alfresco.web.ui.common.component.UIGenericPicker; @@ -138,6 +142,58 @@ public abstract class BaseInviteUsersWizard extends BaseWizardBean protected abstract Node getNode(); /** + * @return Returns the list of email templates for user notification + */ + public List getEmailTemplates() + { + List wrappers = null; + + try + { + FacesContext fc = FacesContext.getCurrentInstance(); + NodeRef rootNodeRef = this.getNodeService().getRootNode(Repository.getStoreRef()); + NamespaceService resolver = Repository.getServiceRegistry(fc).getNamespaceService(); + List results = this.getSearchService().selectNodes(rootNodeRef, getEmailTemplateXPath(), null, resolver, false); + + wrappers = new ArrayList(results.size() + 1); + if (results.size() != 0) + { + DictionaryService dd = Repository.getServiceRegistry(fc).getDictionaryService(); + for (NodeRef ref : results) + { + if (this.getNodeService().exists(ref) == true) + { + Node childNode = new Node(ref); + if (dd.isSubClass(childNode.getType(), ContentModel.TYPE_CONTENT)) + { + wrappers.add(new SelectItem(childNode.getId(), childNode.getName())); + } + } + } + + // make sure the list is sorted by the label + QuickSort sorter = new QuickSort(wrappers, "label", true, IDataContainer.SORT_CASEINSENSITIVE); + sorter.sort(); + } + } + catch (AccessDeniedException accessErr) + { + // ignore the result if we cannot access the root + } + + // add an entry (at the start) to instruct the user to select an item + if (wrappers == null) + { + wrappers = new ArrayList(1); + } + wrappers.add(0, new SelectItem("none", Application.getMessage(FacesContext.getCurrentInstance(), "select_a_template"))); + + return wrappers; + } + + protected abstract String getEmailTemplateXPath(); + + /** * @param namespaceService The NamespaceService to set. */ public void setNamespaceService(NamespaceService namespaceService) diff --git a/source/web/jsp/users/invite-users-wizard/notify.jsp b/source/web/jsp/users/invite-users-wizard/notify.jsp index 750f795fa4..3efd9b5295 100644 --- a/source/web/jsp/users/invite-users-wizard/notify.jsp +++ b/source/web/jsp/users/invite-users-wizard/notify.jsp @@ -80,7 +80,7 @@ - + diff --git a/source/web/jsp/wcm/create-website-wizard/notify.jsp b/source/web/jsp/wcm/create-website-wizard/notify.jsp index 561b68c34d..f4de46e2ad 100644 --- a/source/web/jsp/wcm/create-website-wizard/notify.jsp +++ b/source/web/jsp/wcm/create-website-wizard/notify.jsp @@ -80,7 +80,7 @@ - +