diff -Naur --exclude='*.svn*' roundcube_svn/plugins/sauserprefs/config.inc.php roundcube_pub/plugins/sauserprefs/config.inc.php
--- roundcube_svn/plugins/sauserprefs/config.inc.php	1970-01-01 01:00:00.000000000 +0100
+++ roundcube_pub/plugins/sauserprefs/config.inc.php	2008-08-16 18:55:07.000000000 +0100
@@ -0,0 +1,141 @@
+<?php
+
+/*
+ +-----------------------------------------------------------------------+
+ | SAUserPrefs configuration file                                        |
+ |                                                                       |
+ | This file is part of the RoundCube Webmail client                     |
+ | Copyright (C) 2005-2008, RoundCube Dev. - Switzerland                 |
+ | Licensed under the GNU GPL                                            |
+ |                                                                       |
+ +-----------------------------------------------------------------------+
+
+*/
+
+$sauserprefs_config = array();
+
+// spamassassin database settings
+$sauserprefs_config['db_dsnw'] = 'mysql://username:password@localhost/database';
+
+// PEAR database DSN for read only operations (if empty write database will be used)
+// useful for database replication
+$sauserprefs_config['db_dsnr'] = '';
+
+// database backend to use (only db or mdb2 are supported)
+$sauserprefs_config['db_backend'] = 'mdb2';
+
+// use persistent db-connections
+// beware this will not "always" work as expected
+// see: http://www.php.net/manual/en/features.persistent-connections.php
+$sauserprefs_config['db_persistent'] = FALSE;
+
+// table that holds user prefs
+$sauserprefs_config['sql_table_name'] = "userpref";
+
+// name of the username field in the user prefs table
+$sauserprefs_config['sql_username_field'] = "username";
+
+// name of the preference field in the user prefs table, holds the name of the preference
+$sauserprefs_config['sql_preference_field'] = "preference";
+
+// name of the value field in the user prefs table, holds the value of the preference
+$sauserprefs_config['sql_value_field'] = "value";
+
+// define what options to show
+$sauserprefs_config['settings'] = array(
+									"score" => TRUE,
+									"subject" => TRUE,
+									"language" => TRUE,
+                                                                       "headers" => TRUE,
+                                                                       "tests" => TRUE,
+									"report" => TRUE,
+									"addresses" => TRUE
+								);
+
+// default settings
+// these are overridden by $GLOBAL and user settings from the database
+$sauserprefs_config['default_prefs'] = array(
+									"required_hits" => "5",
+									"rewrite_subject" => "0",
+									"rewrite_header Subject" => "*****SPAM*****",
+									"ok_languages" => "all",
+									"ok_locales" => "all",
+									"fold_headers" => "1",
+									"add_header all Level" => "_STARS(*)_",
+									"use_razor1" => "0",
+									"use_razor2" => "1",
+									"use_pyzor" => "1",
+									"use_dcc" => "1",
+									"use_bayes" => "1",
+									"skip_rbl_checks" => "0",
+									"report_safe" => "1"
+								);
+
+// define languages
+$sauserprefs_config['languages'] = array(
+									"af" => "Afrikaans",
+									"sq" => "Albanian",
+									"am" => "Amharic",
+									"ar" => "Arabic",
+									"hy" => "Armenian",
+									"eu" => "Basque",
+									"bs" => "Bosnian",
+									"bg" => "Bulgarian",
+									"be" => "Byelorussian",
+									"ca" => "Catalan",
+									"zh" => "Chinese",
+									"hr" => "Croatian",
+									"cs" => "Czech",
+									"da" => "Danish",
+									"nl" => "Dutch",
+									"en" => "English",
+									"eo" => "Esperanto",
+									"et" => "Estonian",
+									"fi" => "Finnish",
+									"fr" => "French",
+									"fy" => "Frisian",
+									"ka" => "Georgian",
+									"de" => "German",
+									"el" => "Greek",
+									"he" => "Hebrew",
+									"hi" => "Hindi",
+									"hu" => "Hungarian",
+									"is" => "Icelandic",
+									"id" => "Indonesian",
+									"ga" => "Irish Gaelic",
+									"it" => "Italian",
+									"ja" => "Japanese",
+									"ko" => "Korean",
+									"la" => "Latin",
+									"lv" => "Latvian",
+									"lt" => "Lithuanian",
+									"ms" => "Malay",
+									"mr" => "Marathi",
+									"ne" => "Nepali",
+									"no" => "Norwegian",
+									"fa" => "Persian",
+									"pl" => "Polish",
+									"pt" => "Portuguese",
+									"qu" => "Quechua",
+									"rm" => "Rhaeto-Romance",
+									"ro" => "Romanian",
+									"ru" => "Russian",
+									"sa" => "Sanskrit",
+									"sco" => "Scots",
+									"gd" => "Scottish Gaelic",
+									"sr" => "Serbian",
+									"sk" => "Slovak",
+									"sl" => "Slovenian",
+									"es" => "Spanish",
+									"sw" => "Swahili",
+									"sv" => "Swedish",
+									"tl" => "Tagalog",
+									"ta" => "Tamil",
+									"th" => "Thai",
+									"tr" => "Turkish",
+									"uk" => "Ukrainian",
+									"vi" => "Vietnamese",
+									"cy" => "Welsh",
+									"yi" => "Yiddish"
+								);
+?>
\ No newline at end of file
diff -Naur --exclude='*.svn*' roundcube_svn/plugins/sauserprefs/disabled.png roundcube_pub/plugins/sauserprefs/disabled.png
--- roundcube_svn/plugins/sauserprefs/disabled.png	1970-01-01 01:00:00.000000000 +0100
+++ roundcube_pub/plugins/sauserprefs/disabled.png	2008-08-16 18:55:05.000000000 +0100
@@ -0,0 +1,5 @@
+�PNG
+
+
+
+(��#x��Q@
\ No newline at end of file
diff -Naur --exclude='*.svn*' roundcube_svn/plugins/sauserprefs/enabled.png roundcube_pub/plugins/sauserprefs/enabled.png
--- roundcube_svn/plugins/sauserprefs/enabled.png	1970-01-01 01:00:00.000000000 +0100
+++ roundcube_pub/plugins/sauserprefs/enabled.png	2008-08-16 18:55:05.000000000 +0100
@@ -0,0 +1,5 @@
+�PNG
+
+
+���b[�a�='�L�a�W�{����x���D����[�u9J�B�GqzfGN��0��os��6�"f��fh�ZR��".��2H-[��{���(7�h�@`%E��[I��W�u3��e�+� ����l�GQ&���'� ������������k|���<R
+H
\ No newline at end of file
diff -Naur --exclude='*.svn*' roundcube_svn/plugins/sauserprefs/func.inc roundcube_pub/plugins/sauserprefs/func.inc
--- roundcube_svn/plugins/sauserprefs/func.inc	1970-01-01 01:00:00.000000000 +0100
+++ roundcube_pub/plugins/sauserprefs/func.inc	2008-08-16 18:55:05.000000000 +0100
@@ -0,0 +1,465 @@
+<?php
+
+/*
+ +-----------------------------------------------------------------------+
+ | plugins/sauserprefs/func.inc 										 |
+ |																		 |
+ | This file is part of the RoundCube Webmail client					 |
+ | Copyright (C) 2008, RoundCube Dev. - Switzerland 					 |
+ | Licensed under the GNU GPL											 |
+ |																		 |
+ | PURPOSE: 															 |
+ |	 Provide functionality for user's spamassassin settings modification |
+ |																		 |
+ | CREDITS:                                                              |
+ |   Based on webuserprefs http://sourceforge.net/projects/webuserprefs/ |
+ +-----------------------------------------------------------------------+
+ | Author: Philip Weir													 |
+ +-----------------------------------------------------------------------+
+ | Requires: plugins/sauserprefs/config.inc.php                          |
+ +-----------------------------------------------------------------------+
+
+ $Id: $
+
+*/
+
+require_once('plugins/sauserprefs/config.inc.php');
+
+function rcmail_sauserprefs_form($attrib){
+	global $RCMAIL, $sauserprefs_config;
+
+	// add some labels to client
+	rcube_add_label('spamaddressexists');
+	rcube_add_label('spamenteraddress');
+	rcube_add_label('spamaddresserror');
+	rcube_add_label('enabled');
+	rcube_add_label('disabled');
+
+	$user_dbclass = "rcube_" . $sauserprefs_config['db_backend'];
+	$user_db = new $user_dbclass($sauserprefs_config['db_dsnw'], $sauserprefs_config['db_dsnr'], $sauserprefs_config['db_persistent']);
+	$user_db->db_connect('r');
+	
+	// check DB connections and exit on failure
+	if ($err_str = $user_db->is_error()) {
+	  raise_error(array(
+	    'code' => 603,
+	    'type' => 'db',
+	    'message' => $err_str), FALSE, TRUE);
+	}
+	
+	// global settings
+	$global_prefs = array();
+	
+	$sql_result = $user_db->query(
+	  "SELECT ". $sauserprefs_config['sql_preference_field'] .", ". $sauserprefs_config['sql_value_field'] ."
+	   FROM   ". $sauserprefs_config['sql_table_name'] ."
+	   WHERE  ". $sauserprefs_config['sql_username_field'] ."='\$GLOBAL'
+	   AND    ". $sauserprefs_config['sql_preference_field'] ." <> 'whitelist_from' 
+	   AND    ". $sauserprefs_config['sql_preference_field'] ." <> 'blacklist_from' 
+	   AND    ". $sauserprefs_config['sql_preference_field'] ." <> 'whitelist_to';"
+   	  );
+		  
+	while ($sql_result && ($sql_arr = $user_db->fetch_assoc($sql_result)))
+	    $global_prefs[$sql_arr[$sauserprefs_config['sql_preference_field']]] = $sql_arr[$sauserprefs_config['sql_value_field']];
+    	
+	// user settings
+	$user_prefs = array();
+	
+	$sql_result = $user_db->query(
+	  "SELECT ". $sauserprefs_config['sql_preference_field'] .", ". $sauserprefs_config['sql_value_field'] ."
+	   FROM   ". $sauserprefs_config['sql_table_name'] ."
+	   WHERE  ". $sauserprefs_config['sql_username_field'] ."='".$_SESSION['username']."'
+	   AND    ". $sauserprefs_config['sql_preference_field'] ." <> 'whitelist_from' 
+	   AND    ". $sauserprefs_config['sql_preference_field'] ." <> 'blacklist_from' 
+	   AND    ". $sauserprefs_config['sql_preference_field'] ." <> 'whitelist_to';"
+	  );
+	
+    while ($sql_result && ($sql_arr = $user_db->fetch_assoc($sql_result)))
+	    $user_prefs[$sql_arr[$sauserprefs_config['sql_preference_field']]] = $sql_arr[$sauserprefs_config['sql_value_field']];
+ 
+	$global_prefs = array_merge($sauserprefs_config['default_prefs'], $global_prefs);
+	$user_prefs = array_merge($global_prefs, $user_prefs);
+
+	list($form_start, $form_end) = get_form_tags($attrib, 'save-sauserprefs');
+	unset($attrib['form']);
+
+	// allow the following attributes to be added to the <table> tag
+	$attrib_str = create_attrib_string($attrib, array('style', 'class', 'id', 'cellpadding', 'cellspacing', 'border', 'summary'));
+
+	$out = $form_start;
+	if ($sauserprefs_config['settings']['score'] || $sauserprefs_config['settings']['subject'] || $sauserprefs_config['settings']['language']){
+		// return the complete edit form as table
+		$out .= "<fieldset><legend>" . Q(rcube_label('spamgeneralsettings')) . "</legend>\n<table" . $attrib_str . ">\n\n";
+	
+		if ($sauserprefs_config['settings']['score']) {
+			$field_id = 'rcmfd_spamthres';
+			$input_spamthres = new html_select(array('name' => '_spamthres', 'id' => $field_id));
+			$input_spamthres->add('1','1');
+			$input_spamthres->add('2','2');
+			$input_spamthres->add('3','3');
+			$input_spamthres->add('4','4');
+			$input_spamthres->add('5','5');
+			$input_spamthres->add('6','6');
+			$input_spamthres->add('7','7');
+			$input_spamthres->add('8','8');
+			$input_spamthres->add('9','9');
+			$input_spamthres->add('10','10');
+		
+			$out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
+							$field_id,
+							rep_specialchars_output(rcube_label('spamthres')),
+							$input_spamthres->show($user_prefs['required_hits']));
+		
+			$out .= sprintf("<tr><td colspan=\"4\">%s</td></tr>\n",
+							rep_specialchars_output(rcube_label('spamthresexp')));
+		}
+		
+		if ($sauserprefs_config['settings']['subject']) {
+			if ($sauserprefs_config['settings']['score']) $out .= "<tr><td>&nbsp;</td></tr>\n";
+						
+			$field_id = 'rcmfd_spamsubject';
+			$input_spamsubject = new html_inputfield(array('name' => '_spamsubject', 'id' => $field_id, 'value' => $user_prefs['rewrite_header Subject'], 'style' => 'width:200px;'));
+		
+			$out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
+							$field_id,
+							rep_specialchars_output(rcube_label('spamsubject')),
+							$input_spamsubject->show());
+		
+			$out .= sprintf("<tr><td></td><td>%s</td></tr>\n",
+							rep_specialchars_output(rcube_label('spamsubjectblank')));
+		}
+	
+		if ($sauserprefs_config['settings']['language']) {
+			if ($sauserprefs_config['settings']['subject'] || ($sauserprefs_config['settings']['score'] && !$sauserprefs_config['settings']['subject'])) $out .= "<tr><td>&nbsp;</td></tr>\n";
+			
+			$out .= sprintf("<tr><td class=\"title\" valign=\"top\">%s</td></tr>\n",
+							rep_specialchars_output(rcube_label('spamlang')));
+							
+			$out .= sprintf("<tr><td colspan=\"4\">%s</td></tr>\n",
+							rep_specialchars_output(rcube_label('spamlangexp')));
+							
+			$out .= "<tr><td>&nbsp;</td></tr>\n";
+			
+			if (!empty($attrib['enableicon']))
+				$enable_button = sprintf('<img src="%s" alt="%s" border="0" />', $attrib['enableicon'], rcube_label('enabled'));
+			else
+				$enable_button = rcube_label('enabled');
+				
+			if (!empty($attrib['disableicon']))
+				$disable_button = sprintf('<img src="%s" alt="%s" border="0" />', $attrib['disableicon'], rcube_label('disabled'));
+			else
+				$disable_button = rcube_label('disabled');
+	
+				
+				
+
+					
+			$out .= "<tr><td colspan=\"3\" id=\"listcontrols\">".rcube_label('select').":&nbsp;<a href=\"#\" onclick=\"return select_all_langs()\">".rcube_label('all')."</a>&nbsp;<a href=\"#\" onclick=\"return select_no_langs()\">".rcube_label('none')."</a></td></tr>\n";
+			$out .= "<tr><td colspan=\"3\">\n";
+		
+			$field_id = 'rcmfd_spamlang';
+			$input_spamlang = new html_select(array('name' => '_spamlang[]', 'id' => $field_id, 'multiple' => 'multiple', 'style' => 'display: none;'));
+			
+			$out .= "<div id='spam-langs-cont'><table class=\"records-table\" id=\"spam-langs-table\" cellspacing=\"0\" summary=\"". rcube_label('spamlang') ."\">";
+			$out .= "<thead>";
+			$out .= sprintf("<tr><td>%s</td><td width=\"40px\">&nbsp;</td></tr>\n",
+							rep_specialchars_output(rcube_label('language')));
+			$out .= "</thead>";
+			$out .= "<tbody>";
+		
+			$out .= "<tr style=\"display: none;\"><td id=\"enable_button\">".$enable_button."</td><td id=\"disable_button\">".$disable_button."</td></tr>";
+
+			if ($user_prefs['ok_locales'] == "all")
+				$ok_locales = array_keys($sauserprefs_config['languages']);
+			else
+				$ok_locales = split(" ", $user_prefs['ok_locales']);
+	
+			$i = 0;
+			foreach ($sauserprefs_config['languages'] as $lang_code => $name) {
+				$input_spamlang->add($name,$lang_code);
+				
+				if (in_array($lang_code, $ok_locales)) {
+					$action = rcube_label('enabled');
+					$button = $enable_button;
+				}
+				else {
+					$action = rcube_label('disabled');
+					$button = $disable_button;
+				}	
+				
+				$out .= sprintf("<tr><td valign=\"middle\">%s</td><td style=\"text-align: right;\" valign=\"middle\">&nbsp;<a id=\"spam_lang_".$i."\" href=\"#\" onclick=\"return message_lang('".$lang_code."', this);\" title=\"%s\">%s</a></td></tr>\n",
+								$name,
+								$action,
+								$button);
+								
+				$i++;
+			}
+		
+			$out .= "</tbody></table></div>";
+		
+			$out .= $input_spamlang->show($ok_locales);
+			
+			$out .= "</td></tr>\n";
+		}
+		
+		$out .= "</table></fieldset>\n";
+	}
+
+	if ($sauserprefs_config['settings']['headers']) {
+		$out .= "<fieldset><legend>" . Q(rcube_label('headers')) . "</legend>\n<table" . $attrib_str . ">\n\n";
+		
+		$out .= sprintf("<tr><td colspan=\"4\">%s</td></tr>\n",
+						rep_specialchars_output(rcube_label('headersexp')));
+						
+		$out .= "<tr><td>&nbsp;</td></tr>\n";
+
+		$field_id = 'rcmfd_spamfoldheaders';
+		$input_spamshortreport = new html_checkbox(array('name' => '_spamfoldheaders', 'id' => $field_id, 'value' => '1'));
+	
+		$out .= sprintf("<tr><td>%s&nbsp;<label for=\"%s\">%s</label></td></tr>\n",
+						$input_spamshortreport->show($user_prefs['fold_headers']),
+						$field_id,
+						rep_specialchars_output(rcube_label('foldheaders')));
+
+		if ($user_prefs['remove_header all'] != 'Level') {
+			$enabled = "1";
+			$char = $user_prefs['add_header all Level'];
+			$char = substr($char, 7, 1);
+		}
+		else {
+			$enabled = "0";
+			$char = "*";
+		}
+		
+		$field_id = 'rcmfd_spamlevelstars';
+		$input_spamshortreport = new html_checkbox(array('name' => '_spamlevelstars', 'id' => $field_id, 'value' => '1'));
+	
+		$out .= sprintf("<tr><td>%s&nbsp;<label for=\"%s\">%s</label></td></tr>\n",
+						$input_spamshortreport->show($enabled),
+						$field_id,
+						rep_specialchars_output(rcube_label('spamlevelstars')));
+
+		$field_id = 'rcmfd_spamlevelchar';
+		$input_spamsubject = new html_inputfield(array('name' => '_spamlevelchar', 'id' => $field_id, 'value' => $char, 'style' => 'width:20px;'));
+	
+		$out .= sprintf("<tr><td style=\"padding-left: 30px;\">%s&nbsp;<label for=\"%s\">%s</label></td></tr>\n",
+						$input_spamsubject->show(),
+						$field_id,
+						rep_specialchars_output(rcube_label('spamlevelchar')));
+
+		$out .= "</table></fieldset>\n";
+	}
+	
+	if ($sauserprefs_config['settings']['tests']) {
+		$out .= "<fieldset><legend>" . Q(rcube_label('spamtests')) . "</legend>\n<table" . $attrib_str . ">\n\n";
+		
+		$out .= sprintf("<tr><td colspan=\"4\">%s</td></tr>\n",
+						rep_specialchars_output(rcube_label('spamtestssexp')));
+						
+		$out .= "<tr><td>&nbsp;</td></tr>\n";
+	
+		$field_id = 'rcmfd_spamuserazor1';
+		$input_spamshortreport = new html_checkbox(array('name' => '_spamuserazor1', 'id' => $field_id, 'value' => '1'));
+	
+		$out .= sprintf("<tr><td>%s&nbsp;<label for=\"%s\">%s</label></td></tr>\n",
+						$input_spamshortreport->show($user_prefs['use_razor1']),
+						$field_id,
+						rep_specialchars_output(rcube_label('userazor1')));
+						
+		$field_id = 'rcmfd_spamuserazor2';
+		$input_spamshortreport = new html_checkbox(array('name' => '_spamuserazor2', 'id' => $field_id, 'value' => '1'));
+	
+		$out .= sprintf("<tr><td>%s&nbsp;<label for=\"%s\">%s</label></td></tr>\n",
+						$input_spamshortreport->show($user_prefs['use_razor2']),
+						$field_id,
+						rep_specialchars_output(rcube_label('userazor2')));
+						
+		$field_id = 'rcmfd_spamusepyzor';
+		$input_spamshortreport = new html_checkbox(array('name' => '_spamusepyzor', 'id' => $field_id, 'value' => '1'));
+	
+		$out .= sprintf("<tr><td>%s&nbsp;<label for=\"%s\">%s</label></td></tr>\n",
+						$input_spamshortreport->show($user_prefs['use_pyzor']),
+						$field_id,
+						rep_specialchars_output(rcube_label('usepyzor')));
+						
+		$field_id = 'rcmfd_spamusebayes';
+		$input_spamshortreport = new html_checkbox(array('name' => '_spamusebayes', 'id' => $field_id, 'value' => '1'));
+	
+		$out .= sprintf("<tr><td>%s&nbsp;<label for=\"%s\">%s</label></td></tr>\n",
+						$input_spamshortreport->show($user_prefs['use_bayes']),
+						$field_id,
+						rep_specialchars_output(rcube_label('usebayes')));
+						
+		$field_id = 'rcmfd_spamusedcc';
+		$input_spamshortreport = new html_checkbox(array('name' => '_spamusedcc', 'id' => $field_id, 'value' => '1'));
+	
+		$out .= sprintf("<tr><td>%s&nbsp;<label for=\"%s\">%s</label></td></tr>\n",
+						$input_spamshortreport->show($user_prefs['use_dcc']),
+						$field_id,
+						rep_specialchars_output(rcube_label('usedcc')));
+				
+		if ($user_prefs['skip_rbl_checks'] == "1")
+			$enabled = "0";
+		else
+			$enabled = "1";
+	
+		$field_id = 'rcmfd_spamskiprblchecks';
+		$input_spamshortreport = new html_checkbox(array('name' => '_spamskiprblchecks', 'id' => $field_id, 'value' => '1'));
+	
+		$out .= sprintf("<tr><td>%s&nbsp;<label for=\"%s\">%s</label></td></tr>\n",
+						$input_spamshortreport->show($enabled),
+						$field_id,
+						rep_specialchars_output(rcube_label('skiprblchecks')));
+						
+		$out .= "</table></fieldset>\n";
+	}
+		
+	if ($sauserprefs_config['settings']['report']) {
+		$out .= "<fieldset><legend>" . Q(rcube_label('spamreportsettings')) . "</legend>\n<table" . $attrib_str . ">\n\n";
+	
+		$out .= sprintf("<tr><td colspan=\"4\">%s</td></tr>\n",
+						rep_specialchars_output(rcube_label('spamreport')));
+						
+		$out .= "<tr><td>&nbsp;</td></tr>\n";
+	
+		$field_id = 'rcmfd_spamreport';
+		$input_spamreport0 = new html_radiobutton(array('name' => '_spamreport', 'id' => $field_id.'_0', 'value' => '0'));
+		$input_spamreport1 = new html_radiobutton(array('name' => '_spamreport', 'id' => $field_id.'_1', 'value' => '1'));
+		$input_spamreport2 = new html_radiobutton(array('name' => '_spamreport', 'id' => $field_id.'_2', 'value' => '2'));
+	
+		$out .= sprintf("<tr><td>%s&nbsp;<label for=\"%s_0\">%s</label></td></tr>\n",
+						$input_spamreport0->show($user_prefs['report_safe']),
+						$field_id,
+						rep_specialchars_output(rcube_label('spamreport0')));
+	
+		$out .= sprintf("<tr><td>%s&nbsp;<label for=\"%s_1\">%s</label></td></tr>\n",
+						$input_spamreport1->show($user_prefs['report_safe']),
+						$field_id,
+						rep_specialchars_output(rcube_label('spamreport1')),
+						$input_spamreport1->show($user_prefs['report_safe']));
+						
+		$out .= sprintf("<tr><td>%s&nbsp;<label for=\"%s_2\">%s</label></td></tr>\n",
+						$input_spamreport2->show($user_prefs['report_safe']),
+						$field_id,
+						rep_specialchars_output(rcube_label('spamreport2')));
+	
+		$out .= "</table></fieldset>\n";
+	}
+	
+	if ($sauserprefs_config['settings']['addresses']) {
+		$out .= "<fieldset><legend>" . Q(rcube_label('spamaddressrules')) . "</legend>\n<table" . $attrib_str . " id=\"address-rules-frame\">\n\n";
+		
+		$out .= sprintf("<tr><td colspan=\"4\">%s</td></tr>\n",
+						rep_specialchars_output(rcube_label('autowhitelist')));
+	
+		$out .= "<tr><td>&nbsp;</td></tr>\n";
+		
+		$field_id = 'rcmfd_spamaddressrule';
+		$input_spamaddressrule = new html_select(array('name' => '_spamaddressrule', 'id' => $field_id));
+		$input_spamaddressrule->add(rcube_label('whitelist_from'),'whitelist_from');
+		$input_spamaddressrule->add(rcube_label('blacklist_from'), 'blacklist_from');
+		$input_spamaddressrule->add(rcube_label('whitelist_to'), 'whitelist_to');
+	
+		$field_id = 'rcmfd_spamaddress';
+		$input_spamaddress = new html_inputfield(array('name' => '_spamaddress', 'id' => $field_id, 'style' => 'width:200px;'));
+	
+		$out .= sprintf("<tr><td>%s</td><td>%s</td><td align=\"right\"><input type=\"button\" value=\"%s\" onclick=\"addressrule_add()\" id=\"rcmbtn_badd\" class=\"button\" style=\"width:75px;\" /></td></tr>\n",
+						$input_spamaddressrule->show(),
+						$input_spamaddress->show(),
+						rep_specialchars_output(rcube_label('add')));
+	
+		$out .= "<tr><td>&nbsp;</td></tr>\n";
+		
+		if (!empty($attrib['deleteicon']))
+			$del_button = sprintf('<img src="%s%s" alt="%s" border="0" />', $RCMAIL->config->get('skin_path'), $attrib['deleteicon'], rcube_label('delete'));
+		else
+			$del_button = rcube_label('delete');
+	
+		$out .= "<tr><td colspan=\"3\">\n";
+	
+		$out .= "<div id='address-rules-cont'><table class=\"records-table\" id=\"address-rules-table\" cellspacing=\"0\" summary=\"". rcube_label('spamaddressrules') ."\">";
+		$out .= "<thead>";
+		$out .= sprintf("<tr><td width=\"180px\">%s</td><td>%s</td><td width=\"40px\">&nbsp;</td></tr>\n",
+						rep_specialchars_output(rcube_label('rule')),
+						rep_specialchars_output(rcube_label('email')));
+		$out .= "</thead>";
+		$out .= "<tbody>";
+	
+		$hidden_action = new html_hiddenfield(array('name' => '_address_rule_act_rowid', 'id' => 'rcmfd_address_rule_act_rowid'));
+		$hidden_field = new html_hiddenfield(array('name' => '_address_rule_field_rowid', 'id' => 'rcmfd_address_rule_field_rowid'));
+		$hidden_text = new html_hiddenfield(array('name' => '_address_rule_value_rowid', 'id' => 'rcmfd_address_rule_value_rowid'));
+	
+		$out .= sprintf("<tr style=\"display: none;\"><td valign=\"middle\" id=\"address_rule_rowid\"></td><td valign=\"middle\" id=\"address_rowid\"></td><td style=\"text-align: right;\" valign=\"middle\">&nbsp;<a id=\"rcmfd_address_rule_del_rowid\" href=\"#\" onclick=\"return addressrule_del('rowid', this);\" title=\"%s\">".$del_button."</a>%s</td></tr>\n",
+						rcube_label('delete'),
+						$hidden_action->show() . $hidden_field->show() . $hidden_text->show());
+			  
+		$sql_result = $user_db->query(
+		  "SELECT ". $sauserprefs_config['sql_preference_field'] .", ". $sauserprefs_config['sql_value_field'] ."
+		   FROM   ". $sauserprefs_config['sql_table_name'] ."
+		   WHERE  ". $sauserprefs_config['sql_username_field'] ."='".$_SESSION['username']."'
+		   AND   (". $sauserprefs_config['sql_preference_field'] ." = 'whitelist_from' 
+		   OR     ". $sauserprefs_config['sql_preference_field'] ." = 'blacklist_from' 
+		   OR     ". $sauserprefs_config['sql_preference_field'] ." = 'whitelist_to')
+		   ORDER BY ". $sauserprefs_config['sql_value_field'] .";"
+		  );
+		    
+		$i = 1;
+		while ($sql_result && ($sql_arr = $user_db->fetch_assoc($sql_result))) {
+			$field = $sql_arr[$sauserprefs_config['sql_preference_field']];
+			$value = $sql_arr[$sauserprefs_config['sql_value_field']];
+			
+			$hidden_action = new html_hiddenfield(array('name' => '_address_rule_act_' . $i, 'id' => 'rcmfd_address_rule_act_' . $i, 'value' => ''));
+			$hidden_field = new html_hiddenfield(array('name' => '_address_rule_field_' . $i, 'id' => 'rcmfd_address_rule_field_' . $i, 'value' => $field));
+			$hidden_text = new html_hiddenfield(array('name' => '_address_rule_value_' . $i, 'id' => 'rcmfd_address_rule_value_' . $i, 'value' => $value));
+			
+			switch ($field) {
+				case "whitelist_from":
+					$fieldtxt = rep_specialchars_output(rcube_label('whitelist_from'));
+					break;
+				case "blacklist_from":
+					$fieldtxt = rep_specialchars_output(rcube_label('blacklist_from'));
+					break;
+				case "whitelist_to":
+					$fieldtxt = rep_specialchars_output(rcube_label('whitelist_to'));
+					break;
+			}
+	
+			$out .= sprintf("<tr><td valign=\"middle\" id=\"address_rule_".$i."\" class=\"%s\">%s</td><td valign=\"middle\" id=\"address_".$i."\">%s</td><td style=\"text-align: right;\" valign=\"middle\">&nbsp;<a id=\"rcmfd_address_rule_del_".$i."\" href=\"#\" onclick=\"return addressrule_del('".$i."', this);\" title=\"%s\">".$del_button."</a>%s</td></tr>\n",
+							$field,
+							$fieldtxt,
+							$value,
+							rcube_label('delete'),
+							$hidden_action->show() . $hidden_field->show() . $hidden_text->show());
+		
+			$i++;
+		}
+			
+		if ($i == 1)  {
+			$out .= sprintf("<tr id=\"filter_table_none\"><td colspan=\"3\">%s</td></tr>\n",
+							rep_specialchars_output(rcube_label('noaddressrules')));
+		}
+	
+		$out .= "</tbody></table>";
+		
+		$out .= "<table id=\"address-rules-table-none\" style=\"display: none;\"><tbody>";
+		$out .= sprintf("<tr id=\"filter_table_none\"><td colspan=\"3\">%s</td></tr>\n",
+						rep_specialchars_output(rcube_label('noaddressrules')));
+		$out .= "</tbody></table></div>";
+		
+		$hidden_addressrulecount = new html_hiddenfield(array('name' => '_addressrulecount', 'id' => 'rcmfd_addressrulecount', 'value' => $i - 1));
+	
+		$out .= $hidden_addressrulecount->show();
+		$out .= "</td></tr>\n";
+	
+		$out .= "\n</table></fieldset>";
+	}
+
+	$out .= sprintf("<p><input type=\"submit\" value=\"%s\" class=\"button\" /></p>\n",
+					rep_specialchars_output(rcube_label('save')));
+
+	$out .= $form_end;
+
+	return $out;
+}
+
+?>
\ No newline at end of file
diff -Naur --exclude='*.svn*' roundcube_svn/plugins/sauserprefs/sauserprefs.php roundcube_pub/plugins/sauserprefs/sauserprefs.php
--- roundcube_svn/plugins/sauserprefs/sauserprefs.php	1970-01-01 01:00:00.000000000 +0100
+++ roundcube_pub/plugins/sauserprefs/sauserprefs.php	2008-08-16 18:55:05.000000000 +0100
@@ -0,0 +1,32 @@
+<?php
+
+/*
+ +-----------------------------------------------------------------------+
+ | plugins/sauserprefs/sauserprefs.php  								 |
+ |																		 |
+ | This file is part of the RoundCube Webmail client					 |
+ | Copyright (C) 2008, RoundCube Dev. - Switzerland 					 |
+ | Licensed under the GNU GPL											 |
+ |																		 |
+ | PURPOSE: 															 |
+ |	 Provide functionality for user's spamassassin settings modification |
+ |   in an SQL database 												 |
+ |                       												 |
+ +-----------------------------------------------------------------------+
+ | Author: Philip Weir													 |
+ +-----------------------------------------------------------------------+
+
+ $Id: $
+
+*/
+
+class sauserprefs extends rcube_plugin
+{
+	function init()
+	{
+		// preperation for Plugin API
+		// not used yet
+	}
+}
+
+?>
\ No newline at end of file
diff -Naur --exclude='*.svn*' roundcube_svn/program/js/app.js roundcube_pub/program/js/app.js
--- roundcube_svn/program/js/app.js	2008-08-16 14:16:58.000000000 +0100
+++ roundcube_pub/program/js/app.js	2008-08-16 18:55:07.000000000 +0100
@@ -288,7 +288,8 @@
 
       case 'settings':
         this.enable_command('preferences', 'identities', 'save', 'folders', true);
