/*
* $Id$
- *
- * Administrative screens for floor maintenance
- *
*/
-
+/**
+ * \defgroup AdminFloor Administrative screens for floor maintenance
+ * \ingroup CitadelConfig
+ */
+/*@{*/
#include "webcit.h"
#include "webserver.h"
-/*
+/**
+ * \brief Display floor config
* Display floor configuration. If prepend_html is not NULL, its contents
* will be displayed at the top of the screen.
+ * \param prepend_html pagetitle to prepend
*/
-void display_floorconfig(char *prepend_html)
+void display_floorconfig(StrBuf *prepend_html)
{
char buf[SIZ];
int refcount;
output_headers(1, 1, 2, 0, 0, 0);
- wprintf("<div id=\"banner\">\n"
- "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
- "<SPAN CLASS=\"titlebar\">");
+ wprintf("<div id=\"banner\">\n");
+ wprintf("<h1>");
wprintf(_("Add/change/delete floors"));
- wprintf("</SPAN>"
- "</TD></TR></TABLE>\n"
- "</div>\n<div id=\"content\">\n"
- );
+ wprintf("</h1>");
+ wprintf("</div>\n");
+
+ wprintf("<div id=\"content\" class=\"service\">\n");
if (prepend_html != NULL) {
wprintf("<br /><b><i>");
- client_write(prepend_html, strlen(prepend_html));
+ StrBufAppendBuf(WC->WBuf, prepend_html, 0);
wprintf("</i></b><br /><br />\n");
}
serv_printf("LFLR");
serv_getln(buf, sizeof buf);
if (buf[0] != '1') {
- wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
+ wprintf("<TABLE class=\"floors_config\"><TR><TD>");
wprintf("<SPAN CLASS=\"titlebar\">");
wprintf(_("Error"));
wprintf("</SPAN>\n");
return;
}
- wprintf("<div id=\"fix_scrollbar_bug\">"
+ wprintf("<div class=\"fix_scrollbar_bug\">"
"<TABLE BORDER=1 WIDTH=100%% bgcolor=\"#ffffff\">\n"
"<TR><TH>");
wprintf(_("Floor number"));
wprintf(_("Floor name"));
wprintf("</TH><TH>");
wprintf(_("Number of rooms"));
+ wprintf("</TH><TH>");
+ wprintf(_("Floor CSS"));
wprintf("</TH></TR>\n");
while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
"<INPUT TYPE=\"text\" NAME=\"floorname\" "
"VALUE=\"%s\" MAXLENGTH=\"250\">\n",
floornum, floorname);
+ wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
wprintf("<INPUT TYPE=\"SUBMIT\" NAME=\"sc\" "
"VALUE=\"%s\">"
"</FORM></TD>", _("Change name"));
- wprintf("<TD>%d</TD></TR>\n", refcount);
+ wprintf("<TD>%d</TD>\n", refcount);
+
+ wprintf("<TD>"
+ "<FORM METHOD=\"POST\" action=\"set_floor_css\">"
+ "<INPUT TYPE=\"hidden\" NAME=\"floornum\" "
+ "VALUE=\"%d\">"
+ "<INPUT TYPE=\"text\" NAME=\"floorcss\" "
+ "VALUE=\"%s\" MAXLENGTH=\"250\">\n",
+ floornum, floorname);
+ wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
+ wprintf("<INPUT TYPE=\"SUBMIT\" NAME=\"sc\" "
+ "VALUE=\"%s\">"
+ "</FORM></TD>", _("Change CSS"));
+
+ wprintf("</TR>\n");
}
wprintf("<TR><TD> </TD>"
- "<TD><FORM METHOD=\"POST\" action=\"create_floor\">"
- "<INPUT TYPE=\"text\" NAME=\"floorname\" "
+ "<TD><FORM METHOD=\"POST\" action=\"create_floor\">");
+ wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
+ wprintf("<INPUT TYPE=\"text\" NAME=\"floorname\" "
"MAXLENGTH=\"250\">\n"
"<INPUT TYPE=\"SUBMIT\" NAME=\"sc\" "
"VALUE=\"%s\">"
}
-
+/**
+ * \brief delete the actual floor
+ */
void delete_floor(void) {
int floornum;
- char buf[SIZ];
- char message[SIZ];
-
- floornum = atoi(bstr("floornum"));
-
+ StrBuf *Buf;
+ const char *Err;
+
+ floornum = ibstr("floornum");
+ Buf = NewStrBuf();
serv_printf("KFLR %d|1", floornum);
- serv_getln(buf, sizeof buf);
+
+ StrBufTCP_read_line(Buf, &WC->serv_sock, 0, &Err);
- if (buf[0] == '2') {
- sprintf(message, _("Floor has been deleted."));
+ if (GetServerStatus(Buf, NULL) == 2) {
+ StrBufPlain(Buf, _("Floor has been deleted."),-1);
}
else {
- sprintf(message, "%s", &buf[4]);
+ StrBufCutLeft(Buf, 4);
}
- display_floorconfig(message);
+ display_floorconfig(Buf);
+ FreeStrBuf(&Buf);
}
-
+/**
+ * \brief tart creating a new floor
+ */
void create_floor(void) {
- char buf[SIZ];
- char message[SIZ];
- char floorname[SIZ];
-
- strcpy(floorname, bstr("floorname"));
+ StrBuf *Buf;
+ const char *Err;
- serv_printf("CFLR %s|1", floorname);
- serv_getln(buf, sizeof buf);
+ Buf = NewStrBuf();
+ serv_printf("CFLR %s|1", bstr("floorname"));
+ StrBufTCP_read_line(Buf, &WC->serv_sock, 0, &Err);
- if (buf[0] == '2') {
- sprintf(message, _("New floor has been created."));
- } else {
- sprintf(message, "%s", &buf[4]);
+ if (GetServerStatus(Buf, NULL) == 2) {
+ StrBufPlain(Buf, _("New floor has been created."),-1);
+ }
+ else {
+ StrBufCutLeft(Buf, 4);
}
- display_floorconfig(message);
+ display_floorconfig(Buf);
+ FreeStrBuf(&Buf);
}
+/**
+ * \brief rename this floor
+ */
void rename_floor(void) {
- int floornum;
- char buf[SIZ];
- char message[SIZ];
- char floorname[SIZ];
+ StrBuf *Buf;
- floornum = atoi(bstr("floornum"));
- strcpy(floorname, bstr("floorname"));
+ Buf = NewStrBuf();
- serv_printf("EFLR %d|%s", floornum, floorname);
- serv_getln(buf, sizeof buf);
+ serv_printf("EFLR %d|%s",
+ ibstr("floornum"),
+ bstr("floorname"));
+ StrBuf_ServGetln(Buf);
- sprintf(message, "%s", &buf[4]);
+ StrBufCutLeft(Buf, 4);
- display_floorconfig(message);
+ display_floorconfig(Buf);
+ FreeStrBuf(&Buf);
}
+void _display_floorconfig(void) {display_floorconfig(NULL);}
+void
+InitModule_FLOORS
+(void)
+{
+ WebcitAddUrlHandler(HKEY("delete_floor"), delete_floor, 0);
+ WebcitAddUrlHandler(HKEY("rename_floor"), rename_floor, 0);
+ WebcitAddUrlHandler(HKEY("create_floor"), create_floor, 0);
+ WebcitAddUrlHandler(HKEY("display_floorconfig"), _display_floorconfig, 0);
+}
+/*@}*/