ROOMEDIT: add a way to configure aliases
authorWilfried Goesgens <dothebart@citadel.org>
Sun, 16 Dec 2012 21:58:07 +0000 (22:58 +0100)
committerWilfried Goesgens <dothebart@citadel.org>
Sun, 16 Dec 2012 21:58:07 +0000 (22:58 +0100)
  - the room edit mailinglist tab now knows howto add/delete a mail alias via SNET/GNET

webcit/roomlist.c
webcit/roomops.c
webcit/static/t/room/edit/alias_removal.html [new file with mode: 0644]
webcit/static/t/room/edit/digestrecp_removal.html
webcit/static/t/room/edit/tab_listserv.html

index 129d60bc079b0141a5394046e877c7d014100047..6246e313b22c48100e5920686b9e0de6b15bc83f 100644 (file)
@@ -320,6 +320,62 @@ HashList *GetRoomListHash(StrBuf *Target, WCTemplputParams *TP)
        return rooms;
 }
 
+HashList *GetThisRoomMAlias(StrBuf *Target, WCTemplputParams *TP) 
+{
+       wcsession *WCC = WC;
+       StrBuf *Line;
+       StrBuf *Token;
+       HashList *Aliases = NULL;
+       const char *pComma;
+       long aliaslen;
+       long locallen;
+       long State;
+       
+       serv_puts("GNET "FILE_MAILALIAS);
+       Line = NewStrBuf();
+       StrBuf_ServGetln(Line);
+       if (GetServerStatus(Line, &State) == 1) 
+       {
+               int Done = 0;
+               int n = 0;
+
+               Aliases = NewHash(1, NULL);
+               while(!Done && (StrBuf_ServGetln(Line) >= 0))
+                       if ( (StrLength(Line)==3) && 
+                            !strcmp(ChrPtr(Line), "000"))
+                       {
+                               Done = 1;
+                       }
+                       else
+                       {
+                               pComma = strchr(ChrPtr(Line), ',');
+                               if (pComma == NULL)
+                                       continue;
+                               aliaslen = pComma - ChrPtr(Line);
+                               locallen = StrLength(Line) - 1 - aliaslen;
+                               if (locallen - 5 != StrLength(WCC->CurRoom.name))
+                                       continue;
+                               if (strncmp(pComma + 1, "room_", 5) != 0)
+                                       continue;
+
+                               if (strcasecmp(pComma + 6, ChrPtr(WCC->CurRoom.name)) != 0)
+                                       continue;
+                               Token = NewStrBufPlain(ChrPtr(Line), aliaslen);
+                               Put(Aliases, 
+                                   IKEY(n),
+                                   Token, 
+                                   HFreeStrBuf);
+                               n++; /* #0 is the type... */
+                       }
+       }
+       else if (State == 550)
+               AppendImportantMessage(_("Higher access is required to access this function."), -1);
+
+       FreeStrBuf(&Line);
+
+       return Aliases;
+}
+
 HashList *GetNetConfigHash(StrBuf *Target, WCTemplputParams *TP) 
 {
        wcsession *WCC = WC;
@@ -687,6 +743,7 @@ InitModule_ROOMLIST
 
        RegisterIterator("ITERATE:THISROOM:WHO_KNOWS", 0, NULL, GetWhoKnowsHash, NULL, DeleteHash, CTX_STRBUF, CTX_NONE, IT_NOFLAG);
        RegisterIterator("ITERATE:THISROOM:GNET", 1, NULL, GetNetConfigHash, NULL, NULL, CTX_STRBUFARR, CTX_NONE, IT_NOFLAG);
+       RegisterIterator("ITERATE:THISROOM:MALIAS", 1, NULL, GetThisRoomMAlias, NULL, NULL, CTX_STRBUF, CTX_NONE, IT_NOFLAG);
 
        RegisterIterator("LFLR", 0, NULL, GetFloorListHash, NULL, NULL, CTX_FLOORS, CTX_NONE, IT_FLAG_DETECT_GROUPCHANGE);
        RegisterIterator("LKRA", 0, NULL, GetRoomListHashLKRA, NULL, NULL, CTX_ROOMS, CTX_NONE, IT_FLAG_DETECT_GROUPCHANGE);
index 0c3eaa21d1867131f99fd479a896d00dc290d130..3dd97ecab4773327348561da6fb9753ab23fb98c 100644 (file)
@@ -1050,8 +1050,11 @@ void netedit(void) {
        int i, num_addrs;
        StrBuf *Line;
        StrBuf *TmpBuf;
+       int malias = 0;
+       char sepchar = '|';
        int Done;
 
+       line[0] = '\0';
         if (havebstr("force_room")) {
                 gotoroom(sbstr("force_room"));
        }
@@ -1074,6 +1077,14 @@ void netedit(void) {
                strcat(line, bstr("line"));
                strcat(line, bstr("suffix"));
        }
+       else if (havebstr("alias")) {
+               malias = 1;
+               sepchar = ',';
+               strcat(line, bstr("prefix"));
+               strcat(line, ",");
+               strcat(line, "room_");
+               strcat(line, ChrPtr(WC->CurRoom.name));
+       }
        else {
                output_headers(1, 1, 1, 0, 0, 0);       
                do_template("room_edit");
@@ -1083,7 +1094,10 @@ void netedit(void) {
 
        Line = NewStrBuf();
        TmpBuf = NewStrBuf();
-       serv_puts("GNET");
+       if (malias)
+               serv_puts("GNET "FILE_MAILALIAS);
+       else
+               serv_puts("GNET");
        StrBuf_ServGetln(Line);
        if  (GetServerStatus(Line, NULL) != 1) {
                AppendImportantMessage(SRV_STATUS_MSG(Line));   
@@ -1096,8 +1110,8 @@ void netedit(void) {
 
        /** This loop works for add *or* remove.  Spiffy, eh? */
        Done = 0;
-       extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
-       extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
+       extract_token(cmpb0, line, 0, sepchar, sizeof cmpb0);
+       extract_token(cmpb1, line, 1, sepchar, sizeof cmpb1);
        while (!Done && StrBuf_ServGetln(Line)>=0) {
                if ( (StrLength(Line)==3) && 
                     !strcmp(ChrPtr(Line), "000")) 
@@ -1106,17 +1120,23 @@ void netedit(void) {
                }
                else
                {
-                       extract_token(cmpa0, ChrPtr(Line), 0, '|', sizeof cmpa0);
-                       extract_token(cmpa1, ChrPtr(Line), 1, '|', sizeof cmpa1);
-                       if ( (strcasecmp(cmpa0, cmpb0)) 
-                            || (strcasecmp(cmpa1, cmpb1)) ) {
+                       if (StrLength(Line) == 0)
+                               continue;
+
+                       extract_token(cmpa0, ChrPtr(Line), 0, sepchar, sizeof cmpa0);
+                       extract_token(cmpa1, ChrPtr(Line), 1, sepchar, sizeof cmpa1);
+                       if ( (strcasecmp(cmpa0, cmpb0)) || (strcasecmp(cmpa1, cmpb1)) )
+                       {
                                StrBufAppendBufPlain(Line, HKEY("\n"), 0);
                                StrBufAppendBuf(TmpBuf, Line, 0);
                        }
                }
        }
 
-       serv_puts("SNET");
+       if (malias)
+               serv_puts("SNET "FILE_MAILALIAS);
+       else
+               serv_puts("SNET");
        StrBuf_ServGetln(Line);
        if  (GetServerStatus(Line, NULL) != 4) {
 
diff --git a/webcit/static/t/room/edit/alias_removal.html b/webcit/static/t/room/edit/alias_removal.html
new file mode 100644 (file)
index 0000000..af6f5fd
--- /dev/null
@@ -0,0 +1 @@
+<tr class="<?ITERATE:ODDEVEN>"><td><?CONTEXTSTR("X")><a href="netedit?cmd=removealias?tab=listserv?alias=1&prefix=<?CONTEXTSTR("U")>?last_tabsel=<?TAB:N>"><?_("(remove)")></a></td></tr>
index e514632f2bffa8f21e8c4d7ef3281929473a46ab..130d51b9fb981074197cadfd135ccd106dc9be54 100644 (file)
@@ -1 +1 @@
-<tr class="<?ITERATE:ODDEVEN>"><td><?CONTEXTSTRARR(1, "X")><a href="netedit?cmd=remove?tab=listserv?line=digestrecp|<?CONTEXTSTRARR(1, "U")>"><?_("(remove)")></a></td></tr>
+<tr class="<?ITERATE:ODDEVEN>"><td><?CONTEXTSTRARR(1, "X")><a href="netedit?cmd=remove?tab=listserv?line=digestrecp|<?CONTEXTSTRARR(1, "U")>?last_tabsel=<?TAB:N>"><?_("(remove)")></a></td></tr>
index 9c70376e4aeb71d73a3f9a967fb5a78c2356a07f..f34e024ee7f3f40afad5726a93c0407d3471866e 100644 (file)
                                                <tt><?%("COND:IS_HTTPS", 3, 1, 0, "https", "http")>://<?SERV:FQDN>/listsub</tt>
                                        </td>
                                </tr>
-
                                <tr>
-                                       <td colspan="2" align="center">
-                                               <input type="hidden" name="last_tabsel" value="<?TAB:N>">
-                                               <input type="hidden" name="nonce" value="<?NONCE>">
-                                               <input type="hidden" name="go" value="<?THISROOM:NAME("X")>">
-                                               <input type="submit" name="add_button" value="<?_("Save changes")>">
-                                       </td>
+                               <tr>
+                                 <td colspan="2" align="center">
+                                   <input type="hidden" name="last_tabsel" value="<?TAB:N>">
+                                   <input type="hidden" name="nonce" value="<?NONCE>">
+                                   <input type="hidden" name="go" value="<?THISROOM:NAME("X")>">
+                                   <input type="submit" name="add_button" value="<?_("Save changes")>">
+                                 </td>
                                </tr>
                        </table>
                </form>
+               <table class="altern">
+                 <td colspan="2">
+                   <?_("Alternative public emailaddresses pointing to this room: ")>
+                 </td>
+                 <?ITERATE("ITERATE:THISROOM:MALIAS", ="room_edit_alias_removal", 0, 0, -1, "")>
+                 <tr>
+                   <td colspan="2">
+                     <form method="post" action="netedit">
+                       <p>
+                         <input type="hidden" name="last_tabsel" value="<?TAB:N>">
+                         <input type="hidden" name="alias" value="room_<?THISROOM:NAME("X")>">
+                         <input type="hidden" name="nonce" value="<?NONCE>">
+                         <input type="hidden" name="go" value="<?THISROOM:NAME("X")>">
+                         <input type="text" id="prefix" name="prefix">
+                         <input type="submit" name="add_button" value="<?_("Add")>">
+                       </p>
+                     </form>
+                   </td>
+                 </tr>
+               </table>
+               
        </center>
 </div>