Index: lams_admin/conf/language/lams/ApplicationResources.properties =================================================================== diff -u -r3b9707dcbfd876311df224d857247b123a738aa2 -r4abf8ee86bc60a0b94edfdc4c907c28c6c5df13e --- lams_admin/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 3b9707dcbfd876311df224d857247b123a738aa2) +++ lams_admin/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 4abf8ee86bc60a0b94edfdc4c907c28c6c5df13e) @@ -398,6 +398,18 @@ admin.statistics.group.learners =Total Learners: admin.statistics.group.monitors =Total Monitors: admin.statistics.group.authors =Total Authors: +admin.themes.title =Theme Management +admin.themes.theme =Theme +admin.themes.description =Description +admin.themes.imageDir =CSS image directory +admin.themes.defaultTheme =Current default theme +admin.themes.remove =Remove +admin.themes.edit =Edit +admin.themes.addNew =Add/Edit theme +admin.themes.name =Name +admin.themes.makeThemeDefault =Make this theme the server default +admin.themes.makeDefault =Make default +admin.themes.deleteConfirm =Are you sure you want to delete this theme? +admin.themes.nameAlreadyExists =Please enter a new unused theme name, or click the edit icon to edit. - #======= End labels: Exported 391 labels for en AU ===== Index: lams_admin/conf/language/lams/ApplicationResources_en_AU.properties =================================================================== diff -u -r3b9707dcbfd876311df224d857247b123a738aa2 -r4abf8ee86bc60a0b94edfdc4c907c28c6c5df13e --- lams_admin/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 3b9707dcbfd876311df224d857247b123a738aa2) +++ lams_admin/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 4abf8ee86bc60a0b94edfdc4c907c28c6c5df13e) @@ -398,6 +398,18 @@ admin.statistics.group.learners =Total Learners: admin.statistics.group.monitors =Total Monitors: admin.statistics.group.authors =Total Authors: +admin.themes.title =Theme Management +admin.themes.theme =Theme +admin.themes.description =Description +admin.themes.imageDir =CSS image directory +admin.themes.defaultTheme =Current default theme +admin.themes.remove =Remove +admin.themes.edit =Edit +admin.themes.addNew =Add/Edit theme +admin.themes.name =Name +admin.themes.makeThemeDefault =Make this theme the server default +admin.themes.makeDefault =Make default +admin.themes.deleteConfirm =Are you sure you want to delete this theme? +admin.themes.nameAlreadyExists =Please enter a new unused theme name, or click the edit icon to edit. - #======= End labels: Exported 391 labels for en AU ===== Index: lams_admin/src/java/org/lamsfoundation/lams/admin/service/AdminServiceProxy.java =================================================================== diff -u -r70b2844ef7a633436b631e9e55096dc55ee63ed7 -r4abf8ee86bc60a0b94edfdc4c907c28c6c5df13e --- lams_admin/src/java/org/lamsfoundation/lams/admin/service/AdminServiceProxy.java (.../AdminServiceProxy.java) (revision 70b2844ef7a633436b631e9e55096dc55ee63ed7) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/service/AdminServiceProxy.java (.../AdminServiceProxy.java) (revision 4abf8ee86bc60a0b94edfdc4c907c28c6c5df13e) @@ -27,6 +27,7 @@ import org.lamsfoundation.lams.integration.service.IIntegrationService; import org.lamsfoundation.lams.statistics.service.IStatisticsService; +import org.lamsfoundation.lams.themes.service.IThemeService; import org.lamsfoundation.lams.usermanagement.service.IUserManagementService; import org.lamsfoundation.lams.usermanagement.service.LdapService; import org.lamsfoundation.lams.util.MessageService; @@ -48,6 +49,7 @@ private static IImportService importService; private static LdapService ldapService; private static IStatisticsService statisticsService; + private static IThemeService themeService; public static final IUserManagementService getService(ServletContext servletContext) { @@ -100,6 +102,13 @@ return statisticsService; } + public static final IThemeService getThemeService(ServletContext servletContext) { + if (themeService == null) { + themeService = (IThemeService)getDomainService(servletContext, "themeService"); + } + return themeService; + } + private static Object getDomainService(ServletContext servletContext,String serviceName) { WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext); return wac.getBean(serviceName); Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/SysAdminStartAction.java =================================================================== diff -u -r70b2844ef7a633436b631e9e55096dc55ee63ed7 -r4abf8ee86bc60a0b94edfdc4c907c28c6c5df13e --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/SysAdminStartAction.java (.../SysAdminStartAction.java) (revision 70b2844ef7a633436b631e9e55096dc55ee63ed7) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/SysAdminStartAction.java (.../SysAdminStartAction.java) (revision 4abf8ee86bc60a0b94edfdc4c907c28c6c5df13e) @@ -72,6 +72,7 @@ links.add(new LinkBean("register.do", "sysadmin.register.server")); links.add(new LinkBean("libraryManage.do", "sysadmin.library.management")); links.add(new LinkBean("statistics.do", "admin.statistics.title")); + links.add(new LinkBean("themeManagement.do", "admin.themes.title")); } else if (request.isUserInRole(Role.AUTHOR_ADMIN)) { LinkBean linkBean = new LinkBean("toolcontentlist.do", "sysadmin.tool.management"); links.add(linkBean); Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/ThemeManagementAction.java =================================================================== diff -u --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/ThemeManagementAction.java (revision 0) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/ThemeManagementAction.java (revision 4abf8ee86bc60a0b94edfdc4c907c28c6c5df13e) @@ -0,0 +1,170 @@ +/**************************************************************** + * Copyright (C) 2006 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ +package org.lamsfoundation.lams.admin.web.action; + +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.lamsfoundation.lams.admin.service.AdminServiceProxy; +import org.lamsfoundation.lams.admin.web.form.ThemeForm; +import org.lamsfoundation.lams.config.ConfigurationItem; +import org.lamsfoundation.lams.themes.CSSThemeVisualElement; +import org.lamsfoundation.lams.themes.service.IThemeService; +import org.lamsfoundation.lams.usermanagement.Role; +import org.lamsfoundation.lams.util.CSSThemeUtil; +import org.lamsfoundation.lams.util.Configuration; +import org.lamsfoundation.lams.util.ConfigurationKeys; +import org.lamsfoundation.lams.util.MessageService; +import org.lamsfoundation.lams.web.action.LamsDispatchAction; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.context.support.WebApplicationContextUtils; + +/** + * @author Luke Foxton + * + * Actions for maintaining and altering system themes + * + * @struts.action path="/themeManagement" parameter="method" name="themeForm" + * input=".themeManagement" scope="request" validate="false" + * @struts.action-forward name="success" path=".themeManagement" + * @struts.action-forward name="error" path=".error" + */ +public class ThemeManagementAction extends LamsDispatchAction { + + private static IThemeService themeService; + private static Configuration configurationService; + + public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + + // check permission + if (!request.isUserInRole(Role.SYSADMIN)) { + request.setAttribute("errorName", "RegisterAction"); + request.setAttribute("errorMessage", AdminServiceProxy.getMessageService(getServlet().getServletContext()) + .getMessage("error.authorisation")); + return mapping.findForward("error"); + } + + if (themeService == null) { + themeService = AdminServiceProxy.getThemeService(getServlet().getServletContext()); + } + + List themes = themeService.getAllThemes(); + + String currentTheme = Configuration.get(ConfigurationKeys.DEFAULT_HTML_THEME); + for (CSSThemeVisualElement theme : themes) { + theme.setCurrentDefaultTheme(Boolean.FALSE); + if (theme.getName().equals(currentTheme)) { + theme.setCurrentDefaultTheme(Boolean.TRUE); + } + + theme.setNotEditable(Boolean.FALSE); + if (theme.getName().equals(CSSThemeUtil.DEFAULT_HTML_THEME)) { + theme.setNotEditable(Boolean.TRUE); + } + } + + request.setAttribute("themes", themes); + return mapping.findForward("success"); + } + + public ActionForward addOrEditTheme(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + ThemeForm themeForm = (ThemeForm) form; + + CSSThemeVisualElement theme = null; + + if (themeForm.getId() != null && themeForm.getId() != 0) { + theme = themeService.getTheme(themeForm.getId()); + } else { + theme = new CSSThemeVisualElement(); + } + updateThemeFromForm(theme, themeForm); + + themeService.saveOrUpdateTheme(theme); + + if (themeForm.getCurrentDefaultTheme() != null && themeForm.getCurrentDefaultTheme() == true) { + Configuration.updateItem(ConfigurationKeys.DEFAULT_HTML_THEME, themeForm.getName()); + getConfiguration().persistUpdate(); + } else { + String currentTheme = Configuration.get(ConfigurationKeys.DEFAULT_HTML_THEME); + if (themeForm.getName().equals(currentTheme)) { + Configuration.updateItem(ConfigurationKeys.DEFAULT_HTML_THEME, CSSThemeUtil.DEFAULT_HTML_THEME); + getConfiguration().persistUpdate(); + } + } + themeForm.clear(); + return unspecified(mapping, themeForm, request, response); + } + + public ActionForward removeTheme(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + ThemeForm themeForm = (ThemeForm) form; + if (themeForm.getId() != null) { + themeService.removeTheme(themeForm.getId()); + } + + String currentTheme = Configuration.get(ConfigurationKeys.DEFAULT_HTML_THEME); + if (themeForm.getName().equals(currentTheme)) { + Configuration.updateItem(ConfigurationKeys.DEFAULT_HTML_THEME, CSSThemeUtil.DEFAULT_HTML_THEME); + getConfiguration().persistUpdate(); + } + + themeForm.clear(); + return unspecified(mapping, themeForm, request, response); + } + + public ActionForward setAsDefault(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + ThemeForm themeForm = (ThemeForm) form; + if (themeForm.getName() != null) { + Configuration.updateItem(ConfigurationKeys.DEFAULT_HTML_THEME, themeForm.getName()); + getConfiguration().persistUpdate(); + } + themeForm.clear(); + return unspecified(mapping, themeForm, request, response); + } + + private CSSThemeVisualElement updateThemeFromForm(CSSThemeVisualElement theme, ThemeForm form) { + theme.setName(form.getName()); + theme.setDescription(form.getDescription()); + theme.setImageDirectory(form.getImageDirectory()); + theme.setTheme(Boolean.TRUE); + return theme; + } + + private Configuration getConfiguration() { + if (configurationService == null) { + WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() + .getServletContext()); + configurationService = (Configuration) ctx.getBean("configurationService"); + + } + return configurationService; + } +} Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/ThemeForm.java =================================================================== diff -u --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/ThemeForm.java (revision 0) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/ThemeForm.java (revision 4abf8ee86bc60a0b94edfdc4c907c28c6c5df13e) @@ -0,0 +1,94 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ +package org.lamsfoundation.lams.admin.web.form; + +import org.apache.struts.action.ActionForm; + +/** + * + * Form for theme management + * + * @author lfoxton + * + * @struts.form name="themeForm" + */ +public class ThemeForm extends ActionForm { + + private static final long serialVersionUID = -3127221000563399156L; + + public ThemeForm() {} + + private String method; + private Long id; + private String name; + private String description; + private String imageDirectory; + private Boolean currentDefaultTheme; + + public String getMethod() { + return method; + } + public void setMethod(String method) { + this.method = method; + } + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + public String getImageDirectory() { + return imageDirectory; + } + public void setImageDirectory(String imageDirectory) { + this.imageDirectory = imageDirectory; + } + public Boolean getCurrentDefaultTheme() { + return currentDefaultTheme; + } + public void setCurrentDefaultTheme(Boolean currentDefaultTheme) { + this.currentDefaultTheme = currentDefaultTheme; + } + + public void clear() { + this.method = null; + this.id = null; + this.name = null; + this.description = null; + this.imageDirectory = null; + this.currentDefaultTheme = null; + } +} + Index: lams_admin/web/WEB-INF/struts/struts-config.xml =================================================================== diff -u -r70b2844ef7a633436b631e9e55096dc55ee63ed7 -r4abf8ee86bc60a0b94edfdc4c907c28c6c5df13e --- lams_admin/web/WEB-INF/struts/struts-config.xml (.../struts-config.xml) (revision 70b2844ef7a633436b631e9e55096dc55ee63ed7) +++ lams_admin/web/WEB-INF/struts/struts-config.xml (.../struts-config.xml) (revision 4abf8ee86bc60a0b94edfdc4c907c28c6c5df13e) @@ -41,6 +41,10 @@ name="ImportExcelForm" type="org.lamsfoundation.lams.admin.web.ImportExcelForm" /> + @@ -246,6 +250,10 @@ @@ -255,6 +263,11 @@ redirect="false" /> + + + + + + + + + + + \ No newline at end of file Index: lams_admin/web/themeManagement.jsp =================================================================== diff -u --- lams_admin/web/themeManagement.jsp (revision 0) +++ lams_admin/web/themeManagement.jsp (revision 4abf8ee86bc60a0b94edfdc4c907c28c6c5df13e) @@ -0,0 +1,191 @@ +<%@ include file="/taglibs.jsp"%> + + + + +

