From: Wilfried Goesgens Date: Sun, 16 Dec 2012 21:58:07 +0000 (+0100) Subject: ROOMEDIT: add a way to configure aliases X-Git-Tag: v8.20~171 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=d0a61d5cc7cb65fbef956eca1fd40ade5d7cadc0 ROOMEDIT: add a way to configure aliases - the room edit mailinglist tab now knows howto add/delete a mail alias via SNET/GNET --- diff --git a/webcit/roomlist.c b/webcit/roomlist.c index 129d60bc0..6246e313b 100644 --- a/webcit/roomlist.c +++ b/webcit/roomlist.c @@ -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); diff --git a/webcit/roomops.c b/webcit/roomops.c index 0c3eaa21d..3dd97ecab 100644 --- a/webcit/roomops.c +++ b/webcit/roomops.c @@ -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 index 000000000..af6f5fd93 --- /dev/null +++ b/webcit/static/t/room/edit/alias_removal.html @@ -0,0 +1 @@ +?last_tabsel="> diff --git a/webcit/static/t/room/edit/digestrecp_removal.html b/webcit/static/t/room/edit/digestrecp_removal.html index e514632f2..130d51b9f 100644 --- a/webcit/static/t/room/edit/digestrecp_removal.html +++ b/webcit/static/t/room/edit/digestrecp_removal.html @@ -1 +1 @@ -"> +?last_tabsel="> diff --git a/webcit/static/t/room/edit/tab_listserv.html b/webcit/static/t/room/edit/tab_listserv.html index 9c70376e4..f34e024ee 100644 --- a/webcit/static/t/room/edit/tab_listserv.html +++ b/webcit/static/t/room/edit/tab_listserv.html @@ -72,16 +72,37 @@ :///listsub - - - - - "> - "> - + + + + + "> + "> + + + + + + + +
+ +
+
+

+ + "> + + "> + + "> +

+
+
+