From: Art Cancro Date: Mon, 1 Mar 2004 04:08:34 +0000 (+0000) Subject: * Revoke access to room when /kicked X-Git-Tag: v7.86~5562 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=470ca677737d359a89a7a4094256729c6d255bb8;p=citadel.git * Revoke access to room when /kicked --- diff --git a/citadel/ChangeLog b/citadel/ChangeLog index db6a7da4c..71fc242cf 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,7 @@ $Log$ + Revision 614.58 2004/03/01 04:08:34 ajc + * Revoke access to room when /kicked + Revision 614.57 2004/02/29 23:26:48 ajc * Added /kick command to chat. /ban coming soon. @@ -5431,3 +5434,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import + diff --git a/citadel/serv_chat.c b/citadel/serv_chat.c index c4bb1f424..308b323cd 100644 --- a/citadel/serv_chat.c +++ b/citadel/serv_chat.c @@ -354,9 +354,8 @@ void cmd_chat(char *argbuf) strptr1 = &cmdbuf[6]; strcat(strptr1, " "); if ((t_context = find_context(&strptr1))) { - allwrite(strptr1, 3, CC->curr_user); if (strcasecmp(CC->curr_user, t_context->curr_user)) - allwrite(strptr1, 2, t_context->curr_user); + allwrite(strptr1, 3, t_context->curr_user); } else cprintf(":|User not found.\n"); cprintf("\n"); @@ -389,6 +388,12 @@ void cmd_chat(char *argbuf) if (!strcmp(&clptr->chat_text[2], KICKEDMSG)) { cprintf("000\n"); CC->cs_flags = CC->cs_flags - CS_CHAT; + + /* Kick user out of room */ + CtdlInvtKick(CC->user.fullname, 0); + + /* And return to the Lobby */ + usergoto(config.c_baseroom, 0, 0, NULL, NULL); return; } } diff --git a/citadel/user_ops.c b/citadel/user_ops.c index a85a553ad..2d343ae3c 100644 --- a/citadel/user_ops.c +++ b/citadel/user_ops.c @@ -1093,16 +1093,48 @@ void cmd_gtsn(char *argbuf) { } - /* - * INVT and KICK commands + * API function for cmd_invt_kick() and anything else that needs to + * invite or kick out a user to/from a room. + * + * Set iuser to the name of the user, and op to 1=invite or 0=kick */ -void cmd_invt_kick(char *iuser, int op) - /* user name */ -{ /* 1 = invite, 0 = kick out */ +int CtdlInvtKick(char *iuser, int op) { struct ctdluser USscratch; - char bbb[SIZ]; struct visit vbuf; + char bbb[SIZ]; + + if (getuser(&USscratch, iuser) != 0) { + return(1); + } + + CtdlGetRelationship(&vbuf, &USscratch, &CC->room); + if (op == 1) { + vbuf.v_flags = vbuf.v_flags & ~V_FORGET & ~V_LOCKOUT; + vbuf.v_flags = vbuf.v_flags | V_ACCESS; + } + if (op == 0) { + vbuf.v_flags = vbuf.v_flags & ~V_ACCESS; + vbuf.v_flags = vbuf.v_flags | V_FORGET | V_LOCKOUT; + } + CtdlSetRelationship(&vbuf, &USscratch, &CC->room); + + /* post a message in Aide> saying what we just did */ + snprintf(bbb, sizeof bbb, "%s %s %s> by %s\n", + iuser, + ((op == 1) ? "invited to" : "kicked out of"), + CC->room.QRname, + CC->user.fullname); + aide_message(bbb); + + return(0); +} + + +/* + * INVT and KICK commands + */ +void cmd_invt_kick(char *iuser, int op) { /* * These commands are only allowed by aides, room aides, @@ -1125,32 +1157,11 @@ void cmd_invt_kick(char *iuser, int op) return; } - if (lgetuser(&USscratch, iuser) != 0) { + if (CtdlInvtKick(iuser, op) != 0) { cprintf("%d No such user.\n", ERROR + NO_SUCH_USER); return; } - CtdlGetRelationship(&vbuf, &USscratch, &CC->room); - if (op == 1) { - vbuf.v_flags = vbuf.v_flags & ~V_FORGET & ~V_LOCKOUT; - vbuf.v_flags = vbuf.v_flags | V_ACCESS; - } - if (op == 0) { - vbuf.v_flags = vbuf.v_flags & ~V_ACCESS; - vbuf.v_flags = vbuf.v_flags | V_FORGET | V_LOCKOUT; - } - CtdlSetRelationship(&vbuf, &USscratch, &CC->room); - - lputuser(&USscratch); - - /* post a message in Aide> saying what we just did */ - snprintf(bbb, sizeof bbb, "%s %s %s> by %s\n", - iuser, - ((op == 1) ? "invited to" : "kicked out of"), - CC->room.QRname, - CC->user.fullname); - aide_message(bbb); - cprintf("%d %s %s %s.\n", CIT_OK, iuser, ((op == 1) ? "invited to" : "kicked out of"), diff --git a/citadel/user_ops.h b/citadel/user_ops.h index de83dc3c4..9d4e8aa01 100644 --- a/citadel/user_ops.h +++ b/citadel/user_ops.h @@ -20,6 +20,7 @@ void cmd_setp (char *new_pw); void cmd_getu (void); void cmd_setu (char *new_parms); void cmd_slrp (char *new_ptr); +int CtdlInvtKick(char *iuser, int op); void cmd_invt_kick (char *iuser, int op); void cmd_forg (void); void cmd_gnur (void);