Index: lams_admin/conf/language/lams/ApplicationResources.properties
===================================================================
diff -u -r21991bdc561db26de7c7e0687a10b2c2d7743074 -r39f1f7974c647ec9524ebb630759a27094027c9c
--- lams_admin/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 21991bdc561db26de7c7e0687a10b2c2d7743074)
+++ lams_admin/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 39f1f7974c647ec9524ebb630759a27094027c9c)
@@ -513,6 +513,6 @@
label.upload.info =Uploaded file must be an Excel file and not exceed size of {0}
errors.maxfilesize =Uploaded file exceeded maximum size: {0}
error.attachment.not.xls =File is not an Excel .xls file.
-
-
+error.portrait.removal.failed=Unable to delete portrait. See error file for details
+label.delete.portrait=Delete Portrait
#======= End labels: Exported 503 labels for en AU =====
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/UserAction.java
===================================================================
diff -u -r85ef8aca5722a36582117db1e8b988e2c16b6369 -r39f1f7974c647ec9524ebb630759a27094027c9c
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/UserAction.java (.../UserAction.java) (revision 85ef8aca5722a36582117db1e8b988e2c16b6369)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/UserAction.java (.../UserAction.java) (revision 39f1f7974c647ec9524ebb630759a27094027c9c)
@@ -175,6 +175,7 @@
userSelectedTheme = UserAction.themeService.getDefaultTheme().getThemeId();
}
userForm.set("userTheme", userSelectedTheme);
+ userForm.set("initialPortraitId", user.getPortraitUuid());
//property available for modification only to sysadmins
userForm.set("twoFactorAuthenticationEnabled", user.isTwoFactorAuthenticationEnabled());
Index: lams_admin/web/WEB-INF/struts-config.xml
===================================================================
diff -u -r21991bdc561db26de7c7e0687a10b2c2d7743074 -r39f1f7974c647ec9524ebb630759a27094027c9c
--- lams_admin/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision 21991bdc561db26de7c7e0687a10b2c2d7743074)
+++ lams_admin/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision 39f1f7974c647ec9524ebb630759a27094027c9c)
@@ -84,6 +84,7 @@
+
Index: lams_admin/web/user.jsp
===================================================================
diff -u -r757f4919e3cf9567eaad331bc4323fda7ea50eb2 -r39f1f7974c647ec9524ebb630759a27094027c9c
--- lams_admin/web/user.jsp (.../user.jsp) (revision 757f4919e3cf9567eaad331bc4323fda7ea50eb2)
+++ lams_admin/web/user.jsp (.../user.jsp) (revision 39f1f7974c647ec9524ebb630759a27094027c9c)
@@ -13,8 +13,8 @@
-
+
@@ -144,38 +181,60 @@
-
-
- :
-
- -
-
-
-
-
+
+
+
+
+
+ :
+
-
-
-
- -
-
-
-
- -
-
-
-
-
- -
-
-
-
+ key='label.password.min.length'>
+
+
+
+
+ -
+
+
+ -
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
Index: lams_central/conf/language/lams/ApplicationResources.properties
===================================================================
diff -u -r32d1d2ae1e17adb6839a95ecd2331a08168d11a8 -r39f1f7974c647ec9524ebb630759a27094027c9c
--- lams_central/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 32d1d2ae1e17adb6839a95ecd2331a08168d11a8)
+++ lams_central/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 39f1f7974c647ec9524ebb630759a27094027c9c)
@@ -724,6 +724,6 @@
label.course.groups.name.not.unique =Course grouping with such name already exists. Please enter another one.
label.save.as.course.grouping.hint =You can save the groups as "Course groupings" so it can be used in other lessons as well. If the groups are just specifically for this lesson, you might not want to do this. Otherwise, click the button to give them a name and reuse them later.
label.advanced.settings =Advanced settings
+audit.delete.portrait=Portrait for user {0} {1}({2}) deleted. Portrait Id was {3}.
-
#======= End labels: Exported 718 labels for en AU =====
Index: lams_central/src/java/org/lamsfoundation/lams/web/PortraitSaveAction.java
===================================================================
diff -u -rba7ef9fb0209892892930cb3583066b70880b08b -r39f1f7974c647ec9524ebb630759a27094027c9c
--- lams_central/src/java/org/lamsfoundation/lams/web/PortraitSaveAction.java (.../PortraitSaveAction.java) (revision ba7ef9fb0209892892930cb3583066b70880b08b)
+++ lams_central/src/java/org/lamsfoundation/lams/web/PortraitSaveAction.java (.../PortraitSaveAction.java) (revision 39f1f7974c647ec9524ebb630759a27094027c9c)
@@ -23,6 +23,7 @@
package org.lamsfoundation.lams.web;
+import java.io.IOException;
import java.io.InputStream;
import javax.servlet.http.HttpServletRequest;
@@ -38,10 +39,15 @@
import org.apache.struts.action.ActionMessages;
import org.apache.struts.upload.FormFile;
import org.lamsfoundation.lams.contentrepository.NodeKey;
+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.IUserManagementService;
+import org.lamsfoundation.lams.util.CentralConstants;
import org.lamsfoundation.lams.util.CentralToolContentHandler;
+import org.lamsfoundation.lams.util.MessageService;
+import org.lamsfoundation.lams.util.WebUtil;
+import org.lamsfoundation.lams.util.audit.IAuditService;
import org.lamsfoundation.lams.util.imgscalr.ResizePictureUtil;
import org.lamsfoundation.lams.web.action.LamsDispatchAction;
import org.lamsfoundation.lams.web.session.SessionManager;
@@ -57,11 +63,14 @@
private static Logger log = Logger.getLogger(PortraitSaveAction.class);
private static IUserManagementService service;
+ private static IAuditService auditService;
+ private static MessageService messageService;
private static CentralToolContentHandler centralToolContentHandler;
private static int LARGEST_DIMENSION_ORIGINAL = 400;
private static int LARGEST_DIMENSION_LARGE = 200;
private static int LARGEST_DIMENSION_MEDIUM = 80;
private static int LARGEST_DIMENSION_SMALL = 35;
+ private static final String PORTRAIT_DELETE_AUDIT_KEY = "audit.delete.portrait";
/**
* Upload portrait image.
@@ -153,7 +162,45 @@
return mapping.findForward("profile");
}
+
+ /** Called from sysadmin to delete an inappropriate portrait */
+ public ActionForward deletePortrait(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+ Integer userId = WebUtil.readIntParam(request, "userId", true);
+
+ // check user is sysadmin
+ if (!(request.isUserInRole(Role.SYSADMIN))) {
+ log.error("Attempt to delete a portrait by user that is not sysadmin. User is "+request.getRemoteUser()+" portrait to be deleted is for user "+userId+".");
+ return deleteResponse(response, "error");
+ }
+
+ String responseValue = "deleted";
+ User userToModify = (User) getService().findById(User.class, userId);
+ if (userToModify != null && userToModify.getPortraitUuid() != null) {
+
+ Object[] args = new Object[] { userToModify.getFullName(), userToModify.getLogin(), userToModify.getUserId(), userToModify.getPortraitUuid() };
+ String auditMessage = getMessageService().getMessage(PORTRAIT_DELETE_AUDIT_KEY, args);
+ getAuditService().log(CentralConstants.MODULE_NAME, auditMessage);
+
+ try {
+ getCentralToolContentHandler().deleteFile(userToModify.getPortraitUuid());
+ userToModify.setPortraitUuid(null);
+ getService().saveUser(userToModify);
+ } catch (Exception e) {
+ log.error("Unable to delete a portrait for user "+userId+".", e);
+ return deleteResponse(response, "error");
+ }
+ }
+ return deleteResponse(response, responseValue);
+ }
+
+ private ActionForward deleteResponse(HttpServletResponse response, String data) throws IOException {
+ response.setContentType("text/plain;charset=utf-8");
+ response.getWriter().write(data);
+ return null;
+ }
+
private CentralToolContentHandler getCentralToolContentHandler() {
if (centralToolContentHandler == null) {
WebApplicationContext wac = WebApplicationContextUtils
@@ -171,4 +218,23 @@
}
return service;
}
+
+ private IAuditService getAuditService() {
+ if (PortraitSaveAction.auditService == null) {
+ WebApplicationContext ctx = WebApplicationContextUtils
+ .getRequiredWebApplicationContext(getServlet().getServletContext());
+ PortraitSaveAction.auditService = (IAuditService) ctx.getBean("auditService");
+ }
+ return PortraitSaveAction.auditService;
+ }
+
+ private MessageService getMessageService() {
+ if (PortraitSaveAction.messageService == null) {
+ WebApplicationContext ctx = WebApplicationContextUtils
+ .getRequiredWebApplicationContext(getServlet().getServletContext());
+ PortraitSaveAction.messageService = (MessageService) ctx.getBean("centralMessageService");
+ }
+ return PortraitSaveAction.messageService;
+ }
+
}