-        
+        this.enable_command('sauserprefs', true);
+
         if (this.env.action=='identities' || this.env.action=='edit-identity' || this.env.action=='add-identity')
           this.enable_command('edit', 'add', 'delete', true);
 
@@ -992,6 +993,10 @@
         this.goto_url('identities');
         break;
           
+      case 'sauserprefs':
+        this.goto_url('sauserprefs');
+        break;  
+        
       case 'delete-identity':
         this.delete_identity();
         
diff -Naur --exclude='*.svn*' roundcube_svn/program/js/sauserprefs.js roundcube_pub/program/js/sauserprefs.js
--- roundcube_svn/program/js/sauserprefs.js	1970-01-01 01:00:00.000000000 +0100
+++ roundcube_pub/program/js/sauserprefs.js	2008-08-16 18:55:05.000000000 +0100
@@ -0,0 +1,158 @@
+/*
+ +-----------------------------------------------------------------------+
+ | RoundCube Webmail Client Script										 |
+ |																		 |
+ | This file is part of the RoundCube Webmail client					 |
+ | Copyright (C) 2008, RoundCube Dev, - Switzerland 					 |
+ | Licensed under the GNU GPL											 |
+ |																		 |
+ +-----------------------------------------------------------------------+
+ | Author: Philip Weir													 |
+ +-----------------------------------------------------------------------+
+
+ $Id: $
+
+*/
+
+function select_all_langs() {
+	var langlist = rcube_find_object('_spamlang[]');
+	var obj;
+	
+	for (i = 0; i < langlist.options.length; i++) {
+		obj = rcube_find_object('spam_lang_'+ i)
+		langlist.options[i].selected = true;
+		obj.title = rcmail.get_label('enabled');
+		obj.innerHTML = rcube_find_object('enable_button').innerHTML;
+	}
+	
+	return false;
+}
+
+function select_no_langs() {
+	var langlist = rcube_find_object('_spamlang[]');
+	var obj;
+	
+	for (i = 0; i < langlist.options.length; i++) {
+		obj = rcube_find_object('spam_lang_'+ i)
+		langlist.options[i].selected = false;
+		obj.title = rcmail.get_label('disabled');
+		obj.innerHTML = rcube_find_object('disable_button').innerHTML;
+	}
+	
+	return false;
+}
+
+function message_lang(lang_code, obj) {
+	var langlist = rcube_find_object('_spamlang[]');
+	
+	for (i = 0; i < langlist.options.length; i++) {
+		if (langlist.options[i].value == lang_code && langlist.options[i].selected) {
+			langlist.options[i].selected = false;
+			obj.title = rcmail.get_label('disabled');
+			obj.innerHTML = rcube_find_object('disable_button').innerHTML;
+			break;
+		}
+		else if (langlist.options[i].value == lang_code && !langlist.options[i].selected) {
+			langlist.options[i].selected = true;
+			obj.title = rcmail.get_label('enabled');
+			obj.innerHTML = rcube_find_object('enable_button').innerHTML;
+			break;
+		}
+	}
+	
+	return false;
+}
+
+function addressrule_del(props, obj) {
+	if (rcube_find_object('_address_rule_act_'+ props).value == "INSERT") {
+		var count = rcube_find_object('_addressrulecount').value;
+		var curRow = rcube_find_object('address-rules-table');
+
+		curRow.deleteRow(obj.parentNode.parentNode.rowIndex);
+		count--;
+
+		if (count == 0){
+			var tblBody = rcube_find_object('address-rules-table').tBodies[0];
+			var tblBody1 = rcube_find_object('address-rules-table-none').tBodies[0];
+			var newNode = tblBody1.rows[0].cloneNode(true);
+			tblBody.appendChild(newNode);
+		}
+
+		rcube_find_object('_addressrulecount').value = count;
+	}
+	else{
+		rcube_find_object('address_rule_'+ props).style.textDecoration = 'line-through';
+		rcube_find_object('address_'+ props).style.textDecoration = 'line-through';
+		rcube_find_object('rcmfd_address_rule_del_'+ props).style.display = "none";
+		rcube_find_object('_address_rule_act_'+ props).value = "DELETE";
+	}
+	
+	return false;
+}
+
+function addressrule_add() {
+	var input_spamaddressrule = rcube_find_object('_spamaddressrule');
+	var selrule = input_spamaddressrule.selectedIndex;
+	var input_spamaddress = rcube_find_object('_spamaddress');
+	var count = rcube_find_object('_addressrulecount').value;
+			
+	if (input_spamaddress.value.replace(/^\s+|\s+$/g, '')==''){
+		alert(rcmail.get_label('spamenteraddress'));
+		input_spamaddress.focus();
+	}
+	else if (!rcube_check_email(input_spamaddress.value.replace(/^\s+/, '').replace(/[\s,;]+$/, ''), true)){
+		alert(rcmail.get_label('spamaddresserror'));
+		input_spamaddress.focus();
+	}
+	else{
+		var exts = false;
+		var insHere;
+		
+		for (var i = 0; i <= count; i++){
+			if (rcube_find_object('address_'+ i)){
+				if (rcube_find_object('_address_rule_value_'+ i).value == input_spamaddress.value && rcube_find_object('_address_rule_act_'+ i).value != "DELETE") { 
+					alert(rcmail.get_label('spamaddressexists'));
+					input_spamaddress.focus();
+					exts = true;
+					break;
+				} else if (rcube_find_object('_address_rule_value_'+ i).value > input_spamaddress.value) {
+					insHere = rcube_find_object('address-rules-table').rows[rcube_find_object('_address_rule_value_'+ i).parentNode.parentNode.rowIndex];
+					break;
+				}
+			}
+		}
+		
+		if (!exts){
+			var tblBody = rcube_find_object('address-rules-table').tBodies[0];
+			var newNode = tblBody.rows[0].cloneNode(true);
+			count++;
+			
+			if (count == 1)
+				tblBody.deleteRow(1);
+				
+			if (insHere)
+				insHere.parentNode.insertBefore(newNode, insHere);
+			else
+				tblBody.appendChild(newNode);
+						
+			newNode.style.display = "";
+			
+			newNode.cells[0].id = newNode.cells[0].id.replace('rowid', count);
+			newNode.cells[1].id = newNode.cells[1].id.replace('rowid', count);
+			newNode.cells[2].id = newNode.cells[2].id.replace('rowid', count);
+			newNode.cells[2].innerHTML = newNode.cells[2].innerHTML.replace(/rowid/g, count);
+	
+			rcube_find_object('address_rule_'+ count).className = input_spamaddressrule.options[selrule].value;
+			rcube_find_object('address_rule_'+ count).innerHTML = input_spamaddressrule.options[selrule].text;
+			rcube_find_object('address_'+ count).innerHTML = input_spamaddress.value;
+			rcube_find_object('_address_rule_act_'+ count).value = "INSERT";
+			rcube_find_object('_address_rule_field_'+ count).value = input_spamaddressrule.options[selrule].value;
+			rcube_find_object('_address_rule_value_'+ count).value = input_spamaddress.value;
+	
+			rcube_find_object('_addressrulecount').value = count;
+			
+			input_spamaddressrule.selectedIndex = 0;
+			input_spamaddress.value = '';
+		}
+	}
+}
\ No newline at end of file
diff -Naur --exclude='*.svn*' roundcube_svn/program/localization/en_US/labels.inc roundcube_pub/program/localization/en_US/labels.inc
--- roundcube_svn/program/localization/en_US/labels.inc	2008-08-01 14:13:41.000000000 +0100
+++ roundcube_pub/program/localization/en_US/labels.inc	2008-08-16 18:55:06.000000000 +0100
@@ -292,4 +292,38 @@
 $labels['sortasc']  = 'Sort ascending';
 $labels['sortdesc'] = 'Sort descending';
 
