user-delete.jsp 4.51 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 12 13 14 15
<%@ page import="org.jivesoftware.openfire.PresenceManager,
                 org.jivesoftware.openfire.XMPPServer,
                 org.jivesoftware.openfire.group.GroupManager,
                 org.jivesoftware.openfire.session.ClientSession,
                 org.jivesoftware.openfire.user.User"
Bill Lynch's avatar
Bill Lynch committed
16
    errorPage="error.jsp"
Matt Tucker's avatar
Matt Tucker committed
17
%>
18 19 20 21 22 23 24 25 26 27
<%@ page import="org.jivesoftware.openfire.user.UserManager" %>
<%@ page import="org.jivesoftware.util.JiveGlobals" %>
<%@ page import="org.jivesoftware.util.LocaleUtils" %>
<%@ page import="org.jivesoftware.util.ParamUtils" %>
<%@ page import="org.jivesoftware.util.StringUtils" %>
<%@ page import="org.xmpp.packet.JID" %>
<%@ page import="org.xmpp.packet.Presence" %>
<%@ page import="org.xmpp.packet.StreamError" %>
<%@ page import="java.net.URLEncoder" %>
<%@ page import="java.util.Collection" %>
Bill Lynch's avatar
Bill Lynch committed
28

29
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
30
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
31

Derek DeMoro's avatar
Derek DeMoro committed
32 33
<jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager" />
<% webManager.init(request, response, session, application, out ); %>
Matt Tucker's avatar
Matt Tucker committed
34 35 36 37

<%  // Get parameters //
    boolean cancel = request.getParameter("cancel") != null;
    boolean delete = request.getParameter("delete") != null;
38
    String username = ParamUtils.getParameter(request,"username");
Matt Tucker's avatar
Matt Tucker committed
39 40 41

    // Handle a cancel
    if (cancel) {
42
        response.sendRedirect("user-properties.jsp?username=" + URLEncoder.encode(username, "UTF-8"));
Matt Tucker's avatar
Matt Tucker committed
43 44 45 46
        return;
    }

    // Load the user object
Derek DeMoro's avatar
Derek DeMoro committed
47
    User user = webManager.getUserManager().getUser(username);
Matt Tucker's avatar
Matt Tucker committed
48 49 50

    // Handle a user delete:
    if (delete) {
51
        // Delete the user
Derek DeMoro's avatar
Derek DeMoro committed
52
        webManager.getUserManager().deleteUser(user);
53
        // Delete the user's roster
54
        JID userAddress = new JID(username, webManager.getServerInfo().getXMPPDomain(), null);
55
        // Delete the roster of the user
56
        webManager.getRosterManager().deleteRoster(userAddress);
57 58
        // Delete the user from all the Groups
        GroupManager.getInstance().deleteUser(user);
59 60 61 62 63 64 65
        // Close the user's connection
        final StreamError error = new StreamError(StreamError.Condition.not_authorized);
        for (ClientSession sess : webManager.getSessionManager().getSessions(user.getUsername()) )
        {
            sess.deliverRawText(error.toXML());
            sess.close();
        }
Matt Tucker's avatar
Matt Tucker committed
66
        // Deleted your own user account, force login
Derek DeMoro's avatar
Derek DeMoro committed
67
        if (username.equals(webManager.getAuthToken().getUsername())){
Matt Tucker's avatar
Matt Tucker committed
68 69 70 71 72
            session.removeAttribute("jive.admin.authToken");
            response.sendRedirect("login.jsp");
        }
        else {
            // Done, so redirect
Bill Lynch's avatar
Bill Lynch committed
73
            response.sendRedirect("user-summary.jsp?deletesuccess=true");
Matt Tucker's avatar
Matt Tucker committed
74 75 76 77 78
        }
        return;
    }
%>

79 80 81 82 83 84 85 86
<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
87

88 89 90 91 92 93
<% if (UserManager.getUserProvider().isReadOnly()) { %>
<div class="error">
    <fmt:message key="user.read_only"/>
</div>
<% } %>

Matt Tucker's avatar
Matt Tucker committed
94
<p>
95
<fmt:message key="user.delete.info" />
96
<b><a href="user-properties.jsp?username=<%= URLEncoder.encode(user.getUsername(), "UTF-8") %>"><%= JID.unescapeNode(user.getUsername()) %></a></b>
97
<fmt:message key="user.delete.info1" />
Matt Tucker's avatar
Matt Tucker committed
98 99
</p>

100
<c:if test="${admin.user.username == param.username}">
Matt Tucker's avatar
Matt Tucker committed
101
    <p class="jive-warning-text">
102
    <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
103 104 105 106
    </p>
</c:if>

<form action="user-delete.jsp">
107
<input type="hidden" name="username" value="<%= username %>">
108 109
<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
110 111
</form>

112 113
<%  // Disable the form if a read-only user provider.
    if (UserManager.getUserProvider().isReadOnly()) { %>
114 115 116 117 118 119 120 121 122 123 124 125

<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>
    <% } %>

126 127
    </body>
</html>