Index: lams_admin/conf/language/lams/ApplicationResources.properties =================================================================== diff -u -r7998a31f6d7d4f1eef3e866bafef22caa012eb7a -ra23376f298830f9cb4d3d18e5dc7ef11b907c173 --- lams_admin/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 7998a31f6d7d4f1eef3e866bafef22caa012eb7a) +++ lams_admin/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision a23376f298830f9cb4d3d18e5dc7ef11b907c173) @@ -414,5 +414,7 @@ admin.themes.type =Type admin.themes.html =HTML admin.themes.flash =Flash +label.html.htmlTheme =HTML Theme +label.html.flashTheme =Flash Theme #======= End labels: Exported 391 labels for en AU ===== Index: lams_admin/conf/language/lams/ApplicationResources_en_AU.properties =================================================================== diff -u -r7998a31f6d7d4f1eef3e866bafef22caa012eb7a -ra23376f298830f9cb4d3d18e5dc7ef11b907c173 --- lams_admin/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 7998a31f6d7d4f1eef3e866bafef22caa012eb7a) +++ lams_admin/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision a23376f298830f9cb4d3d18e5dc7ef11b907c173) @@ -414,5 +414,7 @@ admin.themes.type =Type admin.themes.html =HTML admin.themes.flash =Flash +label.html.htmlTheme =HTML Theme +label.html.flashTheme =Flash Theme #======= End labels: Exported 391 labels for en AU ===== Index: lams_admin/conf/xdoclet/struts-forms.xml =================================================================== diff -u -r16a173502ea5c23248e95a73afd859ea77d0ac23 -ra23376f298830f9cb4d3d18e5dc7ef11b907c173 --- lams_admin/conf/xdoclet/struts-forms.xml (.../struts-forms.xml) (revision 16a173502ea5c23248e95a73afd859ea77d0ac23) +++ lams_admin/conf/xdoclet/struts-forms.xml (.../struts-forms.xml) (revision a23376f298830f9cb4d3d18e5dc7ef11b907c173) @@ -46,6 +46,8 @@ + + Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserAction.java =================================================================== diff -u -rdc670ce921e2b9d4fda9fae27392e9bb69560856 -ra23376f298830f9cb4d3d18e5dc7ef11b907c173 --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserAction.java (.../UserAction.java) (revision dc670ce921e2b9d4fda9fae27392e9bb69560856) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserAction.java (.../UserAction.java) (revision a23376f298830f9cb4d3d18e5dc7ef11b907c173) @@ -40,6 +40,8 @@ import org.lamsfoundation.lams.admin.AdminConstants; import org.lamsfoundation.lams.admin.service.AdminServiceProxy; import org.lamsfoundation.lams.admin.web.dto.UserOrgRoleDTO; +import org.lamsfoundation.lams.themes.Theme; +import org.lamsfoundation.lams.themes.service.IThemeService; import org.lamsfoundation.lams.usermanagement.AuthenticationMethod; import org.lamsfoundation.lams.usermanagement.Organisation; import org.lamsfoundation.lams.usermanagement.OrganisationState; @@ -62,7 +64,8 @@ */ /** - * @struts:action path="/user" name="UserForm" scope="request" parameter="method" validate="false" + * @struts:action path="/user" name="UserForm" scope="request" + * parameter="method" validate="false" * * @struts:action-forward name="user" path=".user" * @struts:action-forward name="userlist" path="/usermanage.do" @@ -75,6 +78,7 @@ private static Logger log = Logger.getLogger(UserAction.class); private IUserManagementService service; private MessageService messageService; + private static IThemeService themeService; private static List locales; private static List authenticationMethods; @@ -85,10 +89,12 @@ if (messageService == null) { messageService = AdminServiceProxy.getMessageService(getServlet().getServletContext()); } + if (themeService == null) { + themeService = AdminServiceProxy.getThemeService(getServlet().getServletContext()); + } } - public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws Exception { + public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { initServices(); if (UserAction.locales == null) { @@ -103,15 +109,37 @@ Integer orgId = WebUtil.readIntParam(request, "orgId", true); Integer userId = WebUtil.readIntParam(request, "userId", true); + // Get all the css and flash themes themes + List cssThemes = themeService.getAllCSSThemes(); + request.setAttribute("cssThemes", cssThemes); + List flashThemes = themeService.getAllFlashThemes(); + request.setAttribute("flashThemes", flashThemes); + + // Select the default themes by default + Theme defaultCSSTheme = themeService.getDefaultCSSTheme(); + for (Theme theme : cssThemes) { + if (theme.getThemeId().equals(defaultCSSTheme.getThemeId())) { + userForm.set("userCSSTheme", theme.getThemeId()); + break; + } + } + Theme defaultFlashTheme = themeService.getDefaultFlashTheme(); + for (Theme theme : cssThemes) { + if (theme.getThemeId().equals(defaultFlashTheme.getThemeId())) { + userForm.set("userFlashTheme", theme.getThemeId()); + break; + } + } + // test requestor's permission Organisation org = null; Boolean canEdit = service.isUserGlobalGroupAdmin(); if (orgId != null) { org = (Organisation) service.findById(Organisation.class, orgId); if (!canEdit) { OrganisationType orgType = org.getOrganisationType(); - Integer orgIdOfCourse = orgType.getOrganisationTypeId().equals(OrganisationType.CLASS_TYPE) ? org - .getParentOrganisation().getOrganisationId() : orgId; + Integer orgIdOfCourse = orgType.getOrganisationTypeId().equals(OrganisationType.CLASS_TYPE) ? org.getParentOrganisation().getOrganisationId() + : orgId; User requestor = service.getUserByLogin(request.getRemoteUser()); if (service.isUserInRole(requestor.getUserId(), orgIdOfCourse, Role.GROUP_ADMIN) || service.isUserInRole(requestor.getUserId(), orgIdOfCourse, Role.GROUP_MANAGER)) { @@ -141,6 +169,39 @@ // set user's organisations to display request.setAttribute("userOrgRoles", getUserOrgRoles(user)); request.setAttribute("globalRoles", getGlobalRoles(user)); + + // Check the user css theme is still installed + Long userSelectedCSSTheme = null; + if (user.getHtmlTheme() != null) { + for (Theme theme : cssThemes) { + if (theme.getThemeId() == user.getHtmlTheme().getThemeId()) { + userSelectedCSSTheme = theme.getThemeId(); + break; + } + } + } + // if still null, use the default + if (userSelectedCSSTheme == null) { + userSelectedCSSTheme = themeService.getDefaultCSSTheme().getThemeId(); + } + userForm.set("userCSSTheme", userSelectedCSSTheme); + + // Check the user flash theme is still installed + Long userSelectedFlashTheme = null; + if (user.getHtmlTheme() != null) { + for (Theme theme : flashThemes) { + if (theme.getThemeId() == user.getFlashTheme().getThemeId()) { + userSelectedFlashTheme = theme.getThemeId(); + break; + } + } + } + // if still null, use the default + if (userSelectedFlashTheme == null) { + userSelectedFlashTheme = themeService.getDefaultFlashTheme().getThemeId(); + } + userForm.set("userFlashTheme", userSelectedFlashTheme); + } else { // create a user try { SupportedLocale locale = LanguageUtil.getDefaultLocale(); @@ -170,8 +231,7 @@ // display user's global roles, if any private UserOrgRoleDTO getGlobalRoles(User user) { initServices(); - UserOrganisation uo = service.getUserOrganisation(user.getUserId(), service.getRootOrganisation() - .getOrganisationId()); + UserOrganisation uo = service.getUserOrganisation(user.getUserId(), service.getRootOrganisation().getOrganisationId()); if (uo == null) { return null; } @@ -191,8 +251,8 @@ initServices(); List uorDTOs = new ArrayList(); - List uos = service.getUserOrganisationsForUserByTypeAndStatus(user.getLogin(), - OrganisationType.COURSE_TYPE, OrganisationState.ACTIVE); + List uos = service + .getUserOrganisationsForUserByTypeAndStatus(user.getLogin(), OrganisationType.COURSE_TYPE, OrganisationState.ACTIVE); for (UserOrganisation uo : uos) { UserOrgRoleDTO uorDTO = new UserOrgRoleDTO(); List roles = new ArrayList(); @@ -203,9 +263,8 @@ uorDTO.setOrgName(uo.getOrganisation().getName()); uorDTO.setRoles(roles); List childDTOs = new ArrayList(); - List childuos = service.getUserOrganisationsForUserByTypeAndStatusAndParent(user - .getLogin(), OrganisationType.CLASS_TYPE, OrganisationState.ACTIVE, uo.getOrganisation() - .getOrganisationId()); + List childuos = service.getUserOrganisationsForUserByTypeAndStatusAndParent(user.getLogin(), OrganisationType.CLASS_TYPE, + OrganisationState.ACTIVE, uo.getOrganisation().getOrganisationId()); for (UserOrganisation childuo : childuos) { UserOrgRoleDTO childDTO = new UserOrgRoleDTO(); List childroles = new ArrayList(); @@ -225,8 +284,7 @@ } // determine whether to disable or delete user based on their lams data - public ActionForward remove(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws Exception { + public ActionForward remove(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { initServices(); @@ -248,8 +306,7 @@ return mapping.findForward("remove"); } - public ActionForward disable(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws Exception { + public ActionForward disable(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { initServices(); @@ -275,8 +332,7 @@ } } - public ActionForward delete(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws Exception { + public ActionForward delete(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { initServices(); @@ -309,8 +365,7 @@ } // called from disabled users screen - public ActionForward enable(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws Exception { + public ActionForward enable(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { initServices(); Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserSaveAction.java =================================================================== diff -u -ra99beebd296504aff314ec52850543f1823f650b -ra23376f298830f9cb4d3d18e5dc7ef11b907c173 --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserSaveAction.java (.../UserSaveAction.java) (revision a99beebd296504aff314ec52850543f1823f650b) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserSaveAction.java (.../UserSaveAction.java) (revision a23376f298830f9cb4d3d18e5dc7ef11b907c173) @@ -43,6 +43,7 @@ import org.apache.struts.action.DynaActionForm; import org.lamsfoundation.lams.admin.AdminConstants; import org.lamsfoundation.lams.admin.service.AdminServiceProxy; +import org.lamsfoundation.lams.themes.Theme; import org.lamsfoundation.lams.usermanagement.AuthenticationMethod; import org.lamsfoundation.lams.usermanagement.SupportedLocale; import org.lamsfoundation.lams.usermanagement.User; @@ -58,7 +59,8 @@ /** * struts doclets * - * @struts:action path="/usersave" name="UserForm" input=".user" scope="request" validate="false" + * @struts:action path="/usersave" name="UserForm" input=".user" scope="request" + * validate="false" * * @struts:action-forward name="user" path="/user.do?method=edit" * @struts:action-forward name="userlist" path="/usermanage.do" @@ -72,8 +74,7 @@ @Override @SuppressWarnings("unchecked") - public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws Exception { + public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { UserSaveAction.service = AdminServiceProxy.getService(getServlet().getServletContext()); @@ -86,10 +87,9 @@ UserSaveAction.log.debug("orgId: " + orgId); Boolean edit = false; Boolean passwordChanged = true; - SupportedLocale locale = (SupportedLocale) UserSaveAction.service.findById(SupportedLocale.class, - (Integer) userForm.get("localeId")); - AuthenticationMethod authenticationMethod = (AuthenticationMethod) UserSaveAction.service.findById( - AuthenticationMethod.class, (Integer) userForm.get("authenticationMethodId")); + SupportedLocale locale = (SupportedLocale) UserSaveAction.service.findById(SupportedLocale.class, (Integer) userForm.get("localeId")); + AuthenticationMethod authenticationMethod = (AuthenticationMethod) UserSaveAction.service.findById(AuthenticationMethod.class, (Integer) userForm + .get("authenticationMethodId")); UserSaveAction.log.debug("locale: " + locale); UserSaveAction.log.debug("authenticationMethod:" + authenticationMethod); @@ -157,22 +157,37 @@ BeanUtils.copyProperties(user, userForm); user.setLocale(locale); user.setAuthenticationMethod(authenticationMethod); + + Theme cssTheme = (Theme) service.findById(Theme.class, (Long) userForm.get("userCSSTheme")); + user.setHtmlTheme(cssTheme); + + Theme flashTheme = (Theme) service.findById(Theme.class, (Long) userForm.get("userFlashTheme")); + user.setFlashTheme(flashTheme); + UserSaveAction.service.save(user); } else { // create user user = new User(); userForm.set("password", HashUtil.sha1((String) userForm.get("password"))); BeanUtils.copyProperties(user, userForm); UserSaveAction.log.debug("creating user... new login: " + user.getLogin()); if (errors.isEmpty()) { - // TODO set flash/html themes according to user input instead of server default. + // TODO set flash/html themes according to user input + // instead of server default. user.setFlashTheme(UserSaveAction.service.getDefaultFlashTheme()); user.setHtmlTheme(UserSaveAction.service.getDefaultHtmlTheme()); user.setDisabledFlag(false); user.setCreateDate(new Date()); - user.setAuthenticationMethod((AuthenticationMethod) UserSaveAction.service.findByProperty( - AuthenticationMethod.class, "authenticationMethodName", "LAMS-Database").get(0)); + user.setAuthenticationMethod((AuthenticationMethod) UserSaveAction.service.findByProperty(AuthenticationMethod.class, + "authenticationMethodName", "LAMS-Database").get(0)); user.setUserId(null); user.setLocale(locale); + + Theme cssTheme = (Theme) service.findById(Theme.class, (Long) userForm.get("userCSSTheme")); + user.setHtmlTheme(cssTheme); + + Theme flashTheme = (Theme) service.findById(Theme.class, (Long) userForm.get("userFlashTheme")); + user.setFlashTheme(flashTheme); + UserSaveAction.service.save(user); // make 'create user' audit log entry Index: lams_admin/web/user.jsp =================================================================== diff -u -rdc670ce921e2b9d4fda9fae27392e9bb69560856 -ra23376f298830f9cb4d3d18e5dc7ef11b907c173 --- lams_admin/web/user.jsp (.../user.jsp) (revision dc670ce921e2b9d4fda9fae27392e9bb69560856) +++ lams_admin/web/user.jsp (.../user.jsp) (revision a23376f298830f9cb4d3d18e5dc7ef11b907c173) @@ -131,6 +131,26 @@ + : + + + + ${theme.name} + + + + + + : + + + + ${theme.name} + + + + + Index: lams_central/src/java/org/lamsfoundation/lams/web/ProfileAction.java =================================================================== diff -u -r7998a31f6d7d4f1eef3e866bafef22caa012eb7a -ra23376f298830f9cb4d3d18e5dc7ef11b907c173 --- lams_central/src/java/org/lamsfoundation/lams/web/ProfileAction.java (.../ProfileAction.java) (revision 7998a31f6d7d4f1eef3e866bafef22caa012eb7a) +++ lams_central/src/java/org/lamsfoundation/lams/web/ProfileAction.java (.../ProfileAction.java) (revision a23376f298830f9cb4d3d18e5dc7ef11b907c173) @@ -214,12 +214,13 @@ List cssThemes = themeService.getAllCSSThemes(); request.setAttribute("cssThemes", cssThemes); - // Check the user theme is still installed + // Check the user css theme is still installed Long userSelectedCSSTheme = null; if (requestor.getHtmlTheme() != null) { for (Theme theme : cssThemes) { if (theme.getThemeId() == requestor.getHtmlTheme().getThemeId()) { userSelectedCSSTheme = theme.getThemeId(); + break; } } } @@ -233,12 +234,13 @@ List flashThemes = themeService.getAllFlashThemes(); request.setAttribute("flashThemes", flashThemes); - // Check the user theme is still installed + // Check the user flash theme is still installed Long userSelectedFlashTheme = null; if (requestor.getHtmlTheme() != null) { for (Theme theme : flashThemes) { if (theme.getThemeId() == requestor.getFlashTheme().getThemeId()) { userSelectedFlashTheme = theme.getThemeId(); + break; } } }