From 4840b5b6dfe82499f2274aeff0229e4aaf2ef0c1 Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Wed, 25 Jan 2012 00:27:34 +0100 Subject: [PATCH] Roomediting: add permission check to to some dialogs --- webcit/roomops.c | 18 +++++++++++------- webcit/roomtokens.c | 10 ++++++++++ webcit/static/t/room/edit/tab_access.html | 3 ++- webcit/static/t/room/edit/tab_config.html | 3 ++- webcit/static/t/room/edit/tab_expire.html | 3 ++- 5 files changed, 27 insertions(+), 10 deletions(-) diff --git a/webcit/roomops.c b/webcit/roomops.c index 85e998bcb..b6fdaa8df 100644 --- a/webcit/roomops.c +++ b/webcit/roomops.c @@ -481,7 +481,7 @@ int SaveRoomAide(folder *Room) } -int GetCurrentRoomFlags(folder *Room) +int GetCurrentRoomFlags(folder *Room, int CareForStatusMessage) { StrBuf *Buf; @@ -492,8 +492,10 @@ int GetCurrentRoomFlags(folder *Room) FlushStrBuf(Room->XAPass); FlushStrBuf(Room->Directory); StrBufCutLeft(Buf, 4); - AppendImportantMessage (SKEY(Buf)); + if (CareForStatusMessage) + AppendImportantMessage (SKEY(Buf)); FreeStrBuf(&Buf); + Room->XALoaded = 2; return 0; } else { const char *Pos; @@ -560,10 +562,10 @@ void LoadRoomXA (void) { wcsession *WCC = WC; - if (WCC->CurRoom.XALoaded) + if (WCC->CurRoom.XALoaded > 0) return; - GetCurrentRoomFlags(&WCC->CurRoom); + GetCurrentRoomFlags(&WCC->CurRoom, 0); } @@ -658,7 +660,7 @@ void LoadXRoomXCountFiles(void) void toggle_self_service(void) { wcsession *WCC = WC; - if (GetCurrentRoomFlags (&WCC->CurRoom) == 0) + if (GetCurrentRoomFlags (&WCC->CurRoom, 1) == 0) return; if (yesbstr("QR2_SelfList")) @@ -707,8 +709,10 @@ void editroom(void) http_transmit_thing(ChrPtr(do_template("room_edit")), 0); return; } - if (GetCurrentRoomFlags (&WCC->CurRoom) == 0) + if (GetCurrentRoomFlags (&WCC->CurRoom, 1) == 0) { + http_transmit_thing(ChrPtr(do_template("room_edit")), 0); return; + } LoadRoomAide(); @@ -849,7 +853,7 @@ void do_invt_kick(void) wcsession *WCC = WC; - if (GetCurrentRoomFlags(&WCC->CurRoom) == 1) + if (GetCurrentRoomFlags(&WCC->CurRoom, 1) == 1) { const char *Pos; UserNames = sbstr("username"); diff --git a/webcit/roomtokens.c b/webcit/roomtokens.c index d41b36af1..21b8cc4a3 100644 --- a/webcit/roomtokens.c +++ b/webcit/roomtokens.c @@ -266,6 +266,15 @@ int ConditionalRoomIsInbox(StrBuf *Target, WCTemplputParams *TP) /****** Properties ******/ +int ConditionalRoom_MayEdit(StrBuf *Target, WCTemplputParams *TP) +{ + wcsession *WCC = WC; + + LoadRoomXA (); + + return WCC->CurRoom.XALoaded == 1; +} + int ConditionalThisRoomHas_QRFlag(StrBuf *Target, WCTemplputParams *TP) { long QR_CheckFlag; @@ -613,6 +622,7 @@ InitModule_ROOMTOKENS /****** Properties ******/ RegisterNamespace("ROOM:INFO:QRFLAGS", 0, 1, tmplput_ROOM_QRFLAGS, NULL, CTX_ROOMS); RegisterConditional(HKEY("COND:THISROOM:FLAG:QR"), 0, ConditionalThisRoomHas_QRFlag, CTX_NONE); + RegisterConditional(HKEY("COND:THISROOM:EDIT"), 0, ConditionalRoom_MayEdit, CTX_NONE); RegisterConditional(HKEY("COND:ROOM:FLAG:QR"), 0, ConditionalRoomHas_QRFlag, CTX_ROOMS); RegisterConditional(HKEY("COND:THISROOM:FLAG:QR2"), 0, ConditionalThisRoomHas_QRFlag2, CTX_NONE); diff --git a/webcit/static/t/room/edit/tab_access.html b/webcit/static/t/room/edit/tab_access.html index 3048972f4..8cad949fe 100644 --- a/webcit/static/t/room/edit/tab_access.html +++ b/webcit/static/t/room/edit/tab_access.html @@ -1,4 +1,4 @@ -
+
@@ -39,3 +39,4 @@
+
diff --git a/webcit/static/t/room/edit/tab_config.html b/webcit/static/t/room/edit/tab_config.html index 0a6891c4a..7c45b6ec7 100644 --- a/webcit/static/t/room/edit/tab_config.html +++ b/webcit/static/t/room/edit/tab_config.html @@ -1,4 +1,4 @@ -
+
    @@ -146,3 +146,4 @@
+
diff --git a/webcit/static/t/room/edit/tab_expire.html b/webcit/static/t/room/edit/tab_expire.html index dc4e61c21..fb958151b 100644 --- a/webcit/static/t/room/edit/tab_expire.html +++ b/webcit/static/t/room/edit/tab_expire.html @@ -1,4 +1,4 @@ -
+

@@ -69,3 +69,4 @@
+
-- 2.30.2