user-properties.jsp 9.96 KB
Newer Older
Bill Lynch's avatar
Bill Lynch 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
<%@ page import="org.jivesoftware.util.JiveGlobals,
                 org.jivesoftware.util.ParamUtils,
13 14 15 16
                 org.jivesoftware.openfire.PresenceManager,
                 org.jivesoftware.openfire.group.Group,
                 org.jivesoftware.openfire.user.User,
                 org.jivesoftware.openfire.user.UserNotFoundException"
Bill Lynch's avatar
Bill Lynch committed
17
    errorPage="error.jsp"
Matt Tucker's avatar
Matt Tucker committed
18
%>
19 20
<%@ page import="org.xmpp.packet.Presence"%>
<%@ page import="java.net.URLEncoder"%>
Matt Tucker's avatar
Matt Tucker committed
21
<%@ page import="java.util.Collection"%>
22
<%@ page import="org.jivesoftware.openfire.user.UserManager"%><%@ page import="org.xmpp.packet.JID"%>
23
<%@ page import="org.jivesoftware.openfire.lockout.NotLockedOutException" %>
Matt Tucker's avatar
Matt Tucker committed
24

25
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
26
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
Bill Lynch's avatar
Bill Lynch committed
27
<jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager" />
Matt Tucker's avatar
Matt Tucker committed
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42

<%  // Get parameters //
    boolean cancel = request.getParameter("cancel") != null;
    boolean delete = request.getParameter("delete") != null;
    boolean password = request.getParameter("password") != null;
    String username = ParamUtils.getParameter(request,"username");

    // Handle a cancel
    if (cancel) {
        response.sendRedirect("user-summary.jsp");
        return;
    }

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

47
    // Handle password change
Matt Tucker's avatar
Matt Tucker committed
48
    if (password) {
49
        response.sendRedirect("user-password.jsp?username=" + URLEncoder.encode(username, "UTF-8"));
Matt Tucker's avatar
Matt Tucker committed
50 51 52 53 54 55
        return;
    }

    // Load the user object
    User user = null;
    try {
Derek DeMoro's avatar
Derek DeMoro committed
56
        user = webManager.getUserManager().getUser(username);
Matt Tucker's avatar
Matt Tucker committed
57 58 59 60
    }
    catch (UserNotFoundException unfe) {
    }

Bill Lynch's avatar
Bill Lynch committed
61
    PresenceManager presenceManager = webManager.getPresenceManager();
62 63 64 65 66 67 68 69 70 71 72 73 74 75
    Boolean lockedOut = false;
    Boolean pendingLockOut = false;
    try {
        webManager.getLockOutManager().getDisabledStatus(username);
        if (webManager.getLockOutManager().isAccountDisabled(username)) {
            lockedOut = true;
        }
        else {
            pendingLockOut = true;
        }
    }
    catch (NotLockedOutException e) {
        // Nothing, we're good.
    }
Matt Tucker's avatar
Matt Tucker committed
76
%>
Bill Lynch's avatar
Bill Lynch committed
77

78 79 80 81 82 83 84 85
<html>
    <head>
        <title><fmt:message key="user.properties.title"/></title>
        <meta name="subPageID" content="user-properties"/>
        <meta name="extraParams" content="<%= "username="+URLEncoder.encode(username, "UTF-8") %>"/>
        <meta name="helpPage" content="edit_user_properties.html"/>
    </head>
    <body>
Matt Tucker's avatar
Matt Tucker committed
86

Bill Lynch's avatar
Bill Lynch committed
87
<p>
88
<fmt:message key="user.properties.info" />
Bill Lynch's avatar
Bill Lynch committed
89 90
</p>

