/*
* Lots of different room-related operations.
+ *
+ * Copyright (c) 1996-2012 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, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*/
#include "webcit.h"
*
* got The information returned from a GOTO server command
* navbar_style Determines which navigation buttons to display
- *
*/
void tmplput_roombanner(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
- /* refresh current room states... */
- /* dosen't work??? gotoroom(NULL); */
+ /* Refresh current room states. Doesn't work? gotoroom(NULL); */
+
wc_printf("<div id=\"banner\">\n");
/* The browser needs some information for its own use */
" room_is_trash = %d; \n"
"</script>\n",
((WC->CurRoom.RAFlags & UA_ISTRASH) != 0)
- );
+ );
/*
* If the user happens to select the "make this my start page" link,
if (WCC->Hdr->this_page == NULL) {
WCC->Hdr->this_page = NewStrBuf();
}
- StrBufPrintf(WCC->Hdr->this_page,
- "dotskip?room=%s",
- ChrPtr(WC->CurRoom.name)
- );
+ StrBufPrintf(WCC->Hdr->this_page, "dotskip?room=%s", ChrPtr(WC->CurRoom.name));
- do_template("roombanner", NULL);
- /* roombanner contains this for mobile */
- if (WC->is_mobile)
- return;
+ do_template("roombanner");
- do_template("navbar", NULL);
+ do_template("navbar");
wc_printf("</div>\n");
}
/*******************************************************************************
********************** FLOOR Tokens *******************************************
- ******************************************************************************/
+ *******************************************************************************/
+
+
void tmplput_FLOOR_ID(StrBuf *Target, WCTemplputParams *TP)
{
Floor *myFloor = (Floor *)CTX;
StrBufAppendPrintf(Target, "%d", myFloor->ID);
}
+
+
void tmplput_ROOM_FLOORID(StrBuf *Target, WCTemplputParams *TP)
{
folder *Folder = (folder *)CTX;
StrBufAppendPrintf(Target, "%d", Folder->floorid);
}
+
+
void tmplput_ROOM_FLOOR_ID(StrBuf *Target, WCTemplputParams *TP)
{
folder *Folder = (folder *)CTX;
StrBufAppendPrintf(Target, "%d", pFloor->ID);
}
+
void tmplput_ROOM_FLOOR_NAME(StrBuf *Target, WCTemplputParams *TP)
{
folder *Folder = (folder *)CTX;
StrBufAppendTemplate(Target, TP, pFloor->Name, 0);
}
+
+
void tmplput_ThisRoomFloorName(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
StrBufAppendTemplate(Target, TP, pFloor->Name, 0);
}
+
+
void tmplput_FLOOR_NAME(StrBuf *Target, WCTemplputParams *TP)
{
Floor *myFloor = (Floor *)CTX;
StrBufAppendTemplate(Target, TP, myFloor->Name, 0);
}
+
void tmplput_FLOOR_NROOMS(StrBuf *Target, WCTemplputParams *TP)
{
Floor *myFloor = (Floor *)CTX;
StrBufAppendPrintf(Target, "%d", myFloor->NRooms);
}
+
+
void tmplput_ROOM_FLOOR_NROOMS(StrBuf *Target, WCTemplputParams *TP)
{
folder *Folder = (folder *)CTX;
return;
StrBufAppendPrintf(Target, "%d", pFloor->NRooms);
}
+
+
int ConditionalFloorHaveNRooms(StrBuf *Target, WCTemplputParams *TP)
{
Floor *MyFloor = (Floor *)CTX;
return HaveN == MyFloor->NRooms;
}
+
int ConditionalFloorIsRESTSubFloor(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
return 1;
return WCC->CurrentFloor == MyFloor;
}
+
+
int ConditionalFloorIsSUBROOM(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
}
-
/*******************************************************************************
********************** ROOM Tokens ********************************************
- ******************************************************************************/
+ *******************************************************************************/
/**** Name ******/
+
+
void tmplput_RoomName(StrBuf *Target, WCTemplputParams *TP)
{
StrBufAppendTemplate(Target, TP, WC->CurRoom.name, 0);
}
+
+
void tmplput_current_room(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
- if (WCC != NULL)
+ if (WCC != NULL) {
StrBufAppendTemplate(Target, TP,
- WCC->CurRoom.name,
- 0);
+ WCC->CurRoom.name,
+ 0
+ );
+ }
}
+
+
void tmplput_ROOM_NAME(StrBuf *Target, WCTemplputParams *TP)
{
folder *Folder = (folder *)CTX;
}
StrBufAppendTemplate(Target, TP, Folder->name, 0);
}
+
+
void tmplput_ROOM_BASENAME(StrBuf *Target, WCTemplputParams *TP)
{
folder *room = (folder *)CTX;
else
StrBufAppendTemplate(Target, TP, room->name, 0);
}
+
+
void tmplput_ROOM_LEVEL_N_TIMES(StrBuf *Target, WCTemplputParams *TP)
{
folder *room = (folder *)CTX;
StrBufAppendBufPlain(Target, AppendMe, AppendMeLen, 0);
}
}
+
+
int ConditionalRoomIsInbox(StrBuf *Target, WCTemplputParams *TP)
{
folder *Folder = (folder *)CTX;
return Folder->is_inbox;
}
+
/****** 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;
else
return (WCC->CurRoom.QRFlags & QR_CheckFlag) == QR_CheckFlag;
}
+
+
int ConditionalRoomHas_QRFlag(StrBuf *Target, WCTemplputParams *TP)
{
long QR_CheckFlag;
else
return (Folder->QRFlags & QR_CheckFlag) == QR_CheckFlag;
}
+
+
void tmplput_ROOM_QRFLAGS(StrBuf *Target, WCTemplputParams *TP)
{
folder *Folder = (folder *)CTX;
else
return (WCC->CurRoom.QRFlags2 & QR2_CheckFlag) == QR2_CheckFlag;
}
+
+
int ConditionalRoomHas_QRFlag2(StrBuf *Target, WCTemplputParams *TP)
{
long QR2_CheckFlag;
return ((Folder->QRFlags2 & QR2_CheckFlag) != 0);
}
+
int ConditionalRoomHas_UAFlag(StrBuf *Target, WCTemplputParams *TP)
{
folder *Folder = (folder *)(TP->Context);
}
-
-
-
void tmplput_ROOM_ACL(StrBuf *Target, WCTemplputParams *TP)
{
folder *Folder = (folder *)CTX;
}
-
void tmplput_ROOM_RAFLAGS(StrBuf *Target, WCTemplputParams *TP)
{
folder *Folder = (folder *)(TP->Context);
StrBufAppendTemplate(Target, TP, WCC->CurRoom.RoomAide, 0);
}
+
+
int ConditionalRoomAide(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) : 0;
}
+
int ConditionalRoomAcessDelete(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
}
-
int ConditionalHaveRoomeditRights(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
- return ( (WCC!= NULL) &&
- ((WCC->axlevel >= 6) ||
- ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) ||
- (WCC->CurRoom.is_inbox) ));
+ return ( (WCC != NULL)
+ && (WCC->logged_in)
+ && (
+ (WCC->axlevel >= 6)
+ || ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0)
+ || (WCC->CurRoom.is_inbox)
+ )
+ );
}
+
+
void tmplput_ThisRoomPass(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
LoadRoomXA();
-
StrBufAppendTemplate(Target, TP, WCC->CurRoom.XAPass, 0);
}
-
-
-
-
void tmplput_ThisRoom_nNewMessages(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
StrBufAppendPrintf(Target, "%d", WCC->CurRoom.nNewMessages);
}
+
void tmplput_ThisRoom_nTotalMessages(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
}
-
-
-
-
void tmplput_ThisRoomOrder(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
StrBufAppendPrintf(Target, "%d", WCC->CurRoom.Order);
}
+
int ConditionalThisRoomOrder(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
return CheckThis == WCC->CurRoom.Order;
}
+
void tmplput_ROOM_LISTORDER(StrBuf *Target, WCTemplputParams *TP)
{
folder *Folder = (folder *)CTX;
}
-
-
-
int ConditionalThisRoomXHavePic(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
LoadXRoomInfoText();
return (StrLength(WCC->CurRoom.XInfoText)>0);
}
+
+
void tmplput_ThisRoomInfoText(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
/* only a certain number of characters */
StrBuf *SubBuf;
SubBuf = NewStrBufDup(WCC->CurRoom.XInfoText);
- StrBuf_Utf8StrCut(SubBuf, nchars);
- StrBufAppendBufPlain(SubBuf, HKEY("..."), 0);
+ if (StrLength(SubBuf) > nchars) {
+ StrBuf_Utf8StrCut(SubBuf, nchars);
+ StrBufAppendBufPlain(SubBuf, HKEY("..."), 0);
+ }
StrBufAppendTemplate(Target, TP, SubBuf, 1);
FreeStrBuf(&SubBuf);
}
}
-
-
-
-
void tmplput_ROOM_LASTCHANGE(StrBuf *Target, WCTemplputParams *TP)
{
folder *Folder = (folder *)CTX;
}
-
-
-
-
-
-
void tmplput_ThisRoomDirectory(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
StrBufAppendTemplate(Target, TP, WCC->CurRoom.Directory, 0);
}
+
+
void tmplput_ThisRoomXNFiles(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
StrBufAppendPrintf(Target, "%d", WCC->CurRoom.XDownloadCount);
}
+
void tmplput_ThisRoomX_FileString(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
}
+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)
/**** Room... ******/
/**** Name ******/
RegisterNamespace("ROOMNAME", 0, 1, tmplput_RoomName, NULL, CTX_NONE);
- RegisterNamespace("CURRENT_ROOM", 0, 1, tmplput_current_room, NULL, CTX_NONE);
+ RegisterNamespace("THISROOM", 0, 1, tmplput_current_room, NULL, CTX_NONE);
RegisterNamespace("ROOM:INFO:NAME", 0, 1, tmplput_ROOM_NAME, NULL, CTX_ROOMS);
RegisterNamespace("ROOM:INFO:PRINT_NAME", 0, 1, tmplput_ROOM_NAME, NULL, CTX_NONE);
RegisterNamespace("ROOM:INFO:BASENAME", 0, 1, tmplput_ROOM_BASENAME, NULL, CTX_ROOMS);
/****** 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);
RegisterNamespace("THISROOM:FILES:STR", 0, 1, tmplput_ThisRoomX_FileString, NULL, CTX_NONE);
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);
}