<%@ page contentType="text/html;charset=GBK" %>

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

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

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

<%	// get parameters
	int maxPoints = ParamUtils.getIntParameter(request,"maxPoints",-1);
    boolean setProp = ParamUtils.getBooleanParameter(request,"setProp");
    boolean emailNotify = ParamUtils.getBooleanParameter(request,"emailNotify");
    String fromName = ParamUtils.getParameter(request,"fromName",true);
    String fromEmail = ParamUtils.getParameter(request,"fromEmail",true);
    String subject = ParamUtils.getParameter(request,"subject",true);
    String body = ParamUtils.getParameter(request,"body",true);
    String smtpHost = ParamUtils.getParameter(request,"smtpHost",true);
    boolean saveEmailSettings = ParamUtils.getBooleanParameter(request,"saveEmailSettings");
    boolean saveEmailProps = ParamUtils.getBooleanParameter(request,"saveEmailProps");

    // Get the watch manager
    WatchManager watchManager = forumFactory.getWatchManager();

    // save the email settings if requested
    if (saveEmailSettings) {
        watchManager.setEmailNotifyEnabled(emailNotify);
        if (smtpHost != null) {
            JiveGlobals.setJiveProperty("mail.smtp.host", smtpHost);
        }
        response.sendRedirect("editWatches.jsp");
        return;
    }

    if (saveEmailProps) {
        if (fromName != null) {
            watchManager.setEmailFromName(fromName);
        }
        if (fromEmail != null) {
            watchManager.setEmailFromEmail(fromEmail);
        }
        if (subject != null) {
            watchManager.setEmailSubject(subject);
        }
        if (body != null) {
            watchManager.setEmailBody(body);
        }
        response.sendRedirect("editWatches.jsp");
        return;
    }
    fromName = watchManager.getEmailFromName();
    fromEmail = watchManager.getEmailFromEmail();
    subject = watchManager.getEmailSubject();
    body = watchManager.getEmailBody();
    smtpHost = JiveGlobals.getJiveProperty("mail.smtp.host");

    boolean errors = false;
    String errorMessage = "";

    boolean isEmailNotifyEnabled = watchManager.isEmailNotifyEnabled();
%>

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

<p>

<%  // Title of this page and breadcrumbs
    String title = "监控配置";
    String[][] breadcrumbs = {
        {"主页面", "main.jsp"},
        {title, "editWatches.jsp"}
    };
%>
<%@ include file="title.jsp" %>

<font size="-1">
监控允许用户跟踪他们感兴趣的主题，在有更新的情况下发送电子邮件提醒他。使用下面的设置打开或者关闭邮件提醒并定义发送的消息。
</font>

<p>

<form action="editWatches.jsp" name="f">
<input type="hidden" name="saveEmailSettings" value="true">
<font size="-1"><b>Email监控设置</b></font>
<ul>
    <table cellpadding="2" cellspacing="0" border="0">
    <tr>
    	<td width="1%"><input type="radio" name="emailNotify" value="true"<%= (isEmailNotifyEnabled?" checked":"") %> id="rb01"></td>
    	<td><font size="-1"><label for="rb01">激活Email监控通知</label></font></td>
    </tr>
    <tr>
    	<td width="1%"><input type="radio" name="emailNotify" value="false"<%= (!isEmailNotifyEnabled?" checked":"") %> id="rb02"></td>
    	<td><font size="-1"><label for="rb02">激活Email监控通知</label></font></td>
    </tr>
    <tr>
    	<td colspan="2">
            <font size="-1">
            SMTP主机:
            </font>
            <input type="text" name="smtpHost" value="<%= (smtpHost!=null)?smtpHost:"" %>" size="30" maxlength="100">
        </td>
    </tr>
    <tr>
    	<td colspan="2">
            <br><input type="submit" value="保存设置">
        </td>
    </tr>
    </table>
</ul>
</form>

<form action="editWatches.jsp" name="f">
<input type="hidden" name="saveEmailProps" value="true">
<font size="-1"><b>Email属性</b></font>
<ul>
    <font size="-1">
    你可以将下面的标记插入邮件的标题或者正文，在邮件被发送的时候他们被合适的值代替。
    <br>
    </font>
    <font color="#006600">
    <tt>
    {username}
    {email}
    {name}
    {userID}
    {threadID}
    {threadName}
    {threadModifiedDate}
    {threadCreationDate}
    {forumID}
    {forumName}
    </tt>
    </font>
    <p>
    <table cellpadding="2" cellspacing="0" border="0">
    <tr>
    	<td nowrap><font size="-1">发送者姓名:</font></td>
    	<td><input type="text" name="fromName" size="30" value="<%= ((fromName!=null)?fromName:"") %>"></td>
    </tr>
    <tr>
    	<td nowrap><font size="-1">发送者Email:</font></td>
    	<td><input type="text" name="fromEmail" size="30" value="<%= ((fromEmail!=null)?fromEmail:"") %>"></td>
    </tr>
    <tr>
    	<td nowrap><font size="-1">标题:</font></td>
    	<td><input type="text" name="subject" size="40" value="<%= ((subject!=null)?StringUtils.replace(subject,"\"","&quot;"):"") %>"></td>
    </tr>
    <tr>
    	<td valign="top" nowrap><font size="-1">邮件正文:</font></td>
    	<td>
        <textarea name="body" cols="40" rows="6" wrap="virtual"><%= ((body!=null)?body:"") %></textarea>
        </td>
    </tr>
    <tr>
        <td>&nbsp;</td>
    	<td><br><input type="submit" value="保存设置"></td>
    </tr>
    </table>
</ul>
</form>

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