Bill Lynch's avatar
Bill Lynch committed
91 92 93 94 95
<%  if (request.getParameter("success") != null) { %>

    <div class="jive-success">
    <table cellpadding="0" cellspacing="0" border="0">
    <tbody>
96
        <tr><td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0" alt=""></td>
Bill Lynch's avatar
Bill Lynch committed
97
        <td class="jive-icon-label">
98
        <fmt:message key="user.properties.created" />
Bill Lynch's avatar
Bill Lynch committed
99 100 101 102 103
        </td></tr>
    </tbody>
    </table>
    </div><br>

104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
<%  } else if (request.getParameter("locksuccess") != null) { %>

    <div class="jive-success">
    <table cellpadding="0" cellspacing="0" border="0">
    <tbody>
        <tr><td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0" alt=""></td>
        <td class="jive-icon-label">
        <fmt:message key="user.properties.locksuccess" />
        </td></tr>
    </tbody>
    </table>
    </div><br>

<%  } else if (request.getParameter("unlocksuccess") != null) { %>

    <div class="jive-success">
    <table cellpadding="0" cellspacing="0" border="0">
    <tbody>
        <tr><td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0" alt=""></td>
        <td class="jive-icon-label">
        <fmt:message key="user.properties.unlocksuccess" />
        </td></tr>
    </tbody>
    </table>
    </div><br>

Bill Lynch's avatar
Bill Lynch committed
130 131 132 133 134
<%  } else if (request.getParameter("editsuccess") != null) { %>

    <div class="jive-success">
    <table cellpadding="0" cellspacing="0" border="0">
    <tbody>
135
        <tr><td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0" alt=""></td>
Bill Lynch's avatar
Bill Lynch committed
136
        <td class="jive-icon-label">
137
        <fmt:message key="user.properties.update" />
Bill Lynch's avatar
Bill Lynch committed
138 139 140 141 142
        </td></tr>
    </tbody>
    </table>
    </div><br>

143 144 145 146 147 148 149 150 151 152 153 154 155
<% } else if (user == null) { %>
    <div class="warning">
    <table cellpadding="0" cellspacing="0" border="0">
    <tbody>
        <tr>
        <td class="jive-icon-label">
            <fmt:message key="error.specific_user_not_found">
                <fmt:param value="<%= username%>" />
            </fmt:message>
        </td></tr>
    </tbody>
    </table>
    </div><br>
Bill Lynch's avatar
Bill Lynch committed
156 157
<%  } %>

Bill Lynch's avatar
Bill Lynch committed
158 159 160 161 162
<div class="jive-table">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<thead>
    <tr>
        <th colspan="2">
163
            <fmt:message key="user.properties.title" />
Bill Lynch's avatar
Bill Lynch committed
164 165 166 167
        </th>
    </tr>
