2 * Copyright (c) 1996-2012 by the citadel.org team
4 * This program is open source software. You can redistribute it and/or
5 * modify it under the terms of the GNU General Public License, version 3.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
17 * display the form for editing something (room info, bio, etc)
18 * description the descriptive text for the box
19 * check_cmd command to check????
20 * read_cmd read answer from citadel server???
21 * save_cmd save comand to the citadel server??
22 * with_room_banner should we bisplay a room banner?
24 void display_edit(char *description, char *check_cmd,
25 char *read_cmd, char *save_cmd, int with_room_banner)
31 StrBuf_ServGetln(Line);
32 if (GetServerStatusMsg(Line, NULL, 1, 2) != 2) {
38 if (with_room_banner) {
39 output_headers(1, 1, 1, 0, 0, 0);
42 output_headers(1, 1, 0, 0, 0, 0);
45 do_template("box_begin_1");
46 StrBufAppendPrintf (WC->WBuf, _("Edit %s"), description);
47 do_template("box_begin_2");
49 wc_printf(_("Enter %s below. Text is formatted to the reader's browser."
50 " A newline is forced by preceding the next line by a blank."), description);
52 wc_printf("<form method=\"post\" action=\"%s\">\n", save_cmd);
53 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
54 wc_printf("<textarea name=\"msgtext\" wrap=soft "
55 "rows=10 cols=80 width=80>\n");
57 StrBuf_ServGetln(Line);
58 if (GetServerStatusMsg(Line, NULL, 0, 0) == 1)
60 wc_printf("</textarea><div class=\"buttons\" >\n");
61 wc_printf("<input type=\"submit\" name=\"save_button\" value=\"%s\">", _("Save changes"));
63 wc_printf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\"><br>\n", _("Cancel"));
64 wc_printf("</div></form>\n");
66 do_template("box_end");
73 * save a screen which was displayed with display_edit()
74 * description the window title???
75 * enter_cmd which command to enter at the citadel server???
76 * regoto should we go to that room again after executing that command?
78 void save_edit(char *description, char *enter_cmd, int regoto)
82 if (!havebstr("save_button")) {
83 AppendImportantMessage(_("Cancelled. %s was not saved."), -1);
89 StrBuf_ServGetln(Line);
90 if (GetServerStatusMsg(Line, NULL, 1, 0) != 4) {
96 text_to_server(bstr("msgtext"));
100 smart_goto(WC->CurRoom.name);
102 AppendImportantMessage(description, -1);
103 AppendImportantMessage(_(" has been saved."), -1);
110 void display_editinfo(void){ display_edit(_("Room info"), "EINF 0", "RINF", "editinfo", 1);}
111 void editinfo(void) {save_edit(_("Room info"), "EINF 1", 1);}
112 void display_editbio(void) {
115 snprintf(buf, SIZ, "RBIO %s", ChrPtr(WC->wc_fullname));
116 display_edit(_("Your bio"), "NOOP", buf, "editbio", 3);
118 void editbio(void) { save_edit(_("Your bio"), "EBIO", 0); }
124 WebcitAddUrlHandler(HKEY("display_editinfo"), "", 0, display_editinfo, 0);
125 WebcitAddUrlHandler(HKEY("editinfo"), "", 0, editinfo, 0);
126 WebcitAddUrlHandler(HKEY("display_editbio"), "", 0, display_editbio, 0);
127 WebcitAddUrlHandler(HKEY("editbio"), "", 0, editbio, 0);