+$labels['add'] = 'Add';
+
+$labels['sauserprefs']  = 'Spam';
+$labels['sauserprefssettings']  = 'Spam Settings';
+$labels['spamgeneralsettings']  = 'General Settings';
+$labels['spamthres']  = 'Score threshold';
+$labels['spamsubject']  = 'Subject tag';
+$labels['spamsubjectblank']  = '(leave blank for none)';
+$labels['spamlang']  = 'Message Languages';
+$labels['enabled']  = 'Enabled';
+$labels['disabled']  = 'Disabled';
+$labels['headers'] = "Message Headers";
+$labels['headersexp'] = "SpamAssassin adds headers to processed messages providing information about the results. Use the options below to configure these headers.";
+$labels['foldheaders'] = "Allow multiple lines in headers";
+$labels['spamlevelstars'] = "Use 'Spam Level' header";
+$labels['spamlevelchar'] = "Spam level character";
+$labels['spamtests'] = "Internet Based Spam Tests";
+$labels['spamtestssexp'] = "Some checks use internet based services to help identify spam. Select the ones you wish to use:";
+$labels['userazor1'] = "Use Razor v1";
+$labels['userazor2'] = "Use Razor v2";
+$labels['usepyzor'] = "Use Pyzor";
+$labels['usebayes'] = "Use naive Bayesian style classifier";
+$labels['usedcc'] = "Use DCC";
+$labels['skiprblchecks'] = "Use Realtime Blackhole List";
+$labels['spamreportsettings']  = 'Report Settings';
+$labels['spamreport0']  = 'Include report in headers of original message';
+$labels['spamreport1']  = 'Include original as MIME attachment to report';
+$labels['spamreport2']  = 'Include original as text-only attachment to report';
+$labels['spamaddressrules']  = 'Address Rules';
+$labels['whitelist_from']  = 'Accept Mail From';
+$labels['blacklist_from']  = 'Reject Mail From';
+$labels['whitelist_to']  = 'Accept Mail Sent To';
+$labels['rule']  = 'Rule';
+
 ?>
