More ui-lib conversion
authorJamie Cameron <jcameron@webmin.com>
Sat, 24 Jan 2009 21:26:32 +0000 (21:26 +0000)
committerJamie Cameron <jcameron@webmin.com>
Sat, 24 Jan 2009 21:26:32 +0000 (21:26 +0000)
spam/edit_db.cgi
spam/edit_header.cgi
spam/edit_priv.cgi
spam/edit_procmail.cgi
spam/save_header.cgi
spam/save_procmail.cgi

index 9eef288..1c52467 100755 (executable)
@@ -65,42 +65,37 @@ $ldaptable .= &ui_table_end();
 
 
 # Show backend type selector
-print "<tr> <td valign=top><b>$text{'db_dsn'}</b></td> <td nowrap>";
-print &ui_radio_table("mode", $mode,
+print &ui_table_row($text{'db_dsn'},
+   &ui_radio_table("mode", $mode,
        [ [ 0, $text{'db_mode0'} ],
          [ 1, $text{'db_mode1'}, $dbtable ],
          [ 3, $text{'db_mode3'}, $ldaptable ],
          [ 4, $text{'db_mode4'},
-              &ui_textbox("dsn", $dsn, 60) ] ]);
-print "</td> </tr>\n";
+              &ui_textbox("dsn", $dsn, 60) ] ]));
 
-print "<tr> <td colspan=2><hr></td> </tr>\n";
+print &ui_table_hr();
 
 # DB login
-print "<tr> <td><b>$text{'db_user'}</b></td> <td nowrap>";
 $user = &find("user_scores_sql_username", $conf);
-&opt_field("user_scores_sql_username", $user, 20, undef);
-print "</td> </tr>\n";
+print &ui_table_row($text{'db_user'},
+       &opt_field("user_scores_sql_username", $user, 20, undef));
 
 # DB password
-print "<tr> <td><b>$text{'db_pass'}</b></td> <td nowrap>";
 $pass = &find("user_scores_sql_password", $conf);
-&opt_field("user_scores_sql_password", $pass, 20, undef);
-print "</td> </tr>\n";
+print &ui_table_row($text{'db_pass'},
+       &opt_field("user_scores_sql_password", $pass, 20, undef));
 
-print "<tr> <td colspan=2><hr></td> </tr>\n";
+print &ui_table_hr();
 
 # LDAP login
-print "<tr> <td><b>$text{'db_luser'}</b></td> <td nowrap>";
 $user = &find("user_scores_ldap_username", $conf);
-&opt_field("user_scores_ldap_username", $user, 40, undef);
-print "</td> </tr>\n";
+print &ui_table_row($text{'db_luser'},
+       &opt_field("user_scores_ldap_username", $user, 40, undef));
 
 # LDAP password
-print "<tr> <td><b>$text{'db_lpass'}</b></td> <td nowrap>";
 $pass = &find("user_scores_ldap_password", $conf);
-&opt_field("user_scores_ldap_password", $pass, 20, undef);
-print "</td> </tr>\n";
+print &ui_table_row($text{'db_lpass'},
+       &opt_field("user_scores_ldap_password", $pass, 20, undef));
 
 &end_form(undef, $text{'save'});
 &ui_print_footer($redirect_url, $text{'index_return'});
index deed855..4234a25 100755 (executable)
@@ -6,7 +6,7 @@ require './spam-lib.pl';
 &ReadParse();
 &set_config_file_in(\%in);
 &can_use_check("header");
-&ui_print_header(undef, $text{'header_title'}, "");
+&ui_print_header($header_subtext, $text{'header_title'}, "");
 $conf = &get_config();
 
 print "$text{'header_desc'}<p>\n";
index 28695f6..c173f53 100755 (executable)
@@ -12,27 +12,31 @@ $conf = &get_config();
 print "$text{'priv_desc'}<p>\n";
 &start_form("save_priv.cgi", $text{'priv_header'});
 
-print "<tr> <td><b>$text{'priv_white'}</b></td> <td colspan=3 nowrap>";
-&opt_field("auto_whitelist_path", $x=&find("auto_whitelist_path", $conf), 40,
-          "~/.spamassassin/auto-whitelist");
-print "</td> </tr>\n";
-
-print "<tr> <td><b>$text{'priv_mode'}</b></td> <td nowrap>";
-&opt_field("auto_whitelist_file_mode", $x=&find("auto_whitelist_file_mode", $conf), 4,
-          "0700");
-print "</td> </tr>\n";
-
-print "<tr> <td><b>$text{'priv_dcc'}</b></td> <td nowrap>";
-&opt_field("dcc_options", $x=&find("dcc_options", $conf), 10, "-R");
-print "</td> </tr>\n";
-
-print "<tr> <td><b>$text{'priv_log'}</b></td> <td colspan=3 nowrap>";
-&opt_field("timelog_path", $x=&find("timelog_path", $conf), 40, "NULL");
-print "</td> </tr>\n";
-
-print "<tr> <td><b>$text{'priv_razor'}</b></td> <td colspan=3 nowrap>";
-&opt_field("razor_config", $x=&find("razor_config", $conf), 40, "~/razor.conf");
-print "</td> </tr>\n";
+# Whitelist file path
+$path = &find("auto_whitelist_path", $conf);
+print &ui_table_row($text{'priv_white'},
+       &opt_field("auto_whitelist_path", $path, 40,
+                  "~/.spamassassin/auto-whitelist"));
+
+# Whitelist file mode
+$mode = &find("auto_whitelist_file_mode", $conf);
+print &ui_table_row($text{'priv_mode'},
+       &opt_field("auto_whitelist_file_mode", $mode, 4, "0700"));
+
+# DCC options
+$dcc = &find("dcc_options", $conf);
+print &ui_table_row($text{'priv_dcc'},
+       &opt_field("dcc_options", $dcc, 10, "-R"));
+
+# Timing log file
+$log = &find("timelog_path", $conf);
+print &ui_table_row($text{'priv_log'},
+       &opt_field("timelog_path", $log, 40, "NULL"));
+
+# Razor config file
+$razor = &find("razor_config", $conf);
+print &ui_table_row($text{'priv_razor'},
+       &opt_field("razor_config", $razor, 40, "~/razor.conf"));
 
 &end_form(undef, $text{'save'});
 &ui_print_footer($redirect_url, $text{'index_return'});
