Templatize the info editing boxes
[citadel.git] / webcit / sysmsgs.c
1 /*
2  * Copyright (c) 1996-2012 by the citadel.org team
3  *
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.
6  *
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.
11  */
12
13 #include "webcit.h"
14
15 /**
16  *  save a screen which was displayed with display_edit()
17  *  description the window title???
18  *  enter_cmd which command to enter at the citadel server???
19  *  regoto should we go to that room again after executing that command?
20  */
21 void save_edit(char *description, char *enter_cmd, int regoto)
22 {
23         StrBuf *Line;
24         const StrBuf *templ;
25
26         if (!havebstr("save_button")) {
27                 AppendImportantMessage(_("Cancelled.  %s was not saved."), -1);
28                 display_main_menu();
29                 return;
30         }
31         Line = NewStrBuf();
32         serv_puts(enter_cmd);
33         StrBuf_ServGetln(Line);
34         if (GetServerStatusMsg(Line, NULL, 1, 0) != 4) {
35                 FreeStrBuf(&Line);
36                 display_main_menu();
37                 return;
38         }
39         FreeStrBuf(&Line);
40         text_to_server(bstr("msgtext"));
41         serv_puts("000");
42
43         templ=sbstr("template");
44         AppendImportantMessage(description, -1);
45         AppendImportantMessage(_(" has been saved."), -1);
46         if (templ != NULL) {
47                 DoTemplate(SKEY(templ), NULL, &NoCtx);
48         }
49         else if (regoto) {
50                 smart_goto(WC->CurRoom.name);
51         } else {
52                 display_main_menu();
53                 return;
54         }
55 }
56
57
58 void editinfo(void) {save_edit(_("Room info"), "EINF 1", 1);}
59 void editbio(void) { save_edit(_("Your bio"), "EBIO", 0); }
60
61 void 
62 InitModule_SYSMSG
63 (void)
64 {
65         WebcitAddUrlHandler(HKEY("editinfo"), "", 0, editinfo, 0);
66         WebcitAddUrlHandler(HKEY("editbio"), "", 0, editbio, 0);
67 }