diff -Naur --exclude='*.svn*' roundcube_svn/program/localization/en_US/messages.inc roundcube_pub/program/localization/en_US/messages.inc
--- roundcube_svn/program/localization/en_US/messages.inc	2008-08-16 14:16:58.000000000 +0100
+++ roundcube_pub/program/localization/en_US/messages.inc	2008-08-16 18:55:07.000000000 +0100
@@ -81,4 +81,15 @@
 $messages['addsubfolderhint'] = 'This folder will be created as subfolder of the currently selected one';
 $messages['forbiddencharacter'] = 'Folder name contains a forbidden character';
 
+$messages['sauserprefchanged'] = 'Successfully changed spam settings';
+$messages['sauserpreffailed'] = 'Error: Cannot change spam settings';
+$messages['spamthresexp'] = 'Anything above the threshold is marked as spam. Increasing this threshold will increase the amount of spam missed, but will reduce the risk of false positives.';
+$messages['spamlangexp'] = 'Select all the languages you expect to receive e-mail in. Any messages received that are written in non selected languages will be treated as possible spam.';
+$messages['spamreport']  = 'When a message is identified as spam a report of all tests and scores assigned is created...';
+$messages['autowhitelist'] = 'An asterisk (*) can be used as a wild card for greater flexibility. For example: *@example.com or *@*.example.com.';
+$messages['spamaddressexists'] = 'A rule already exists for this address';
+$messages['spamenteraddress'] = 'Please enter an address to add';
+$messages['spamaddresserror'] = 'Error: Address appears invalid';
+$messages['noaddressrules'] = 'You currently have no address rules setup.';
+
 ?>
