user-properties.jsp 11.6 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-2008 Jive Software. All rights reserved.
Bill Lynch's avatar
Bill Lynch committed
6
  -
7 8 9 10 11 12 13 14 15 16 17
  - Licensed under the Apache License, Version 2.0 (the "License");
  - you may not use this file except in compliance with the License.
  - You may obtain a copy of the License at
  -
  -     http://www.apache.org/licenses/LICENSE-2.0
  -
  - Unless required by applicable law or agreed to in writing, software
  - distributed under the License is distributed on an "AS IS" BASIS,
  - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  - See the License for the specific language governing permissions and
  - limitations under the License.
Matt Tucker's avatar
Matt Tucker committed
18 19
--%>

20 21
<%@ page import="org.jivesoftware.openfire.PresenceManager,
                 org.jivesoftware.openfire.admin.AdminManager,
22 23
                 org.jivesoftware.openfire.group.Group,
                 org.jivesoftware.openfire.user.User,
24
                 org.jivesoftware.openfire.user.UserManager,
25
                 org.jivesoftware.openfire.user.UserNotFoundException"
Bill Lynch's avatar
Bill Lynch committed
26
    errorPage="error.jsp"
Matt Tucker's avatar
Matt Tucker committed
27
%>
28 29 30
<%@ page import="org.jivesoftware.util.JiveGlobals"%>
<%@ page import="org.jivesoftware.util.LocaleUtils"%>
<%@ page import="org.jivesoftware.util.ParamUtils"%>
Sven Tantau's avatar
Sven Tantau committed
31
<%@ page import="org.jivesoftware.util.StringUtils"%>
32 33 34
<%@ page import="org.xmpp.packet.JID"%><%@ page import="org.xmpp.packet.Presence"%>
<%@ page import="java.net.URLEncoder" %>
<%@ page import="java.util.Collection" %>
35
<%@ page import="java.util.Map" %>
36
<%@ page import="org.jivesoftware.util.StringUtils" %>
Matt Tucker's avatar
Matt Tucker committed
37

38 39
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
Bill Lynch's avatar
Bill Lynch committed
40
<jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager" />
Matt Tucker's avatar
Matt Tucker committed
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55

<%  // 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) {
56
        response.sendRedirect("user-delete.jsp?username=" + URLEncoder.encode(username, "UTF-8"));
Matt Tucker's avatar
Matt Tucker committed
57 58 59
        return;
    }

60
    // Handle password change
Matt Tucker's avatar
Matt Tucker committed
61
    if (password) {
62
        response.sendRedirect("user-password.jsp?username=" + URLEncoder.encode(username, "UTF-8"));
Matt Tucker's avatar
Matt Tucker committed
63 64 65 66 67 68
        return;
    }

    // Load the user object
    User user = null;
    try {
Derek DeMoro's avatar
Derek DeMoro committed
69
        user = webManager.getUserManager().getUser(username);
Matt Tucker's avatar
Matt Tucker committed
70 71 72 73
    }
    catch (UserNotFoundException unfe) {
    }

Bill Lynch's avatar
Bill Lynch committed
74
    PresenceManager presenceManager = webManager.getPresenceManager();
75 76
    Boolean lockedOut = false;
    Boolean pendingLockOut = false;
77 78
    if (webManager.getLockOutManager().getDisabledStatus(username) != null) {
        // User is locked out. Check if he is locket out now
79 80 81 82 83 84 85
        if (webManager.getLockOutManager().isAccountDisabled(username)) {
            lockedOut = true;
        }
        else {
            pendingLockOut = true;
        }
    }
Matt Tucker's avatar
Matt Tucker committed
86
%>
Bill Lynch's avatar
Bill Lynch committed
87

88 89 90 91 92 93 94 95
<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
96

Bill Lynch's avatar
Bill Lynch committed
97
<p>
98
<fmt:message key="user.properties.info" />
Bill Lynch's avatar
Bill Lynch committed
99 100
</p>

