Index: lams_admin/conf/language/lams/ApplicationResources.properties =================================================================== diff -u -r7e8d8f6da0288d69a0b816900e9cdd1ca4244f92 -r6a414b5f0f7756f0376670914c59c84b9ae916ef --- lams_admin/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 7e8d8f6da0288d69a0b816900e9cdd1ca4244f92) +++ lams_admin/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 6a414b5f0f7756f0376670914c59c84b9ae916ef) @@ -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 =================================================================== diff -u -r7e8d8f6da0288d69a0b816900e9cdd1ca4244f92 -r6a414b5f0f7756f0376670914c59c84b9ae916ef --- lams_admin/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 7e8d8f6da0288d69a0b816900e9cdd1ca4244f92) +++ lams_admin/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 6a414b5f0f7756f0376670914c59c84b9ae916ef) @@ -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 =================================================================== diff -u -r7b89a024a3408d102799244f2f6fbceb03f34ed1 -r6a414b5f0f7756f0376670914c59c84b9ae916ef --- lams_central/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 7b89a024a3408d102799244f2f6fbceb03f34ed1) +++ lams_central/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 6a414b5f0f7756f0376670914c59c84b9ae916ef) @@ -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 =================================================================== diff -u -r7b89a024a3408d102799244f2f6fbceb03f34ed1 -r6a414b5f0f7756f0376670914c59c84b9ae916ef --- lams_central/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 7b89a024a3408d102799244f2f6fbceb03f34ed1) +++ lams_central/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 6a414b5f0f7756f0376670914c59c84b9ae916ef) @@ -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 =================================================================== diff -u -ra23376f298830f9cb4d3d18e5dc7ef11b907c173 -r6a414b5f0f7756f0376670914c59c84b9ae916ef --- lams_central/src/java/org/lamsfoundation/lams/web/ProfileAction.java (.../ProfileAction.java) (revision a23376f298830f9cb4d3d18e5dc7ef11b907c173) +++ lams_central/src/java/org/lamsfoundation/lams/web/ProfileAction.java (.../ProfileAction.java) (revision 6a414b5f0f7756f0376670914c59c84b9ae916ef) @@ -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 =================================================================== diff -u -r7998a31f6d7d4f1eef3e866bafef22caa012eb7a -r6a414b5f0f7756f0376670914c59c84b9ae916ef --- lams_central/src/java/org/lamsfoundation/lams/web/ProfileSaveAction.java (.../ProfileSaveAction.java) (revision 7998a31f6d7d4f1eef3e866bafef22caa012eb7a) +++ lams_central/src/java/org/lamsfoundation/lams/web/ProfileSaveAction.java (.../ProfileSaveAction.java) (revision 6a414b5f0f7756f0376670914c59c84b9ae916ef) @@ -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 =================================================================== diff -u -r7998a31f6d7d4f1eef3e866bafef22caa012eb7a -r6a414b5f0f7756f0376670914c59c84b9ae916ef --- lams_central/web/editprofile.jsp (.../editprofile.jsp) (revision 7998a31f6d7d4f1eef3e866bafef22caa012eb7a) +++ lams_central/web/editprofile.jsp (.../editprofile.jsp) (revision 6a414b5f0f7756f0376670914c59c84b9ae916ef) @@ -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 =================================================================== diff -u -r5d49eeaf81f1d43d9e9cc233a695ec24c6bee1f1 -r6a414b5f0f7756f0376670914c59c84b9ae916ef --- lams_common/db/sql/insert_lams_unix_config_data.sql (.../insert_lams_unix_config_data.sql) (revision 5d49eeaf81f1d43d9e9cc233a695ec24c6bee1f1) +++ lams_common/db/sql/insert_lams_unix_config_data.sql (.../insert_lams_unix_config_data.sql) (revision 6a414b5f0f7756f0376670914c59c84b9ae916ef) @@ -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 =================================================================== diff -u -r5d49eeaf81f1d43d9e9cc233a695ec24c6bee1f1 -r6a414b5f0f7756f0376670914c59c84b9ae916ef --- lams_common/db/sql/insert_lams_windows_config_data.sql (.../insert_lams_windows_config_data.sql) (revision 5d49eeaf81f1d43d9e9cc233a695ec24c6bee1f1) +++ lams_common/db/sql/insert_lams_windows_config_data.sql (.../insert_lams_windows_config_data.sql) (revision 6a414b5f0f7756f0376670914c59c84b9ae916ef) @@ -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 =================================================================== diff -u -ra3c20ed7d34b7655a3593927b410a77d56c0bb36 -r6a414b5f0f7756f0376670914c59c84b9ae916ef --- lams_common/db/sql/insert_types_data.sql (.../insert_types_data.sql) (revision a3c20ed7d34b7655a3593927b410a77d56c0bb36) +++ lams_common/db/sql/insert_types_data.sql (.../insert_types_data.sql) (revision 6a414b5f0f7756f0376670914c59c84b9ae916ef) @@ -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 =================================================================== diff -u --- lams_common/src/java/org/lamsfoundation/lams/dbupdates/patch02040002.sql (revision 0) +++ lams_common/src/java/org/lamsfoundation/lams/dbupdates/patch02040002.sql (revision 6a414b5f0f7756f0376670914c59c84b9ae916ef) @@ -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 =================================================================== diff -u -r42aa5319fbd33938828764c43dd0ab1ca80e2416 -r6a414b5f0f7756f0376670914c59c84b9ae916ef --- lams_common/src/java/org/lamsfoundation/lams/util/ConfigurationKeys.java (.../ConfigurationKeys.java) (revision 42aa5319fbd33938828764c43dd0ab1ca80e2416) +++ lams_common/src/java/org/lamsfoundation/lams/util/ConfigurationKeys.java (.../ConfigurationKeys.java) (revision 6a414b5f0f7756f0376670914c59c84b9ae916ef) @@ -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