summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/channels.cpp39
-rw-r--r--src/coremods/core_channel/cmd_kick.cpp37
2 files changed, 37 insertions, 39 deletions
diff --git a/src/channels.cpp b/src/channels.cpp
index 19b1281d5..8b9e38e9c 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -448,45 +448,6 @@ void Channel::KickUser(User* src, User* victim, const std::string& reason, Membe
{
UserMembIter victimiter = userlist.find(victim);
Membership* memb = ((victimiter != userlist.end()) ? victimiter->second : NULL);
-
- if (!memb)
- {
- src->WriteNumeric(ERR_USERNOTINCHANNEL, "%s %s :They are not on that channel", victim->nick.c_str(), this->name.c_str());
- return;
- }
-
- // Do the following checks only if the KICK is done by a local user;
- // each server enforces its own rules.
- if (IS_LOCAL(src))
- {
- // Modules are allowed to explicitly allow or deny kicks done by local users
- ModResult res;
- FIRST_MOD_RESULT(OnUserPreKick, res, (src,memb,reason));
- if (res == MOD_RES_DENY)
- return;
-
- if (res == MOD_RES_PASSTHRU)
- {
- if (!srcmemb)
- srcmemb = GetUser(src);
- unsigned int them = srcmemb ? srcmemb->getRank() : 0;
- unsigned int req = HALFOP_VALUE;
- for (std::string::size_type i = 0; i < memb->modes.length(); i++)
- {
- ModeHandler* mh = ServerInstance->Modes->FindMode(memb->modes[i], MODETYPE_CHANNEL);
- if (mh && mh->GetLevelRequired() > req)
- req = mh->GetLevelRequired();
- }
-
- if (them < req)
- {
- src->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s :You must be a channel %soperator",
- this->name.c_str(), req > HALFOP_VALUE ? "" : "half-");
- return;
- }
- }
- }
-
CUList except_list;
FOREACH_MOD(OnUserKick, (src, memb, reason, except_list));
diff --git a/src/coremods/core_channel/cmd_kick.cpp b/src/coremods/core_channel/cmd_kick.cpp
index 715f35d54..a9e7ee2cd 100644
--- a/src/coremods/core_channel/cmd_kick.cpp
+++ b/src/coremods/core_channel/cmd_kick.cpp
@@ -66,6 +66,13 @@ CmdResult CommandKick::Handle (const std::vector<std::string>& parameters, User
}
}
+ Membership* const memb = c->GetUser(u);
+ if (!memb)
+ {
+ user->WriteNumeric(ERR_USERNOTINCHANNEL, "%s %s :They are not on that channel", u->nick.c_str(), c->name.c_str());
+ return CMD_FAILURE;
+ }
+
if (parameters.size() > 2)
{
reason.assign(parameters[2], 0, ServerInstance->Config->Limits.MaxKick);
@@ -75,6 +82,36 @@ CmdResult CommandKick::Handle (const std::vector<std::string>& parameters, User
reason.assign(user->nick, 0, ServerInstance->Config->Limits.MaxKick);
}
+ // Do the following checks only if the KICK is done by a local user;
+ // each server enforces its own rules.
+ if (srcmemb)
+ {
+ // Modules are allowed to explicitly allow or deny kicks done by local users
+ ModResult res;
+ FIRST_MOD_RESULT(OnUserPreKick, res, (user, memb, reason));
+ if (res == MOD_RES_DENY)
+ return CMD_FAILURE;
+
+ if (res == MOD_RES_PASSTHRU)
+ {
+ unsigned int them = srcmemb->getRank();
+ unsigned int req = HALFOP_VALUE;
+ for (std::string::size_type i = 0; i < memb->modes.length(); i++)
+ {
+ ModeHandler* mh = ServerInstance->Modes->FindMode(memb->modes[i], MODETYPE_CHANNEL);
+ if (mh && mh->GetLevelRequired() > req)
+ req = mh->GetLevelRequired();
+ }
+
+ if (them < req)
+ {
+ user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s :You must be a channel %soperator",
+ this->name.c_str(), req > HALFOP_VALUE ? "" : "half-");
+ return CMD_FAILURE;
+ }
+ }
+ }
+
c->KickUser(user, u, reason, srcmemb);
return CMD_SUCCESS;