Implement selecting of sieve rule target room in dropdown.
authorWilfried Goesgens <dothebart@citadel.org>
Sun, 24 Jul 2011 15:56:42 +0000 (15:56 +0000)
committerWilfried Goesgens <dothebart@citadel.org>
Sun, 4 Sep 2011 21:41:25 +0000 (21:41 +0000)
webcit/roomtokens.c
webcit/sieve.c
webcit/static/t/sieve/display_one.html
webcit/static/t/sieve/roomlist.html

index 21653af5263fa203d2ed69a3eff3855f8c10225b..d41b36af1a5e52a717f36fdab5670dae4471bbf0 100644 (file)
@@ -566,6 +566,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)
@@ -635,4 +647,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);
 }
index 38d7b8c6bf5e06b575c0c2387bcd03bd4bac79ee..2eab1c098d5870a902cc8f58cdf96060a89c4c2c 100644 (file)
@@ -1514,9 +1514,21 @@ void tmplput_SieveRule_sizeval(StrBuf *Target, WCTemplputParams *TP)
        SieveRule     *Rule = (SieveRule *)CTX;
        wc_printf("%d", Rule->sizeval);
 }
+
+void tmplput_SieveRule_lookup_FileIntoRoom(StrBuf *Target, WCTemplputParams *TP) 
+{
+       void *vRoom;
+       SieveRule     *Rule = (SieveRule *)CTX;
+        wcsession *WCC = WC;
+       HashList *Rooms = GetRoomListHashLKRA(Target, TP);
+
+       GetHash(Rooms, SKEY(Rule->fileinto), &vRoom);
+       WCC->ThisRoom = (folder*) vRoom;
+}
+
 void FreeSieveRule(void *vRule)
 {
-       SieveRule *Rule = (SieveRule*) Rule;
+       SieveRule *Rule = (SieveRule*) vRule;
 
        FreeStrBuf(&Rule->htext);
        FreeStrBuf(&Rule->fileinto);
@@ -1693,6 +1705,8 @@ InitModule_SIEVE
        RegisterNamespace("SIEVE:SCRIPT:REDIRECT", 0, 1, tmplput_SieveRule_redirect, NULL, CTX_SIEVESCRIPT);
        RegisterNamespace("SIEVE:SCRIPT:AUTOMSG", 0, 1, tmplput_SieveRule_automsg, NULL, CTX_SIEVESCRIPT);
        ///RegisterNamespace("SIEVE:SCRIPT:FINAL", 0, 1, tmplput_SieveRule_final, NULL, CTX_SIEVESCRIPT);
+       /* fetch our room into WCC->ThisRoom, to evaluate while iterating over rooms with COND:THIS:THAT:ROOM */
+       RegisterNamespace("SIEVE:SCRIPT:LOOKUP_FILEINTO", 0, 1, tmplput_SieveRule_lookup_FileIntoRoom, NULL, CTX_SIEVESCRIPT);
 
 #if FOO
        WebcitAddUrlHandler(HKEY("display_sieve"), "", 0, display_sieve, 0);
index 9e266b082ca6ef5380c0cd6ad1ef5e99aca8a885..e7bf253732f526fc4ffd8ec7c1cc54dde4b2fef4 100644 (file)
@@ -1,4 +1,4 @@
-<table cellpadding=2 width=100%>
+<?SIEVE:SCRIPT:LOOKUP_FILEINTO><table cellpadding=2 width=100%>
 <tr id="rule<?ITERATE:N>" class="<?ITERATE:ODDEVEN>">
 <td width=5% align="center">
 <div style="display:none">
index 87763efd0dba16bdcc069ce4703aac039ceb79c1..9479a5eefbcc1d8edb874c3b4ef08141942db683 100644 (file)
@@ -1 +1 @@
-<option <?%("COND:SIEVE:THISROOM", 1, 0, 0, "checked", "")> value='<?ROOM:INFO:NAME("U")>' ><?ROOM:INFO:NAME("X")></select>
+<option <?%("COND:THIS:THAT:ROOM", 1, 0, 0, "checked", "")> value='<?ROOM:INFO:NAME("U")>' ><?ROOM:INFO:NAME("X")></select>