From 6f5ff1aa3e9b81adbeaca8c7cd95c67c49cf4df9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Sat, 14 Aug 2010 14:09:33 +0000 Subject: [PATCH] * defines may now be ored or anded * conditionals should check, whether one of the above, ored: != 0, anded: == checkvalue * added that to the QR* conditionals * use the or/and notation in QR of room edit --- webcit/roomlist.c | 7 ++ webcit/roomops.c | 28 ++++++-- webcit/static/t/room/edit/tab_config.html | 30 +++----- webcit/static/t/room/select_targetfloor.html | 2 +- webcit/subst.c | 75 +++++++++++++++++++- webcit/subst.h | 6 ++ 6 files changed, 122 insertions(+), 26 deletions(-) diff --git a/webcit/roomlist.c b/webcit/roomlist.c index 61a43c2e5..dcffe0fea 100644 --- a/webcit/roomlist.c +++ b/webcit/roomlist.c @@ -719,6 +719,12 @@ int ConditionalFloorIsRESTSubFloor(StrBuf *Target, WCTemplputParams *TP) return WCC->CurrentFloor == MyFloor; } +int ConditionalFloorIsVirtual(StrBuf *Target, WCTemplputParams *TP) +{ + Floor *MyFloor = (Floor *)CTX; + + return MyFloor->ID == VIRTUAL_MY_FLOOR; +} int ConditionalFloorIsSUBROOM(StrBuf *Target, WCTemplputParams *TP) { @@ -849,6 +855,7 @@ InitModule_ROOMLIST RegisterNamespace("FLOOR:NAME", 0, 1, tmplput_FLOOR_NAME, NULL, CTX_FLOORS); RegisterNamespace("FLOOR:NROOMS", 0, 0, tmplput_FLOOR_NROOMS, NULL, CTX_FLOORS); RegisterConditional(HKEY("COND:FLOOR:ISSUBROOM"), 0, ConditionalFloorIsSUBROOM, CTX_FLOORS); + RegisterConditional(HKEY("COND:FLOOR:ISVIRTUAL"), 0, ConditionalFloorIsVirtual, CTX_FLOORS); RegisterConditional(HKEY("COND:ROOM:REST:ISSUBFLOOR"), 0, ConditionalFloorIsRESTSubFloor, CTX_FLOORS); RegisterIterator("ITERATE:THISROOM:GNET", 1, NULL, GetNetConfigHash, NULL, NULL, CTX_STRBUFARR, CTX_NONE, IT_NOFLAG); diff --git a/webcit/roomops.c b/webcit/roomops.c index 455de1d2e..2a2b34722 100644 --- a/webcit/roomops.c +++ b/webcit/roomops.c @@ -2979,9 +2979,15 @@ int ConditionalCurrentRoomHas_QRFlag(StrBuf *Target, WCTemplputParams *TP) if (QR_CheckFlag == 0) LogTemplateError(Target, "Conditional", ERR_PARM1, TP, "requires one of the #\"QR*\"- defines or an integer flag 0 is invalid!"); + + if (WCC == NULL) + return 0; - return ((WCC!=NULL) && - ((WCC->CurRoom.QRFlags & QR_CheckFlag) != 0)); + if ((TP->Tokens->Params[2]->MaskBy == eOR) || + (TP->Tokens->Params[2]->MaskBy == eNO)) + return (WCC->CurRoom.QRFlags & QR_CheckFlag) != 0; + else + return (WCC->CurRoom.QRFlags & QR_CheckFlag) == QR_CheckFlag; } int ConditionalRoomHas_QRFlag(StrBuf *Target, WCTemplputParams *TP) @@ -2993,7 +2999,12 @@ int ConditionalRoomHas_QRFlag(StrBuf *Target, WCTemplputParams *TP) if (QR_CheckFlag == 0) LogTemplateError(Target, "Conditional", ERR_PARM1, TP, "requires one of the #\"QR*\"- defines or an integer flag 0 is invalid!"); - return ((Folder->QRFlags & QR_CheckFlag) != 0); + + if ((TP->Tokens->Params[2]->MaskBy == eOR) || + (TP->Tokens->Params[2]->MaskBy == eNO)) + return (Folder->QRFlags & QR_CheckFlag) != 0; + else + return (Folder->QRFlags & QR_CheckFlag) == QR_CheckFlag; } @@ -3007,8 +3018,15 @@ int ConditionalCurrentRoomHas_QRFlag2(StrBuf *Target, WCTemplputParams *TP) LogTemplateError(Target, "Conditional", ERR_PARM1, TP, "requires one of the #\"QR2*\"- defines or an integer flag 0 is invalid!"); - return ((WCC!=NULL) && - ((WCC->CurRoom.QRFlags2 & QR2_CheckFlag) != 0)); + + if (WCC == NULL) + return 0; + + if ((TP->Tokens->Params[2]->MaskBy == eOR) || + (TP->Tokens->Params[2]->MaskBy == eNO)) + return (WCC->CurRoom.QRFlags2 & QR2_CheckFlag) != 0; + else + return (WCC->CurRoom.QRFlags2 & QR2_CheckFlag) == QR2_CheckFlag; } int ConditionalRoomHas_QRFlag2(StrBuf *Target, WCTemplputParams *TP) diff --git a/webcit/static/t/room/edit/tab_config.html b/webcit/static/t/room/edit/tab_config.html index 7baaf925c..143550117 100644 --- a/webcit/static/t/room/edit/tab_config.html +++ b/webcit/static/t/room/edit/tab_config.html @@ -4,7 +4,7 @@