* All OS-level includes are now included from webcit.h instead of from
[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, 0);
28         }
29         else {
30                 output_headers(1, 1, 0, 0, 0, 0, 0);
31         }
32
33         svprintf("BOXTITLE", WCS_STRING, "Edit %s", description);
34         do_template("beginbox");
35
36         wprintf("<CENTER>Enter %s below.  Text is formatted to\n", description);
37         wprintf("the <EM>reader's</EM> screen width.  To defeat the\n");
38         wprintf("formatting, indent a line at least one space.  \n");
39         wprintf("<br />");
40
41         wprintf("<FORM METHOD=\"POST\" ACTION=\"%s\">\n", save_cmd);
42         wprintf("<TEXTAREA NAME=\"msgtext\" wrap=soft "
43                 "ROWS=10 COLS=80 WIDTH=80>\n");
44         serv_puts(read_cmd);
45         serv_getln(buf, sizeof buf);
46         if (buf[0] == '1')
47                 server_to_text();
48         wprintf("</TEXTAREA><br /><br />\n");
49         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Save\">");
50         wprintf("&nbsp;");
51         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\"><br />\n");
52
53         wprintf("</FORM></CENTER>\n");
54         do_template("endbox");
55         wDumpContent(1);
56 }
57
58
59 /*
60  * save a screen which was displayed with display_edit()
61  */
62 void save_edit(char *description, char *enter_cmd, int regoto)
63 {
64         char buf[SIZ];
65
66         if (strcmp(bstr("sc"), "Save")) {
67                 sprintf(WC->ImportantMessage,
68                         "Cancelled.  %s was not saved.\n", description);
69                 display_main_menu();
70                 return;
71         }
72         serv_puts(enter_cmd);
73         serv_getln(buf, sizeof buf);
74         if (buf[0] != '4') {
75                 safestrncpy(WC->ImportantMessage, &buf[4], sizeof WC->ImportantMessage);
76                 display_main_menu();
77                 return;
78         }
79         text_to_server(bstr("msgtext"), 0);
80         serv_puts("000");
81
82         if (regoto) {
83                 smart_goto(WC->wc_roomname);
84         } else {
85                 sprintf(WC->ImportantMessage,
86                         "%s has been saved.\n", description);
87                 display_main_menu();
88                 return;
89         }
90 }