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