Commit e9cdafae authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Added "last logout" column to users summary page. JM-595

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@5718 b35dd754-fafc-0310-a699-88a17e54d16e
parent 8a9b33c7
...@@ -124,6 +124,16 @@ ...@@ -124,6 +124,16 @@
## Added key: 'plugin.enterprise.dont.show' ## Added key: 'plugin.enterprise.dont.show'
## Added key: 'plugin.enterprise.installing' ## Added key: 'plugin.enterprise.installing'
## Added key: 'plugin.enterprise.installed' ## Added key: 'plugin.enterprise.installed'
##
## 3.1.1
## Added key: 'global.second'
## Added key: 'global.minute'
## Added key: 'global.less-minute'
## Added key: 'global.hour'
## Added key: 'global.hours'
## Added key: 'global.day'
## Added key: 'global.days'
## Added key: 'user.summary.last-logout'
# Wildfire # Wildfire
...@@ -412,8 +422,15 @@ global.main=Main ...@@ -412,8 +422,15 @@ global.main=Main
global.continue=Continue global.continue=Continue
global.none=None global.none=None
global.refresh=Refresh global.refresh=Refresh
global.second=second
global.seconds=seconds global.seconds=seconds
global.minute=minute
global.minutes=minutes global.minutes=minutes
global.less-minute=Less than 1 minute
global.hour=hour
global.hours=hours
global.day=day
global.days=days
global.showing=Showing global.showing=Showing
global.pages=Pages global.pages=Pages
global.delete=Delete global.delete=Delete
...@@ -1729,6 +1746,7 @@ user.summary.total_user=Total Users ...@@ -1729,6 +1746,7 @@ user.summary.total_user=Total Users
user.summary.sorted=Sorted by Username user.summary.sorted=Sorted by Username
user.summary.users_per_page=Users per page user.summary.users_per_page=Users per page
user.summary.created=Created user.summary.created=Created
user.summary.last-logout=Last Logout
user.summary.edit=Edit user.summary.edit=Edit
user.summary.not_user=No users in the system. user.summary.not_user=No users in the system.
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
## ##
## For a full changelog, refer to the English bundle, wildfire_i18n_en.properties. ## For a full changelog, refer to the English bundle, wildfire_i18n_en.properties.
## ##
## Updated for release: 3.1.0 ## Updated for release: 3.1.1
# Wildfire # Wildfire
...@@ -290,8 +290,15 @@ global.main=Principal ...@@ -290,8 +290,15 @@ global.main=Principal
global.continue=Continuar global.continue=Continuar
global.none=Ninguno global.none=Ninguno
global.refresh=Refrescar global.refresh=Refrescar
global.second=segundo
global.seconds=segundos global.seconds=segundos
global.minute=minuto
global.minutes=minutos global.minutes=minutos
global.less-minute=Menos de 1 minuto
global.hour=hora
global.hours=horas
global.day=d\u00eda
global.days=d\u00edas
global.showing=Mostrando global.showing=Mostrando
global.pages=P\u00e1ginas global.pages=P\u00e1ginas
global.delete=Borrar global.delete=Borrar
...@@ -1493,6 +1500,7 @@ user.summary.total_user=Total de Usuarios ...@@ -1493,6 +1500,7 @@ user.summary.total_user=Total de Usuarios
user.summary.sorted=Ordenados por Nombre de Usuario user.summary.sorted=Ordenados por Nombre de Usuario
user.summary.users_per_page=Usuarios por p\u00e1gina user.summary.users_per_page=Usuarios por p\u00e1gina
user.summary.created=Creado user.summary.created=Creado
user.summary.last-logout=\u00daltima Salida
user.summary.edit=Editar user.summary.edit=Editar
user.summary.not_user=No hay usuarios en el sistema. user.summary.not_user=No hay usuarios en el sistema.
......
...@@ -893,6 +893,52 @@ public class StringUtils { ...@@ -893,6 +893,52 @@ public class StringUtils {
return zeroPadString(Long.toString(date.getTime()), 15); return zeroPadString(Long.toString(date.getTime()), 15);
} }
/**
* Returns a textual representation for the time that has elapsed.
*
* @param delta the elapsed time.
* @return textual representation for the time that has elapsed.
*/
public static String getElapsedTime(long delta) {
if (delta < JiveConstants.MINUTE) {
return LocaleUtils.getLocalizedString("global.less-minute");
}
else if (delta < JiveConstants.HOUR) {
long mins = delta / JiveConstants.MINUTE;
StringBuilder sb = new StringBuilder();
sb.append(mins).append(" ");
sb.append((mins==1) ? LocaleUtils.getLocalizedString("global.minute") : LocaleUtils.getLocalizedString("global.minutes"));
return sb.toString();
}
else if (delta < JiveConstants.DAY) {
long hours = delta / JiveConstants.HOUR;
delta -= hours * JiveConstants.HOUR;
long mins = delta / JiveConstants.MINUTE;
StringBuilder sb = new StringBuilder();
sb.append(hours).append(" ");
sb.append((hours == 1) ? LocaleUtils.getLocalizedString("global.hour") : LocaleUtils.getLocalizedString("global.hours"));
sb.append(", ");
sb.append(mins).append(" ");
sb.append((mins == 1) ? LocaleUtils.getLocalizedString("global.minute") : LocaleUtils.getLocalizedString("global.minutes"));
return sb.toString();
} else {
long days = delta / JiveConstants.DAY;
delta -= days * JiveConstants.DAY;
long hours = delta / JiveConstants.HOUR;
delta -= hours * JiveConstants.HOUR;
long mins = delta / JiveConstants.MINUTE;
StringBuilder sb = new StringBuilder();
sb.append(days).append(" ");
sb.append((days == 1) ? LocaleUtils.getLocalizedString("global.day") : LocaleUtils.getLocalizedString("global.days"));
sb.append(", ");
sb.append(hours).append(" ");
sb.append((hours == 1) ? LocaleUtils.getLocalizedString("global.hour") : LocaleUtils.getLocalizedString("global.hours"));
sb.append(", ");
sb.append(mins).append(" ");
sb.append((mins == 1) ? LocaleUtils.getLocalizedString("global.minute") : LocaleUtils.getLocalizedString("global.minutes"));
return sb.toString();
}
}
/** /**
* Returns a collection of Strings as a comma-delimitted list of strings. * Returns a collection of Strings as a comma-delimitted list of strings.
* *
......
...@@ -58,6 +58,10 @@ public class IQLastActivityHandler extends IQHandler implements ServerFeaturesPr ...@@ -58,6 +58,10 @@ public class IQLastActivityHandler extends IQHandler implements ServerFeaturesPr
// The user is offline so answer the user's "last available time and the // The user is offline so answer the user's "last available time and the
// status message of the last unavailable presence received from the user" // status message of the last unavailable presence received from the user"
long lastActivityTime = presenceManager.getLastActivity(user); long lastActivityTime = presenceManager.getLastActivity(user);
if (lastActivityTime > -1) {
// Convert it to seconds
lastActivityTime = lastActivityTime / 1000;
}
lastActivity.addAttribute("seconds", String.valueOf(lastActivityTime)); lastActivity.addAttribute("seconds", String.valueOf(lastActivityTime));
String lastStatus = presenceManager.getLastPresenceStatus(user); String lastStatus = presenceManager.getLastPresenceStatus(user);
if (lastStatus != null && lastStatus.length() > 0) { if (lastStatus != null && lastStatus.length() > 0) {
......
...@@ -127,7 +127,7 @@ public class PresenceManagerImpl extends BasicModule implements PresenceManager ...@@ -127,7 +127,7 @@ public class PresenceManagerImpl extends BasicModule implements PresenceManager
String offline = user.getProperties().get(LAST_ACTIVITY_PROP); String offline = user.getProperties().get(LAST_ACTIVITY_PROP);
if (offline != null) { if (offline != null) {
try { try {
answer = (System.currentTimeMillis() - Long.parseLong(offline)) / 1000; answer = (System.currentTimeMillis() - Long.parseLong(offline));
} }
catch (NumberFormatException e) { catch (NumberFormatException e) {
Log.error(LocaleUtils.getLocalizedString("admin.error"), e); Log.error(LocaleUtils.getLocalizedString("admin.error"), e);
......
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
--%> --%>
<%@ page import="org.jivesoftware.admin.AdminConsole, <%@ page import="org.jivesoftware.admin.AdminConsole,
org.jivesoftware.util.JiveConstants, org.jivesoftware.util.JiveGlobals,
org.jivesoftware.util.JiveGlobals" org.jivesoftware.util.StringUtils"
%> %>
<%@ page import="org.jivesoftware.wildfire.XMPPServer"%> <%@ page import="org.jivesoftware.wildfire.XMPPServer"%>
<%@ page import="org.jivesoftware.wildfire.update.Update"%> <%@ page import="org.jivesoftware.wildfire.update.Update"%>
...@@ -121,37 +121,10 @@ ...@@ -121,37 +121,10 @@
<td class="c1"><fmt:message key="index.uptime" /></td> <td class="c1"><fmt:message key="index.uptime" /></td>
<td> <td>
<% <%
String uptimeDisplay = null; long now = System.currentTimeMillis();
if ("en".equals(JiveGlobals.getLocale().getLanguage())) { long lastStarted = webManager.getXMPPServer().getServerInfo().getLastStarted().getTime();
long now = System.currentTimeMillis(); long uptime = now - lastStarted;
long lastStarted = webManager.getXMPPServer().getServerInfo().getLastStarted().getTime(); String uptimeDisplay = StringUtils.getElapsedTime(uptime);
long uptime = now - lastStarted;
if (uptime < JiveConstants.MINUTE) {
uptimeDisplay = "Less than 1 minute";
}
else if (uptime < JiveConstants.HOUR) {
long mins = uptime / JiveConstants.MINUTE;
uptimeDisplay = mins + ((mins==1) ? " minute" : " minutes");
}
else if (uptime < JiveConstants.DAY) {
long hours = uptime / JiveConstants.HOUR;
uptime -= hours * JiveConstants.HOUR;
long mins = uptime / JiveConstants.MINUTE;
uptimeDisplay = hours + ((hours==1) ? " hour" : " hours" + ", " +
mins + ((mins==1) ? " minute" : " minutes"));
}
else {
long days = uptime / JiveConstants.DAY;
uptime -= days * JiveConstants.DAY;
long hours = uptime / JiveConstants.HOUR;
uptime -= hours * JiveConstants.HOUR;
long mins = uptime / JiveConstants.MINUTE;
uptimeDisplay = days + ((days==1) ? " day" : " days") + ", " +
hours + ((hours==1) ? " hour" : " hours") + ", " +
mins + ((mins==1) ? " minute" : " minutes");
}
}
%> %>
<% if (uptimeDisplay != null) { %> <% if (uptimeDisplay != null) { %>
......
...@@ -9,14 +9,17 @@ ...@@ -9,14 +9,17 @@
- a copy of which is included in this distribution. - a copy of which is included in this distribution.
--%> --%>
<%@ page import="org.jivesoftware.util.*, <%@ page import="org.jivesoftware.util.JiveGlobals,
org.jivesoftware.wildfire.user.*, org.jivesoftware.util.LocaleUtils,
java.util.*, org.jivesoftware.util.ParamUtils,
org.jivesoftware.util.StringUtils,
org.jivesoftware.wildfire.PresenceManager, org.jivesoftware.wildfire.PresenceManager,
org.xmpp.packet.Presence, org.jivesoftware.wildfire.user.User,
java.net.URLEncoder, org.jivesoftware.wildfire.user.UserManager"
org.jivesoftware.util.JiveGlobals"
%><%@ page import="org.xmpp.packet.JID"%> %><%@ page import="org.xmpp.packet.JID"%>
<%@ page import="org.xmpp.packet.Presence" %>
<%@ page import="java.net.URLEncoder" %>
<%@ page import="java.util.Collection" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %> <%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %> <%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
...@@ -154,6 +157,7 @@ ...@@ -154,6 +157,7 @@
<th nowrap><fmt:message key="user.create.username" /></th> <th nowrap><fmt:message key="user.create.username" /></th>
<th nowrap><fmt:message key="user.create.name" /></th> <th nowrap><fmt:message key="user.create.name" /></th>
<th nowrap><fmt:message key="user.summary.created" /></th> <th nowrap><fmt:message key="user.summary.created" /></th>
<th nowrap><fmt:message key="user.summary.last-logout" /></th>
<% // Don't allow editing or deleting if users are read-only. <% // Don't allow editing or deleting if users are read-only.
if (!UserManager.getUserProvider().isReadOnly()) { %> if (!UserManager.getUserProvider().isReadOnly()) { %>
<th nowrap><fmt:message key="user.summary.edit" /></th> <th nowrap><fmt:message key="user.summary.edit" /></th>
...@@ -209,14 +213,23 @@ ...@@ -209,14 +213,23 @@
<% } %> <% } %>
</td> </td>
<td width="30%"> <td width="23%">
<a href="user-properties.jsp?username=<%= URLEncoder.encode(user.getUsername(), "UTF-8") %>"><%= JID.unescapeNode(user.getUsername()) %></a> <a href="user-properties.jsp?username=<%= URLEncoder.encode(user.getUsername(), "UTF-8") %>"><%= JID.unescapeNode(user.getUsername()) %></a>
</td> </td>
<td width="40%"> <td width="33%">
<%= user.getName() %> &nbsp; <%= user.getName() %> &nbsp;
</td> </td>
<td width="26%"> <td width="15%">
<%= JiveGlobals.formatDate(user.getCreationDate()) %> <%= JiveGlobals.formatDate(user.getCreationDate()) %>
</td>
<td width="25%">
<% long logoutTime = presenceManager.getLastActivity(user);
if (logoutTime > -1) {
out.println(StringUtils.getElapsedTime(logoutTime));
}
else {
out.println("&nbsp;");
} %>
</td> </td>
<% // Don't allow editing or deleting if users are read-only. <% // Don't allow editing or deleting if users are read-only.
if (!UserManager.getUserProvider().isReadOnly()) { %> if (!UserManager.getUserProvider().isReadOnly()) { %>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment