Index: lams_admin/conf/language/lams/ApplicationResources.properties =================================================================== RCS file: /usr/local/cvsroot/lams_admin/conf/language/lams/ApplicationResources.properties,v diff -u -r1.63 -r1.64 --- lams_admin/conf/language/lams/ApplicationResources.properties 28 Aug 2009 04:29:22 -0000 1.63 +++ lams_admin/conf/language/lams/ApplicationResources.properties 6 Nov 2009 06:48:41 -0000 1.64 @@ -416,6 +416,8 @@ admin.themes.flash =Flash label.html.htmlTheme =HTML Theme label.html.flashTheme =Flash Theme +config.profile.edit.enable = Enable Profile Editing +config.profile.partial.edit.enable = Enable Partial Profile Editing #======= End labels: Exported 409 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.63 -r1.64 --- lams_admin/conf/language/lams/ApplicationResources_en_AU.properties 28 Aug 2009 04:29:22 -0000 1.63 +++ lams_admin/conf/language/lams/ApplicationResources_en_AU.properties 6 Nov 2009 06:48:41 -0000 1.64 @@ -416,6 +416,8 @@ admin.themes.flash =Flash label.html.htmlTheme =HTML Theme label.html.flashTheme =Flash Theme +config.profile.edit.enable = Enable Profile Editing +config.profile.partial.edit.enable = Enable Partial Profile Editing #======= End labels: Exported 409 labels for en AU ===== Index: lams_central/conf/language/lams/ApplicationResources.properties =================================================================== RCS file: /usr/local/cvsroot/lams_central/conf/language/lams/ApplicationResources.properties,v diff -u -r1.85 -r1.86 --- lams_central/conf/language/lams/ApplicationResources.properties 30 Oct 2009 00:40:39 -0000 1.85 +++ lams_central/conf/language/lams/ApplicationResources.properties 6 Nov 2009 06:48:31 -0000 1.86 @@ -274,6 +274,8 @@ label.html.htmlTheme =HTML Theme label.html.flashTheme =Flash Theme error.password.empty = New password cannot be empty. +error.edit.disabled = Profile editing is disabled. +message.partial.edit.only = Only contact fields are editable due to server configuration. #======= 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.78 -r1.79 --- lams_central/conf/language/lams/ApplicationResources_en_AU.properties 30 Oct 2009 00:40:39 -0000 1.78 +++ lams_central/conf/language/lams/ApplicationResources_en_AU.properties 6 Nov 2009 06:48:31 -0000 1.79 @@ -274,6 +274,8 @@ label.html.htmlTheme =HTML Theme label.html.flashTheme =Flash Theme error.password.empty = New password cannot be empty. +error.edit.disabled = Profile editing is disabled. +message.profile.partially.edited = Profile has only been partially updated due to server configuration. #======= End labels: Exported 268 labels for en AU ===== 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.20 -r1.21 --- lams_central/src/java/org/lamsfoundation/lams/web/ProfileAction.java 20 Aug 2009 06:40:02 -0000 1.20 +++ lams_central/src/java/org/lamsfoundation/lams/web/ProfileAction.java 6 Nov 2009 06:48:31 -0000 1.21 @@ -36,6 +36,8 @@ import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; +import org.apache.struts.action.ActionMessage; +import org.apache.struts.action.ActionMessages; import org.apache.struts.action.DynaActionForm; import org.lamsfoundation.lams.index.IndexLessonBean; import org.lamsfoundation.lams.index.IndexOrgBean; @@ -194,6 +196,16 @@ public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { + ActionMessages errors = new ActionMessages(); + if (!Configuration.getAsBoolean(ConfigurationKeys.PROFILE_EDIT_ENABLE)) { + if (!Configuration.getAsBoolean(ConfigurationKeys.PROFILE_PARTIAL_EDIT_ENABLE)) { + errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.edit.disabled")); + } else { + errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("message.partial.edit.only")); + } + saveErrors(request, errors); + } + User requestor = (User) getService().getUserByLogin(request.getRemoteUser()); DynaActionForm userForm = (DynaActionForm) form; BeanUtils.copyProperties(userForm, requestor); 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.14 -r1.15 --- lams_central/src/java/org/lamsfoundation/lams/web/ProfileSaveAction.java 20 Aug 2009 04:38:20 -0000 1.14 +++ lams_central/src/java/org/lamsfoundation/lams/web/ProfileSaveAction.java 6 Nov 2009 06:48:31 -0000 1.15 @@ -40,11 +40,12 @@ import org.apache.struts.action.ActionMessage; import org.apache.struts.action.ActionMessages; import org.apache.struts.action.DynaActionForm; -import org.hibernate.Hibernate; 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; +import org.lamsfoundation.lams.util.Configuration; +import org.lamsfoundation.lams.util.ConfigurationKeys; import org.lamsfoundation.lams.web.session.SessionManager; import org.lamsfoundation.lams.web.util.AttributeNames; import org.springframework.web.context.WebApplicationContext; @@ -78,15 +79,22 @@ } ActionMessages errors = new ActionMessages(); + + if (!Configuration.getAsBoolean(ConfigurationKeys.PROFILE_EDIT_ENABLE)) { + if (!Configuration.getAsBoolean(ConfigurationKeys.PROFILE_PARTIAL_EDIT_ENABLE)) { + return mapping.findForward("editprofile"); + } + } + User requestor = (User) getService().getUserByLogin(request.getRemoteUser()); DynaActionForm userForm = (DynaActionForm) form; // check requestor is same as user being edited - log.debug("requestor: " + requestor.getLogin() + ", form login: " + userForm.get("login")); if (!requestor.getLogin().equals(userForm.get("login"))) { + log.warn(requestor.getLogin() + " tried to edit profile of user " + userForm.get("login")); errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.authorisation")); saveErrors(request, errors); - return (mapping.getInputForward()); + return mapping.findForward("editprofile"); } // (dyna)form validation @@ -111,27 +119,35 @@ return (mapping.findForward("editprofile")); } - BeanUtils.copyProperties(requestor, userForm); - SupportedLocale locale = (SupportedLocale) getService().findById(SupportedLocale.class, - (Integer) userForm.get("localeId")); - requestor.setLocale(locale); + if (!Configuration.getAsBoolean(ConfigurationKeys.PROFILE_EDIT_ENABLE) + && Configuration.getAsBoolean(ConfigurationKeys.PROFILE_PARTIAL_EDIT_ENABLE)) { + // update only contact fields + requestor.setEmail(userForm.getString("email")); + requestor.setDayPhone(userForm.getString("dayPhone")); + requestor.setEveningPhone(userForm.getString("eveningPhone")); + requestor.setMobilePhone(userForm.getString("mobilePhone")); + requestor.setFax(userForm.getString("fax")); + } else { + // update all fields + BeanUtils.copyProperties(requestor, userForm); + SupportedLocale locale = (SupportedLocale) getService().findById(SupportedLocale.class, + (Integer) userForm.get("localeId")); + requestor.setLocale(locale); - 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); + Theme cssTheme = (Theme) getService().findById(Theme.class, (Long) userForm.get("userCSSTheme")); + requestor.setHtmlTheme(cssTheme); - if (userForm.get("disableLamsCommunityUsername") != null - && (Boolean) userForm.get("disableLamsCommunityUsername")) { - requestor.setLamsCommunityToken(null); - requestor.setLamsCommunityUsername(null); + 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); + requestor.setLamsCommunityUsername(null); + } } getService().save(requestor); - log.debug("profile edited: " + requestor); // replace UserDTO in the shared session HttpSession ss = SessionManager.getSession(); Index: lams_central/web/editprofile.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_central/web/editprofile.jsp,v diff -u -r1.19 -r1.20 --- lams_central/web/editprofile.jsp 20 Aug 2009 04:38:20 -0000 1.19 +++ lams_central/web/editprofile.jsp 6 Nov 2009 06:48:31 -0000 1.20 @@ -19,6 +19,8 @@ <%=Configuration.get(ConfigurationKeys.FLASH_ENABLE)%> +<%=Configuration.get(ConfigurationKeys.PROFILE_EDIT_ENABLE)%> +<%=Configuration.get(ConfigurationKeys.PROFILE_PARTIAL_EDIT_ENABLE)%>
@@ -40,69 +42,69 @@ : - + *: - + *: - + *: - + : - + : - + : - + : - + : - + : - + : - + : - + : - + : - + : - + : - + @@ -117,7 +119,7 @@ : - + @@ -129,7 +131,7 @@ : - + @@ -144,7 +146,7 @@ But for simplicity of coding, we keep it as a negative value - "should the tutorials be disabled?" This is the reason to mix true/false and yes/no answers. --> - + @@ -153,7 +155,7 @@ : - + ${theme.name} @@ -163,7 +165,7 @@ : - + ${theme.name} @@ -179,7 +181,7 @@ : - + @@ -270,7 +272,7 @@ : - + ${theme.name} @@ -280,7 +282,7 @@ : - + ${theme.name} @@ -291,7 +293,7 @@ : - + @@ -327,7 +329,7 @@ But for simplicity of coding, we keep it as a negative value - "should the tutorials be disabled?" This is the reason to mix true/false and yes/no answers. --> - + @@ -341,8 +343,10 @@
+ +
Index: lams_common/db/sql/insert_lams_unix_config_data.sql =================================================================== RCS file: /usr/local/cvsroot/lams_common/db/sql/insert_lams_unix_config_data.sql,v diff -u -r1.49 -r1.50 --- lams_common/db/sql/insert_lams_unix_config_data.sql 25 Sep 2009 03:55:06 -0000 1.49 +++ lams_common/db/sql/insert_lams_unix_config_data.sql 6 Nov 2009 06:48:33 -0000 1.50 @@ -252,3 +252,9 @@ insert into lams_configuration (config_key, config_value, description_key, header_name, format, required) values ('Red5RecordingsUrl','', 'config.red5.recordings.url', 'config.header.red5', 'STRING', 0); + +insert into lams_configuration (config_key, config_value, description_key, header_name, format, required) +values ('ProfileEditEnable','true', 'config.profile.edit.enable', 'config.header.features', 'BOOLEAN', 1); + +insert into lams_configuration (config_key, config_value, description_key, header_name, format, required) +values ('ProfilePartialEditEnable','true', 'config.profile.partial.edit.enable', 'config.header.features', 'BOOLEAN', 1); Index: lams_common/db/sql/insert_lams_windows_config_data.sql =================================================================== RCS file: /usr/local/cvsroot/lams_common/db/sql/insert_lams_windows_config_data.sql,v diff -u -r1.41 -r1.42 --- lams_common/db/sql/insert_lams_windows_config_data.sql 25 Sep 2009 03:55:06 -0000 1.41 +++ lams_common/db/sql/insert_lams_windows_config_data.sql 6 Nov 2009 06:48:33 -0000 1.42 @@ -252,3 +252,9 @@ insert into lams_configuration (config_key, config_value, description_key, header_name, format, required) values ('Red5RecordingsUrl','', 'config.red5.recordings.url', 'config.header.red5', 'STRING', 0); + +insert into lams_configuration (config_key, config_value, description_key, header_name, format, required) +values ('ProfileEditEnable','true', 'config.profile.edit.enable', 'config.header.features', 'BOOLEAN', 1); + +insert into lams_configuration (config_key, config_value, description_key, header_name, format, required) +values ('ProfilePartialEditEnable','true', 'config.profile.partial.edit.enable', 'config.header.features', 'BOOLEAN', 1); Index: lams_common/db/sql/insert_types_data.sql =================================================================== RCS file: /usr/local/cvsroot/lams_common/db/sql/insert_types_data.sql,v diff -u -r1.90 -r1.91 --- lams_common/db/sql/insert_types_data.sql 27 Aug 2009 00:26:01 -0000 1.90 +++ lams_common/db/sql/insert_types_data.sql 6 Nov 2009 06:48:33 -0000 1.91 @@ -309,4 +309,4 @@ (1,'moodle','moodle','moodle','moodle','mdl','http://localhost/moodle/mod/lamstwo/userinfo.php?ts=%timestamp%&un=%username%&hs=%hash%', '', 'http://dummy','\0',7); -- initialise db version -INSERT INTO patches VALUES ('lams', 02040001, NOW(), 'F'); \ No newline at end of file +INSERT INTO patches VALUES ('lams', 02040002, NOW(), 'F'); \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/dbupdates/patch02040002.sql =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/dbupdates/patch02040002.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_common/src/java/org/lamsfoundation/lams/dbupdates/patch02040002.sql 6 Nov 2009 06:48:34 -0000 1.1 @@ -0,0 +1,11 @@ +SET AUTOCOMMIT = 0; + +-- LDEV-1616 +insert into lams_configuration (config_key, config_value, description_key, header_name, format, required) +values ('ProfileEditEnable','true', 'config.profile.edit.enable', 'config.header.features', 'BOOLEAN', 1); + +insert into lams_configuration (config_key, config_value, description_key, header_name, format, required) +values ('ProfilePartialEditEnable','true', 'config.profile.partial.edit.enable', 'config.header.features', 'BOOLEAN', 1); + +COMMIT; +SET AUTOCOMMIT = 1; \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/util/ConfigurationKeys.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/util/ConfigurationKeys.java,v diff -u -r1.40 -r1.41 --- lams_common/src/java/org/lamsfoundation/lams/util/ConfigurationKeys.java 19 Feb 2009 05:36:30 -0000 1.40 +++ lams_common/src/java/org/lamsfoundation/lams/util/ConfigurationKeys.java 6 Nov 2009 06:48:33 -0000 1.41 @@ -252,5 +252,9 @@ public static String SMTP_AUTH_USER = "SMTPUser"; public static String SMTP_AUTH_PASSWORD = "SMTPPassword"; + + public static String PROFILE_EDIT_ENABLE = "ProfileEditEnable"; + + public static String PROFILE_PARTIAL_EDIT_ENABLE = "ProfilePartialEditEnable"; } \ No newline at end of file