4 * Copyright (c) 1996-2010 by the citadel.org team
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "webserver.h"
28 * Display floor configuration. If prepend_html is not NULL, its contents
29 * will be displayed at the top of the screen.
31 void display_floorconfig(StrBuf *prepend_html)
39 output_headers(1, 1, 2, 0, 0, 0);
40 wc_printf("<div id=\"banner\">\n");
42 wc_printf(_("Add/change/delete floors"));
44 wc_printf("</div>\n");
46 wc_printf("<div id=\"content\" class=\"service\">\n");
48 if (prepend_html != NULL) {
49 wc_printf("<br /><b><i>");
50 StrBufAppendBuf(WC->WBuf, prepend_html, 0);
51 wc_printf("</i></b><br /><br />\n");
55 serv_getln(buf, sizeof buf);
57 wc_printf("<TABLE class=\"floors_config\"><TR><TD>");
58 wc_printf("<SPAN CLASS=\"titlebar\">");
59 wc_printf(_("Error"));
60 wc_printf("</SPAN>\n");
61 wc_printf("</TD></TR></TABLE>\n");
62 wc_printf("%s<br />\n", &buf[4]);
67 wc_printf("<div class=\"fix_scrollbar_bug\">"
68 "<TABLE BORDER=1 WIDTH=100%% bgcolor=\"#ffffff\">\n"
70 wc_printf(_("Floor number"));
71 wc_printf("</TH><TH>");
72 wc_printf(_("Floor name"));
73 wc_printf("</TH><TH>");
74 wc_printf(_("Number of rooms"));
75 wc_printf("</TH><TH>");
76 wc_printf(_("Floor CSS"));
77 wc_printf("</TH></TR>\n");
79 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
80 floornum = extract_int(buf, 0);
81 extract_token(floorname, buf, 1, '|', sizeof floorname);
82 refcount = extract_int(buf, 2);
84 wc_printf("<TR><TD><TABLE border=0><TR><TD>%d", floornum);
87 "<a href=\"delete_floor?floornum=%d\">"
88 "<FONT SIZE=-1>", floornum);
89 wc_printf(_("(delete floor)"));
90 wc_printf("</A></FONT><br />");
92 wc_printf("<FONT SIZE=-1>"
93 "<a href=\"display_editfloorpic?"
94 "which_floor=%d\">", floornum);
95 wc_printf(_("(edit graphic)"));
96 wc_printf("</A></TD></TR></TABLE>");
100 "<FORM METHOD=\"POST\" action=\"rename_floor\">"
101 "<INPUT TYPE=\"hidden\" NAME=\"floornum\" "
103 "<INPUT TYPE=\"text\" NAME=\"floorname\" "
104 "VALUE=\"%s\" MAXLENGTH=\"250\">\n",
105 floornum, floorname);
106 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
107 wc_printf("<INPUT TYPE=\"SUBMIT\" NAME=\"sc\" "
109 "</FORM></TD>", _("Change name"));
111 wc_printf("<TD>%d</TD>\n", refcount);
114 "<FORM METHOD=\"POST\" action=\"set_floor_css\">"
115 "<INPUT TYPE=\"hidden\" NAME=\"floornum\" "
117 "<INPUT TYPE=\"text\" NAME=\"floorcss\" "
118 "VALUE=\"%s\" MAXLENGTH=\"250\">\n",
119 floornum, floorname);
120 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
121 wc_printf("<INPUT TYPE=\"SUBMIT\" NAME=\"sc\" "
123 "</FORM></TD>", _("Change CSS"));
125 wc_printf("</TR>\n");
128 wc_printf("<TR><TD> </TD>"
129 "<TD><FORM METHOD=\"POST\" action=\"create_floor\">");
130 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
131 wc_printf("<INPUT TYPE=\"text\" NAME=\"floorname\" "
132 "MAXLENGTH=\"250\">\n"
133 "<INPUT TYPE=\"SUBMIT\" NAME=\"sc\" "
136 "<TD> </TD></TR>\n", _("Create new floor"));
138 wc_printf("</table></div>\n");
144 * delete the actual floor
146 void delete_floor(void) {
151 floornum = ibstr("floornum");
153 serv_printf("KFLR %d|1", floornum);
155 StrBufTCP_read_line(Buf, &WC->serv_sock, 0, &Err);
157 if (GetServerStatus(Buf, NULL) == 2) {
158 StrBufPlain(Buf, _("Floor has been deleted."),-1);
161 StrBufCutLeft(Buf, 4);
165 display_floorconfig(Buf);
170 * start creating a new floor
172 void create_floor(void) {
177 serv_printf("CFLR %s|1", bstr("floorname"));
178 StrBufTCP_read_line(Buf, &WC->serv_sock, 0, &Err);
180 if (GetServerStatus(Buf, NULL) == 2) {
181 StrBufPlain(Buf, _("New floor has been created."),-1);
184 StrBufCutLeft(Buf, 4);
188 display_floorconfig(Buf);
196 void rename_floor(void) {
202 serv_printf("EFLR %d|%s", ibstr("floornum"), bstr("floorname"));
203 StrBuf_ServGetln(Buf);
205 StrBufCutLeft(Buf, 4);
207 display_floorconfig(Buf);
211 void _display_floorconfig(void) {display_floorconfig(NULL);}
217 WebcitAddUrlHandler(HKEY("delete_floor"), "", 0, delete_floor, 0);
218 WebcitAddUrlHandler(HKEY("rename_floor"), "", 0, rename_floor, 0);
219 WebcitAddUrlHandler(HKEY("create_floor"), "", 0, create_floor, 0);
220 WebcitAddUrlHandler(HKEY("display_floorconfig"), "", 0, _display_floorconfig, 0);