* GetWhoKnowsHash(): don't forget to step forward.
authorWilfried Göesgens <willi@citadel.org>
Mon, 16 Aug 2010 21:43:35 +0000 (21:43 +0000)
committerWilfried Göesgens <willi@citadel.org>
Mon, 16 Aug 2010 21:43:35 +0000 (21:43 +0000)
* 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
webcit/static/t/room/edit.html

index a68f896f29291792e4cdaae1a783de9f7fd83c1e..04e251dffec2ba2ec15ad4870024290be9155886 100644 (file)
@@ -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,
-                               _("<B><I>User %s kicked out of room %s.</I></B>\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,
-                               _("<B><I>User %s invited to room %s.</I></B>\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)
index 112a82f12098b70361ff4dc9e6152b12034a2c79..15647b971f295d9edf95a2fa2e927016a70fecf4 100644 (file)
@@ -16,4 +16,5 @@
 </td></tr></table>
 
 </div>
+<?=("addressbook_popup")>
 <?=("trailing")>