* we have now several bstrs:
[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(_("Enter %s below. Text is formatted to the reader's browser."
44                 " A newline is forced by preceding the next line by a blank."), description);
45
46         wprintf("<form method=\"post\" action=\"%s\">\n", save_cmd);
47         wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
48         wprintf("<textarea name=\"msgtext\" wrap=soft "
49                 "rows=10 cols=80 width=80>\n");
50         serv_puts(read_cmd);
51         serv_getln(buf, sizeof buf);
52         if (buf[0] == '1')
53                 server_to_text();
54         wprintf("</textarea><div class=\"buttons\" >\n");
55         wprintf("<input type=\"submit\" name=\"save_button\" value=\"%s\">", _("Save changes"));
56         wprintf("&nbsp;");
57         wprintf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\"><br />\n", _("Cancel"));
58         wprintf("</div></form>\n");
59
60         do_template("endbox");
61         wDumpContent(1);
62 }
63
64
65 /**
66  * \brief save a screen which was displayed with display_edit()
67  * \param description the window title???
68  * \param enter_cmd which command to enter at the citadel server???
69  * \param regoto should we go to that room again after executing that command?
70  */
71 void save_edit(char *description, char *enter_cmd, int regoto)
72 {
73         char buf[SIZ];
74
75         if (!havebstr("save_button")) {
76                 sprintf(WC->ImportantMessage,
77                         _("Cancelled.  %s was not saved."),
78                         description);
79                 display_main_menu();
80                 return;
81         }
82         serv_puts(enter_cmd);
83         serv_getln(buf, sizeof buf);
84         if (buf[0] != '4') {
85                 safestrncpy(WC->ImportantMessage, &buf[4], sizeof WC->ImportantMessage);
86                 display_main_menu();
87                 return;
88         }
89         text_to_server(bstr("msgtext"));
90         serv_puts("000");
91
92         if (regoto) {
93                 smart_goto(WC->wc_roomname);
94         } else {
95                 sprintf(WC->ImportantMessage,
96                         _("%s has been saved."),
97                         description);
98                 display_main_menu();
99                 return;
100         }
101 }
102
103
104 /*@}*/