<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ page trimDirectiveWhitespaces="true" %> <%@ page import="org.crosswire.community.projects.ntmss.data.ProjectManagement" %> <%@ page import="org.crosswire.xml.XMLBlock" %> <%@ page import="org.crosswire.webtools.annotation.*" %> <%@ page import="javax.validation.constraints.NotNull" %> <%@ page import="org.crosswire.webtools.*" %> <%! @Description(value = "Remove the assignment of a task from a user.", name = "projectmanagement/task/unassign") public static class MyParameters extends Parameters { @Description(value = "from which project to remove the assignment", defaultValue = "0 (none)", example = "146") public Integer projectID = 0; @NotNull @Description(value = "typically a manuscript id", example = "10046") public Integer objectID; @NotNull @Description(value = "type of task to be unassigned; 1 - imaging; 2 - indexing; 3 - transcribing", example = "3") public Integer taskTypeID; @Description(value = "whose assignment to remove", example = "joe") public String assignedTo; @Override protected void afterLoad() { if (assignedTo == null && getUser() != null) assignedTo = getUser().getUserName(); } @Override protected void customValidation() { if (getUser() == null) { addError(-5, "Must be logged in."); return; } } } %> <% MyParameters params = new MyParameters().loadFromRequest(request, response, false); if (params.getErrors().size() == 0) { String role = "Administrator"; switch (params.taskTypeID) { case 2: role = "Power User"; break; case 3: role = "VMR Administrator"; break; } ProjectManagement.Project p = ProjectManagement.getProject(params.projectID); boolean permission = params.getUser().hasRole(role) || (p != null && params.getUser().hasRole("Site Administrator", p.getProjectName())); if (permission) { ProjectManagement.removeAssignment(params.objectID, params.taskTypeID, params.assignedTo, params.projectID); Serializer.output(response, out, params, XMLBlock.createXMLBlock("")); return; } else { params.addError(-6, "Permission denied."); } } else params.format = "html"; Serializer.reportErrors(request, response, out, params, true); %>