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