Mailing list header changes (fuck you Google)
[citadel.git] / webcit / roomtokens.c
1 /*
2  * Lots of different room-related operations.
3  *
4  * Copyright (c) 1996-2012 by the citadel.org team
5  *
6  * This program is open source software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License, version 3.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  */
14
15 #include "webcit.h"
16 #include "webserver.h"
17
18 CtxType CTX_ROOMS = CTX_NONE;
19 CtxType CTX_FLOORS = CTX_NONE;
20
21 /*
22  * Embed the room banner
23  *
24  * got                  The information returned from a GOTO server command
25  * navbar_style         Determines which navigation buttons to display
26  */
27 void tmplput_roombanner(StrBuf *Target, WCTemplputParams *TP)
28 {
29         wcsession *WCC = WC;
30         
31         /* Refresh current room states.  Doesn't work? gotoroom(NULL); */
32
33         wc_printf("<div id=\"banner\">\n");
34
35         /* The browser needs some information for its own use */
36         wc_printf("<script type=\"text/javascript\">    \n"
37                   "     room_is_trash = %d;             \n"
38                   "</script>\n",
39                   ((WC->CurRoom.RAFlags & UA_ISTRASH) != 0)
40         );
41
42         /*
43          * If the user happens to select the "make this my start page" link,
44          * we want it to remember the URL as a "/dotskip" one instead of
45          * a "skip" or "gotonext" or something like that.
46          */
47         if (WCC->Hdr->this_page == NULL) {
48                 WCC->Hdr->this_page = NewStrBuf();
49         }
50         StrBufPrintf(WCC->Hdr->this_page, "dotskip?room=%s", ChrPtr(WC->CurRoom.name));
51
52         do_template("roombanner");
53
54         do_template("navbar");
55         wc_printf("</div>\n");
56 }
57
58
59 /*******************************************************************************
60  ********************** FLOOR Tokens *******************************************
61  *******************************************************************************/
62
63
64 void tmplput_FLOOR_ID(StrBuf *Target, WCTemplputParams *TP) 
65 {
66         Floor *myFloor = (Floor *)CTX(CTX_FLOORS);
67
68         StrBufAppendPrintf(Target, "%d", myFloor->ID);
69 }
70
71
72 void tmplput_ROOM_FLOORID(StrBuf *Target, WCTemplputParams *TP) 
73 {
74         folder *Folder = (folder *)CTX(CTX_ROOMS);
75         StrBufAppendPrintf(Target, "%d", Folder->floorid);
76 }
77
78
79 void tmplput_ROOM_FLOOR_ID(StrBuf *Target, WCTemplputParams *TP) 
80 {
81         folder *Folder = (folder *)CTX(CTX_ROOMS);
82         const Floor *pFloor = Folder->Floor;
83
84         if (pFloor == NULL)
85                 return;
86
87         StrBufAppendPrintf(Target, "%d", pFloor->ID);
88 }
89
90
91 void tmplput_ROOM_FLOOR_NAME(StrBuf *Target, WCTemplputParams *TP) 
92 {
93         folder *Folder = (folder *)CTX(CTX_ROOMS);
94         const Floor *pFloor = Folder->Floor;
95
96         if (pFloor == NULL)
97                 return;
98
99         StrBufAppendTemplate(Target, TP, pFloor->Name, 0);
100 }
101
102
103 void tmplput_ThisRoomFloorName(StrBuf *Target, WCTemplputParams *TP) 
104 {
105         wcsession *WCC = WC;
106         folder *Folder = &WCC->CurRoom;
107         const Floor *pFloor;
108
109         if (Folder == NULL)
110                 return;
111
112         pFloor = Folder->Floor;
113         if (pFloor == NULL)
114                 return;
115
116         StrBufAppendTemplate(Target, TP, pFloor->Name, 0);
117 }
118
119
120 void tmplput_FLOOR_NAME(StrBuf *Target, WCTemplputParams *TP) 
121 {
122         Floor *myFloor = (Floor *)CTX(CTX_FLOORS);
123
124         StrBufAppendTemplate(Target, TP, myFloor->Name, 0);
125 }
126
127
128 void tmplput_FLOOR_NROOMS(StrBuf *Target, WCTemplputParams *TP) 
129 {
130         Floor *myFloor = (Floor *)CTX(CTX_FLOORS);
131
132         StrBufAppendPrintf(Target, "%d", myFloor->NRooms);
133 }
134
135
136 void tmplput_ROOM_FLOOR_NROOMS(StrBuf *Target, WCTemplputParams *TP) 
137 {
138         folder *Folder = (folder *)CTX(CTX_ROOMS);
139         const Floor *pFloor = Folder->Floor;
140
141         if (pFloor == NULL)
142                 return;
143         StrBufAppendPrintf(Target, "%d", pFloor->NRooms);
144 }
145
146
147 int ConditionalFloorHaveNRooms(StrBuf *Target, WCTemplputParams *TP)
148 {
149         Floor *MyFloor = (Floor *)CTX(CTX_FLOORS);
150         int HaveN;
151
152         HaveN = GetTemplateTokenNumber(Target, TP, 0, 0);
153
154         return HaveN == MyFloor->NRooms;
155 }
156
157
158 int ConditionalFloorIsRESTSubFloor(StrBuf *Target, WCTemplputParams *TP)
159 {
160         wcsession  *WCC = WC;
161         Floor *MyFloor = (Floor *)CTX(CTX_FLOORS);
162         /** if we have dav_depth the client just wants the subfloors */
163         if ((WCC->Hdr->HR.dav_depth == 1) && 
164             (GetCount(WCC->Directory) == 0))
165                 return 1;
166         return WCC->CurrentFloor == MyFloor;
167 }
168
169
170 int ConditionalFloorIsSUBROOM(StrBuf *Target, WCTemplputParams *TP)
171 {
172         wcsession  *WCC = WC;
173         Floor *MyFloor = (Floor *)CTX(CTX_FLOORS);
174
175         return WCC->CurRoom.floorid == MyFloor->ID;
176 }
177
178
179 int ConditionalFloorIsVirtual(StrBuf *Target, WCTemplputParams *TP)
180 {
181         Floor *MyFloor = (Floor *)CTX(CTX_FLOORS);
182
183         return MyFloor->ID == VIRTUAL_MY_FLOOR;
184 }
185
186
187 /*******************************************************************************
188  ********************** ROOM Tokens ********************************************
189  *******************************************************************************/
190 /**** Name ******/
191
192 void tmplput_ThisRoom(StrBuf *Target, WCTemplputParams *TP)
193 {
194         wcsession *WCC = WC;
195
196         if (WCC != NULL) {
197                 StrBufAppendTemplate(Target, TP, 
198                      WCC->CurRoom.name, 
199                      0
200                 );
201         }
202 }
203
204
205 void tmplput_ROOM_NAME(StrBuf *Target, WCTemplputParams *TP) 
206 {
207         folder *Folder = (folder *)CTX(CTX_ROOMS);
208
209         StrBufAppendTemplate(Target, TP, Folder->name, 0);
210 }
211
212
213 void tmplput_ROOM_BASENAME(StrBuf *Target, WCTemplputParams *TP) 
214 {
215         folder *room = (folder *)CTX(CTX_ROOMS);
216
217         if (room->nRoomNameParts > 1)
218                 StrBufAppendTemplate(Target, TP, 
219                                       room->RoomNameParts[room->nRoomNameParts - 1], 0);
220         else 
221                 StrBufAppendTemplate(Target, TP, room->name, 0);
222 }
223
224
225 void tmplput_ROOM_LEVEL_N_TIMES(StrBuf *Target, WCTemplputParams *TP) 
226 {
227         folder *room = (folder *)CTX(CTX_ROOMS);
228         int i;
229         const char *AppendMe;
230         long AppendMeLen;
231
232
233         if (room->nRoomNameParts > 1)
234         {
235                 GetTemplateTokenString(Target, TP, 0, &AppendMe, &AppendMeLen);
236                 for (i = 0; i < room->nRoomNameParts; i++)
237                         StrBufAppendBufPlain(Target, AppendMe, AppendMeLen, 0);
238         }
239 }
240
241
242 int ConditionalRoomIsInbox(StrBuf *Target, WCTemplputParams *TP)
243 {
244         folder *Folder = (folder *)CTX(CTX_ROOMS);
245         return Folder->is_inbox;
246 }
247
248 int ConditionalRoomIsType(StrBuf *Target, WCTemplputParams *TP)
249 {
250         folder *Folder = (folder *)CTX(CTX_ROOMS);
251
252         if (Folder == NULL)
253                 return 0;
254
255         if ((TP->Tokens->nParameters < 3))
256         {
257                 return ((Folder->view < VIEW_BBS) || 
258                         (Folder->view > VIEW_MAX));
259         }
260
261         return Folder->view == GetTemplateTokenNumber(Target, TP, 2, VIEW_BBS);
262 }
263
264
265
266 /****** Properties ******/
267 int ConditionalRoom_MayEdit(StrBuf *Target, WCTemplputParams *TP)
268 {
269         wcsession *WCC = WC;
270
271         LoadRoomXA ();
272
273         return WCC->CurRoom.XALoaded == 1;
274 }
275
276 int ConditionalThisRoomHas_QRFlag(StrBuf *Target, WCTemplputParams *TP)
277 {
278         long QR_CheckFlag;
279         wcsession *WCC = WC;
280         
281         QR_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
282         if (QR_CheckFlag == 0)
283                 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
284                                  "requires one of the #\"QR*\"- defines or an integer flag 0 is invalid!");
285         
286         if (WCC == NULL)
287                 return 0;
288
289         if ((TP->Tokens->Params[2]->MaskBy == eOR) ||
290             (TP->Tokens->Params[2]->MaskBy == eNO))
291                 return (WCC->CurRoom.QRFlags & QR_CheckFlag) != 0;
292         else
293                 return (WCC->CurRoom.QRFlags & QR_CheckFlag) == QR_CheckFlag;
294 }
295
296
297 int ConditionalRoomHas_QRFlag(StrBuf *Target, WCTemplputParams *TP)
298 {
299         long QR_CheckFlag;
300         folder *Folder = (folder *)(TP->Context);
301
302         QR_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
303         if (QR_CheckFlag == 0)
304                 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
305                                  "requires one of the #\"QR*\"- defines or an integer flag 0 is invalid!");
306
307         if ((TP->Tokens->Params[2]->MaskBy == eOR) ||
308             (TP->Tokens->Params[2]->MaskBy == eNO))
309                 return (Folder->QRFlags & QR_CheckFlag) != 0;
310         else
311                 return (Folder->QRFlags & QR_CheckFlag) == QR_CheckFlag;
312 }
313
314
315 void tmplput_ROOM_QRFLAGS(StrBuf *Target, WCTemplputParams *TP) 
316 {
317         folder *Folder = (folder *)CTX(CTX_ROOMS);
318         StrBufAppendPrintf(Target, "%d", Folder->QRFlags);
319 }
320
321
322 int ConditionalThisRoomHas_QRFlag2(StrBuf *Target, WCTemplputParams *TP)
323 {
324         long QR2_CheckFlag;
325         wcsession *WCC = WC;
326         
327         QR2_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
328         if (QR2_CheckFlag == 0)
329                 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
330                                  "requires one of the #\"QR2*\"- defines or an integer flag 0 is invalid!");
331
332         
333         if (WCC == NULL)
334                 return 0;
335
336         if ((TP->Tokens->Params[2]->MaskBy == eOR) ||
337             (TP->Tokens->Params[2]->MaskBy == eNO))
338                 return (WCC->CurRoom.QRFlags2 & QR2_CheckFlag) != 0;
339         else
340                 return (WCC->CurRoom.QRFlags2 & QR2_CheckFlag) == QR2_CheckFlag;
341 }
342
343
344 int ConditionalRoomHas_QRFlag2(StrBuf *Target, WCTemplputParams *TP)
345 {
346         long QR2_CheckFlag;
347         folder *Folder = (folder *)(TP->Context);
348
349         QR2_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
350         if (QR2_CheckFlag == 0)
351                 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
352                                  "requires one of the #\"QR2*\"- defines or an integer flag 0 is invalid!");
353         return ((Folder->QRFlags2 & QR2_CheckFlag) != 0);
354 }
355
356
357 int ConditionalRoomHas_UAFlag(StrBuf *Target, WCTemplputParams *TP)
358 {
359         folder *Folder = (folder *)(TP->Context);
360         long UA_CheckFlag;
361                 
362         UA_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
363         if (UA_CheckFlag == 0)
364                 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
365                                  "requires one of the #\"UA_*\"- defines or an integer flag 0 is invalid!");
366
367         return ((Folder->RAFlags & UA_CheckFlag) != 0);
368 }
369
370
371 void tmplput_ROOM_ACL(StrBuf *Target, WCTemplputParams *TP) 
372 {
373         folder *Folder = (folder *)CTX(CTX_ROOMS);
374
375         StrBufAppendPrintf(Target, "%ld", Folder->RAFlags, 0);
376 }
377
378
379 void tmplput_ROOM_RAFLAGS(StrBuf *Target, WCTemplputParams *TP) 
380 {
381         folder *Folder = (folder *)(TP->Context);
382         StrBufAppendPrintf(Target, "%d", Folder->RAFlags);
383 }
384
385
386 void tmplput_ThisRoomAide(StrBuf *Target, WCTemplputParams *TP) 
387 {
388         wcsession *WCC = WC;
389
390         LoadRoomAide();
391
392         StrBufAppendTemplate(Target, TP, WCC->CurRoom.RoomAide, 0);
393 }
394
395
396 int ConditionalRoomAide(StrBuf *Target, WCTemplputParams *TP)
397 {
398         wcsession *WCC = WC;
399         return (WCC != NULL)? 
400                 ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) : 0;
401 }
402
403
404 int ConditionalRoomAcessDelete(StrBuf *Target, WCTemplputParams *TP)
405 {
406         wcsession *WCC = WC;
407         return (WCC == NULL)? 0 : 
408                 ( ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) ||
409                    (WCC->CurRoom.is_inbox) || 
410                    (WCC->CurRoom.QRFlags2 & QR2_COLLABDEL) );
411 }
412
413
414 int ConditionalHaveRoomeditRights(StrBuf *Target, WCTemplputParams *TP)
415 {
416         wcsession *WCC = WC;
417
418         return (        (WCC != NULL)
419                         && (WCC->logged_in)
420                         && (
421                                 (WCC->axlevel >= 6)
422                                 || ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0)
423                                 || (WCC->CurRoom.is_inbox)
424                         )
425                 );
426 }
427
428
429 void tmplput_ThisRoomPass(StrBuf *Target, WCTemplputParams *TP) 
430 {
431         wcsession *WCC = WC;
432
433         LoadRoomXA();
434         StrBufAppendTemplate(Target, TP, WCC->CurRoom.XAPass, 0);
435 }
436
437
438 void tmplput_ThisRoom_nNewMessages(StrBuf *Target, WCTemplputParams *TP) 
439 {
440         wcsession *WCC = WC;
441
442         StrBufAppendPrintf(Target, "%d", WCC->CurRoom.nNewMessages);
443 }
444
445
446 void tmplput_ThisRoom_nTotalMessages(StrBuf *Target, WCTemplputParams *TP) 
447 {
448         wcsession *WCC = WC;
449
450         StrBufAppendPrintf(Target, "%d", WCC->CurRoom.nTotalMessages);
451 }
452
453
454 void tmplput_ThisRoomOrder(StrBuf *Target, WCTemplputParams *TP) 
455 {
456         wcsession *WCC = WC;
457
458         LoadRoomXA();
459
460         StrBufAppendPrintf(Target, "%d", WCC->CurRoom.Order);
461 }
462
463
464 int ConditionalThisRoomOrder(StrBuf *Target, WCTemplputParams *TP)
465 {
466         wcsession *WCC = WC;
467         long CheckThis;
468
469         if (WCC == NULL)
470                 return 0;
471
472         LoadRoomXA();
473
474         CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
475         return CheckThis == WCC->CurRoom.Order;
476 }
477
478
479 void tmplput_ROOM_LISTORDER(StrBuf *Target, WCTemplputParams *TP) 
480 {
481         folder *Folder = (folder *)CTX(CTX_ROOMS);
482         StrBufAppendPrintf(Target, "%d", Folder->Order);
483 }
484
485
486 int ConditionalThisRoomXHavePic(StrBuf *Target, WCTemplputParams *TP)
487 {
488         wcsession *WCC = WC;
489         
490         if (WCC == NULL)
491                 return 0;
492
493         LoadXRoomPic();
494         return WCC->CurRoom.XHaveRoomPic == 1;
495 }
496
497 int ConditionalThisRoomIsEdit(StrBuf *Target, WCTemplputParams *TP)
498 {
499         wcsession *WCC = WC;
500
501         if (WCC == NULL)
502                 return 0;
503         return ((WCC->CurRoom.nRoomNameParts > 1) && 
504                 (strcmp(ChrPtr(WCC->CurRoom.RoomNameParts[WCC->CurRoom.nRoomNameParts]), "edit") == 0));
505 }
506
507 int ConditionalThisRoomXHaveInfoText(StrBuf *Target, WCTemplputParams *TP)
508 {
509         wcsession *WCC = WC;
510         
511         if (WCC == NULL)
512                 return 0;
513
514         LoadXRoomInfoText();
515         return (StrLength(WCC->CurRoom.XInfoText)>0);
516 }
517
518
519 void tmplput_ThisRoomInfoText(StrBuf *Target, WCTemplputParams *TP) 
520 {
521         wcsession *WCC = WC;
522         long nchars = 0;
523
524         LoadXRoomInfoText();
525
526         nchars = GetTemplateTokenNumber(Target, TP, 0, 0);
527         if (!nchars) {
528                 /* the whole thing */
529                 StrBufAppendTemplate(Target, TP, WCC->CurRoom.XInfoText, 1);
530         }
531         else {
532                 /* only a certain number of characters */
533                 StrBuf *SubBuf;
534                 SubBuf = NewStrBufDup(WCC->CurRoom.XInfoText);
535                 if (StrLength(SubBuf) > nchars) {
536                         StrBuf_Utf8StrCut(SubBuf, nchars);
537                         StrBufAppendBufPlain(SubBuf, HKEY("..."), 0);
538                 }
539                 StrBufAppendTemplate(Target, TP, SubBuf, 1);
540                 FreeStrBuf(&SubBuf);
541         }
542 }
543
544
545 void tmplput_ROOM_LASTCHANGE(StrBuf *Target, WCTemplputParams *TP) 
546 {
547         folder *Folder = (folder *)CTX(CTX_ROOMS);
548         StrBufAppendPrintf(Target, "%d", Folder->lastchange);
549 }
550
551
552 void tmplput_ThisRoomDirectory(StrBuf *Target, WCTemplputParams *TP) 
553 {
554         wcsession *WCC = WC;
555
556         LoadRoomXA();
557
558         StrBufAppendTemplate(Target, TP, WCC->CurRoom.Directory, 0);
559 }
560
561
562 void tmplput_ThisRoomXNFiles(StrBuf *Target, WCTemplputParams *TP) 
563 {
564         wcsession *WCC = WC;
565
566         LoadXRoomXCountFiles();
567
568         StrBufAppendPrintf(Target, "%d", WCC->CurRoom.XDownloadCount);
569 }
570
571
572 void tmplput_ThisRoomX_FileString(StrBuf *Target, WCTemplputParams *TP) 
573 {
574         wcsession *WCC = WC;
575
576         LoadXRoomXCountFiles();
577
578         if (WCC->CurRoom.XDownloadCount == 1)
579                 StrBufAppendBufPlain(Target, _("file"), -1, 0);
580         else
581                 StrBufAppendBufPlain(Target, _("files"), -1, 0);
582 }
583
584
585 int ConditionalIsThisThatRoom(StrBuf *Target, WCTemplputParams *TP)
586 {
587         folder *Folder = (folder *)CTX(CTX_ROOMS);
588         wcsession *WCC = WC;
589
590         if (WCC == NULL)
591                 return 0;
592
593         return Folder == WCC->ThisRoom;
594 }
595
596 int ConditionalRoomIsName(StrBuf *Target, WCTemplputParams *TP)
597 {
598         folder *Folder = (folder *)CTX(CTX_ROOMS);
599         const char *CheckRoomName = NULL;
600         long CheckRoomNameLen;
601
602         GetTemplateTokenString(Target, TP, 3, &CheckRoomName, &CheckRoomNameLen);
603         if (CheckRoomName == NULL)
604                 return 0;
605         return strcmp(ChrPtr(Folder->name), CheckRoomName) == 0;
606 }
607
608
609 void 
610 InitModule_ROOMTOKENS
611 (void)
612 {
613         /* we duplicate this, just to be shure its already done. */
614         RegisterCTX(CTX_ROOMS);
615         RegisterCTX(CTX_FLOORS);
616
617         RegisterNamespace("ROOMBANNER", 0, 1, tmplput_roombanner, NULL, CTX_NONE);
618
619         RegisterNamespace("FLOOR:ID", 0, 0, tmplput_FLOOR_ID, NULL, CTX_FLOORS);
620         RegisterNamespace("ROOM:INFO:FLOORID", 0, 1, tmplput_ROOM_FLOORID, NULL, CTX_ROOMS);
621         RegisterNamespace("ROOM:INFO:FLOOR:ID", 0, 0, tmplput_ROOM_FLOOR_ID, NULL, CTX_ROOMS);
622
623         RegisterNamespace("FLOOR:NAME", 0, 1, tmplput_FLOOR_NAME, NULL, CTX_FLOORS);
624         RegisterNamespace("ROOM:INFO:FLOOR:NAME", 0, 1, tmplput_ROOM_FLOOR_NAME, NULL, CTX_ROOMS);
625         RegisterNamespace("THISROOM:FLOOR:NAME", 0, 1, tmplput_ThisRoomFloorName, NULL, CTX_NONE);
626
627         RegisterNamespace("FLOOR:NROOMS", 0, 0, tmplput_FLOOR_NROOMS, NULL, CTX_FLOORS);
628         RegisterNamespace("ROOM:INFO:FLOOR:NROOMS", 0, 0, tmplput_ROOM_FLOOR_NROOMS, NULL, CTX_ROOMS);
629
630         RegisterConditional("COND:FLOOR:ISSUBROOM", 0, ConditionalFloorIsSUBROOM, CTX_FLOORS);
631         RegisterConditional("COND:FLOOR:NROOMS", 1, ConditionalFloorHaveNRooms, CTX_FLOORS);
632         RegisterConditional("COND:ROOM:REST:ISSUBFLOOR", 0, ConditionalFloorIsRESTSubFloor, CTX_FLOORS);
633         RegisterConditional("COND:FLOOR:ISVIRTUAL", 0, ConditionalFloorIsVirtual, CTX_FLOORS);
634
635         /**** Room... ******/
636         /**** Name ******/
637         RegisterNamespace("THISROOM:NAME", 0, 1, tmplput_ThisRoom, NULL, CTX_NONE);
638
639         RegisterNamespace("ROOM:INFO:NAME", 0, 1, tmplput_ROOM_NAME, NULL, CTX_ROOMS);
640         RegisterNamespace("ROOM:INFO:BASENAME", 0, 1, tmplput_ROOM_BASENAME, NULL, CTX_ROOMS);
641         RegisterNamespace("ROOM:INFO:LEVELNTIMES", 1, 2, tmplput_ROOM_LEVEL_N_TIMES, NULL, CTX_ROOMS);
642         RegisterConditional("COND:ROOM:INFO:IS_INBOX", 0, ConditionalRoomIsInbox, CTX_ROOMS);
643         RegisterConditional("COND:ROOM:INFO:TYPE_IS", 0, ConditionalRoomIsType, CTX_ROOMS);
644         RegisterConditional("COND:ROOM:INFO:NAME_IS", 1, ConditionalRoomIsName, CTX_ROOMS);
645
646         /****** Properties ******/
647         RegisterNamespace("ROOM:INFO:QRFLAGS", 0, 1, tmplput_ROOM_QRFLAGS, NULL, CTX_ROOMS);
648         RegisterConditional("COND:THISROOM:FLAG:QR", 0, ConditionalThisRoomHas_QRFlag, CTX_NONE);
649         RegisterConditional("COND:THISROOM:EDIT", 0, ConditionalRoom_MayEdit, CTX_NONE);
650         RegisterConditional("COND:ROOM:FLAG:QR", 0, ConditionalRoomHas_QRFlag, CTX_ROOMS);
651
652         RegisterConditional("COND:THISROOM:FLAG:QR2", 0, ConditionalThisRoomHas_QRFlag2, CTX_NONE);
653         RegisterConditional("COND:ROOM:FLAG:QR2", 0, ConditionalRoomHas_QRFlag2, CTX_ROOMS);
654
655         RegisterConditional("COND:ROOM:FLAG:UA", 0, ConditionalRoomHas_UAFlag, CTX_ROOMS);
656         RegisterNamespace("ROOM:INFO:RAFLAGS", 0, 1, tmplput_ROOM_RAFLAGS, NULL, CTX_ROOMS);
657
658
659         RegisterNamespace("ROOM:INFO:LISTORDER", 0, 1, tmplput_ROOM_LISTORDER, NULL, CTX_ROOMS);
660         RegisterNamespace("THISROOM:ORDER", 0, 0, tmplput_ThisRoomOrder, NULL, CTX_NONE);
661         RegisterConditional("COND:THISROOM:ORDER", 0, ConditionalThisRoomOrder, CTX_NONE);
662
663         RegisterNamespace("ROOM:INFO:LASTCHANGE", 0, 1, tmplput_ROOM_LASTCHANGE, NULL, CTX_ROOMS);
664
665         RegisterNamespace("THISROOM:MSGS:NEW", 0, 0, tmplput_ThisRoom_nNewMessages, NULL, CTX_NONE);
666         RegisterNamespace("THISROOM:MSGS:TOTAL", 0, 0, tmplput_ThisRoom_nTotalMessages, NULL, CTX_NONE);
667
668         RegisterNamespace("THISROOM:PASS", 0, 1, tmplput_ThisRoomPass, NULL, CTX_NONE);
669         RegisterNamespace("THISROOM:AIDE", 0, 1, tmplput_ThisRoomAide, NULL, CTX_NONE);
670         RegisterConditional("COND:ROOMAIDE", 2, ConditionalRoomAide, CTX_NONE);
671         RegisterConditional("COND:ACCESS:DELETE", 2, ConditionalRoomAcessDelete, CTX_NONE);
672         RegisterConditional("COND:ROOM:EDITACCESS", 0, ConditionalHaveRoomeditRights, CTX_NONE);
673
674         RegisterConditional("COND:THISROOM:HAVE_PIC", 0, ConditionalThisRoomXHavePic, CTX_NONE);
675         RegisterConditional("COND:THISROOM:IS_EDIT", 0, ConditionalThisRoomIsEdit, CTX_NONE);
676
677         RegisterNamespace("THISROOM:INFOTEXT", 1, 2, tmplput_ThisRoomInfoText, NULL, CTX_NONE);
678         RegisterConditional("COND:THISROOM:HAVE_INFOTEXT", 0, ConditionalThisRoomXHaveInfoText, CTX_NONE);
679
680         RegisterNamespace("THISROOM:FILES:N", 0, 1, tmplput_ThisRoomXNFiles, NULL, CTX_NONE);
681         RegisterNamespace("THISROOM:FILES:STR", 0, 1, tmplput_ThisRoomX_FileString, NULL, CTX_NONE);
682         RegisterNamespace("THISROOM:DIRECTORY", 0, 1, tmplput_ThisRoomDirectory, NULL, CTX_NONE);
683
684         RegisterNamespace("ROOM:INFO:ACL", 0, 1, tmplput_ROOM_ACL, NULL, CTX_ROOMS);
685         RegisterConditional("COND:THIS:THAT:ROOM", 0, ConditionalIsThisThatRoom, CTX_ROOMS);
686 }