lower case tags
[citadel.git] / webcit / sysmsgs.c
1 /*
2  * $Id$
3  *
4  * Editing of various text files on the Citadel server.
5  */
6
7 #include "webcit.h"
8
9
10 /*
11  * display the form for editing something (room info, bio, etc)
12  */
13 void display_edit(char *description, char *check_cmd,
14                   char *read_cmd, char *save_cmd, int with_room_banner)
15 {
16         char buf[SIZ];
17
18         serv_puts(check_cmd);
19         serv_getln(buf, sizeof buf);
20
21         if (buf[0] != '2') {
22                 safestrncpy(WC->ImportantMessage, &buf[4], sizeof WC->ImportantMessage);
23                 display_main_menu();
24                 return;
25         }
26         if (with_room_banner) {
27                 output_headers(1, 1, 1, 0, 0, 0);
28         }
29         else {
30                 output_headers(1, 1, 0, 0, 0, 0);
31         }
32
33         svprintf("BOXTITLE", WCS_STRING, _("Edit %s"), description);
34         do_template("beginbox");
35
36         wprintf("<div align=\"center\">");
37         wprintf(_("Enter %s below.  Text is formatted to "
38                 "the reader's screen width.  To defeat the "
39                 "formatting, indent a line at least one space."), description);
40         wprintf("<br />");
41
42         wprintf("<FORM METHOD=\"POST\" action=\"%s\">\n", save_cmd);
43         wprintf("<TEXTAREA NAME=\"msgtext\" wrap=soft "
44                 "ROWS=10 COLS=80 WIDTH=80>\n");
45         serv_puts(read_cmd);
46         serv_getln(buf, sizeof buf);
47         if (buf[0] == '1')
48                 server_to_text();
49         wprintf("</TEXTAREA><br /><br />\n");
50         wprintf("<INPUT TYPE=\"submit\" NAME=\"save_button\" VALUE=\"%s\">", _("Save changes"));
51         wprintf("&nbsp;");
52         wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\"><br />\n", _("Cancel"));
53
54         wprintf("</FORM></div>\n");
55         do_template("endbox");
56         wDumpContent(1);
57 }
58
59
60 /*
61  * save a screen which was displayed with display_edit()
62  */
63 void save_edit(char *description, char *enter_cmd, int regoto)
64 {
65         char buf[SIZ];
66
67         if (strlen(bstr("save_button")) == 0) {
68                 sprintf(WC->ImportantMessage,
69                         _("Cancelled.  %s was not saved."),
70                         description);
71                 display_main_menu();
72                 return;
73         }
74         serv_puts(enter_cmd);
75         serv_getln(buf, sizeof buf);
76         if (buf[0] != '4') {
77                 safestrncpy(WC->ImportantMessage, &buf[4], sizeof WC->ImportantMessage);
78                 display_main_menu();
79                 return;
80         }
81         text_to_server(bstr("msgtext"), 0);
82         serv_puts("000");
83
84         if (regoto) {
85                 smart_goto(WC->wc_roomname);
86         } else {
87                 sprintf(WC->ImportantMessage,
88                         _("%s has been saved."),
89                         description);
90                 display_main_menu();
91                 return;
92         }
93 }