</thead>
<tbody>
168 169 170
    <% if (user == null) { %>
    <tr>
        <td colspan="2" align="center">
171
            <fmt:message key="error.requested_user_not_found" />
172 173 174
        </td>
    </tr>
    <% } else { %>
Bill Lynch's avatar
Bill Lynch committed
175 176
    <tr>
        <td class="c1">
177
            <fmt:message key="user.create.username" />:
Bill Lynch's avatar
Bill Lynch committed
178 179
        </td>
        <td>
180
            <%= JID.unescapeNode(user.getUsername()) %>
181 182
            <% if (lockedOut) { %><img src="/images/forbidden-16x16.gif" align="top" height="16" width="16" alt="<fmt:message key='user.properties.locked'/>" title="<fmt:message key='user.properties.locked'/>"/><% } %>
            <% if (pendingLockOut) { %><img src="/images/warning-16x16.gif" align="top" height="16" width="16" alt="<fmt:message key='user.properties.locked_set'/>" title="<fmt:message key='user.properties.locked_set'/>"/><% } %>
Bill Lynch's avatar
Bill Lynch committed
183 184 185 186
        </td>
    </tr>
    <tr>
        <td class="c1">
187
            <fmt:message key="session.details.status" />:
Bill Lynch's avatar
Bill Lynch committed
188 189 190 191 192
        </td>
        <td>
            <%  if (presenceManager.isAvailable(user)) {
                    Presence presence = presenceManager.getPresence(user);
            %>
Derek DeMoro's avatar
Derek DeMoro committed
193
                <% if (presence.getShow() == null) { %>
194
                <img src="images/user-green-16x16.gif" width="16" height="16" border="0" title="<fmt:message key="user.properties.available" />" alt="<fmt:message key="user.properties.available" />">
Bill Lynch's avatar
Bill Lynch committed
195
                <% } %>
Derek DeMoro's avatar
Derek DeMoro committed
196
                <% if (presence.getShow() == Presence.Show.chat) { %>
197
                <img src="images/user-green-16x16.gif" width="16" height="16" border="0" title="<fmt:message key="session.details.chat_available" />" alt="<fmt:message key="session.details.chat_available" />">
Bill Lynch's avatar
Bill Lynch committed
198
                <% } %>
Derek DeMoro's avatar
Derek DeMoro committed
199
                <% if (presence.getShow() == Presence.Show.away) { %>
200
                <img src="images/user-yellow-16x16.gif" width="16" height="16" border="0" title="<fmt:message key="session.details.away" />" alt="<fmt:message key="session.details.away" />">
Bill Lynch's avatar
Bill Lynch committed
201
                <% } %>
Derek DeMoro's avatar
Derek DeMoro committed
202
                <% if (presence.getShow() == Presence.Show.xa) { %>
203
                <img src="images/user-yellow-16x16.gif" width="16" height="16" border="0" title="<fmt:message key="session.details.extended" />" alt="<fmt:message key="session.details.extended" />">
Bill Lynch's avatar
Bill Lynch committed
204
                <% } %>
Derek DeMoro's avatar
Derek DeMoro committed
205
                <% if (presence.getShow() == Presence.Show.dnd) { %>
206
                <img src="images/user-red-16x16.gif" width="16" height="16" border="0" title="<fmt:message key="session.details.not_disturb" />" alt="<fmt:message key="session.details.not_disturb" />">
Bill Lynch's avatar
Bill Lynch committed
207 208 209 210
                <% } %>

            <%  } else { %>

211 212
                <img src="images/user-clear-16x16.gif" width="16" height="16" border="0" alt="<fmt:message key="user.properties.offline" />">
                (<fmt:message key="user.properties.offline" />)
Bill Lynch's avatar
Bill Lynch committed
213 214 215 216 217 218

            <%  } %>
        </td>
    </tr>
    <tr>
        <td class="c1">
219
            <fmt:message key="user.create.name" />:
Bill Lynch's avatar
Bill Lynch committed
220 221
        </td>
        <td>
222
            <%  if ("".equals(user.getName())) { %>
Bill Lynch's avatar
Bill Lynch committed
223
                <span style="color:#999">
224
                <i><fmt:message key="user.properties.not_set" /></i>
Bill Lynch's avatar
Bill Lynch committed
225 226 227
                </span>

            <%  } else { %>
Matt Tucker's avatar
Matt Tucker committed
228
                <%= user.getName() %>
Bill Lynch's avatar
Bill Lynch committed
229 230 231 232 233 234

            <%  } %>
        </td>
    </tr>
    <tr>
        <td class="c1">
235
            <fmt:message key="user.create.email" />:
Bill Lynch's avatar
Bill Lynch committed
236 237
        </td>
        <td>
238 239
            <%  if (user.getEmail() == null) { %>
                <span style="color:#999">
240
                <i><fmt:message key="user.properties.not_set" /></i>
241 242 243 244 245 246
                </span>

            <%  } else { %>
                <a href="mailto:<%= user.getEmail() %>"><%= user.getEmail() %></a>

            <%  } %>
247
            &nbsp;
Bill Lynch's avatar
Bill Lynch committed
248 249 250 251
        </td>
    </tr>
    <tr>
        <td class="c1">
252
            <fmt:message key="user.properties.registered" />:
Bill Lynch's avatar
Bill Lynch committed
253 254
        </td>
        <td>
Matt Tucker's avatar
Matt Tucker committed
255
            <%= JiveGlobals.formatDate(user.getCreationDate()) %>
Bill Lynch's avatar
Bill Lynch committed
256 257
        </td>
    </tr>
Matt Tucker's avatar
Matt Tucker committed
258 259 260 261 262 263
    <tr>
        <td class="c1">
            Groups:
        </td>
        <td>
            <%
264
                Collection<Group> groups = webManager.getGroupManager().getGroups(user);
Matt Tucker's avatar
Matt Tucker committed
265 266 267 268 269 270 271
                if (groups.isEmpty()) {
            %>
                <i>None</i>
            <%
                }
                else {
                    int count = 0;
272
                    for (Group group : groups) {
Matt Tucker's avatar
Matt Tucker committed
273 274 275 276
                        if (count != 0) {
                            out.print(", ");
                        }
                        out.print(group.getName());
277
                        count++;
Matt Tucker's avatar
Matt Tucker committed
278 279 280 281 282
                    }
                }
            %>
        </td>
    </tr>
283
    <% } %>
Bill Lynch's avatar
Bill Lynch committed
284
</tbody>
Matt Tucker's avatar
Matt Tucker committed
285 286 287
</table>
</div>

Bill Lynch's avatar
Bill Lynch committed
288
<br><br>
Matt Tucker's avatar
Matt Tucker committed
289

290
<% if (user != null && !UserManager.getUserProvider().isReadOnly()) { %>
291

Bill Lynch's avatar
Bill Lynch committed
292 293
<form action="user-edit-form.jsp">
<input type="hidden" name="username" value="<%= user.getUsername() %>">
294
<input type="submit" value="<fmt:message key="global.edit_properties" />">
Matt Tucker's avatar
Matt Tucker committed
295 296
</form>

297 298
<% } %>

299 300
</body>
</html>