* finish off ROOMPIC hard coded callback, thanks the_mgt for starting the template
authorWilfried Göesgens <willi@citadel.org>
Thu, 5 Aug 2010 21:07:38 +0000 (21:07 +0000)
committerWilfried Göesgens <willi@citadel.org>
Thu, 5 Aug 2010 21:07:38 +0000 (21:07 +0000)
libcitadel/lib/libcitadel.h
webcit/roomops.c
webcit/roomops.h
webcit/static/t/roombanner.html
webcit/static/t/roombanner.m.html

index 3949e87525149948b8db4490940ef84946b09073..e6e097d4e9bf70695b24a70a0b110555bd04e39a 100644 (file)
@@ -102,6 +102,8 @@ typedef enum __GPEXWhichPolicy {
 #define        VIEW_WIKI               6       /* Wiki view */
 #define VIEW_CALBRIEF          7       /* Brief Calendar view */
 #define VIEW_JOURNAL           8       /* Journal view */
+#define VIEW_MAX                8       /* increment me... */
+
 #define VIEW_BLOG              9       /* Blog view (not yet implemented) */
 
 
index 6226ada8a914428047315dedc34991a4748285f7..aa771800fda40ef06fd8741c77985f020099c401 100644 (file)
@@ -276,67 +276,6 @@ void readinfo(StrBuf *Target, WCTemplputParams *TP)
 }
 
 
-
-
-/*
- * Display room banner icon.  
- * The server doesn't actually need the room name, but we supply it in
- * order to keep the browser from using a cached icon from another room.
- */
-void embed_room_graphic(StrBuf *Target, WCTemplputParams *TP)
-{
-       char buf[SIZ];
-
-       serv_puts("OIMG _roompic_");
-       serv_getln(buf, sizeof buf);
-       if (buf[0] == '2') {
-               wc_printf("<img height=\"64px\" src=\"image?name=_roompic_&room=");
-               urlescputs(ChrPtr(WC->CurRoom.name));
-               wc_printf("\">");
-               serv_puts("CLOS");
-               serv_getln(buf, sizeof buf);
-       }
-       else if (WC->CurRoom.view == VIEW_ADDRESSBOOK) {
-               wc_printf("<img class=\"roompic\" alt=\"\" src=\""
-                       "static/viewcontacts_48x.gif"
-                       "\" >"
-                       );
-       }
-       else if ( (WC->CurRoom.view == VIEW_CALENDAR) || (WC->CurRoom.view == VIEW_CALBRIEF) ) {
-               wc_printf("<img class=\"roompic\" alt=\"\" src=\""
-                       "static/calarea_48x.gif"
-                       "\" width=\"48\" height=\"48\">"
-                       );
-       }
-       else if (WC->CurRoom.view == VIEW_TASKS) {
-               wc_printf("<img class=\"roompic\" alt=\"\" src=\""
-                       "static/taskmanag_48x.gif"
-                       "\" width=\"48\" height=\"48\">"
-                       );
-       }
-       else if (WC->CurRoom.view == VIEW_NOTES) {
-               wc_printf("<img class=\"roompic\" alt=\"\" src=\""
-                       "static/storenotes_48x.gif"
-                       "\" width=\"48\" height=\"48\">"
-                       );
-       }
-       else if (WC->CurRoom.view == VIEW_MAILBOX) {
-               wc_printf("<img class=\"roompic\" alt=\"\" src=\""
-                       "static/privatemess_48x.gif"
-                       "\" width=\"48\" height=\"48\">"
-                       );
-       }
-       else {
-               wc_printf("<img class=\"roompic\" alt=\"\" src=\""
-                       "static/chatrooms_48x.gif"
-                       "\" width=\"48\" height=\"48\">"
-                       );
-       }
-
-}
-
-
-
 /*
  * Display the current view and offer an option to change it
  */
@@ -468,7 +407,6 @@ void embed_room_banner(char *got, int navbar_style) {
                 extract_int(&got[4], 2),
                 with_files
                );
-       svcallback("ROOMPIC", embed_room_graphic);
        svcallback("ROOMINFO", readinfo);
        svcallback("VIEWOMATIC", embed_view_o_matic); 
        svcallback("SEARCHOMATIC", embed_search_o_matic);
