user-delete.jsp 3.63 KB
Newer Older
Derek DeMoro's avatar
Derek DeMoro committed
1
<%--
Matt Tucker's avatar
Matt Tucker committed
2 3
  -	$Revision$
  -	$Date$
Bill Lynch's avatar
Bill Lynch committed
4
  -
5
  - Copyright (C) 2004-2005 Jive Software. All rights reserved.
Bill Lynch's avatar
Bill Lynch committed
6 7 8
  -
  - This software is published under the terms of the GNU Public License (GPL),
  - a copy of which is included in this distribution.
Matt Tucker's avatar
Matt Tucker committed
9 10 11
--%>

<%@ page import="org.jivesoftware.util.*,
12
                 org.jivesoftware.wildfire.user.*,
13
                 org.xmpp.packet.JID,
14
                 java.net.URLEncoder,
15
                 org.jivesoftware.wildfire.group.GroupManager"
Bill Lynch's avatar
Bill Lynch committed
16
    errorPage="error.jsp"
Matt Tucker's avatar
Matt Tucker committed
17
%>
Bill Lynch's avatar
Bill Lynch committed
18

19
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
20
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
21

Derek DeMoro's avatar
Derek DeMoro committed
22 23
<jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager" />
<% webManager.init(request, response, session, application, out ); %>
Matt Tucker's avatar
Matt Tucker committed
24 25 26 27

<%  // Get parameters //
    boolean cancel = request.getParameter("cancel") != null;
    boolean delete = request.getParameter("delete") != null;
28
    String username = ParamUtils.getParameter(request,"username");
Matt Tucker's avatar
Matt Tucker committed
29 30 31

    // Handle a cancel
    if (cancel) {
32
        response.sendRedirect("user-properties.jsp?username=" + URLEncoder.encode(username, "UTF-8"));
Matt Tucker's avatar
Matt Tucker committed
33 34 35 36
        return;
    }

    // Load the user object
Derek DeMoro's avatar
Derek DeMoro committed
37
    User user = webManager.getUserManager().getUser(username);
Matt Tucker's avatar
Matt Tucker committed
38 39 40

    // Handle a user delete:
    if (delete) {
41
        // Delete the user
Derek DeMoro's avatar
Derek DeMoro committed
42
        webManager.getUserManager().deleteUser(user);
43
        // Delete the user's roster
Derek DeMoro's avatar
Derek DeMoro committed
44
        JID userAddress = new JID(username, webManager.getServerInfo().getName(), null);
45
        // Delete the roster of the user
46
        webManager.getRosterManager().deleteRoster(userAddress);
47 48
        // Delete the user from all the Groups
        GroupManager.getInstance().deleteUser(user);
Matt Tucker's avatar
Matt Tucker committed
49
        // Deleted your own user account, force login
Derek DeMoro's avatar
Derek DeMoro committed
50
        if (username.equals(webManager.getAuthToken().getUsername())){
Matt Tucker's avatar
Matt Tucker committed
51 52 53 54 55
            session.removeAttribute("jive.admin.authToken");
            response.sendRedirect("login.jsp");
        }
        else {
            // Done, so redirect
Bill Lynch's avatar
Bill Lynch committed
56
            response.sendRedirect("user-summary.jsp?deletesuccess=true");
Matt Tucker's avatar
Matt Tucker committed
57 58 59 60 61
        }
        return;
    }
%>

62 63 64 65 66 67 68 69
<html>
    <head>
        <title><fmt:message key="user.delete.title"/></title>
        <meta name="subPageID" content="user-delete"/>
        <meta name="extraParams" content="<%= "username="+URLEncoder.encode(username, "UTF-8") %>"/>
        <meta name="helpPage" content="remove_a_user_from_the_system.html"/>
    </head>
    <body>
Matt Tucker's avatar
Matt Tucker committed
70

71 72 73 74 75 76
<% if (UserManager.getUserProvider().isReadOnly()) { %>
<div class="error">
    <fmt:message key="user.read_only"/>
</div>
<% } %>

Matt Tucker's avatar
Matt Tucker committed
77
<p>
78
<fmt:message key="user.delete.info" />
79
<b><a href="user-properties.jsp?username=<%= URLEncoder.encode(user.getUsername(), "UTF-8") %>"><%= JID.unescapeNode(user.getUsername()) %></a></b>
80
<fmt:message key="user.delete.info1" />
Matt Tucker's avatar
Matt Tucker committed
81 82
</p>

83
<c:if test="${admin.user.username == param.username}">
Matt Tucker's avatar
Matt Tucker committed
84
    <p class="jive-warning-text">
85
    <fmt:message key="user.delete.warning" /> <b><fmt:message key="user.delete.warning2" /></b> <fmt:message key="user.delete.warning3" />
Matt Tucker's avatar
Matt Tucker committed
86 87 88 89
    </p>
</c:if>

<form action="user-delete.jsp">
90
<input type="hidden" name="username" value="<%= username %>">
91 92
<input type="submit" name="delete" value="<fmt:message key="user.delete.delete" />">
<input type="submit" name="cancel" value="<fmt:message key="global.cancel" />">
Matt Tucker's avatar
Matt Tucker committed
93 94
</form>

95 96
<%  // Disable the form if a read-only user provider.
    if (UserManager.getUserProvider().isReadOnly()) { %>
97 98 99 100 101 102 103 104 105 106 107 108

<script language="Javascript" type="text/javascript">
  function disable() {
    var limit = document.forms[0].elements.length;
    for (i=0;i<limit;i++) {
      document.forms[0].elements[i].disabled = true;
    }
  }
  disable();
</script>
    <% } %>

109 110
    </body>
</html>