More work on the rules editor
[citadel.git] / webcit / sieve.c
1 /* 
2  * $Id: $
3  */
4 /**
5  * \defgroup Sieve view/edit sieve config
6  * \ingroup WebcitDisplayItems
7  */
8 /*@{*/
9 #include "webcit.h"
10
11 #define MAX_SCRIPTS     100
12 #define MAX_RULES       25
13
14 /**
15  * \brief view/edit sieve config
16  */
17 void display_sieve(void)
18 {
19         char script_names[MAX_SCRIPTS][64];
20         int num_scripts = 0;
21         int active_script = (-1);
22         char buf[256];
23         int i;
24         
25
26         memset(script_names, 0, sizeof script_names);
27
28         serv_puts("MSIV listscripts");
29         serv_getln(buf, sizeof(buf));
30         if (buf[0] == '1') while (serv_getln(buf, sizeof(buf)), strcmp(buf, "000")) {
31                 if (num_scripts < MAX_SCRIPTS) {
32                         extract_token(script_names[num_scripts], buf, 0, '|', 64);
33                         if (extract_int(buf, 1) > 0) {
34                                 active_script = num_scripts;
35                         }
36                         ++num_scripts;
37                 }
38         }
39
40         output_headers(1, 1, 2, 0, 0, 0);
41
42         wprintf("<script type=\"text/javascript\">                                      \n"
43                 "                                                                       \n"
44                 "var previously_active_script;                                          \n"
45                 "                                                                       \n"
46                 "function ToggleSievePanels() {                                         \n"
47                 " d = ($('sieveform').bigaction.options[$('sieveform').bigaction.selectedIndex].value); \n"
48                 " for (i=0; i<3; ++i) {                                                 \n"
49                 "  if (i == d) {                                                        \n"
50                 "   $('sievediv' + i).style.display = 'block';                          \n"
51                 "  }                                                                    \n"
52                 "  else {                                                               \n"
53                 "   $('sievediv' + i).style.display = 'none';                           \n"
54                 "  }                                                                    \n"
55                 " }                                                                     \n"
56                 "}                                                                      \n"
57                 "                                                                       \n"
58                 "function ToggleScriptPanels() {                                        \n"
59                 " d = ($('sieveform').active_script.options[$('sieveform').active_script.selectedIndex].value); \n"
60                 " if ($('script_' + previously_active_script)) {                        \n"
61                 "  $('script_' + previously_active_script).style.display = 'none';      \n"
62                 " }                                                                     \n"
63                 " $('script_' + d).style.display = 'block';                             \n"
64                 " previously_active_script = d;                                         \n"
65                 "}                                                                      \n"
66                 "                                                                       \n"
67                 "</script>                                                              \n"
68         );
69
70         wprintf("<div id=\"banner\">\n");
71         wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>");
72         wprintf("<SPAN CLASS=\"titlebar\">"
73                 "<img src=\"static/advanpage2_48x.gif\">");
74         wprintf(_("View/edit server-side mail filters"));
75         wprintf("</SPAN>\n");
76         wprintf("</TD></TR></TABLE>\n");
77         wprintf("</div>\n<div id=\"content\">\n");
78
79         wprintf("<div class=\"fix_scrollbar_bug\">"
80                 "<table border=0 width=100%% bgcolor=\"#FFFFFF\">"
81                 "<tr><td valign=top>\n");
82
83
84         wprintf("<form id=\"sieveform\" method=\"post\" action=\"save_sieve\">\n");
85
86         wprintf(_("When new mail arrives: "));
87         wprintf("<select name=\"bigaction\" size=1 onChange=\"ToggleSievePanels();\">\n");
88
89         wprintf("<option %s value=\"0\">", ((active_script < 0) ? "selected" : ""));
90         wprintf(_("Leave it in my inbox without filtering"));
91         wprintf("</option>\n");
92
93         wprintf("<option value=\"1\">");
94         wprintf(_("Filter it according to rules selected below"));
95         wprintf("</option>\n");
96
97         wprintf("<option %s value=\"2\">", ((active_script >= 0) ? "selected" : ""));
98         wprintf(_("Filter it through a manually edited script (advanced users only)"));
99         wprintf("</option>\n");
100
101         wprintf("</select>");
102
103
104
105         /* The "no filtering" div */
106
107         wprintf("<div id=\"sievediv0\" style=\"display:none\">\n");
108         wprintf("<div align=\"center\"><br /><br />");
109         wprintf(_("Your incoming mail will not be filtered through any scripts."));
110         wprintf("<br /><br /></div>\n");
111         wprintf("</div>\n");
112
113         /* The "webcit managed scripts" div */
114
115         wprintf("<div id=\"sievediv1\" style=\"display:none\">\n");
116         display_rules_editor_inner_div();
117         wprintf("</div>\n");
118
119         /* The "I'm smart and can write my own Sieve scripts" div */
120
121         wprintf("<div id=\"sievediv2\" style=\"display:none\">\n");
122
123         if (num_scripts > 0) {
124                 wprintf(_("The currently active script is: "));
125                 wprintf("<select name=\"active_script\" size=1 onChange=\"ToggleScriptPanels();\">\n");
126                 for (i=0; i<num_scripts; ++i) {
127                         wprintf("<option %s value=\"%s\">%s</option>\n",
128                                 ((active_script == i) ? "selected" : ""),
129                                 script_names[i],
130                                 script_names[i]
131                         );
132                 }
133                 wprintf("</select>\n");
134         }
135
136         wprintf("&nbsp;&nbsp;&nbsp;");
137         wprintf("<a href=\"display_add_remove_scripts\">%s</a>\n", _("Add or delete scripts"));
138
139         wprintf("<br />\n");
140
141         if (num_scripts > 0) {
142                 for (i=0; i<num_scripts; ++i) {
143                         wprintf("<div id=\"script_%s\" style=\"display:none\">\n", script_names[i]);
144                         wprintf("<textarea name=\"text_%s\" wrap=soft rows=20 cols=80 width=80>\n", script_names[i]);
145                         serv_printf("MSIV getscript|%s", script_names[i]);
146                         serv_getln(buf, sizeof buf);
147                         if (buf[0] == '1') while(serv_getln(buf, sizeof (buf)), strcmp(buf, "000")) {
148                                 wprintf("%s\n", buf);
149                         }
150                         wprintf("</textarea>\n");
151                         wprintf("</div>\n");
152                 }
153         }
154
155         wprintf("<script type=\"text/javascript\">      \n"
156                 "ToggleScriptPanels();                  \n"
157                 "</script>                              \n"
158         );
159
160         wprintf("</div>\n");
161
162
163         /* The rest of this is common for all panels... */
164
165         wprintf("<div align=\"center\"><br>");
166         wprintf("<input type=\"submit\" name=\"save_button\" value=\"%s\">", _("Save changes"));
167         wprintf("&nbsp;");
168         wprintf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\">\n", _("Cancel"));
169         wprintf("</div></form>\n");
170
171         wprintf("</td></tr></table></div>\n");
172
173         wprintf("<script type=\"text/javascript\">      \n"
174                 "ToggleSievePanels();                   \n"
175                 "</script>                              \n"
176         );
177
178         wDumpContent(1);
179
180 }
181
182
183 /**
184  * \brief save sieve config
185  */
186 void save_sieve(void) {
187         int bigaction;
188         char script_names[MAX_SCRIPTS][64];
189         int num_scripts = 0;
190         int active_script = (-1);
191         int i;
192         char this_name[64];
193         char buf[256];
194
195         if (strlen(bstr("save_button")) == 0) {
196                 strcpy(WC->ImportantMessage,
197                         _("Cancelled.  Changes were not saved."));
198                 display_main_menu();
199                 return;
200         }
201
202         serv_puts("MSIV listscripts");
203         serv_getln(buf, sizeof(buf));
204         if (buf[0] == '1') while (serv_getln(buf, sizeof(buf)), strcmp(buf, "000")) {
205                 if (num_scripts < MAX_SCRIPTS) {
206                         extract_token(script_names[num_scripts], buf, 0, '|', 64);
207                         if (extract_int(buf, 1) > 0) {
208                                 active_script = num_scripts;
209                         }
210                         ++num_scripts;
211                 }
212         }
213
214         bigaction = atoi(bstr("bigaction"));
215
216         if (bigaction == 0) {
217                 serv_puts("MSIV setactive||");
218                 serv_getln(buf, sizeof buf);
219         }
220
221         else if (bigaction == 2) {
222                 serv_printf("MSIV setactive|%s|", bstr("active_script"));
223                 serv_getln(buf, sizeof buf);
224         }
225
226         if (num_scripts > 0) {
227                 for (i=0; i<num_scripts; ++i) {
228                         serv_printf("MSIV putscript|%s|", script_names[i]);
229                         serv_getln(buf, sizeof buf);
230                         if (buf[0] == '4') {
231                                 snprintf(this_name, sizeof this_name, "text_%s", script_names[i]);
232                                 striplt(bstr(this_name));
233                                 serv_printf("%s", bstr(this_name));
234                                 serv_puts("000");
235                         }
236                 }
237         }
238
239         strcpy(WC->ImportantMessage, _("Your changes have been saved."));
240         display_main_menu();
241         return;
242 }
243
244
245 /**
246  * \brief show a list of available scripts to add/remove them
247  */
248 void display_add_remove_scripts(char *message)
249 {
250         char buf[256];
251         char script_name[256];
252
253         output_headers(1, 1, 2, 0, 0, 0);
254         wprintf("<div id=\"banner\">\n");
255         wprintf("<table width=100%% border=0 bgcolor=#444455><tr>"
256                 "<td>"
257                 "<span class=\"titlebar\">"
258                 "<img src=\"static/advanpage2_48x.gif\">");
259         wprintf(_("Add or delete scripts"));
260         wprintf("</span></td></tr></table>\n"
261                 "</div>\n<div id=\"content\">\n"
262         );
263
264         if (message != NULL) wprintf(message);
265
266         wprintf("<table border=0 cellspacing=10><tr valign=top><td>\n");
267
268         svprintf("BOXTITLE", WCS_STRING, _("Add a new script"));
269         do_template("beginbox");
270
271         wprintf(_("To create a new script, enter the desired "
272                 "script name in the box below and click 'Create'."));
273         wprintf("<br /><br />");
274
275         wprintf("<center><form method=\"POST\" action=\"create_script\">\n");
276         wprintf(_("Script name: "));
277         wprintf("<input type=\"text\" name=\"script_name\"><br />\n"
278                 "<input type=\"submit\" name=\"create_button\" value=\"%s\">"
279                 "</form></center>\n", _("Create"));
280
281         do_template("endbox");
282
283         svprintf("BOXTITLE", WCS_STRING, _("Edit scripts"));
284         do_template("beginbox");
285         wprintf("<br /><div align=center><a href=\"display_sieve\">%s</a><br /><br />\n",
286                 _("Return to the script editing screen")
287         );
288         do_template("endbox");
289
290         wprintf("</td><td>");
291
292         svprintf("BOXTITLE", WCS_STRING, _("Delete scripts"));
293         do_template("beginbox");
294
295         wprintf(_("To delete an existing script, select the script "
296                 "name from the list and click 'Delete'."));
297         wprintf("<br /><br />");
298         
299         wprintf("<center>"
300                 "<form method=\"POST\" action=\"delete_script\">\n");
301         wprintf("<select name=\"script_name\" size=10 style=\"width:100%%\">\n");
302
303         serv_puts("MSIV listscripts");
304         serv_getln(buf, sizeof buf);
305         if (buf[0] == '1') {
306                 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
307                         extract_token(script_name, buf, 0, '|', sizeof script_name);
308                         if (extract_int(buf, 1) == 0) {
309                                 wprintf("<option>");
310                                 escputs(script_name);
311                                 wprintf("</option>\n");
312                         }
313                 }
314         }
315         wprintf("</select><br />\n");
316
317         wprintf("<input type=\"submit\" name=\"delete_button\" value=\"%s\" "
318                 "onClick=\"return confirm('%s');\">", _("Delete script"), _("Delete this script?"));
319         wprintf("</form></center>\n");
320         do_template("endbox");
321
322         wprintf("</td></tr></table>\n");
323
324         wDumpContent(1);
325 }
326
327
328
329 /**
330  * \brief delete a script
331  */
332 void delete_script(void) {
333         char buf[256];
334
335         serv_printf("MSIV deletescript|%s", bstr("script_name"));
336         serv_getln(buf, sizeof buf);
337         display_add_remove_scripts(&buf[4]);
338 }
339                 
340
341
342 /**
343  * \brief create a new script
344  * take the web environment script name and create it on the citadel server
345  */
346 void create_script(void) {
347         char buf[256];
348
349         serv_printf("MSIV getscript|%s", bstr("script_name"));
350         serv_getln(buf, sizeof buf);
351         if (buf[0] == '1') {
352                 while (serv_getln(buf, sizeof(buf)), strcmp(buf, "000")) {
353                         /* flush */
354                 }
355                 display_add_remove_scripts(_("A script by that name already exists."));
356                 return;
357         }
358         
359         serv_printf("MSIV putscript|%s", bstr("script_name"));
360         serv_getln(buf, sizeof buf);
361         if (buf[0] == '4') {
362                 serv_puts("keep;");
363                 serv_puts("000");
364                 display_add_remove_scripts(_("A new script has been created.  Return to the script editing screen to edit and activate it."));
365                 return;
366         }
367
368         display_add_remove_scripts(&buf[4]);
369 }
370
371
372
373
374 void display_rules_editor_inner_div(void) {
375         int i, j;
376         char buf[256];
377
378         struct {
379                 char name[128];
380         } *rooms = NULL;
381         int num_roomnames = 0;
382         int num_roomnames_alloc = 0;
383
384
385         /* load the roomnames */
386         serv_puts("LKRA");
387         serv_getln(buf, sizeof buf);
388         if (buf[0] == '1') {
389                 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
390                         ++num_roomnames;
391                         if (num_roomnames > num_roomnames_alloc) {
392                                 num_roomnames_alloc += 250;
393                                 rooms = realloc(rooms, (num_roomnames_alloc * 128));
394                         }
395                         extract_token(rooms[num_roomnames-1].name, buf, 0, '|', 128);
396                 }
397         }
398
399
400 /*
401  * This script should get called by every onChange event...
402  *
403  */
404         wprintf("<script type=\"text/javascript\">                                      \n"
405                 "                                                                       \n"
406                 "var highest_active_rule = (-1);                                        \n"
407                 "                                                                       \n"
408                 "function UpdateRules() {                                               \n"
409                 "  for (i=0; i<%d; ++i) {                                               \n", MAX_RULES);
410         wprintf("    d = ($('movedown'+i));                                             \n"
411                 "    if (i < highest_active_rule) {                                     \n"
412                 "      d.style.display = 'block';                                       \n"
413                 "    }                                                                  \n"
414                 "    else {                                                             \n"
415                 "      d.style.display = 'none';                                        \n"
416                 "    }                                                                  \n"
417                 "    d = ($('hfield'+i).options[$('hfield'+i).selectedIndex].value);    \n"
418                 "    if (d == 'all') {                                                  \n"
419                 "      $('div_size'+i).style.display = 'none';                          \n"
420                 "      $('div_compare'+i).style.display = 'none';                       \n"
421                 "    }                                                                  \n"
422                 "    else if (d == 'size') {                                            \n"
423                 "      $('div_size'+i).style.display = 'block';                         \n"
424                 "      $('div_compare'+i).style.display = 'none';                       \n"
425                 "    }                                                                  \n"
426                 "    else {                                                             \n"
427                 "      $('div_size'+i).style.display = 'none';                          \n"
428                 "      $('div_compare'+i).style.display = 'block';                      \n"
429                 "    }                                                                  \n"
430                 "    d = ($('action'+i).options[$('action'+i).selectedIndex].value);    \n"
431                 "    if (d == 'fileinto') {                                             \n"
432                 "      $('div_fileinto'+i).style.display = 'block';                     \n"
433                 "      $('div_redirect'+i).style.display = 'none';                      \n"
434                 "      $('div_automsg'+i).style.display = 'none';                       \n"
435                 "    } else if (d == 'redirect') {                                      \n"
436                 "      $('div_fileinto'+i).style.display = 'none';                      \n"
437                 "      $('div_redirect'+i).style.display = 'block';                     \n"
438                 "      $('div_automsg'+i).style.display = 'none';                       \n"
439                 "    } else if ((d == 'reject') || (d == 'vacation'))  {                \n"
440                 "      $('div_fileinto'+i).style.display = 'none';                      \n"
441                 "      $('div_redirect'+i).style.display = 'none';                      \n"
442                 "      $('div_automsg'+i).style.display = 'block';                      \n"
443                 "    } else {                                                           \n"
444                 "      $('div_fileinto'+i).style.display = 'none';                      \n"
445                 "      $('div_redirect'+i).style.display = 'none';                      \n"
446                 "      $('div_automsg'+i).style.display = 'none';                       \n"
447                 "    }                                                                  \n"
448                 "    if (highest_active_rule < %d) {                                    \n", MAX_RULES-1 );
449         wprintf("      $('div_addrule').style.display = 'block';                        \n"
450                 "    } else {                                                           \n"
451                 "      $('div_addrule').style.display = 'none';                         \n"
452                 "    }                                                                  \n"
453                 "  }                                                                    \n"
454         );
455 /*
456  * Show only the active rows...
457  */
458         wprintf("  highest_active_rule = (-1);                                          \n");
459         wprintf("  for (i=0; i<%d; ++i) {                                               \n", MAX_RULES);
460         wprintf("   if ($('active'+i).checked) {                                        \n"
461                 "     $('rule' + i).style.display = 'block';                            \n"
462                 "     highest_active_rule = i;                                          \n"
463                 "   }                                                                   \n"
464                 "   else {                                                              \n"
465                 "     $('rule' + i).style.display = 'none';                             \n"
466                 "   }                                                                   \n"
467                 "  }                                                                    \n"
468                 "}                                                                      \n"
469 /*
470  * Add a rule (really, just un-hide it)
471  */
472                 "function AddRule() {                                                   \n"
473                 "  highest_active_rule = highest_active_rule + 1;                       \n"
474                 "  $('active'+highest_active_rule).checked = true;                      \n"
475                 "  UpdateRules();                                                       \n"
476                 "}                                                                      \n"
477 /*
478  * Swap two rules
479  */
480                 "function SwapRules(ra, rb) {                                           \n"
481                 "                                                                       \n"
482                 "  var things = new Array();                                            \n"
483                 "  things[0] = 'hfield';                                                \n"
484                 "  things[1] = 'compare';                                               \n"
485                 "  things[2] = 'htext';                                                 \n"
486                 "  things[3] = 'action';                                                \n"
487                 "  things[4] = 'fileinto';                                              \n"
488                 "  things[5] = 'redirect';                                              \n"
489                 "  things[6] = 'final';                                                 \n"
490                 "  things[7] = 'sizecomp';                                              \n"
491                 "  things[8] = 'sizeval';                                               \n"
492                 "  things[9] = 'automsg';                                               \n"
493                 "                                                                       \n"
494                 "  for (i=0; i<=9; ++i) {                                               \n"
495                 "    tempval=$(things[i]+ra).value;                                     \n"
496                 "    $(things[i]+ra).value = $(things[i]+rb).value;                     \n"
497                 "    $(things[i]+rb).value = tempval;                                   \n"
498                 "  }                                                                    \n"
499                 "}                                                                      \n"
500 /*
501  * Delete a rule (percolate the deleted rule out to the end,
502  *                and then decrement highest_active_rule)
503  */
504                 "function DeleteRule(rd) {                                              \n"
505                 "  for (i=rd; i<highest_active_rule; ++i) {                             \n"
506                 "    SwapRules(i, (i+1));                                               \n"
507                 "  }                                                                    \n"
508                 "  $('active'+highest_active_rule).checked = false;                     \n"
509                 "}                                                                      \n"
510                 "</script>                                                              \n"
511         );
512
513
514         wprintf("<br />");
515
516         wprintf("<table border=1 cellpadding=2 width=100%%>");
517
518         for (i=0; i<MAX_RULES; ++i) {
519                 
520                 wprintf("<tr id=\"rule%d\">", i);
521
522                 wprintf("<td>");
523
524                 wprintf("<div style=\"display:none\">");
525                 wprintf("<input type=\"checkbox\" id=\"active%d\">", i);
526                 wprintf("</div>");
527
528                 if (i>0) wprintf("<a href=\"javascript:SwapRules(%d,%d);UpdateRules();\">"
529                         "<img border=\"0\" src=\"static/up_pointer.gif\" /></a>", i-1, i);
530
531                 wprintf("<a href=\"javascript:SwapRules(%d,%d);UpdateRules();\">"
532                         "<img id=\"movedown%d\" border=\"0\" src=\"static/down_pointer.gif\" /></a>",
533                         i, i+1, i);
534
535                 wprintf("<a href=\"javascript:DeleteRule(%d);UpdateRules();\">"
536                         "<img id=\"delete%d\" border=\"0\" src=\"static/delete.gif\" /></a>",
537                         i, i);
538
539                 wprintf("&nbsp;%d.&nbsp;%s</td>", i+1, _("If") );
540
541                 wprintf("<td>");
542
543                 wprintf("<select id=\"hfield%d\" name=\"hfield%d\" size=1 onChange=\"UpdateRules();\">",
544                         i, i);
545                 wprintf("<option value=\"from\">%s</option>", _("From"));
546                 wprintf("<option value=\"tocc\">%s</option>", _("To or Cc"));
547                 wprintf("<option value=\"subject\">%s</option>", _("Subject"));
548                 wprintf("<option value=\"replyto\">%s</option>", _("Reply-to"));
549                 wprintf("<option value=\"sender\">%s</option>", _("Sender"));
550                 wprintf("<option value=\"resentfrom\">%s</option>", _("Resent-From"));
551                 wprintf("<option value=\"resentto\">%s</option>", _("Resent-To"));
552                 wprintf("<option value=\"envfrom\">%s</option>", _("Envelope From"));
553                 wprintf("<option value=\"envto\">%s</option>", _("Envelope To"));
554                 wprintf("<option value=\"xmailer\">%s</option>", _("X-Mailer"));
555                 wprintf("<option value=\"xspamflag\">%s</option>", _("X-Spam-Flag"));
556                 wprintf("<option value=\"xspamstatus\">%s</option>", _("X-Spam-Status"));
557                 wprintf("<option value=\"size\">%s</option>", _("Message size"));
558                 wprintf("<option value=\"all\">%s</option>", _("(All messages)"));
559                 wprintf("</select>");
560                 wprintf("</td>");
561
562                 wprintf("<td>");
563
564                 wprintf("<div id=\"div_compare%d\">", i);
565                 wprintf("<select id=\"compare%d\" name=\"compare%d\" size=1 onChange=\"UpdateRules();\">",
566                         i, i);
567                 wprintf("<option value=\"contains\">%s</option>", _("contains"));
568                 wprintf("<option value=\"notcontains\">%s</option>", _("does not contain"));
569                 wprintf("<option value=\"is\">%s</option>", _("is"));
570                 wprintf("<option value=\"isnot\">%s</option>", _("is not"));
571                 wprintf("</select>");
572
573                 wprintf("<input type=\"text\" id=\"htext%d\" name=\"htext%d\">", i, i);
574                 wprintf("</div>");
575
576                 wprintf("<div id=\"div_size%d\">", i);
577                 wprintf("<select id=\"sizecomp%d\" name=\"sizecomp%d\" size=1 onChange=\"UpdateRules();\">",
578                         i, i);
579                 wprintf("<option value=\"larger\">%s</option>", _("is larger than"));
580                 wprintf("<option value=\"smaller\">%s</option>", _("is smaller than"));
581                 wprintf("</select>");
582
583                 wprintf("<input type=\"text\" id=\"sizeval%d\" name=\"sizeval%d\">", i, i);
584                 wprintf("bytes");
585                 wprintf("</div>");
586
587                 wprintf("</td>");
588
589                 wprintf("<td>");
590                 wprintf("<select id=\"action%d\" name=\"action%d\" size=1 onChange=\"UpdateRules();\">",
591                         i, i);
592                 wprintf("<option value=\"keep\">%s</option>", _("Keep"));
593                 wprintf("<option value=\"discard\">%s</option>", _("Discard silently"));
594                 wprintf("<option value=\"reject\">%s</option>", _("Reject"));
595                 wprintf("<option value=\"fileinto\">%s</option>", _("Move message to"));
596                 wprintf("<option value=\"redirect\">%s</option>", _("Forward to"));
597                 wprintf("<option value=\"vacation\">%s</option>", _("Vacation"));
598                 wprintf("</select>");
599
600                 wprintf("<div id=\"div_fileinto%d\">", i);
601                 wprintf("<select name=\"fileinto%d\" id=\"fileinto%d\">", i, i);
602                 for (j=0; j<num_roomnames; ++j) {
603                         wprintf("<option ");
604                         if (!strcasecmp(rooms[j].name, "Mail")) {
605                                 wprintf("selected ");
606                         }
607                         wprintf("value=\"");
608                         urlescputs(rooms[j].name);
609                         wprintf("\">");
610                         escputs(rooms[j].name);
611                         wprintf("</option>\n");
612                 }
613                 wprintf("</select>\n");
614                 wprintf("</div>");
615
616                 wprintf("<div id=\"div_redirect%d\">", i);
617                 wprintf("<input type=\"text\" id=\"redirect%d\" name=\"redirect%d\">", i, i);
618                 wprintf("</div>");
619
620                 wprintf("<div id=\"div_automsg%d\">", i);
621                 wprintf(_("Message:"));
622                 wprintf("<textarea name=\"automsg%d\" id=\"automsg%d\" wrap=soft rows=5>\n", i, i);
623                 wprintf("</textarea>");
624                 wprintf("</div>");
625
626                 wprintf("</td>");
627
628
629
630                 wprintf("<td>%s</td>", _("and then") );
631
632                 wprintf("<td>");
633                 wprintf("<select name=\"final%d\" id=\"final%d\" size=1 onChange=\"UpdateRules();\">",
634                         i, i);
635                 wprintf("<option value=\"stop\">%s</option>", _("stop"));
636                 wprintf("<option value=\"continue\">%s</option>", _("continue processing"));
637                 wprintf("</select>");
638                 wprintf("</td>");
639
640                 wprintf("</tr>\n");
641
642         }
643
644         wprintf("</table>");
645         wprintf("<div id=\"div_addrule\"><a href=\"javascript:AddRule();\">Add rule</a><br /></div>\n");
646
647         wprintf("<script type=\"text/javascript\">                                      \n"
648                 "UpdateRules();                                                         \n"
649                 "</script>                                                              \n"
650         );
651
652         free(rooms);
653 }
654
655
656
657
658
659
660 /*@}*/