Roomediting: add permission check to to some dialogs
[citadel.git] / webcit / roomtokens.c
index df6b1581a62967e3cfabcde9358ec2e171f49044..21b8cc4a3a11d270f986643918183cff3fa733d7 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Lots of different room-related operations.
  *
- * Copyright (c) 1996-2010 by the citadel.org team
+ * Copyright (c) 1996-2011 by the citadel.org team
  *
  * This program is open source software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as published
@@ -53,9 +53,9 @@ void tmplput_roombanner(StrBuf *Target, WCTemplputParams *TP)
        }
        StrBufPrintf(WCC->Hdr->this_page, "dotskip?room=%s", ChrPtr(WC->CurRoom.name));
 
-       do_template("roombanner", NULL);
+       do_template("roombanner");
 
-       do_template("navbar", NULL);
+       do_template("navbar");
        wc_printf("</div>\n");
 }
 
@@ -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;
@@ -566,6 +575,18 @@ void tmplput_ThisRoomX_FileString(StrBuf *Target, WCTemplputParams *TP)
 }
 
 
+int ConditionalIsThisThatRoom(StrBuf *Target, WCTemplputParams *TP)
+{
+       folder *Folder = (folder *)CTX;
+       wcsession *WCC = WC;
+
+       if (WCC == NULL)
+               return 0;
+
+       return Folder == WCC->ThisRoom;
+}
+
+
 void 
 InitModule_ROOMTOKENS
 (void)
@@ -601,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);
@@ -635,4 +657,5 @@ InitModule_ROOMTOKENS
        RegisterNamespace("THISROOM:DIRECTORY", 0, 1, tmplput_ThisRoomDirectory, NULL, CTX_NONE);
 
        RegisterNamespace("ROOM:INFO:ACL", 0, 1, tmplput_ROOM_ACL, NULL, CTX_ROOMS);
+       RegisterConditional(HKEY("COND:THIS:THAT:ROOM"), 0, ConditionalIsThisThatRoom, CTX_ROOMS);
 }