\ No newline at end of file
diff -Naur --exclude='*.svn*' roundcube_svn/program/steps/settings/sauserprefs.inc roundcube_pub/program/steps/settings/sauserprefs.inc
--- roundcube_svn/program/steps/settings/sauserprefs.inc	1970-01-01 01:00:00.000000000 +0100
+++ roundcube_pub/program/steps/settings/sauserprefs.inc	2008-08-16 18:55:05.000000000 +0100
@@ -0,0 +1,31 @@
+<?php
+
+/*
+ +-----------------------------------------------------------------------+
+ | plugins/sauserprefs/sauserprefs.inc                                   |
+ |                                                                       |
+ | This file is part of the RoundCube Webmail client                     |
+ | Copyright (C) 2008, RoundCube Dev. - Switzerland                      |
+ | Licensed under the GNU GPL                                            |
+ |                                                                       |
+ | PURPOSE:                                                              |
+ |   Change user spam assassin settings in sql                           |
+ |                                                                       |
+ +-----------------------------------------------------------------------+
+ | Author: Philip Weir                                                   |
+ +-----------------------------------------------------------------------+
+ | Requires: plugins/sauserprefs/func.inc                                |
+ +-----------------------------------------------------------------------+
+
+ $Id: $
+
+*/
+
+require_once('plugins/sauserprefs/func.inc');
+
+$OUTPUT->set_pagetitle(rcube_label('sauserprefssettings'));
+	
+$OUTPUT->add_handler('usersauserprefs', 'rcmail_sauserprefs_form');
+$OUTPUT->include_script('sauserprefs.js');
+$OUTPUT->send('sauserprefs');
+?>
\ No newline at end of file
diff -Naur --exclude='*.svn*' roundcube_svn/program/steps/settings/save_sauserprefs.inc roundcube_pub/program/steps/settings/save_sauserprefs.inc
--- roundcube_svn/program/steps/settings/save_sauserprefs.inc	1970-01-01 01:00:00.000000000 +0100
+++ roundcube_pub/program/steps/settings/save_sauserprefs.inc	2008-08-16 18:55:05.000000000 +0100
@@ -0,0 +1,202 @@
+<?php
+
+/*
+ +-----------------------------------------------------------------------+
+ | plugins/sauserprefs/save_sauserprefs.inc                              |
+ |                                                                       |
+ | This file is part of the RoundCube Webmail client                     |
+ | Copyright (C) 2008, RoundCube Dev. - Switzerland                      |
+ | Licensed under the GNU GPL                                            |
+ |                                                                       |
+ | PURPOSE:                                                              |
+ |   Save user spamassassin settings to sql                              |
+ |                                                                       |
+ +-----------------------------------------------------------------------+
+ | Author: Philip Weir                                                   |
+ +-----------------------------------------------------------------------+
+ | Requires: plugins/sauserprefs/config.inc.php                          |
+ +-----------------------------------------------------------------------+
+
+ $Id: $
+
+*/
+
+require_once('plugins/sauserprefs/config.inc.php');
+
+$user_dbclass = "rcube_" . $sauserprefs_config['db_backend'];
+$user_db = new $user_dbclass($sauserprefs_config['db_dsnw'], $sauserprefs_config['db_dsnr'], $sauserprefs_config['db_persistent']);
+$user_db->db_connect('w');
+
+// check DB connections and exit on failure
+if ($err_str = $user_db->is_error()) {
+  raise_error(array(
+    'code' => 603,
+    'type' => 'db',
+    'message' => $err_str), FALSE, TRUE);
+}
+	
+// global settings
+$global_prefs = array();
+
+$sql_result = $user_db->query(
+  "SELECT ". $sauserprefs_config['sql_preference_field'] .", ". $sauserprefs_config['sql_value_field'] ."
+   FROM   ". $sauserprefs_config['sql_table_name'] ."
+   WHERE  ". $sauserprefs_config['sql_username_field'] ."='\$GLOBAL'
+   AND    ". $sauserprefs_config['sql_preference_field'] ." <> 'whitelist_from' 
+   AND    ". $sauserprefs_config['sql_preference_field'] ." <> 'blacklist_from' 
+   AND    ". $sauserprefs_config['sql_preference_field'] ." <> 'whitelist_to';"
+  );
+	  
+while ($sql_result && ($sql_arr = $user_db->fetch_assoc($sql_result)))
+	$global_prefs[$sql_arr[$sauserprefs_config['sql_preference_field']]] = $sql_arr[$sauserprefs_config['sql_value_field']];
+	
+$global_prefs = array_merge($sauserprefs_config['default_prefs'], $global_prefs);
+
+// user settings
+$user_prefs = array();
+
+$sql_result = $user_db->query(
+  "SELECT ". $sauserprefs_config['sql_preference_field'] .", ". $sauserprefs_config['sql_value_field'] ."
+   FROM   ". $sauserprefs_config['sql_table_name'] ."
+   WHERE  ". $sauserprefs_config['sql_username_field'] ."='".$_SESSION['username']."'
+   AND    ". $sauserprefs_config['sql_preference_field'] ." <> 'whitelist_from' 
+   AND    ". $sauserprefs_config['sql_preference_field'] ." <> 'blacklist_from' 
+   AND    ". $sauserprefs_config['sql_preference_field'] ." <> 'whitelist_to';"
+  );
+
+while ($sql_result && ($sql_arr = $user_db->fetch_assoc($sql_result)))
+	$user_prefs[$sql_arr[$sauserprefs_config['sql_preference_field']]] = $sql_arr[$sauserprefs_config['sql_value_field']];
+    	    
+$new_prefs = array();
+
+if ($sauserprefs_config['settings']['score'])
+	$new_prefs['required_hits'] = $_POST['_spamthres'];
+	
+if ($sauserprefs_config['settings']['subject'])
+	$new_prefs['rewrite_header Subject'] = $_POST['_spamsubject'];
+
+if ($sauserprefs_config['settings']['language']) {
+	$new_prefs['ok_locales'] = implode(" ", $_POST['_spamlang']);
+	$new_prefs['ok_languages'] = $new_prefs['ok_locales'];
+}
+
+if ($sauserprefs_config['settings']['headers']) {
+	$new_prefs['fold_headers'] = empty($_POST['_spamfoldheaders']) ? "0" : $_POST['_spamfoldheaders'];
+	$spamchar = empty($_POST['_spamlevelchar']) ? "*" : $_POST['_spamlevelchar'];
+	if ($_POST['_spamlevelstars'] == "1")
+		$new_prefs['add_header all Level'] = "_STARS(". $spamchar .")_";
+	else
+		$new_prefs['remove_header all'] = "Level";
+}
+
+if ($sauserprefs_config['settings']['tests']) {
+	$new_prefs['use_razor1'] = empty($_POST['_spamuserazor1']) ? "0" : $_POST['_spamuserazor1'];
+	$new_prefs['use_razor2'] = empty($_POST['_spamuserazor2']) ? "0" : $_POST['_spamuserazor2'];
+	$new_prefs['use_pyzor'] = empty($_POST['_spamusepyzor']) ? "0" : $_POST['_spamusepyzor'];
+	$new_prefs['use_bayes'] = empty($_POST['_spamusebayes']) ? "0" : $_POST['_spamusebayes'];
+	$new_prefs['use_dcc'] = empty($_POST['_spamusedcc']) ? "0" : $_POST['_spamusedcc'];
+	
+	if ($_POST['_spamskiprblchecks'] == "1")
+		$new_prefs['skip_rbl_checks'] = "";
+	else
+		$new_prefs['skip_rbl_checks'] = "1";
+}
+
+if ($sauserprefs_config['settings']['report'])
+	$new_prefs['report_safe'] = $_POST['_spamreport'];
+
+
+foreach ($new_prefs as $preference => $value){
+	if ($value == "" || $value == $global_prefs[$preference]) {
+		$result = false;
+		
+		$user_db->query(
+		  "DELETE FROM ". $sauserprefs_config['sql_table_name'] ."
+		   WHERE  ". $sauserprefs_config['sql_username_field'] ."='".$_SESSION['username']."'
+		   AND    ". $sauserprefs_config['sql_preference_field'] ."='".$preference."';"
+		  );
+		 
+		$result = $user_db->affected_rows();
+		if (!$result) break;
+	}
+	elseif (array_key_exists($preference, $user_prefs) && $value != $user_prefs[$preference]) {
+		$result = false;
+		
+		$user_db->query(
+		  "UPDATE ". $sauserprefs_config['sql_table_name'] ."
+		   SET    ". $sauserprefs_config['sql_value_field'] ."='".$value."'
+		   WHERE  ". $sauserprefs_config['sql_username_field'] ."='".$_SESSION['username']."'
+		   AND    ". $sauserprefs_config['sql_preference_field'] ."='".$preference."';"
+		  );
+		  
+		$result = $user_db->affected_rows();
+		if (!$result) break;
+	}
+	elseif ($value != $global_prefs[$preference] && $value != $user_prefs[$preference]) {
+		$result = false;
+		
+		$user_db->query(
+		  "INSERT INTO ". $sauserprefs_config['sql_table_name'] ."
+		   (".$sauserprefs_config['sql_username_field'].", ".$sauserprefs_config['sql_preference_field'].", ".$sauserprefs_config['sql_value_field'].")
+		   VALUES ('".$_SESSION['username']."', '".$preference."', '".$value."')"
+		  );
+		  
+		$result = $user_db->affected_rows();
+		if (!$result) break;
+	}
+}
+
+if ($result) {
+	if ($sauserprefs_config['settings']['addresses']) {
+		// address rules
+		$count = $_POST['_addressrulecount'];
+		$address_rules = array();
+		for ($i = 1; $i <= $count; $i++) {
+			$address_rules[] = array(
+				'act' => $_POST['_address_rule_act_' . $i],
+				'preference' => $_POST['_address_rule_field_' . $i],
+				'value' => $_POST['_address_rule_value_' . $i]
+			);
+		}
+		
+		foreach ($address_rules as $rule){
+			if ($rule['act'] == "DELETE") {
+				$result = false;
+				
+				$user_db->query(
+				  "DELETE FROM ". $sauserprefs_config['sql_table_name'] ."
+				   WHERE  ". $sauserprefs_config['sql_username_field'] ."='".$_SESSION['username']."'
+				   AND    ". $sauserprefs_config['sql_preference_field'] ."='".$rule['preference']."'
+				   AND    ". $sauserprefs_config['sql_value_field'] ."='".$rule['value']."';"
+				  );
+				 
+				$result = $user_db->affected_rows();
+				if (!$result) break;
+			} elseif ($rule['act'] == "INSERT") {
+				$result = false;
+				
+				$user_db->query(
+				  "INSERT INTO ". $sauserprefs_config['sql_table_name'] ."
+				   (".$sauserprefs_config['sql_username_field'].", ".$sauserprefs_config['sql_preference_field'].", ".$sauserprefs_config['sql_value_field'].")
+				   VALUES ('".$_SESSION['username']."', '".$rule['preference']."', '".$rule['value']."')"
+				  );
+				  
+				$result = $user_db->affected_rows();
+				if (!$result) break;
+			}
+		}
+	}
+	
+	if ($result)
+		$OUTPUT->show_message('sauserprefchanged', 'confirmation');
+	else
+		$OUTPUT->show_message('sauserpreffailed', 'error');
+}
+else {
+	$OUTPUT->show_message('sauserpreffailed', 'error');
+}
+
+// go to next step
+rcmail_overwrite_action('sauserprefs');
+
+?>
\ No newline at end of file
diff -Naur --exclude='*.svn*' roundcube_svn/skins/default/includes/settingstabs.html roundcube_pub/skins/default/includes/settingstabs.html
--- roundcube_svn/skins/default/includes/settingstabs.html	2008-05-20 17:45:39.000000000 +0100
+++ roundcube_pub/skins/default/includes/settingstabs.html	2008-08-16 18:55:07.000000000 +0100
@@ -2,4 +2,5 @@
 <span id="settingstabdefault" class="tablink"><roundcube:button command="preferences" type="link" label="preferences" title="editpreferences" /></span>
 <span id="settingstabfolders" class="tablink"><roundcube:button command="folders" type="link" label="folders" title="managefolders" class="tablink" /></span>
 <span id="settingstabidentities" class="tablink"><roundcube:button command="identities" type="link" label="identities" title="manageidentities" class="tablink" /></span>
