<%@ page contentType="text/html;charset=GBK" %>
<%
/**
 *	$RCSfile: profile.jsp,v $
 *	$Revision: 1.3 $
 *	$Date: 2002/09/30 14:56:16 $
 */
%>

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

<%@ include file="global.jsp" %>

<%  // redirection
    String profileButton = ParamUtils.getParameter(request,"profileButton");
    String referrer = ParamUtils.getParameter(request,"referrer");
    if ("返  回".equals(profileButton)) {
        if (referrer == null || "null".equals(referrer)) {
            referrer = request.getHeader("REFERER");
            if (referrer == null) {
                referrer = "index.jsp";
            }
        }
        System.err.println("referrer: " + referrer);
        response.sendRedirect(referrer);
        return;
    }
%>

<%  String title = "Forums - User Profile"; %>
<%@ include file="header.jsp" %>

<%  // Get parameters
    long userID = ParamUtils.getLongParameter(request,"user",-1L);
    String username = ParamUtils.getParameter(request,"username");

    // Error parameters
    boolean errors = false;
    String errorMessage = "";
	
	User user=myEnv.getUser(userID);

    if (user != null) {
        userID = user.getID();
        username = user.getUsername();
    } else {
        errors = true;
        errorMessage = "用户 <b>" + username + "</b> 没有找到。";
    }

    // Check for more redirection
    if ("编辑配置文件".equals(profileButton) && user != null
            && (user.getID() == pageUser.getID()))
    {
        response.sendRedirect("settings.jsp?user=" + user.getID());
        return;
    }
%>

<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
    <td width="99%" valign="top">

    <font face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>"
     color="<%= JiveGlobals.getJiveProperty("skin.default.linkColor") %>">
    <b><i><%= username %></i>的配置文件</b>
    </font>
    <br>
    <font size="-1" face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>"
     color="<%= JiveGlobals.getJiveProperty("skin.default.linkColor") %>">
    <b>
    <a href="<%= JiveGlobals.getJiveProperty("skin.default.homeURL") %>"
     >首页</a>
    &raquo;
    <a href="index.jsp" title="返回论坛列表"
     >论坛</a>
    &raquo;
    用户配置文件
    </b>
    </font>

    </td>
    <td valign="top" width="1%" align="center">
    <%@ include file="loginbox.jsp" %>
    </td>
</tr>
</table>

<%  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("jiveOccupation");
        String location = user.getProperty("jiveLocation");
        String homepage = user.getProperty("jiveHomepage");
        int totalPosts = myEnv.getForumFactory().getUserManager().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;";
        }
%>

<font size="-1" face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>">

</font>
<p>

<table bgcolor="<%= JiveGlobals.getJiveProperty("skin.default.tableBorderColor") %>" cellpadding="0" cellspacing="0" border="0" width="80%" align="center">
<tr><td>
    <table bgcolor="<%= JiveGlobals.getJiveProperty("skin.default.tableBorderColor") %>" cellpadding="3" cellspacing="1" border="0" width="100%">
    <%  if (nameVisible || (pageUser != null && pageUser.getID() == user.getID())) { %>
    <tr bgcolor="<%= JiveGlobals.getJiveProperty("skin.default.tableRowColor1") %>">
        <td width="50%">
        <font class=p2 face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>">姓名</font>
        </td>
        <td width="50%">
        <font class=p2 face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>"><%= name %>
            <%  if (!nameVisible) { %>
            (隐藏)
            <%  } %>
        </font>
        </td>
    </tr>
    <%  } %>
    <%  if (emailVisible || (pageUser != null && pageUser.getID() == user.getID())) { %>
    <tr bgcolor="<%= JiveGlobals.getJiveProperty("skin.default.tableRowColor1") %>">
        <td width="50%">
        <font class=p2 face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>">Email</font>
        </td>
        <td width="50%">
        <font class=p2 face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>"><%= email %>
            <%  if (!emailVisible) { %>
            (隐藏)
            <%  } %>
        </font>
        </td>
    </tr>
    <%  } %>
    <tr bgcolor="<%= JiveGlobals.getJiveProperty("skin.default.tableRowColor1") %>">
        <td width="50%">
        <font class=p2 face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>">注册时间</font>
        </td>
        <td width="50%">
        <font class=p2 face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>"><%= SkinUtils.formatDate(request,response,pageUser,creationDate) %></font>
        </td>
    </tr>
    <tr bgcolor="<%= JiveGlobals.getJiveProperty("skin.default.tableRowColor1") %>">
        <td width="50%">
        <font class=p2 face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>">职　　业</font>
        </td>
        <td width="50%">
        <font class=p2 face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>"><%= occupation %></font>
        </td>
    </tr>
    <tr bgcolor="<%= JiveGlobals.getJiveProperty("skin.default.tableRowColor1") %>">
        <td width="50%">
        <font class=p2 face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>">地　　址</font>
        </td>
        <td width="50%">
        <font class=p2 face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>"><%= location %></font>
        </td>
    </tr>
    <tr bgcolor="<%= JiveGlobals.getJiveProperty("skin.default.tableRowColor1") %>">
        <td width="50%">
        <font class=p2 face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>">主　　页</font>
        </td>
        <td width="50%">
        <font class=p2 face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>"><%= homepage %></font>
        </td>
    </tr>
    <tr bgcolor="<%= JiveGlobals.getJiveProperty("skin.default.tableRowColor1") %>">
        <td width="50%">
        <font class=p2 face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>">发贴总数</font>
        </td>
        <td width="50%">
        <font class=p2 face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>"><%= totalPosts %></font>
        </td>
    </tr>
    <tr bgcolor="<%= JiveGlobals.getJiveProperty("skin.default.tableRowColor1") %>">
        <td width="50%">
        <font class=p2 face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>">发贴明细</font>
        </td>
        <td width="50%">
        <font class=p2 face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>">
		<a href="usermessages.jsp?user=<%=user.getID()%>">按这里</a></font>
        </td>
    </tr>
	
    </table>
    </td>
</tr>
</table>

<%  } %>

<p>

<center>
<form action="profile.jsp">
<input type="hidden" name="referrer" value="<%= ((referrer!=null)?referrer:request.getHeader("REFERER")) %>">
<input type="hidden" name="user" value="<%= user.getID() %>">
<%  if (pageUser != null && pageUser.getID() == user.getID()) { %>
<input type="submit" value="编辑配置文件" name="profileButton">
<%  } %>
<input type="submit" value="返  回" name="profileButton">
</form>
</center>

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