
<%
/**
 *	$RCSfile: profile.jsp,v $
 *	$Revision: 1.1.1.1 $
 *	$Date: 2002/09/09 13:50:23 $
 */
%>

<%@ page import="java.util.*,
                 com.jivesoftware.forum.*,
                 com.jivesoftware.forum.util.*"
    errorPage="error.jsp"
%>

<%@ include file="include/branding/style.jsp" %>

<%@ include file="include/forumSetup.jsp" %>

<%  // redirection
    boolean redirect = ParamUtils.getBooleanParameter(request,"redirect");
    String referrer = ParamUtils.getParameter(request,"referrer");
    if (referrer == null) {
        referrer = request.getHeader("REFERER");
    }
    if (redirect) {
        response.sendRedirect(referrer);
        return;
    }
%>

<%  String title = "Jive Software: Communities: Profile"; %>
<%@ include file="include/header.jsp" %>

<%@ include file="include/branding/header.jsp" %>

<%  // Get parameters
    long userID = ParamUtils.getLongParameter(request,"user",-1L);
    String username = ParamUtils.getParameter(request,"username");
    
    // Error parameters
    boolean errors = false;
    String errorMessage = "";
    
    // Try to load a user (try by userID first, then try username)
    UserManager userManager = forumFactory.getUserManager();
    User user = null;
    try {
        user = userManager.getUser(userID);
    }
    catch (UserNotFoundException unfe) {
        errorMessage = "User ID " + userID + " not found.";
        try {
            user = userManager.getUser(username);
        }
        catch (UserNotFoundException unfe2) {
            errorMessage = "User <b>" + username + "</b> not found.";
        }
    }
    if (user != null) {
        userID = user.getID();
        username = user.getUsername();
    } else {
        errors = true;
    }
%>

<span class="header">
<%  if (rootBreadcrumbText != null && rootBreadcrumbLink != null) { %>
<a href="<%= rootBreadcrumbLink %>" class="header"
><%= rootBreadcrumbText %></a>
&raquo;
<%  } %>
<a href="index.jsp" class="header" title="Refresh the forum listing"
><%= indexPageHeaderText %></a>
&raquo;
Profile
</span>
<p>

<%  if (errors) { %>
    <%= errorMessage %>
    <p>
<%  } %>

<%  if (!errors && user != null) {
        username = user.getUsername();
        boolean nameVisible = user.isNameVisible();
        boolean emailVisible = user.isEmailVisible();
        String name = user.getName();
        String email = user.getEmail();
        Date creationDate = user.getCreationDate();
        String occupation = user.getProperty("occupation");
        String location = user.getProperty("location");
        String homepage = user.getProperty("homepage");
        int totalPosts = userManager.userMessageCount(user);
        if (email != null && !email.equals("")) {
            email = "<a href=\"mailto:" + email + "\">"
                + email + "</a>";
        }
        if (homepage != null && !homepage.equals("")) {
            if (homepage.startsWith("http://")) {
                homepage = "<a href=\"" + homepage + "\" target=\"_blank\">"
                    + homepage + "</a>";
            }
            else {
                homepage = "<a href=\"http://" + homepage + "\" target=\"_blank\">"
                    + homepage + "</a>";
            }
        }
        if (occupation == null) {
            occupation = "&nbsp;";
        }
        if (location == null) {
            location = "&nbsp;";
        }
        if (homepage == null) {
            homepage = "&nbsp;";
        }
%>

<span class="subheader">
Profile for <%= username %>
</span>
<p>

<table bgcolor="<%= tableBorderColor %>" cellpadding="0" cellspacing="0" border="0" width="80%" align="center">
<tr><td>
    <table bgcolor="<%= tableBorderColor %>" cellpadding="3" cellspacing="1" border="0" width="100%">
    <%  if (nameVisible) { %>
    <tr bgcolor="<%= tableRowColor1 %>">
        <td width="50%">
        <font size="-1">Name</font>
        </td>
        <td width="50%">
        <font size="-1"><%= name %></font>
        </td>
    </tr>
    <%  } %>
    <%  if (emailVisible) { %>
    <tr bgcolor="<%= tableRowColor1 %>">
        <td width="50%">
        <font size="-1">Email</font>
        </td>
        <td width="50%">
        <font size="-1"><%= email %></font>
        </td>
    </tr>
    <%  } %>
    <tr bgcolor="<%= tableRowColor1 %>">
        <td width="50%">
        <font size="-1">Registered Since</font>
        </td>
        <td width="50%">
        <font size="-1"><%= SkinUtils.formatDate(request,response,pageUser,creationDate) %></font>
        </td>
    </tr>
    <tr bgcolor="<%= tableRowColor1 %>">
        <td width="50%">
        <font size="-1">Occupation</font>
        </td>
        <td width="50%">
        <font size="-1"><%= occupation %></font>
        </td>
    </tr>
    <tr bgcolor="<%= tableRowColor1 %>">
        <td width="50%">
        <font size="-1">Location</font>
        </td>
        <td width="50%">
        <font size="-1"><%= location %></font>
        </td>
    </tr>
    <tr bgcolor="<%= tableRowColor1 %>">
        <td width="50%">
        <font size="-1">Homepage</font>
        </td>
        <td width="50%">
        <font size="-1"><%= homepage %></font>
        </td>
    </tr>
    <tr bgcolor="<%= tableRowColor1 %>">
        <td width="50%">
        <font size="-1">Total Posts</font>
        </td>
        <td width="50%">
        <font size="-1"><%= totalPosts %></font>
        </td>
    </tr>
    </table>
    </td>
</tr>
</table>

<%  } %>

<p>

<form action="profile.jsp">
<input type="hidden" name="redirect" value="true">
<input type="hidden" name="referrer" value="<%= ((referrer!=null)?referrer:"") %>">
<center><input type="submit" value="Go Back"></center>
</form>

<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
    <td align="right">
    <a href="http://www.jivesoftware.com/poweredby/" target="_blank"
    ><img src="images/powered_by_jive.gif" width="100" height="30" alt="Powered by Jive" border="0"></a>
    </td>
</tr>
</table>

<%@ include file="include/branding/footer.jsp" %>

<%@ include file="include/footer.jsp" %>