Bill Lynch's avatar
Bill Lynch committed
101 102 103 104 105
<%  if (request.getParameter("success") != null) { %>

    <div class="jive-success">
    <table cellpadding="0" cellspacing="0" border="0">
    <tbody>
106
        <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
107
        <td class="jive-icon-label">
108
        <fmt:message key="user.properties.created" />
Bill Lynch's avatar
Bill Lynch committed
109 110 111 112 113
        </td></tr>
    </tbody>
    </table>
    </div><br>

114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
<%  } 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
140 141 142 143 144
<%  } else if (request.getParameter("editsuccess") != null) { %>

    <div class="jive-success">
    <table cellpadding="0" cellspacing="0" border="0">
    <tbody>
145
        <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
146
        <td class="jive-icon-label">
147
        <fmt:message key="user.properties.update" />
Bill Lynch's avatar
Bill Lynch committed
148 149 150 151 152
        </td></tr>
    </tbody>
    </table>
    </div><br>

153 154 155 156 157 158 159
<% } 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">
160
                <fmt:param value="<%= StringUtils.escapeHTMLTags(username)%>" />
161 162 163 164 165
            </fmt:message>
        </td></tr>
    </tbody>
    </table>
    </div><br>
Bill Lynch's avatar
Bill Lynch committed
166 167
<%  } %>

Bill Lynch's avatar
Bill Lynch committed
168 169 170 171 172
<div class="jive-table">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<thead>
    <tr>
        <th colspan="2">
173
            <fmt:message key="user.properties.title" />
Bill Lynch's avatar
Bill Lynch committed
174 175 176 177
        </th>
    </tr>
</thead>
<tbody>
178 179 180
    <% if (user == null) { %>
    <tr>
        <td colspan="2" align="center">
181
            <fmt:message key="error.requested_user_not_found" />
182 183 184
        </td>
    </tr>
    <% } else { %>
Bill Lynch's avatar
Bill Lynch committed
185 186
    <tr>
        <td class="c1">
187
            <fmt:message key="user.create.username" />:
Bill Lynch's avatar
Bill Lynch committed
188 189
        </td>
        <td>
Sven Tantau's avatar
Sven Tantau committed
190
            <%= StringUtils.escapeHTMLTags(JID.unescapeNode(user.getUsername())) %>
191 192
            <% 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
193 194 195 196
        </td>
    </tr>
    <tr>
        <td class="c1">
197
            <fmt:message key="session.details.status" />:
Bill Lynch's avatar
Bill Lynch committed
198 199 200 201 202
        </td>
        <td>
            <%  if (presenceManager.isAvailable(user)) {
                    Presence presence = presenceManager.getPresence(user);
            %>
Derek DeMoro's avatar
Derek DeMoro committed
203
                <% if (presence.getShow() == null) { %>
204
                <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
205
                <% } %>
Derek DeMoro's avatar
Derek DeMoro committed
206
                <% if (presence.getShow() == Presence.Show.chat) { %>
207
                <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
208
                <% } %>
Derek DeMoro's avatar
Derek DeMoro committed
209
                <% if (presence.getShow() == Presence.Show.away) { %>
210
                <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
211
                <% } %>
Derek DeMoro's avatar
Derek DeMoro committed
212
                <% if (presence.getShow() == Presence.Show.xa) { %>
213
                <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
214
                <% } %>
Derek DeMoro's avatar
Derek DeMoro committed
215
                <% if (presence.getShow() == Presence.Show.dnd) { %>
216
                <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
217 218 219 220
                <% } %>

            <%  } else { %>

221 222
                <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
223 224 225 226

            <%  } %>
        </td>
    </tr>
227 228 229 230 231 232 233 234
    <tr>
        <td class="c1">
            <fmt:message key="user.create.isadmin" />:
        </td>
        <td>
            <%= AdminManager.getInstance().isUserAdmin(user.getUsername(), true) ? LocaleUtils.getLocalizedString("global.yes") : LocaleUtils.getLocalizedString("global.no") %>
        </td>
    </tr>
Bill Lynch's avatar
Bill Lynch committed
235 236
    <tr>
        <td class="c1">
237
            <fmt:message key="user.create.name" />:
Bill Lynch's avatar
Bill Lynch committed
238 239
        </td>
        <td>
240
            <%  if ("".equals(user.getName())) { %>
Bill Lynch's avatar
Bill Lynch committed
241
                <span style="color:#999">
242
                <i><fmt:message key="user.properties.not_set" /></i>
Bill Lynch's avatar
Bill Lynch committed
243 244 245
                </span>

            <%  } else { %>
Sven Tantau's avatar
Sven Tantau committed
246
                <%= StringUtils.escapeHTMLTags(user.getName()) %>
Bill Lynch's avatar
Bill Lynch committed
247 248 249 250 251 252

            <%  } %>
        </td>
    </tr>
    <tr>
        <td class="c1">
253
            <fmt:message key="user.create.email" />:
Bill Lynch's avatar
Bill Lynch committed
254 255
        </td>
        <td>
256 257
            <%  if (user.getEmail() == null) { %>
                <span style="color:#999">
258
                <i><fmt:message key="user.properties.not_set" /></i>
259 260 261
                </span>

            <%  } else { %>
Sven Tantau's avatar
Sven Tantau committed
262
                <a href="mailto:<%= StringUtils.escapeForXML(user.getEmail()) %>"><%= StringUtils.escapeHTMLTags(user.getEmail()) %></a>
263 264

            <%  } %>
265
            &nbsp;
Bill Lynch's avatar
Bill Lynch committed
266 267 268 269
        </td>
    </tr>
    <tr>
        <td class="c1">
270
            <fmt:message key="user.properties.registered" />:
Bill Lynch's avatar
Bill Lynch committed
271 272
        </td>
        <td>
Matt Tucker's avatar
Matt Tucker committed
273
            <%= JiveGlobals.formatDate(user.getCreationDate()) %>
Bill Lynch's avatar
Bill Lynch committed
274 275
        </td>
    </tr>
Matt Tucker's avatar
Matt Tucker committed
276 277 278 279 280 281
    <tr>
        <td class="c1">
            Groups:
        </td>
        <td>
            <%
282
                Collection<Group> groups = webManager.getGroupManager().getGroups(user);
Matt Tucker's avatar
Matt Tucker committed
283 284 285 286 287 288 289
                if (groups.isEmpty()) {
            %>
                <i>None</i>
            <%
                }
                else {
                    int count = 0;
290
                    for (Group group : groups) {
Matt Tucker's avatar
Matt Tucker committed
291 292 293
                        if (count != 0) {
                            out.print(", ");
                        }
294
                        out.print(StringUtils.escapeHTMLTags(group.getName()));
295
                        count++;
Matt Tucker's avatar
Matt Tucker committed
296 297 298 299 300
                    }
                }
            %>
        </td>
    </tr>
301
    <% } %>
