Index: lams_admin/conf/language/lams/ApplicationResources.properties =================================================================== RCS file: /usr/local/cvsroot/lams_admin/conf/language/lams/ApplicationResources.properties,v diff -u -r1.59 -r1.60 --- lams_admin/conf/language/lams/ApplicationResources.properties 11 Aug 2009 05:07:04 -0000 1.59 +++ lams_admin/conf/language/lams/ApplicationResources.properties 19 Aug 2009 06:45:17 -0000 1.60 @@ -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 =================================================================== RCS file: /usr/local/cvsroot/lams_admin/conf/language/lams/ApplicationResources_en_AU.properties,v diff -u -r1.59 -r1.60 --- lams_admin/conf/language/lams/ApplicationResources_en_AU.properties 11 Aug 2009 05:07:04 -0000 1.59 +++ lams_admin/conf/language/lams/ApplicationResources_en_AU.properties 19 Aug 2009 06:45:17 -0000 1.60 @@ -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 =================================================================== RCS file: /usr/local/cvsroot/lams_admin/src/java/org/lamsfoundation/lams/admin/service/AdminServiceProxy.java,v diff -u -r1.8 -r1.9 --- lams_admin/src/java/org/lamsfoundation/lams/admin/service/AdminServiceProxy.java 11 Aug 2009 03:24:04 -0000 1.8 +++ lams_admin/src/java/org/lamsfoundation/lams/admin/service/AdminServiceProxy.java 19 Aug 2009 06:45:17 -0000 1.9 @@ -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 =================================================================== RCS file: /usr/local/cvsroot/lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/SysAdminStartAction.java,v diff -u -r1.10 -r1.11 --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/SysAdminStartAction.java 11 Aug 2009 03:24:04 -0000 1.10 +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/SysAdminStartAction.java 19 Aug 2009 06:45:17 -0000 1.11 @@ -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 =================================================================== RCS file: /usr/local/cvsroot/lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/ThemeManagementAction.java,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/ThemeManagementAction.java 19 Aug 2009 06:45:17 -0000 1.1 @@ -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 =================================================================== RCS file: /usr/local/cvsroot/lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/ThemeForm.java,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/ThemeForm.java 19 Aug 2009 06:45:17 -0000 1.1 @@ -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/themeManagement.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_admin/web/themeManagement.jsp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_admin/web/themeManagement.jsp 19 Aug 2009 06:45:17 -0000 1.1 @@ -0,0 +1,191 @@ +<%@ include file="/taglibs.jsp"%> + + + + +

+ +

+ +

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

+ +

