* Re-added tiny_mce, this time with the language packs
[citadel.git] / webcit / floors.c
blob78227221b6f5353de6cd27b9ce667ae38894347c
1 /*
2 * $Id$
3 */
4 /**
5 * \defgroup AdminFloor Administrative screens for floor maintenance
6 * \ingroup CitadelConfig
7 */
8 /*@{*/
10 #include "webcit.h"
11 #include "webserver.h"
16 /**
17 * \brief Display floor config
18 * Display floor configuration. If prepend_html is not NULL, its contents
19 * will be displayed at the top of the screen.
20 * \param prepend_html pagetitle to prepend
22 void display_floorconfig(StrBuf *prepend_html)
24 char buf[SIZ];
26 int floornum;
27 char floorname[SIZ];
28 int refcount;
30 output_headers(1, 1, 2, 0, 0, 0);
31 wprintf("<div id=\"banner\">\n");
32 wprintf("<h1>");
33 wprintf(_("Add/change/delete floors"));
34 wprintf("</h1>");
35 wprintf("</div>\n");
37 wprintf("<div id=\"content\" class=\"service\">\n");
39 if (prepend_html != NULL) {
40 wprintf("<br /><b><i>");
41 StrBufAppendBuf(WC->WBuf, prepend_html, 0);
42 wprintf("</i></b><br /><br />\n");
45 serv_printf("LFLR");
46 serv_getln(buf, sizeof buf);
47 if (buf[0] != '1') {
48 wprintf("<TABLE class=\"floors_config\"><TR><TD>");
49 wprintf("<SPAN CLASS=\"titlebar\">");
50 wprintf(_("Error"));
51 wprintf("</SPAN>\n");
52 wprintf("</TD></TR></TABLE>\n");
53 wprintf("%s<br />\n", &buf[4]);
54 wDumpContent(1);
55 return;
58 wprintf("<div class=\"fix_scrollbar_bug\">"
59 "<TABLE BORDER=1 WIDTH=100%% bgcolor=\"#ffffff\">\n"
60 "<TR><TH>");
61 wprintf(_("Floor number"));
62 wprintf("</TH><TH>");
63 wprintf(_("Floor name"));
64 wprintf("</TH><TH>");
65 wprintf(_("Number of rooms"));
66 wprintf("</TH><TH>");
67 wprintf(_("Floor CSS"));
68 wprintf("</TH></TR>\n");
70 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
71 floornum = extract_int(buf, 0);
72 extract_token(floorname, buf, 1, '|', sizeof floorname);
73 refcount = extract_int(buf, 2);
75 wprintf("<TR><TD><TABLE border=0><TR><TD>%d", floornum);
76 if (refcount == 0) {
77 wprintf("</TD><TD>"
78 "<a href=\"delete_floor?floornum=%d\">"
79 "<FONT SIZE=-1>", floornum);
80 wprintf(_("(delete floor)"));
81 wprintf("</A></FONT><br />");
83 wprintf("<FONT SIZE=-1>"
84 "<a href=\"display_editfloorpic&"
85 "which_floor=%d\">", floornum);
86 wprintf(_("(edit graphic)"));
87 wprintf("</A></TD></TR></TABLE>");
88 wprintf("</TD>");
90 wprintf("<TD>"
91 "<FORM METHOD=\"POST\" action=\"rename_floor\">"
92 "<INPUT TYPE=\"hidden\" NAME=\"floornum\" "
93 "VALUE=\"%d\">"
94 "<INPUT TYPE=\"text\" NAME=\"floorname\" "
95 "VALUE=\"%s\" MAXLENGTH=\"250\">\n",
96 floornum, floorname);
97 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
98 wprintf("<INPUT TYPE=\"SUBMIT\" NAME=\"sc\" "
99 "VALUE=\"%s\">"
100 "</FORM></TD>", _("Change name"));
102 wprintf("<TD>%d</TD>\n", refcount);
104 wprintf("<TD>"
105 "<FORM METHOD=\"POST\" action=\"set_floor_css\">"
106 "<INPUT TYPE=\"hidden\" NAME=\"floornum\" "
107 "VALUE=\"%d\">"
108 "<INPUT TYPE=\"text\" NAME=\"floorcss\" "
109 "VALUE=\"%s\" MAXLENGTH=\"250\">\n",
110 floornum, floorname);
111 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
112 wprintf("<INPUT TYPE=\"SUBMIT\" NAME=\"sc\" "
113 "VALUE=\"%s\">"
114 "</FORM></TD>", _("Change CSS"));
116 wprintf("</TR>\n");
119 wprintf("<TR><TD>&nbsp;</TD>"
120 "<TD><FORM METHOD=\"POST\" action=\"create_floor\">");
121 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
122 wprintf("<INPUT TYPE=\"text\" NAME=\"floorname\" "
123 "MAXLENGTH=\"250\">\n"
124 "<INPUT TYPE=\"SUBMIT\" NAME=\"sc\" "
125 "VALUE=\"%s\">"
126 "</FORM></TD>"
127 "<TD>&nbsp;</TD></TR>\n", _("Create new floor"));
129 wprintf("</table></div>\n");
130 wDumpContent(1);
135 * \brief delete the actual floor
137 void delete_floor(void) {
138 int floornum;
139 StrBuf *Buf;
140 const char *Err;
142 floornum = ibstr("floornum");
143 Buf = NewStrBuf();
144 serv_printf("KFLR %d|1", floornum);
146 StrBufTCP_read_line(Buf, &WC->serv_sock, 0, &Err);
148 if (GetServerStatus(Buf, NULL) == 2) {
149 StrBufPlain(Buf, _("Floor has been deleted."),-1);
151 else {
152 StrBufCutLeft(Buf, 4);
155 display_floorconfig(Buf);
156 FreeStrBuf(&Buf);
160 * \brief tart creating a new floor
162 void create_floor(void) {
163 StrBuf *Buf;
164 const char *Err;
166 Buf = NewStrBuf();
167 serv_printf("CFLR %s|1", bstr("floorname"));
168 StrBufTCP_read_line(Buf, &WC->serv_sock, 0, &Err);
170 if (GetServerStatus(Buf, NULL) == 2) {
171 StrBufPlain(Buf, _("New floor has been created."),-1);
173 else {
174 StrBufCutLeft(Buf, 4);
177 display_floorconfig(Buf);
178 FreeStrBuf(&Buf);
183 * \brief rename this floor
185 void rename_floor(void) {
186 StrBuf *Buf;
188 Buf = NewStrBuf();
190 serv_printf("EFLR %d|%s",
191 ibstr("floornum"),
192 bstr("floorname"));
193 StrBuf_ServGetln(Buf);
195 StrBufCutLeft(Buf, 4);
197 display_floorconfig(Buf);
198 FreeStrBuf(&Buf);
201 void _display_floorconfig(void) {display_floorconfig(NULL);}
203 void
204 InitModule_FLOORS
205 (void)
207 WebcitAddUrlHandler(HKEY("delete_floor"), delete_floor, 0);
208 WebcitAddUrlHandler(HKEY("rename_floor"), rename_floor, 0);
209 WebcitAddUrlHandler(HKEY("create_floor"), create_floor, 0);
210 WebcitAddUrlHandler(HKEY("display_floorconfig"), _display_floorconfig, 0);
212 /*@}*/