Bill Lynch's avatar
Bill Lynch committed
302
</tbody>
Matt Tucker's avatar
Matt Tucker committed
303 304 305
</table>
</div>

306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324
<br>
<div class="jive-table">
	<table cellpadding="0" cellspacing="0" border="0" width="100%">
		<thead>
			<tr>
				<th colspan="2"><fmt:message key="user.properties.additional_properties" /></th>
			</tr>
		</thead>
		<tbody>
			<% for(Map.Entry<String, String> properties : user.getProperties().entrySet()) { %>
			<tr>
				<td class="c1"><%= StringUtils.escapeHTMLTags(properties.getKey()) %>:</td>
				<td><%= StringUtils.escapeHTMLTags(properties.getValue()) %></td>
			</tr>
			<% } %>
		</tbody>
	</table>
</div>

Bill Lynch's avatar
Bill Lynch committed
325
<br><br>
Matt Tucker's avatar
Matt Tucker committed
326

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

Bill Lynch's avatar
Bill Lynch committed
329
<form action="user-edit-form.jsp">
Sven Tantau's avatar
Sven Tantau committed
330
<input type="hidden" name="username" value="<%= StringUtils.escapeForXML(user.getUsername()) %>">
331
<input type="submit" value="<fmt:message key="global.edit_properties" />">
Matt Tucker's avatar
Matt Tucker committed
332 333
</form>

334 335
<% } %>

336
</body>
Sven Tantau's avatar
Sven Tantau committed
337
</html>