+
+ + + + + + + + + + + + + + + + + + + + + +
+ * : + + +
+ : + + +
+ : + + +
+ : + + +
+ +
+ +
+ +
+ +
+ Index: lams_admin/web/WEB-INF/struts/struts-config.xml =================================================================== RCS file: /usr/local/cvsroot/lams_admin/web/WEB-INF/struts/Attic/struts-config.xml,v diff -u -r1.26 -r1.27 --- lams_admin/web/WEB-INF/struts/struts-config.xml 11 Aug 2009 03:24:04 -0000 1.26 +++ lams_admin/web/WEB-INF/struts/struts-config.xml 19 Aug 2009 06:45:17 -0000 1.27 @@ -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_central/conf/language/lams/ApplicationResources.properties =================================================================== RCS file: /usr/local/cvsroot/lams_central/conf/language/lams/ApplicationResources.properties,v diff -u -r1.80 -r1.81 --- lams_central/conf/language/lams/ApplicationResources.properties 8 Jul 2009 06:24:23 -0000 1.80 +++ lams_central/conf/language/lams/ApplicationResources.properties 19 Aug 2009 06:45:19 -0000 1.81 @@ -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 =================================================================== RCS file: /usr/local/cvsroot/lams_central/conf/language/lams/ApplicationResources_en_AU.properties,v diff -u -r1.73 -r1.74 --- lams_central/conf/language/lams/ApplicationResources_en_AU.properties 5 Jul 2009 13:19:33 -0000 1.73 +++ lams_central/conf/language/lams/ApplicationResources_en_AU.properties 19 Aug 2009 06:45:19 -0000 1.74 @@ -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 =================================================================== RCS file: /usr/local/cvsroot/lams_central/conf/xdoclet/struts-forms.xml,v diff -u -r1.12 -r1.13 --- lams_central/conf/xdoclet/struts-forms.xml 6 Jul 2009 14:20:05 -0000 1.12 +++ lams_central/conf/xdoclet/struts-forms.xml 19 Aug 2009 06:45:20 -0000 1.13 @@ -38,6 +38,7 @@ + Index: lams_central/src/java/org/lamsfoundation/lams/security/UniversalLoginModule.java =================================================================== RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/security/UniversalLoginModule.java,v diff -u -r1.26 -r1.27 --- lams_central/src/java/org/lamsfoundation/lams/security/UniversalLoginModule.java 13 Nov 2008 01:20:28 -0000 1.26 +++ lams_central/src/java/org/lamsfoundation/lams/security/UniversalLoginModule.java 19 Aug 2009 06:45:19 -0000 1.27 @@ -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 =================================================================== RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/web/ProfileAction.java,v diff -u -r1.17 -r1.18 --- lams_central/src/java/org/lamsfoundation/lams/web/ProfileAction.java 28 Jan 2009 00:10:32 -0000 1.17 +++ lams_central/src/java/org/lamsfoundation/lams/web/ProfileAction.java 19 Aug 2009 06:45:19 -0000 1.18 @@ -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 =================================================================== RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/web/ProfileSaveAction.java,v diff -u -r1.12 -r1.13 --- lams_central/src/java/org/lamsfoundation/lams/web/ProfileSaveAction.java 28 Jan 2009 00:10:32 -0000 1.12 +++ lams_central/src/java/org/lamsfoundation/lams/web/ProfileSaveAction.java 19 Aug 2009 06:45:19 -0000 1.13 @@ -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/editprofile.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_central/web/editprofile.jsp,v diff -u -r1.17 -r1.18 --- lams_central/web/editprofile.jsp 6 Jul 2009 11:04:28 -0000 1.17 +++ lams_central/web/editprofile.jsp 19 Aug 2009 06:45:20 -0000 1.18 @@ -150,8 +150,17 @@ + + : + + + + ${theme.name} + + + + - @@ -248,6 +257,16 @@ : + + : + + + + ${theme.name} + + + + Index: lams_central/web/WEB-INF/web.xml =================================================================== RCS file: /usr/local/cvsroot/lams_central/web/WEB-INF/Attic/web.xml,v diff -u -r1.45 -r1.46 --- lams_central/web/WEB-INF/web.xml 6 Jul 2009 07:25:49 -0000 1.45 +++ lams_central/web/WEB-INF/web.xml 19 Aug 2009 06:45:19 -0000 1.46 @@ -242,11 +242,6 @@ - PresenceChatLoggerServlet - org.lamsfoundation.lams.webservice.PresenceChatLoggerServlet - - - updateCollapsedGroup org.lamsfoundation.lams.web.UpdateCollapsedGroupServlet @@ -468,10 +463,6 @@ /fckeditor/editor/filemanager/upload/simpleuploader - PresenceChatLoggerServlet - /PresenceChatLogger - - updateCollapsedGroup /servlet/updateCollapsedGroup Index: lams_central/web/WEB-INF/struts/struts-config.xml =================================================================== RCS file: /usr/local/cvsroot/lams_central/web/WEB-INF/struts/Attic/struts-config.xml,v diff -u -r1.37 -r1.38 --- lams_central/web/WEB-INF/struts/struts-config.xml 6 Jul 2009 07:25:49 -0000 1.37 +++ lams_central/web/WEB-INF/struts/struts-config.xml 19 Aug 2009 06:45:19 -0000 1.38 @@ -64,10 +64,13 @@ + + +