From 13a6f7fb944137d92754d0e8a987ca4cfa7c2fd4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Thu, 12 Aug 2010 20:43:45 +0000 Subject: [PATCH] * templatize the room creation form --- webcit/auth.c | 20 +++- webcit/roomops.c | 56 +++++++--- webcit/static/t/room/create.html | 111 +++++++++++++++++++ webcit/static/t/room/select_targetfloor.html | 1 + 4 files changed, 169 insertions(+), 19 deletions(-) create mode 100644 webcit/static/t/room/create.html create mode 100644 webcit/static/t/room/select_targetfloor.html diff --git a/webcit/auth.c b/webcit/auth.c index 0734e2bf6..d158492df 100644 --- a/webcit/auth.c +++ b/webcit/auth.c @@ -915,6 +915,24 @@ void changepw(void) } } +int ConditionalHaveAccessCreateRoom(StrBuf *Target, WCTemplputParams *TP) +{ + StrBuf *Buf; + + Buf = NewStrBuf(); + serv_puts("CRE8 0"); + StrBuf_ServGetln(Buf); + + if (GetServerStatus(Buf, NULL) == 2) { + StrBufCutLeft(Buf, 4); + AppendImportantMessage(SKEY(Buf)); + FreeStrBuf(&Buf); + return 0; + } + FreeStrBuf(&Buf); + return 1; +} + int ConditionalAide(StrBuf *Target, WCTemplputParams *TP) { wcsession *WCC = WC; @@ -1059,7 +1077,7 @@ InitModule_AUTH RegisterConditional(HKEY("COND:AIDE"), 2, ConditionalAide, CTX_NONE); RegisterConditional(HKEY("COND:LOGGEDIN"), 2, ConditionalIsLoggedIn, CTX_NONE); - + RegisterConditional(HKEY("COND:MAY_CREATE_ROOM"), 2, ConditionalHaveAccessCreateRoom, CTX_NONE); return ; } diff --git a/webcit/roomops.c b/webcit/roomops.c index 44956be84..8e05a2468 100644 --- a/webcit/roomops.c +++ b/webcit/roomops.c @@ -33,6 +33,20 @@ ROOM_VIEWS exchangeable_views[VIEW_MAX][VIEW_MAX] = { /* the different kinds of }; /* the brief calendar view is disabled: VIEW_CALBRIEF */ +allowed_default_views[VIEW_MAX] = { + 1, /* VIEW_BBS Bulletin board view */ + 1, /* VIEW_MAILBOX Mailbox summary */ + 1, /* VIEW_ADDRESSBOOK Address book view */ + 1, /* VIEW_CALENDAR Calendar view */ + 1, /* VIEW_TASKS Tasks view */ + 1, /* VIEW_NOTES Notes view */ + 1, /* VIEW_WIKI Wiki view */ + 0, /* VIEW_CALBRIEF Brief Calendar view */ + 0, /* VIEW_JOURNAL Journal view */ + 0 /* VIEW_BLOG Blog view (not yet implemented) */ +}; + + /* * Initialize the viewdefs with localized strings */ @@ -49,24 +63,6 @@ void initialize_viewdefs(void) { viewdefs[VIEW_BLOG] = _("Blog"); } -/* - * Determine which views are allowed as the default for creating a new room. - */ -int is_view_allowed_as_default(int which_view) -{ - switch(which_view) { - case VIEW_BBS: return(1); - case VIEW_MAILBOX: return(1); - case VIEW_ADDRESSBOOK: return(1); - case VIEW_CALENDAR: return(1); - case VIEW_TASKS: return(1); - case VIEW_NOTES: return(1); - case VIEW_WIKI: return(1); - case VIEW_CALBRIEF: return(0); - case VIEW_JOURNAL: return(0); - default: return(0); /* should never get here */ - } -} /* @@ -937,6 +933,26 @@ void tmplput_RoomViewString(StrBuf *Target, WCTemplputParams *TP) } +int ConditionalIsAllowedDefaultView(StrBuf *Target, WCTemplputParams *TP) +{ + wcsession *WCC = WC; + long CheckThis; + + if (WCC == NULL) + return 0; + + CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0); + if ((CheckThis >= VIEW_MAX) || (CheckThis < VIEW_BBS)) + { + LogTemplateError(Target, "Conditional", ERR_PARM2, TP, + "Roomview [%ld] not valid\n", + CheckThis); + return 0; + } + + return allowed_default_views[CheckThis] != 0; +} + /* * goto next room */ @@ -2492,12 +2508,14 @@ void display_entroom(void) " } " "\">\n"); for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) { +/* if (is_view_allowed_as_default(i)) { wc_printf("\n"); } +*/ } wc_printf("\n"); wc_printf(""); @@ -3300,6 +3318,8 @@ InitModule_ROOMOPS RegisterNamespace("THISROOM:ORDER", 0, 0, tmplput_CurrentRoomOrder, NULL, CTX_NONE); RegisterNamespace("THISROOM:DEFAULT_VIEW", 0, 0, tmplput_CurrentRoomDefView, NULL, CTX_NONE); RegisterConditional(HKEY("COND:THISROOM:HAVE_VIEW"), 0, ConditionalThisRoomHaveView, CTX_NONE); + RegisterConditional(HKEY("COND:ALLOWED_DEFAULT_VIEW"), 0, ConditionalIsAllowedDefaultView, CTX_NONE); + RegisterNamespace("THISROOM:VIEW_STRING", 0, 1, tmplput_CurrentRoomViewString, NULL, CTX_NONE); RegisterNamespace("ROOM:VIEW_STRING", 1, 2, tmplput_RoomViewString, NULL, CTX_NONE); diff --git a/webcit/static/t/room/create.html b/webcit/static/t/room/create.html new file mode 100644 index 000000000..f3a8b6eb9 --- /dev/null +++ b/webcit/static/t/room/create.html @@ -0,0 +1,111 @@ + + + + + + +
+ + + + +
+ + + + + + + + + + + + + +
+ + + +
+ +
+
    + +
  • + +
  • + +
  • + +
  • + +
  • + + +
  • + +
  • + +
  • + +
  • + +
  • + +
+
+ +
+"> +  +"> +
+

+ + + + + + +
+ + diff --git a/webcit/static/t/room/select_targetfloor.html b/webcit/static/t/room/select_targetfloor.html new file mode 100644 index 000000000..5fa5ba909 --- /dev/null +++ b/webcit/static/t/room/select_targetfloor.html @@ -0,0 +1 @@ + -- 2.30.2