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