index 4a067b4..55bb218 100755 (executable)
@@ -42,50 +42,36 @@ else {
        $file = $spamrec->{'action'};
        }
 
-print "<form action=save_procmail.cgi>\n";
+print &ui_form_start("save_procmail.cgi", "post");
+print &ui_table_start(undef, undef, 2);
 print $form_hiddens;
-print "<table>\n";
 
 # Spam destination inputs
-print "<tr> <td rowspan=6 valign=top><b>$text{'setup_to'}</b></td>\n";
-
-printf "<td><input type=radio name=to value=0 %s> %s</td> </tr>\n",
-       $mode == 0 ? "checked" : "", $text{'setup_null'};
-
-printf "<td><input type=radio name=to value=4 %s> %s</td> </tr>\n",
-       $mode == 4 ? "checked" : "", $text{'setup_default'};
-
-printf "<td><input type=radio name=to value=1 %s> %s</td>\n",
-       $mode == 1 ? "checked" : "", $text{'setup_file'};
-printf "<td><input name=file size=30 value='%s'></td> </tr>\n",
-       $mode == 1 ? $file : undef;
-
-printf "<td><input type=radio name=to value=2 %s> %s</td>\n",
-       $mode == 2 ? "checked" : "", $text{'setup_maildir'};
-printf "<td><input name=maildir size=30 value='%s'></td> </tr>\n",
-       $mode == 2 ? $file : undef;
-
-printf "<td><input type=radio name=to value=3 %s> %s</td>\n",
-       $mode == 3 ? "checked" : "", $text{'setup_mhdir'};
-printf "<td><input name=mhdir size=30 value='%s'></td> </tr>\n",
-       $mode == 3 ? $file : undef;
-
-printf "<td><input type=radio name=to value=5 %s> %s</td>\n",
-       $mode == 5 ? "checked" : "", $text{'setup_email'};
-printf "<td><input name=email size=30 value='%s'></td> </tr>\n",
-       $mode == 5 ? $email : undef;
-
-print "</td></tr></table><br>\n";
-
+print &ui_table_row($text{'setup_to'},
+       &ui_radio_table("to", $mode,
+         [ [ 0, $text{'setup_null'} ],
+           [ 4, $text{'setup_default'} ],
+           [ 1, $text{'setup_file'},
+                &ui_textbox("mbox", $mode == 1 ? $file : "", 40) ],
+           [ 2, $text{'setup_maildir'},
+                &ui_textbox("maildir", $mode == 2 ? $file : "", 40) ],
+           [ 3, $text{'setup_mhdir'},
+                &ui_textbox("mhdir", $mode == 3 ? $file : "", 40) ],
+           [ 5, $text{'setup_email'},
+                &ui_textbox("email", $mode == 5 ? $email : "", 40) ] ]));
+
+# Message about path
 if ($module_info{'usermin'}) {
-       print "$text{'setup_rel'}<p>\n";
+       $msg = "$text{'setup_rel'}<p>\n";
        }
 else {
-       print "$text{'setup_home'}<p>\n";
+       $msg = "$text{'setup_home'}<p>\n";
        }
-print "$text{'setup_head'}<p>\n";
+$msg .= "$text{'setup_head'}<p>\n";
+print &ui_table_row(undef, $msg, 2);
 
-print "<input type=submit value='$text{'procmail_ok'}'></form>\n";
+print &ui_table_end();
+print &ui_form_end([ [ undef, $text{'procmail_ok'} ] ]);
 
 &ui_print_footer($redirect_url, $text{'index_return'});
 
index c87dacb..1d3410a 100755 (executable)
@@ -3,9 +3,10 @@
 # Save custom header and body tests
 
 require './spam-lib.pl';
+&ReadParse();
+&set_config_file_in(\%in);
 &can_use_check("header");
 &error_setup($text{'header_err'});
-&ReadParse();
 &execute_before("header");
 &lock_spam_files();
 $conf = &get_config();
@@ -40,7 +41,7 @@ if (!$module_info{'usermin'}) {
 &unlock_spam_files();
 &execute_after("header");
 &webmin_log("header");
-&redirect("");
+&redirect($redirect_url);
 
 # header_parser(rowname, value, ...)
 sub header_parser
index 67fd2ad..480623c 100755 (executable)
@@ -13,8 +13,8 @@ if ($in{'to'} == 0) {
        $file = "/dev/null";
        }
 elsif ($in{'to'} == 1) {
-       $in{'file'} =~ /^\S+$/ || &error($text{'setup_efile'});
-       $file = $in{'file'};
+       $in{'mbox'} =~ /^\S+$/ || &error($text{'setup_efile'});
+       $file = $in{'mbox'};
        }
 elsif ($in{'to'} == 2) {
        $in{'maildir'} =~ /^\S+$/ || &error($text{'setup_emaildir'});