Performed a bunch of markup fixes suggested by validator.w3.org
[citadel.git] / webcit / sysmsgs.c
1 #include "webcit.h"
2
3
4 /**
5  *  display the form for editing something (room info, bio, etc)
6  *  description the descriptive text for the box
7  *  check_cmd command to check????
8  *  read_cmd read answer from citadel server???
9  *  save_cmd save comand to the citadel server??
10  *  with_room_banner should we bisplay a room banner?
11  */
12 void display_edit(char *description, char *check_cmd,
13                   char *read_cmd, char *save_cmd, int with_room_banner)
14 {
15         char buf[SIZ];
16
17         serv_puts(check_cmd);
18         serv_getln(buf, sizeof buf);
19
20         if (buf[0] != '2') {
21                 safestrncpy(WC->ImportantMessage, &buf[4], sizeof WC->ImportantMessage);
22                 display_main_menu();
23                 return;
24         }
25         if (with_room_banner) {
26                 output_headers(1, 1, 1, 0, 0, 0);
27         }
28         else {
29                 output_headers(1, 1, 0, 0, 0, 0);
30         }
31
32         do_template("beginbox_1", NULL);
33         StrBufAppendPrintf (WC->WBuf, _("Edit %s"), description);
34         do_template("beginbox_2", NULL);
35
36         wc_printf(_("Enter %s below. Text is formatted to the reader's browser."
37                 " A newline is forced by preceding the next line by a blank."), description);
38
39         wc_printf("<form method=\"post\" action=\"%s\">\n", save_cmd);
40         wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
41         wc_printf("<textarea name=\"msgtext\" wrap=soft "
42                 "rows=10 cols=80 width=80>\n");
43         serv_puts(read_cmd);
44         serv_getln(buf, sizeof buf);
45         if (buf[0] == '1')
46                 server_to_text();
47         wc_printf("</textarea><div class=\"buttons\" >\n");
48         wc_printf("<input type=\"submit\" name=\"save_button\" value=\"%s\">", _("Save changes"));
49         wc_printf("&nbsp;");
50         wc_printf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\"><br>\n", _("Cancel"));
51         wc_printf("</div></form>\n");
52
53         do_template("endbox", NULL);
54         wDumpContent(1);
55 }
56
57
58 /**
59  *  save a screen which was displayed with display_edit()
60  *  description the window title???
61  *  enter_cmd which command to enter at the citadel server???
62  *  regoto should we go to that room again after executing that command?
63  */
64 void save_edit(char *description, char *enter_cmd, int regoto)
65 {
66         char buf[SIZ];
67
68         if (!havebstr("save_button")) {
69                 sprintf(WC->ImportantMessage,
70                         _("Cancelled.  %s was not saved."),
71                         description);
72                 display_main_menu();
73                 return;
74         }
75         serv_puts(enter_cmd);
76         serv_getln(buf, sizeof buf);
77         if (buf[0] != '4') {
78                 safestrncpy(WC->ImportantMessage, &buf[4], sizeof WC->ImportantMessage);
79                 display_main_menu();
80                 return;
81         }
82         text_to_server(bstr("msgtext"));
83         serv_puts("000");
84
85         if (regoto) {
86                 smart_goto(WC->CurRoom.name);
87         } else {
88                 sprintf(WC->ImportantMessage,
89                         _("%s has been saved."),
90                         description);
91                 display_main_menu();
92                 return;
93         }
94 }
95
96
97 void display_editinfo(void){ display_edit(_("Room info"), "EINF 0", "RINF", "editinfo", 1);}
98 void editinfo(void) {save_edit(_("Room info"), "EINF 1", 1);}
99 void display_editbio(void) {
100         char buf[SIZ];
101
102         snprintf(buf, SIZ, "RBIO %s", ChrPtr(WC->wc_fullname));
103         display_edit(_("Your bio"), "NOOP", buf, "editbio", 3);
104 }
105 void editbio(void) { save_edit(_("Your bio"), "EBIO", 0); }
106
107 void 
108 InitModule_SYSMSG
109 (void)
110 {
111         WebcitAddUrlHandler(HKEY("display_editinfo"), "", 0, display_editinfo, 0);
112         WebcitAddUrlHandler(HKEY("editinfo"), "", 0, editinfo, 0);
113         WebcitAddUrlHandler(HKEY("display_editbio"), "", 0, display_editbio, 0);
114         WebcitAddUrlHandler(HKEY("editbio"), "", 0, editbio, 0);
115 }