X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Froomlist.c;h=6246e313b22c48100e5920686b9e0de6b15bc83f;hb=d0a61d5cc7cb65fbef956eca1fd40ade5d7cadc0;hp=c86a7f78dcf104cfec004830d9a80c8977432943;hpb=fa4703876cbb0330af860bb686d044ddb59dbadb;p=citadel.git diff --git a/webcit/roomlist.c b/webcit/roomlist.c index c86a7f78d..6246e313b 100644 --- a/webcit/roomlist.c +++ b/webcit/roomlist.c @@ -5,15 +5,15 @@ #include "webcit.h" #include "webserver.h" + HashList *GetWhoKnowsHash(StrBuf *Target, WCTemplputParams *TP) { - wcsession *WCC = WC; StrBuf *Line; StrBuf *Token; long State; HashList *Whok = NULL; int Done = 0; - int n; + int n = 0; serv_puts("WHOK"); Line = NewStrBuf(); @@ -42,8 +42,7 @@ HashList *GetWhoKnowsHash(StrBuf *Target, WCTemplputParams *TP) } } else if (State == 550) - StrBufAppendBufPlain(WCC->ImportantMsg, - _("Higher access is required to access this function."), -1, 0); + AppendImportantMessage(_("Higher access is required to access this function."), -1); FreeStrBuf(&Line); @@ -166,6 +165,12 @@ HashList *GetRoomListHashLKRA(StrBuf *Target, WCTemplputParams *TP) return WCC->Rooms; } +HashList *GetRoomListHashLPRM(StrBuf *Target, WCTemplputParams *TP) +{ + serv_puts("LPRM"); + return GetRoomListHash(Target, TP); +} + void FlushIgnetCfgs(folder *room) { @@ -315,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; @@ -387,9 +448,10 @@ HashList *GetNetConfigHash(StrBuf *Target, WCTemplputParams *TP) } } else if (State == 550) - StrBufAppendBufPlain(WCC->ImportantMsg, - _("Higher access is required to access this function."), -1, 0); + AppendImportantMessage(_("Higher access is required to access this function."), -1); + FreeStrBuf(&Line); + FreeStrBuf(&Token); return WCC->CurRoom.IgnetCfgs[WantThisOne]; } @@ -590,7 +652,7 @@ int CompareRooms(const folder *room1, const folder *room2) int ConditionalRoomIsRESTSubRoom(StrBuf *Target, WCTemplputParams *TP) { wcsession *WCC = WC; - folder *Folder = (folder *)CTX; + folder *Folder = (folder *)CTX(CTX_ROOMS); HashPos *it; StrBuf * Dir; void *vDir; @@ -607,8 +669,10 @@ int ConditionalRoomIsRESTSubRoom(StrBuf *Target, WCTemplputParams *TP) urlp = GetCount(WCC->Directory); delta = Folder->nRoomNameParts - urlp + 1; - syslog(0, "\n->%s: %ld - %ld ", ChrPtr(Folder->name), urlp, - Folder->nRoomNameParts); + syslog(0, "\n->%s: %d - %ld ", + ChrPtr(Folder->name), + urlp, + Folder->nRoomNameParts); /* list only the floors which are in relation to the dav_depth header */ if (WCC->Hdr->HR.dav_depth != delta) { syslog(0, "1\n"); @@ -673,15 +737,23 @@ void InitModule_ROOMLIST (void) { + /* we duplicate this, just to be shure its already done. */ + RegisterCTX(CTX_ROOMS); + RegisterCTX(CTX_FLOORS); 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); RegisterIterator("LZRM", 0, NULL, GetZappedRoomListHash, NULL, DeleteHash, CTX_ROOMS, CTX_NONE, IT_FLAG_DETECT_GROUPCHANGE); + RegisterIterator("LPRM", 0, NULL, GetRoomListHashLPRM, NULL, DeleteHash, CTX_ROOMS, CTX_NONE, IT_FLAG_DETECT_GROUPCHANGE); + + + - RegisterConditional(HKEY("COND:ROOM:REST:ISSUBROOM"), 0, ConditionalRoomIsRESTSubRoom, CTX_ROOMS); + RegisterConditional("COND:ROOM:REST:ISSUBROOM", 0, ConditionalRoomIsRESTSubRoom, CTX_ROOMS); RegisterSortFunc(HKEY("byfloorroom"), NULL, 0,