From 43f31099eaba09e5f9918279ff114940c7607798 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Mon, 16 Aug 2010 21:43:35 +0000 Subject: [PATCH] * GetWhoKnowsHash(): don't forget to step forward. * do_invt_kick(): we need to be able to parse a coma separated list of users; the addressbook popup creates such. * room/edit.html: add the needed includes for the addressbook popup. --- webcit/roomops.c | 89 ++++++++++++++++++++-------------- webcit/static/t/room/edit.html | 1 + 2 files changed, 54 insertions(+), 36 deletions(-) diff --git a/webcit/roomops.c b/webcit/roomops.c index a68f896f2..04e251dff 100644 --- a/webcit/roomops.c +++ b/webcit/roomops.c @@ -1296,45 +1296,61 @@ void editroom(void) /* * Display form for Invite, Kick, and show Who Knows a room */ -void do_invt_kick(void) { - char buf[SIZ], room[SIZ], username[SIZ]; - - serv_puts("GETR"); - serv_getln(buf, sizeof buf); - - if (buf[0] != '2') { - escputs(&buf[4]); - return; - } - extract_token(room, &buf[4], 0, '|', sizeof room); - - strcpy(username, bstr("username")); +void do_invt_kick(void) +{ + StrBuf *Buf, *User; + const StrBuf *UserNames; + int Kick, Invite; + wcsession *WCC = WC; - if (havebstr("kick_button")) { - sprintf(buf, "KICK %s", username); - serv_puts(buf); - serv_getln(buf, sizeof buf); - if (buf[0] != '2') { - strcpy(WC->ImportantMessage, &buf[4]); - } else { - sprintf(WC->ImportantMessage, - _("User %s kicked out of room %s.\n"), - username, room); - } - } + if (GetCurrentRoomFlags(&WCC->CurRoom) == 1) + { + const char *Pos; + UserNames = sbstr("username"); + Kick = havebstr("kick_button"); + Invite = havebstr("invite_button"); - if (havebstr("invite_button")) { - sprintf(buf, "INVT %s", username); - serv_puts(buf); - serv_getln(buf, sizeof buf); - - if (buf[0] != '2') { - strcpy(WC->ImportantMessage, &buf[4]); - } else { - sprintf(WC->ImportantMessage, - _("User %s invited to room %s.\n"), - username, room); + User = NewStrBufPlain(NULL, StrLength(UserNames)); + Buf = NewStrBuf(); + + Pos = ChrPtr(UserNames); + while (Pos != StrBufNOTNULL) + { + StrBufExtract_NextToken(User, UserNames, &Pos, ','); + StrBufTrim(User); + if ((StrLength(User) > 0) && (Kick)) + { + serv_printf("KICK %s", ChrPtr(User)); + StrBuf_ServGetln(Buf); + if (GetServerStatus(Buf, NULL) != 2) { + StrBufCutLeft(Buf, 4); + AppendImportantMessage(SKEY(Buf)); + } else { + StrBufPrintf(Buf, + _("User '%s' kicked out of room '%s'."), + ChrPtr(User), + ChrPtr(WCC->CurRoom.name) + ); + AppendImportantMessage(SKEY(Buf)); + } + } + else if ((StrLength(User) > 0) && (Invite)) + { + serv_printf("INVT %s", ChrPtr(User)); + StrBuf_ServGetln(Buf); + if (GetServerStatus(Buf, NULL) != 2) { + StrBufCutLeft(Buf, 4); + AppendImportantMessage(SKEY(Buf)); + } else { + StrBufPrintf(Buf, + _("User '%s' invited to room '%s'."), + ChrPtr(User), + ChrPtr(WCC->CurRoom.name) + ); + AppendImportantMessage(SKEY(Buf)); + } + } } } @@ -1950,6 +1966,7 @@ HashList *GetWhoKnowsHash(StrBuf *Target, WCTemplputParams *TP) IKEY(n), Token, HFreeStrBuf); + n++; } } else if (State == 550) diff --git a/webcit/static/t/room/edit.html b/webcit/static/t/room/edit.html index 112a82f12..15647b971 100644 --- a/webcit/static/t/room/edit.html +++ b/webcit/static/t/room/edit.html @@ -16,4 +16,5 @@ + -- 2.30.2