+ +

+ +

+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + +
+ ${theme.name} + + ${theme.description} + + ${theme.imageDirectory} + + + + + + + + + + + + + + + + + +
+ +

+ +

+
+ + + + + + + + + + + + + + + + + + + + + +
+ * : + + +
+ : + + +
+ : + + +
+ : + + +
+ +
+ +
+ +
+ +
+ Index: lams_central/conf/language/lams/ApplicationResources.properties =================================================================== diff -u -r242af895b7cc36e5f825a4b99862b92a5faa87ed -r4abf8ee86bc60a0b94edfdc4c907c28c6c5df13e --- lams_central/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 242af895b7cc36e5f825a4b99862b92a5faa87ed) +++ lams_central/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 4abf8ee86bc60a0b94edfdc4c907c28c6c5df13e) @@ -187,7 +187,7 @@ index.welcome =Welcome title.author.window =LAMS :: Author msg.export.choose.format.ims =IMS Learning Design Level A Format (This format cannot be reimported back into LAMS. Export only!) -msg.LAMS.copyright.statement.1 =LAMS\u2122 \u00a9 2002-2009 LAMS Foundation. +msg.LAMS.copyright.statement.1 =LAMS\u2122 \u00A9 2002-2009 LAMS Foundation. title.all.my.lessons =All My Lessons msg.no.lessons =No lessons label.return.to.myprofile =Return to My Profile @@ -369,5 +369,6 @@ label.planner.recent.learning.designs.title=Recently modified Learning Designs label.planner.recent.learning.designs.list.empty=No Learning Designs found +label.html.theme =LAMS Theme #======= End labels: Exported 266 labels for en AU ===== \ No newline at end of file Index: lams_central/conf/language/lams/ApplicationResources_en_AU.properties =================================================================== diff -u -r670004f992e5ed484da927cae0fa9f21802da40d -r4abf8ee86bc60a0b94edfdc4c907c28c6c5df13e --- lams_central/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 670004f992e5ed484da927cae0fa9f21802da40d) +++ lams_central/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 4abf8ee86bc60a0b94edfdc4c907c28c6c5df13e) @@ -187,7 +187,7 @@ index.welcome =Welcome title.author.window =LAMS :: Author msg.export.choose.format.ims =IMS Learning Design Level A Format (This format cannot be reimported back into LAMS. Export only!) -msg.LAMS.copyright.statement.1 =LAMS\u2122 \u00a9 2002-2009 LAMS Foundation. +msg.LAMS.copyright.statement.1 =LAMS\u2122 \u00A9 2002-2009 LAMS Foundation. title.all.my.lessons =All My Lessons msg.no.lessons =No lessons label.return.to.myprofile =Return to My Profile @@ -272,6 +272,6 @@ label.lamscommunity.notRegistered.1 =Your server is not registered with the LAMS Community so you can not seamlessly import sequences directly into your LAMS server from the community. Ask your system administrator to enable this feature. label.lamscommunity.notRegistered.2 =However, you can download and import the sequences manually from the LAMS Community website: label.lamscommunity.info =The LAMS Community is a global online community for all teachers, administrators and developers that use LAMS. Within the various sub-communities, you can access the latest news about LAMS, many different discussion forums, and a repository of shared LAMS sequences. +label.html.theme =LAMS Theme - #======= End labels: Exported 266 labels for en AU ===== Index: lams_central/conf/xdoclet/struts-forms.xml =================================================================== diff -u -re67b31517d5a6991a5d88a3485bc23da8b6e65a0 -r4abf8ee86bc60a0b94edfdc4c907c28c6c5df13e --- lams_central/conf/xdoclet/struts-forms.xml (.../struts-forms.xml) (revision e67b31517d5a6991a5d88a3485bc23da8b6e65a0) +++ lams_central/conf/xdoclet/struts-forms.xml (.../struts-forms.xml) (revision 4abf8ee86bc60a0b94edfdc4c907c28c6c5df13e) @@ -38,6 +38,7 @@ +
Index: lams_central/src/java/org/lamsfoundation/lams/security/UniversalLoginModule.java =================================================================== diff -u -rd69d6409d2853f6a13a2de63e0044e6e7d1ec01c -r4abf8ee86bc60a0b94edfdc4c907c28c6c5df13e --- lams_central/src/java/org/lamsfoundation/lams/security/UniversalLoginModule.java (.../UniversalLoginModule.java) (revision d69d6409d2853f6a13a2de63e0044e6e7d1ec01c) +++ lams_central/src/java/org/lamsfoundation/lams/security/UniversalLoginModule.java (.../UniversalLoginModule.java) (revision 4abf8ee86bc60a0b94edfdc4c907c28c6c5df13e) @@ -52,9 +52,13 @@ import javax.sql.DataSource; import org.apache.log4j.Logger; +import org.lamsfoundation.lams.themes.CSSThemeVisualElement; +import org.lamsfoundation.lams.themes.dto.CSSThemeBriefDTO; +import org.lamsfoundation.lams.themes.service.IThemeService; import org.lamsfoundation.lams.usermanagement.AuthenticationMethodType; import org.lamsfoundation.lams.usermanagement.Role; import org.lamsfoundation.lams.usermanagement.User; +import org.lamsfoundation.lams.usermanagement.dto.UserDTO; import org.lamsfoundation.lams.usermanagement.service.LdapService; import org.lamsfoundation.lams.usermanagement.service.UserManagementService; import org.lamsfoundation.lams.util.Configuration; @@ -82,6 +86,9 @@ protected String principalsQuery; + private IThemeService themeService; + private UserManagementService service; + public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) { super.initialize(subject, callbackHandler, sharedState, options); dsJndiName = (String) options.get("dsJndiName"); @@ -102,9 +109,16 @@ WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(HttpSessionManager .getInstance().getServletContext()); - UserManagementService service = (UserManagementService) ctx.getBean("userManagementService"); + + if (service == null) { + service = (UserManagementService) ctx.getBean("userManagementService"); + } User user = service.getUserByLogin(username); + if (themeService == null) { + themeService = (IThemeService) ctx.getBean("themeService"); + } + // LDAP user provisioning if (user == null) { // provision a new user by checking ldap server @@ -114,8 +128,10 @@ ldapService = (LdapService) ctx.getBean("ldapService"); } catch (NoSuchBeanDefinitionException e) { // LDEV-1937 - log.error("NoSuchBeanDefinitionException while getting ldapService bean, will try another method...", - e); + log + .error( + "NoSuchBeanDefinitionException while getting ldapService bean, will try another method...", + e); ApplicationContext context = new ClassPathXmlApplicationContext( "org/lamsfoundation/lams/usermanagement/ldapContext.xml"); ldapService = (LdapService) context.getBean("ldapService"); @@ -198,8 +214,26 @@ // if login is valid, register userDTO into session. if (isValid) { + UserDTO userDTO = user.getUserDTO(); + + // If the user's theme has been deleted, use the default as fallback + CSSThemeBriefDTO userTheme = userDTO.getHtmlTheme(); + if (userTheme != null) { + boolean themeExists = false; + for (CSSThemeVisualElement theme : themeService.getAllThemes()) { + if (userTheme.getId().equals(theme.getId())) { + themeExists = true; + break; + } + } + + if (!themeExists) { + userDTO.setHtmlTheme(new CSSThemeBriefDTO(themeService.getDefaultTheme())); + } + } + HttpSession sharedsession = SessionManager.getSession(); - sharedsession.setAttribute(AttributeNames.USER, user.getUserDTO()); + sharedsession.setAttribute(AttributeNames.USER, userDTO); } } catch (Exception e) { e.printStackTrace(); Index: lams_central/src/java/org/lamsfoundation/lams/web/ProfileAction.java =================================================================== diff -u -rc234c64ad9ff9d713f6d8e3331d0c20075e49303 -r4abf8ee86bc60a0b94edfdc4c907c28c6c5df13e --- lams_central/src/java/org/lamsfoundation/lams/web/ProfileAction.java (.../ProfileAction.java) (revision c234c64ad9ff9d713f6d8e3331d0c20075e49303) +++ lams_central/src/java/org/lamsfoundation/lams/web/ProfileAction.java (.../ProfileAction.java) (revision 4abf8ee86bc60a0b94edfdc4c907c28c6c5df13e) @@ -41,11 +41,15 @@ import org.lamsfoundation.lams.index.IndexOrgBean; import org.lamsfoundation.lams.learning.service.ICoreLearnerService; import org.lamsfoundation.lams.lesson.dto.LessonDTO; +import org.lamsfoundation.lams.themes.CSSThemeVisualElement; +import org.lamsfoundation.lams.themes.service.IThemeService; import org.lamsfoundation.lams.usermanagement.Organisation; import org.lamsfoundation.lams.usermanagement.OrganisationType; import org.lamsfoundation.lams.usermanagement.SupportedLocale; import org.lamsfoundation.lams.usermanagement.User; import org.lamsfoundation.lams.usermanagement.service.IUserManagementService; +import org.lamsfoundation.lams.util.Configuration; +import org.lamsfoundation.lams.util.ConfigurationKeys; import org.lamsfoundation.lams.util.IndexUtils; import org.lamsfoundation.lams.util.LanguageUtil; import org.lamsfoundation.lams.web.action.LamsDispatchAction; @@ -82,6 +86,8 @@ private static ICoreLearnerService learnerService; + private static IThemeService themeService; + public ActionForward view(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { @@ -198,10 +204,31 @@ userForm.set("localeId", locale.getLocaleId()); request.setAttribute("locales", locales); request.setAttribute("tab", "profile"); - + boolean hasLamsCommunityToken = requestor.getLamsCommunityToken() != null; request.setAttribute("hasLamsCommunityToken", hasLamsCommunityToken); - + + themeService = getThemeService(); + + // Get all the themes + List themes = themeService.getAllThemes(); + request.setAttribute("themes", themes); + + // Check the user theme is still installed + Long userSelectedTheme = null; + if (requestor.getHtmlTheme() != null) { + for (CSSThemeVisualElement theme : themes) { + if (theme.getId() == requestor.getHtmlTheme().getId()) { + userSelectedTheme = theme.getId(); + } + } + } + // if still null, use the default + if (userSelectedTheme == null) { + userSelectedTheme = themeService.getDefaultTheme().getId(); + } + userForm.set("userTheme", userSelectedTheme); + return mapping.findForward("edit"); } @@ -224,4 +251,13 @@ } return learnerService; } + + private IThemeService getThemeService() { + if (themeService == null) { + WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() + .getServletContext()); + themeService = (IThemeService) ctx.getBean("themeService"); + } + return themeService; + } } Index: lams_central/src/java/org/lamsfoundation/lams/web/ProfileSaveAction.java =================================================================== diff -u -rc234c64ad9ff9d713f6d8e3331d0c20075e49303 -r4abf8ee86bc60a0b94edfdc4c907c28c6c5df13e --- lams_central/src/java/org/lamsfoundation/lams/web/ProfileSaveAction.java (.../ProfileSaveAction.java) (revision c234c64ad9ff9d713f6d8e3331d0c20075e49303) +++ lams_central/src/java/org/lamsfoundation/lams/web/ProfileSaveAction.java (.../ProfileSaveAction.java) (revision 4abf8ee86bc60a0b94edfdc4c907c28c6c5df13e) @@ -41,6 +41,7 @@ import org.apache.struts.action.ActionMessages; import org.apache.struts.action.DynaActionForm; import org.hibernate.Hibernate; +import org.lamsfoundation.lams.themes.CSSThemeVisualElement; import org.lamsfoundation.lams.usermanagement.SupportedLocale; import org.lamsfoundation.lams.usermanagement.User; import org.lamsfoundation.lams.usermanagement.service.IUserManagementService; @@ -115,6 +116,10 @@ (Integer) userForm.get("localeId")); requestor.setLocale(locale); + CSSThemeVisualElement theme = (CSSThemeVisualElement) getService().findById(CSSThemeVisualElement.class, + (Long) userForm.get("userTheme")); + requestor.setHtmlTheme(theme); + if (userForm.get("disableLamsCommunityUsername") != null && (Boolean) userForm.get("disableLamsCommunityUsername")) { requestor.setLamsCommunityToken(null); Index: lams_central/web/WEB-INF/struts/struts-config.xml =================================================================== diff -u -rea79f29aed5c764a223234e456442bc1e49fcf85 -r4abf8ee86bc60a0b94edfdc4c907c28c6c5df13e --- lams_central/web/WEB-INF/struts/struts-config.xml (.../struts-config.xml) (revision ea79f29aed5c764a223234e456442bc1e49fcf85) +++ lams_central/web/WEB-INF/struts/struts-config.xml (.../struts-config.xml) (revision 4abf8ee86bc60a0b94edfdc4c907c28c6c5df13e) @@ -64,10 +64,13 @@ + + +