<?php
/*
 *      Patrick Bores - WebUserPrefs - SpamAssassin user_prefs file editor
 *      Copyright (C) 2003  Patrick Bores
 *      This program is free software; you can redistribute it and/or
 *      modify it under the terms of the GNU General Public License
 *      as published by the Free Software Foundation; either version 2
 *      of the License, or (at your option) any later version.
 *
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *
 *      You should have received a copy of the GNU General Public License
 *      along with this program; if not, write to the Free Software
 *      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
	function headers_keys(){
		return array("always_add_headers","fold_headers","spam_level_stars","spam_level_char");
	}

	function headers_html(){
		$init_always_add_headers = get_pref("always_add_headers");
		if($init_always_add_headers == "") $init_always_add_headers = 1;

		$init_fold_headers = get_pref("fold_headers");
		if($init_fold_headers == "") $init_fold_headers = 1;

		$init_spam_level_stars = get_pref("spam_level_stars");
		if($init_spam_level_stars == "") $init_spam_level_stars = 1;

		$init_spam_level_char = get_pref("spam_level_char");
		if($init_spam_level_char == "") $init_spam_level_char = "*";

		$always_checked = ($init_always_add_headers == "1") ? "CHECKED" : "";
		$fold_checked = ($init_fold_headers == "1") ? "CHECKED" : "";
		$stars_checked = ($init_spam_level_stars == "1") ? "CHECKED" : "";
		$init_star_char = ($init_spam_level_char != "") ? $init_spam_level_char : "*";

		echo "<b>Headers</b><br />
			The filter may add certain headers to your messages. You can control this behavior here.<br /><br />
			<input type=\"checkbox\" name=\"always_control\" value=\"1\" $always_checked /> Add headers to non-spam messages<br />
			<input type=\"checkbox\" name=\"fold_control\" value=\"1\" $fold_checked /> Allow multiple lines in headers<br /><br />
			<input type=\"checkbox\" name=\"stars_control\" value=\"1\" $stars_checked /> Use \"Spam Level\" header<br />
			Spam Level Character: <input type=\"text\" name=\"star_char_control\" value=\"$init_star_char\" size=\"2\" maxlength=\"1\" />
		";

	}

	function headers_apply(){
		$always = ($_POST[always_control] != "") ? "1" : "0";
		$fold = ($_POST[fold_control] != "") ? "1" : "0";
		$stars = ($_POST[stars_control] != "") ? "1" : "0";
		set_pref("always_add_headers",$always);
		set_pref("fold_headers",$fold);
		set_pref("spam_level_stars",$stars);
		set_pref("spam_level_char",$_POST[star_char_control]);
	}

?>
