move all source files to src/
[citadel.git] / webcit / src / 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 align=\"center\">");
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("<TEXTAREA NAME=\"msgtext\" wrap=soft "
51                 "ROWS=10 COLS=80 WIDTH=80>\n");
52         serv_puts(read_cmd);
53         serv_getln(buf, sizeof buf);
54         if (buf[0] == '1')
55                 server_to_text();
56         wprintf("</TEXTAREA><br /><br />\n");
57         wprintf("<INPUT TYPE=\"submit\" NAME=\"save_button\" VALUE=\"%s\">", _("Save changes"));
58         wprintf("&nbsp;");
59         wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\"><br />\n", _("Cancel"));
60
61         wprintf("</FORM></div>\n");
62         do_template("endbox");
63         wDumpContent(1);
64 }
65
66
67 /**
68  * \brief save a screen which was displayed with display_edit()
69  * \param description the window title???
70  * \param enter_cmd which command to enter at the citadel server???
71  * \param regoto should we go to that room again after executing that command?
72  */
73 void save_edit(char *description, char *enter_cmd, int regoto)
74 {
75         char buf[SIZ];
76
77         if (strlen(bstr("save_button")) == 0) {
78                 sprintf(WC->ImportantMessage,
79                         _("Cancelled.  %s was not saved."),
80                         description);
81                 display_main_menu();
82                 return;
83         }
84         serv_puts(enter_cmd);
85         serv_getln(buf, sizeof buf);
86         if (buf[0] != '4') {
87                 safestrncpy(WC->ImportantMessage, &buf[4], sizeof WC->ImportantMessage);
88                 display_main_menu();
89                 return;
90         }
91         text_to_server(bstr("msgtext"));
92         serv_puts("000");
93
94         if (regoto) {
95                 smart_goto(WC->wc_roomname);
96         } else {
97                 sprintf(WC->ImportantMessage,
98                         _("%s has been saved."),
99                         description);
100                 display_main_menu();
101                 return;
102         }
103 }
104
105
106 /*@}*/