Index: lams_admin/web/WEB-INF/tiles/tiles-defs.xml
===================================================================
RCS file: /usr/local/cvsroot/lams_admin/web/WEB-INF/tiles/Attic/tiles-defs.xml,v
diff -u -r1.30 -r1.30.10.1
--- lams_admin/web/WEB-INF/tiles/tiles-defs.xml 9 Jan 2008 00:53:14 -0000 1.30
+++ lams_admin/web/WEB-INF/tiles/tiles-defs.xml 1 Mar 2010 04:56:25 -0000 1.30.10.1
@@ -150,4 +150,9 @@
+
+
+
+
+
\ 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.71.2.16.2.3 -r1.71.2.16.2.4
--- lams_central/conf/language/lams/ApplicationResources.properties 19 Feb 2010 04:40:56 -0000 1.71.2.16.2.3
+++ lams_central/conf/language/lams/ApplicationResources.properties 1 Mar 2010 04:55:47 -0000 1.71.2.16.2.4
@@ -275,5 +275,7 @@
unsupport.move =LAMS does not support moving a file via the workspace interface.
videorecorder.instructions.fck =Click the record button to start and stop recording. Once a recording is completed, you can review it by clicking the play button. When ready to add the video, click the tick button. Having problems with recording? It might be that your network blocks the video recording ports. Contact your system administrator.
+label.html.htmlTheme =HTML Theme
+label.html.flashTheme =Flash Theme
#======= End labels: Exported 268 labels for en AU =====
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.67.2.13.4.3 -r1.67.2.13.4.4
--- lams_central/conf/language/lams/ApplicationResources_en_AU.properties 19 Feb 2010 04:40:56 -0000 1.67.2.13.4.3
+++ lams_central/conf/language/lams/ApplicationResources_en_AU.properties 1 Mar 2010 04:55:47 -0000 1.67.2.13.4.4
@@ -275,5 +275,7 @@
unsupport.move =LAMS does not support moving a file via the workspace interface.
videorecorder.instructions.fck =Click the record button to start and stop recording. Once a recording is completed, you can review it by clicking the play button. When ready to add the video, click the tick button. Having problems with recording? It might be that your network blocks the video recording ports. Contact your system administrator.
+label.html.htmlTheme =HTML Theme
+label.html.flashTheme =Flash Theme
#======= End labels: Exported 268 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.8.4.3 -r1.8.4.3.2.1
--- lams_central/conf/xdoclet/struts-forms.xml 19 Jun 2009 04:32:10 -0000 1.8.4.3
+++ lams_central/conf/xdoclet/struts-forms.xml 1 Mar 2010 04:55:47 -0000 1.8.4.3.2.1
@@ -37,6 +37,8 @@
+
+
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.26.10.1
--- 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 1 Mar 2010 04:55:47 -0000 1.26.10.1
@@ -52,9 +52,13 @@
import javax.sql.DataSource;
import org.apache.log4j.Logger;
+import org.lamsfoundation.lams.themes.Theme;
+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;
@@ -71,263 +75,317 @@
public class UniversalLoginModule extends UsernamePasswordLoginModule {
- private static Logger log = Logger.getLogger(UniversalLoginModule.class);
+ private static Logger log = Logger.getLogger(UniversalLoginModule.class);
- public UniversalLoginModule() {
- }
+ public UniversalLoginModule() {
+ }
- protected String dsJndiName;
+ protected String dsJndiName;
- protected String rolesQuery;
+ protected String rolesQuery;
- protected String principalsQuery;
+ protected String principalsQuery;
- public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) {
- super.initialize(subject, callbackHandler, sharedState, options);
- dsJndiName = (String) options.get("dsJndiName");
- principalsQuery = (String) options.get("principalsQuery");
- rolesQuery = (String) options.get("rolesQuery");
- }
+ private IThemeService themeService;
+ private UserManagementService service;
- protected boolean validatePassword(String inputPassword, String expectedPassword) {
- boolean isValid = false;
- if (inputPassword != null) {
- // empty password not allowed
- if (inputPassword.length() == 0)
- return false;
+ public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) {
+ super.initialize(subject, callbackHandler, sharedState, options);
+ dsJndiName = (String) options.get("dsJndiName");
+ principalsQuery = (String) options.get("principalsQuery");
+ rolesQuery = (String) options.get("rolesQuery");
+ }
- try {
- String username = getUsername();
- log.debug("===> authenticating user: " + username);
+ protected boolean validatePassword(String inputPassword, String expectedPassword) {
+ boolean isValid = false;
+ if (inputPassword != null) {
+ // empty password not allowed
+ if (inputPassword.length() == 0)
+ return false;
- WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(HttpSessionManager
- .getInstance().getServletContext());
- UserManagementService service = (UserManagementService) ctx.getBean("userManagementService");
- User user = service.getUserByLogin(username);
-
- // LDAP user provisioning
- if (user == null) {
- // provision a new user by checking ldap server
- if (Configuration.getAsBoolean(ConfigurationKeys.LDAP_PROVISIONING_ENABLED)) {
- LdapService ldapService;
try {
- ldapService = (LdapService) ctx.getBean("ldapService");
- } catch (NoSuchBeanDefinitionException e) {
- // LDEV-1937
- 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");
- }
- log.debug("===> LDAP provisioning is enabled, checking username against LDAP server...");
- LDAPAuthenticator ldap = new LDAPAuthenticator();
- isValid = ldap.authenticate(username, inputPassword);
- if (isValid) { // create a new user
- log.info("===> Creating new user for LDAP username: " + username);
- if (ldapService.createLDAPUser(ldap.getAttrs())) {
- user = service.getUserByLogin(username);
- if (!ldapService.addLDAPUser(ldap.getAttrs(), user.getUserId())) {
- log.error("===> Couldn't add LDAP user: " + username + " to organisation.");
+ String username = getUsername();
+ log.debug("===> authenticating user: " + username);
+
+ WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(HttpSessionManager
+ .getInstance().getServletContext());
+
+ if (service == null) {
+ service = (UserManagementService) ctx.getBean("userManagementService");
}
- } else {
- log.error("===> Couldn't create new user for LDAP username: " + username);
- return false;
- }
- } else { // didn't authenticate successfully with ldap
- return false;
- }
- } else {
- return false;
- }
- }
+ User user = service.getUserByLogin(username);
- // allow sysadmin to login as another user; in this case, the
- // LAMS shared session
- // will be present, allowing the following check to work
- if (service.isUserSysAdmin()) {
- isValid = true;
- }
+ if (themeService == null) {
+ themeService = (IThemeService) ctx.getBean("themeService");
+ }
- // perform password checking according to user's authentication
- // method
- if (!isValid) {
- String type = user.getAuthenticationMethod().getAuthenticationMethodType().getDescription();
- log.debug("===> authentication type: " + type);
- if (AuthenticationMethodType.LDAP.equals(type)) {
- LDAPAuthenticator authenticator = new LDAPAuthenticator();
- isValid = authenticator.authenticate(username, inputPassword);
- // if ldap user profile has updated, udpate user object
- // for dto below
- user = service.getUserByLogin(username);
- } else if (AuthenticationMethodType.LAMS.equals(type)) {
- DatabaseAuthenticator authenticator = new DatabaseAuthenticator(dsJndiName, principalsQuery);
- // if the password is not encrypted when sent from the
- // jsp (e.g. when it is passed
- // unencrypted to say, ldap) then encrypt it here when
- // authenticating against local db
- if (!Configuration.getAsBoolean(ConfigurationKeys.LDAP_ENCRYPT_PASSWORD_FROM_BROWSER)) {
- // try the passed in password first,
- // LoginRequestServlet always passes in encrypted
- // passwords
- isValid = authenticator.authenticate(username, inputPassword);
- if (!isValid) {
- inputPassword = HashUtil.sha1(inputPassword);
- }
- isValid = authenticator.authenticate(username, inputPassword);
- } else {
- isValid = authenticator.authenticate(username, inputPassword);
- }
- } else if (AuthenticationMethodType.WEB_AUTH.equals(type)) {
- WebAuthAuthenticator authenticator = new WebAuthAuthenticator();
- isValid = authenticator.authenticate(username, inputPassword);
- } else {
- log.error("===> Unexpected authentication type: " + type);
- return false;
- }
- }
+ // LDAP user provisioning
+ if (user == null) {
+ // provision a new user by checking ldap server
+ if (Configuration.getAsBoolean(ConfigurationKeys.LDAP_PROVISIONING_ENABLED)) {
+ LdapService ldapService;
+ try {
+ ldapService = (LdapService) ctx.getBean("ldapService");
+ } catch (NoSuchBeanDefinitionException e) {
+ // LDEV-1937
+ 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");
+ }
+ log.debug("===> LDAP provisioning is enabled, checking username against LDAP server...");
+ LDAPAuthenticator ldap = new LDAPAuthenticator();
+ isValid = ldap.authenticate(username, inputPassword);
+ if (isValid) { // create a new user
+ log.info("===> Creating new user for LDAP username: " + username);
+ if (ldapService.createLDAPUser(ldap.getAttrs())) {
+ user = service.getUserByLogin(username);
+ if (!ldapService.addLDAPUser(ldap.getAttrs(), user.getUserId())) {
+ log.error("===> Couldn't add LDAP user: " + username + " to organisation.");
+ }
+ } else {
+ log.error("===> Couldn't create new user for LDAP username: " + username);
+ return false;
+ }
+ } else { // didn't authenticate successfully with ldap
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
- // disabled users can't login;
- // check after authentication to give non-db authentication
- // methods
- // a chance to update disabled flag
- if (user.getDisabledFlag()) {
- log.debug("===> user is disabled.");
- return false;
- }
+ // allow sysadmin to login as another user; in this case, the
+ // LAMS shared session
+ // will be present, allowing the following check to work
+ if (service.isUserSysAdmin()) {
+ isValid = true;
+ }
- // if login is valid, register userDTO into session.
- if (isValid) {
- HttpSession sharedsession = SessionManager.getSession();
- sharedsession.setAttribute(AttributeNames.USER, user.getUserDTO());
- }
- } catch (Exception e) {
- e.printStackTrace();
- log.error("===> exception: " + e, e);
- }
- }
- return isValid;
- }
+ // perform password checking according to user's authentication
+ // method
+ if (!isValid) {
+ String type = user.getAuthenticationMethod().getAuthenticationMethodType().getDescription();
+ log.debug("===> authentication type: " + type);
+ if (AuthenticationMethodType.LDAP.equals(type)) {
+ LDAPAuthenticator authenticator = new LDAPAuthenticator();
+ isValid = authenticator.authenticate(username, inputPassword);
+ // if ldap user profile has updated, udpate user object
+ // for dto below
+ user = service.getUserByLogin(username);
+ } else if (AuthenticationMethodType.LAMS.equals(type)) {
+ DatabaseAuthenticator authenticator = new DatabaseAuthenticator(dsJndiName, principalsQuery);
+ // if the password is not encrypted when sent from the
+ // jsp (e.g. when it is passed
+ // unencrypted to say, ldap) then encrypt it here when
+ // authenticating against local db
+ if (!Configuration.getAsBoolean(ConfigurationKeys.LDAP_ENCRYPT_PASSWORD_FROM_BROWSER)) {
+ // try the passed in password first,
+ // LoginRequestServlet always passes in encrypted
+ // passwords
+ isValid = authenticator.authenticate(username, inputPassword);
+ if (!isValid) {
+ inputPassword = HashUtil.sha1(inputPassword);
+ }
+ isValid = authenticator.authenticate(username, inputPassword);
+ } else {
+ isValid = authenticator.authenticate(username, inputPassword);
+ }
+ } else if (AuthenticationMethodType.WEB_AUTH.equals(type)) {
+ WebAuthAuthenticator authenticator = new WebAuthAuthenticator();
+ isValid = authenticator.authenticate(username, inputPassword);
+ } else {
+ log.error("===> Unexpected authentication type: " + type);
+ return false;
+ }
+ }
- /**
- * According to Lams's security policy, all the authorization must be done
- * locally, in other word, through Lams database or other "local"(logically)
- * data resource.
- *
- * @return Group[] containing the sets of roles
- */
- protected Group[] getRoleSets() throws LoginException {
- String username = getUsername();
- Connection conn = null;
- HashMap setsMap = new HashMap();
- PreparedStatement ps = null;
- ResultSet rs = null;
+ // disabled users can't login;
+ // check after authentication to give non-db authentication
+ // methods
+ // a chance to update disabled flag
+ if (user.getDisabledFlag()) {
+ log.debug("===> user is disabled.");
+ return false;
+ }
- try {
+ // if login is valid, register userDTO into session.
+ if (isValid) {
+ UserDTO userDTO = user.getUserDTO();
- InitialContext ctx = new InitialContext();
- DataSource ds = (DataSource) ctx.lookup(this.dsJndiName);
+ // If the user's theme has been deleted, use the default as
+ // fallback
+ CSSThemeBriefDTO userTheme = userDTO.getHtmlTheme();
+ if (userTheme != null) {
+ // If the user's css theme has been deleted, use the
+ // default as fallback
+ CSSThemeBriefDTO userCSSTheme = userDTO.getHtmlTheme();
+ if (userCSSTheme != null) {
+ boolean themeExists = false;
- // log.debug("===> getRoleSets() called: " + dsJndiName + ": " +
- // rolesQuery);
- conn = ds.getConnection();
- // Get the user role names
- ps = conn.prepareStatement(this.rolesQuery);
- try {
- ps.setString(1, username);
- } catch (ArrayIndexOutOfBoundsException ignore) {
- // The query may not have any parameters so just try it
- }
- rs = ps.executeQuery();
- if (rs.next() == false) {
- if (getUnauthenticatedIdentity() == null)
- throw new FailedLoginException("No matching username found in Roles");
- /*
- * We are running with an unauthenticatedIdentity so create an
- * empty Roles set and return.
- */
- Group[] roleSets = { new SimpleGroup("Roles") };
- return roleSets;
- }
+ for (Theme theme : themeService.getAllCSSThemes()) {
+ if (userCSSTheme.getId().equals(theme.getThemeId())) {
+ themeExists = true;
+ break;
+ }
+ }
- ArrayList groupMembers = new ArrayList();
- do {
- String name = rs.getString(1);
- String groupName = rs.getString(2);
- if (groupName == null || groupName.length() == 0)
- groupName = "Roles";
- Group group = (Group) setsMap.get(groupName);
- if (group == null) {
- group = new SimpleGroup(groupName);
- setsMap.put(groupName, group);
+ if (!themeExists) {
+ userDTO.setHtmlTheme(new CSSThemeBriefDTO(themeService.getDefaultCSSTheme()));
+ }
+ }
+ }
+
+ // If the user's flash theme has been deleted, use the
+ // default as fallback
+ CSSThemeBriefDTO userFlashTheme = userDTO.getFlashTheme();
+ if (userFlashTheme != null) {
+ boolean themeExists = false;
+ for (Theme theme : themeService.getAllFlashThemes()) {
+ if (userFlashTheme.getId().equals(theme.getThemeId())) {
+ themeExists = true;
+ break;
+ }
+ }
+
+ if (!themeExists) {
+ userDTO.setFlashTheme(new CSSThemeBriefDTO(themeService.getDefaultFlashTheme()));
+ }
+ }
+
+ HttpSession sharedsession = SessionManager.getSession();
+ sharedsession.setAttribute(AttributeNames.USER, userDTO);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ log.error("===> exception: " + e, e);
+ }
}
+ return isValid;
+ }
+ /**
+ * According to Lams's security policy, all the authorization must be done
+ * locally, in other word, through Lams database or other "local"(logically)
+ * data resource.
+ *
+ * @return Group[] containing the sets of roles
+ */
+ protected Group[] getRoleSets() throws LoginException {
+ String username = getUsername();
+ Connection conn = null;
+ HashMap setsMap = new HashMap();
+ PreparedStatement ps = null;
+ ResultSet rs = null;
+
try {
- Principal p;
- // Assign minimal role if user has none
- if (name == null) {
- name = Role.LEARNER;
- log.info("===> Found no roles");
- }
- p = super.createIdentity(name);
- if (!groupMembers.contains(name)) {
- log.info("===> Assign user to role " + p.getName());
- group.addMember(p);
- groupMembers.add(name);
- }
- if (name.equals(Role.SYSADMIN) || name.equals(Role.AUTHOR_ADMIN)) {
- p = super.createIdentity(Role.AUTHOR);
- log.info("===> Found " + name);
- if (!groupMembers.contains(Role.AUTHOR)) {
- log.info("===> Assign user to role " + Role.AUTHOR);
- group.addMember(p);
- groupMembers.add(Role.AUTHOR);
+
+ InitialContext ctx = new InitialContext();
+ DataSource ds = (DataSource) ctx.lookup(this.dsJndiName);
+
+ // log.debug("===> getRoleSets() called: " + dsJndiName + ": " +
+ // rolesQuery);
+ conn = ds.getConnection();
+ // Get the user role names
+ ps = conn.prepareStatement(this.rolesQuery);
+ try {
+ ps.setString(1, username);
+ } catch (ArrayIndexOutOfBoundsException ignore) {
+ // The query may not have any parameters so just try it
}
- }
- } catch (Exception e) {
- log.debug("===> Failed to create principal: " + name, e);
+ rs = ps.executeQuery();
+ if (rs.next() == false) {
+ if (getUnauthenticatedIdentity() == null)
+ throw new FailedLoginException("No matching username found in Roles");
+ /*
+ * We are running with an unauthenticatedIdentity so create an
+ * empty Roles set and return.
+ */
+ Group[] roleSets = { new SimpleGroup("Roles") };
+ return roleSets;
+ }
+
+ ArrayList groupMembers = new ArrayList();
+ do {
+ String name = rs.getString(1);
+ String groupName = rs.getString(2);
+ if (groupName == null || groupName.length() == 0)
+ groupName = "Roles";
+ Group group = (Group) setsMap.get(groupName);
+ if (group == null) {
+ group = new SimpleGroup(groupName);
+ setsMap.put(groupName, group);
+ }
+
+ try {
+ Principal p;
+ // Assign minimal role if user has none
+ if (name == null) {
+ name = Role.LEARNER;
+ log.info("===> Found no roles");
+ }
+ p = super.createIdentity(name);
+ if (!groupMembers.contains(name)) {
+ log.info("===> Assign user to role " + p.getName());
+ group.addMember(p);
+ groupMembers.add(name);
+ }
+ if (name.equals(Role.SYSADMIN) || name.equals(Role.AUTHOR_ADMIN)) {
+ p = super.createIdentity(Role.AUTHOR);
+ log.info("===> Found " + name);
+ if (!groupMembers.contains(Role.AUTHOR)) {
+ log.info("===> Assign user to role " + Role.AUTHOR);
+ group.addMember(p);
+ groupMembers.add(Role.AUTHOR);
+ }
+ }
+ } catch (Exception e) {
+ log.debug("===> Failed to create principal: " + name, e);
+ }
+ } while (rs.next());
+ } catch (NamingException ex) {
+ throw new LoginException(ex.toString(true));
+ } catch (SQLException ex) {
+ super.log.error("SQL failure", ex);
+ throw new LoginException(ex.toString());
+ } finally {
+ if (rs != null) {
+ try {
+ rs.close();
+ } catch (SQLException e) {
+ }
+ }
+ if (ps != null) {
+ try {
+ ps.close();
+ } catch (SQLException e) {
+ }
+ }
+ if (conn != null) {
+ try {
+ conn.close();
+ } catch (Exception ex) {
+ }
+ }
}
- } while (rs.next());
- } catch (NamingException ex) {
- throw new LoginException(ex.toString(true));
- } catch (SQLException ex) {
- super.log.error("SQL failure", ex);
- throw new LoginException(ex.toString());
- } finally {
- if (rs != null) {
- try {
- rs.close();
- } catch (SQLException e) {
- }
- }
- if (ps != null) {
- try {
- ps.close();
- } catch (SQLException e) {
- }
- }
- if (conn != null) {
- try {
- conn.close();
- } catch (Exception ex) {
- }
- }
+
+ Group[] roleSets = new Group[setsMap.size()];
+ setsMap.values().toArray(roleSets);
+ return roleSets;
}
- Group[] roleSets = new Group[setsMap.size()];
- setsMap.values().toArray(roleSets);
- return roleSets;
- }
+ /**
+ * Overriden to return an empty password string as typically one cannot
+ * obtain a user's password. We also override the validatePassword so this
+ * is ok.
+ *
+ * @return and empty password String
+ */
+ protected String getUsersPassword() throws LoginException {
+ return "";
+ }
- /**
- * Overriden to return an empty password string as typically one cannot
- * obtain a user's password. We also override the validatePassword so this
- * is ok.
- *
- * @return and empty password String
- */
- protected String getUsersPassword() throws LoginException {
- return "";
- }
-
}
\ No newline at end of file
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.8.2 -r1.17.8.3
--- lams_central/src/java/org/lamsfoundation/lams/web/ProfileAction.java 29 Oct 2009 01:59:21 -0000 1.17.8.2
+++ lams_central/src/java/org/lamsfoundation/lams/web/ProfileAction.java 1 Mar 2010 04:55:47 -0000 1.17.8.3
@@ -41,6 +41,8 @@
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.Theme;
+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;
@@ -81,6 +83,8 @@
private static List locales;
private static ICoreLearnerService learnerService;
+
+ private static IThemeService themeService;
public ActionForward view(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
@@ -201,7 +205,50 @@
boolean hasLamsCommunityToken = requestor.getLamsCommunityToken() != null;
request.setAttribute("hasLamsCommunityToken", hasLamsCommunityToken);
+
+ themeService = getThemeService();
+
+ // Get all the css themes
+ List cssThemes = themeService.getAllCSSThemes();
+ request.setAttribute("cssThemes", cssThemes);
+
+ // Check the user 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;
+ }
+ }
+ }
+ // if still null, use the default
+ if (userSelectedCSSTheme == null) {
+ userSelectedCSSTheme = themeService.getDefaultCSSTheme().getThemeId();
+ }
+ userForm.set("userCSSTheme", userSelectedCSSTheme);
+
+ // Get all the flash themes
+ List flashThemes = themeService.getAllFlashThemes();
+ request.setAttribute("flashThemes", flashThemes);
+ // Check the user 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;
+ }
+ }
+ }
+ // if still null, use the default
+ if (userSelectedFlashTheme == null) {
+ userSelectedFlashTheme = themeService.getDefaultFlashTheme().getThemeId();
+ }
+ userForm.set("userFlashTheme", userSelectedFlashTheme);
+
+
return mapping.findForward("edit");
}
@@ -224,4 +271,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.8.1 -r1.12.8.2
--- lams_central/src/java/org/lamsfoundation/lams/web/ProfileSaveAction.java 1 Mar 2010 00:16:47 -0000 1.12.8.1
+++ lams_central/src/java/org/lamsfoundation/lams/web/ProfileSaveAction.java 1 Mar 2010 04:55:47 -0000 1.12.8.2
@@ -40,7 +40,7 @@
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
import org.apache.struts.action.DynaActionForm;
-import org.lamsfoundation.lams.themes.CSSThemeVisualElement;
+import org.lamsfoundation.lams.themes.Theme;
import org.lamsfoundation.lams.usermanagement.SupportedLocale;
import org.lamsfoundation.lams.usermanagement.User;
import org.lamsfoundation.lams.usermanagement.service.IUserManagementService;
@@ -115,10 +115,14 @@
(Integer) userForm.get("localeId"));
requestor.setLocale(locale);
- CSSThemeVisualElement theme = (CSSThemeVisualElement) getService().findById(CSSThemeVisualElement.class,
- (Long) userForm.get("userTheme"));
- requestor.setHtmlTheme(theme);
-
+ Theme cssTheme = (Theme) getService().findById(Theme.class,
+ (Long) userForm.get("userCSSTheme"));
+ requestor.setHtmlTheme(cssTheme);
+
+ Theme flashTheme = (Theme) getService().findById(Theme.class,
+ (Long) userForm.get("userFlashTheme"));
+ requestor.setFlashTheme(flashTheme);
+
if (userForm.get("disableLamsCommunityUsername") != null
&& (Boolean) userForm.get("disableLamsCommunityUsername")) {
requestor.setLamsCommunityToken(null);
Index: lams_central/src/java/org/lamsfoundation/lams/web/tag/CssTag.java
===================================================================
RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/web/tag/CssTag.java,v
diff -u -r1.20 -r1.20.8.1
--- lams_central/src/java/org/lamsfoundation/lams/web/tag/CssTag.java 23 Jan 2009 06:02:40 -0000 1.20
+++ lams_central/src/java/org/lamsfoundation/lams/web/tag/CssTag.java 1 Mar 2010 04:55:46 -0000 1.20.8.1
@@ -92,14 +92,7 @@
if (pageDirection.toLowerCase().equals(RTL_DIR))
rtl = true;
- String style = getStyle();
- List themeList;
- if(style != null && style.equals(MAIN_STYLE)){
- themeList = CSSThemeUtil.getAllUserThemes(CSSThemeUtil.DEFAULT_MAIN_HTML_THEME);
- }
- else{
- themeList = CSSThemeUtil.getAllUserThemes(CSSThemeUtil.DEFAULT_HTML_THEME);
- }
+ List themeList = CSSThemeUtil.getAllUserThemes();
for (String theme : themeList) {
if (theme != null) {
Index: lams_central/web/editprofile.jsp
===================================================================
RCS file: /usr/local/cvsroot/lams_central/web/editprofile.jsp,v
diff -u -r1.14.4.3 -r1.14.4.3.2.1
--- lams_central/web/editprofile.jsp 19 Jun 2009 04:32:10 -0000 1.14.4.3
+++ lams_central/web/editprofile.jsp 1 Mar 2010 04:55:46 -0000 1.14.4.3.2.1
@@ -139,6 +139,26 @@
|
+