+<span id="settingstabsauserprefs" class="tablink"><roundcube:button command="sauserprefs" type="link" label="sauserprefs" title="sauserprefssettings" class="tablink" /></span>
 </div>
diff -Naur --exclude='*.svn*' roundcube_svn/skins/default/sauserprefs.css roundcube_pub/skins/default/sauserprefs.css
--- roundcube_svn/skins/default/sauserprefs.css	1970-01-01 01:00:00.000000000 +0100
+++ roundcube_pub/skins/default/sauserprefs.css	2008-08-16 18:55:05.000000000 +0100
@@ -0,0 +1,64 @@
+/***** RoundCube|Mail sauserprefs plugin styles *****/
+
+#address-rules-cont, #spam-langs-cont
+{
+  border: 1px solid #999999;
+  background-color: #F9F9F9;
+  height: 200px;
+  overflow: auto;
+  /* css hack for IE */
+  width: expression((parseInt(document.getElementById('address-rules-frame').clientWidth)-10)+'px');
+}
+
+body.address-rules-table, body.spam-langs-table
+{
+  margin: 0px;
+  background-color: #F9F9F9;
+}
+
+#address-rules-table, #spam-langs-table
+{
+  width: 100%;
+  display: table;
+  table-layout: fixed;
+  /* css hack for IE */
+  width: expression((parseInt(document.getElementById('address-rules-cont').clientWidth)-1)+'px');
+}
+
+/* safari hack \*/
+html>body*#address-rules-table[id$="address-rules-table"]:not([class="none"]) { table-layout: auto; }
+/**/
+
+/* safari hack \*/
+html>body*#spam-langs-table[id$="spam-langs-table"]:not([class="none"]) { table-layout: auto; }
+/**/
+
+.whitelist_from, .whitelist_to
+{
+  color: #008800;
+}
+
+.blacklist_from
+{
+  color: #CC0000;
+}
+
+#listcontrols
+{
+  font-size: 11px;
+  text-align: right;
+}
+
+#listcontrols a,
+#listcontrols a:active,
+#listcontrols a:visited
+{
+  color: #CC0000;
+  font-size: 11px;
+  text-decoration: none;
+}
+
+#listcontrols a:hover
+{
+  text-decoration: underline;
+}
\ No newline at end of file
diff -Naur --exclude='*.svn*' roundcube_svn/skins/default/templates/sauserprefs.html roundcube_pub/skins/default/templates/sauserprefs.html
--- roundcube_svn/skins/default/templates/sauserprefs.html	1970-01-01 01:00:00.000000000 +0100
+++ roundcube_pub/skins/default/templates/sauserprefs.html	2008-08-16 18:55:05.000000000 +0100
@@ -0,0 +1,24 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+	<head>
+		<title><roundcube:object name="pagetitle" /></title>
+		<roundcube:include file="/includes/links.html" />
+		<link rel="stylesheet" type="text/css" href="/settings.css" />
+		<link rel="stylesheet" type="text/css" href="/sauserprefs.css" />
+	</head>
+	<body>
+		<roundcube:include file="/includes/taskbar.html" />
+		<roundcube:include file="/includes/header.html" />
+		<roundcube:include file="/includes/settingstabs.html" />
+
+		<div id="userprefs-box">
+			<div id="userprefs-title"><roundcube:label name="sauserprefssettings" /></div>
+
+			<div style="padding:15px">
+				<roundcube:object name="usersauserprefs" deleteIcon="/images/icons/folder-trash.png" enableIcon="plugins/sauserprefs/enabled.png" disableIcon="plugins/sauserprefs/disabled.png">
+			</div>
+		</div>
+
+		<roundcube:include file="/includes/settingscripts.html" />
+	</body>
+</html>
\ No newline at end of file