@@ -992,6 +930,41 @@ void LoadRoomXA (void)
        FreeStrBuf (&Buf);
 }
 
+
+void LoadXRoomPic(void)
+{
+       wcsession *WCC = WC;
+       StrBuf *Buf;
+       
+       if (WCC->CurRoom.XHaveRoomPicLoaded)
+               return;
+
+       WCC->CurRoom.XHaveRoomPicLoaded = 1;
+       Buf = NewStrBuf();
+       serv_puts("OIMG _roompic_");
+       StrBuf_ServGetln(Buf);
+       if (GetServerStatus(Buf, NULL) != 2) {
+               WCC->CurRoom.XHaveRoomPic = 0;
+       } else {
+               WCC->CurRoom.XHaveRoomPic = 1;
+       }
+       serv_puts("CLOS");
+       StrBuf_ServGetln(Buf);
+       GetServerStatus(Buf, NULL);
+       FreeStrBuf (&Buf);
+}
+
+int ConditionalThisRoomXHavePic(StrBuf *Target, WCTemplputParams *TP)
+{
+       wcsession *WCC = WC;
+       
+       if (WCC == NULL)
+               return 0;
+
+       LoadXRoomPic();
+       return WCC->CurRoom.XHaveRoomPic == 1;
+}
+
 void tmplput_CurrentRoomPass(StrBuf *Target, WCTemplputParams *TP) 
 {
        wcsession *WCC = WC;
@@ -3389,7 +3362,11 @@ int ConditionalIsRoomtype(StrBuf *Target, WCTemplputParams *TP)
 
        if ((WCC == NULL) ||
            (TP->Tokens->nParameters < 3))
-               return 0;
+       {
+               return ((WCC->CurRoom.view < VIEW_BBS) || 
+                       (WCC->CurRoom.view > VIEW_MAX));
+       }
+
        return WCC->CurRoom.view == GetTemplateTokenNumber(Target, TP, 2, VIEW_BBS);
 }
 
@@ -3490,7 +3467,7 @@ InitModule_ROOMOPS
        RegisterNamespace("THISROOM:DEFAULT_VIEW", 0, 0, tmplput_CurrentRoomDefView, NULL, CTX_NONE);
        RegisterConditional(HKEY("COND:THISROOM:ORDER"), 0, ConditionalThisRoomOrder, CTX_NONE);
        RegisterConditional(HKEY("COND:THISROOM:DEFAULT_VIEW"), 0, ConditionalThisRoomDefView, CTX_NONE);
-
+       RegisterConditional(HKEY("COND:THISROOM:HAVE_PIC"), 0, ConditionalThisRoomXHavePic, CTX_NONE);
 
        REGISTERTokenParamDefine(QR_PERMANENT);
        REGISTERTokenParamDefine(QR_INUSE);
index 470220d4098c32ec7ca8e71523e4149c57addac3..37a9471b77c94c1feb319cdd9b595a024fa03208 100644 (file)
@@ -100,6 +100,10 @@ typedef struct _folder {
        int UsersNewMAilboxMessages; /* should we notify the user about new messages? */
        int IsTrash;
 
+       int XHaveRoomPic;
+       int XHaveRoomPicLoaded;
+
+
        HashList *IgnetCfgs[maxRoomNetCfg];
 
 }folder;
index 70b3e8a69d2c22ec187983f4a859d4a84ba2ff03..73ffa829d8e4f251142e1d410e7b71662468fda8 100644 (file)
@@ -2,7 +2,7 @@
 <div class="banner" id="room_banner">
 <table border=0><tr>
 <td>
-<?ROOMPIC>
+<?=("room_view_picture")>
 </td>
 <td>
 <h1 id="rmname"><?ROOMNAME></h1>
index 3afa12d691b45e6241d882fa2998d7a26ed749c8..05a4f200736217354ac7ef2ce40d14ce40638db9 100644 (file)
@@ -1,6 +1,6 @@
 <!-- start roombanner.html -->
 <div class="banner" >
-<h1 class="roomname"><?ROOMPIC> <?ROOMNAME></h1>
+<h1 class="roomname"><?=("room_view_picture")> <?ROOMNAME></h1>
 <p><?ROOMINFO> <?NUMMSGS></p>
 <p><?START> <?SEARCHOMATIC></p>
 </div>