]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/channels.cpp
Fix bug #83
[user/henk/code/inspircd.git] / src / channels.cpp
index 5603ef1ddf2f16171b692663f1e845ea2d1081d9..8e7d4af06cc5426e1d76f231587c29e350cd7462 100644 (file)
@@ -92,13 +92,14 @@ int Channel::SetTopic(User *u, std::string &ntopic, bool forceset)
                        return CMD_FAILURE;
                if (res != MOD_RES_ALLOW)
                {
-                       bool defok = IsModeSet('t') ? GetPrefixValue(u) >= HALFOP_VALUE : HasUser(u);
-                       if (!ServerInstance->OnCheckExemption(u,this,"topiclock").check(defok))
+                       if (!this->HasUser(u))
                        {
-                               if (!this->HasUser(u))
-                                       u->WriteNumeric(442, "%s %s :You're not on that channel!",u->nick.c_str(), this->name.c_str());
-                               else
-                                       u->WriteNumeric(482, "%s %s :You do not have access to change the topic on this channel", u->nick.c_str(), this->name.c_str());
+                               u->WriteNumeric(442, "%s %s :You're not on that channel!",u->nick.c_str(), this->name.c_str());
+                               return CMD_FAILURE;
+                       }
+                       if (IsModeSet('t') && !ServerInstance->OnCheckExemption(u,this,"topiclock").check(GetPrefixValue(u) >= HALFOP_VALUE))
+                       {
+                               u->WriteNumeric(482, "%s %s :You do not have access to change the topic on this channel", u->nick.c_str(), this->name.c_str());
                                return CMD_FAILURE;
                        }
                }
@@ -391,9 +392,8 @@ Channel* Channel::ForceChan(Channel* Ptr, User* user, const std::string &privs,
        for(unsigned int i=0; i < memb->modes.length(); i++)
                ms.append(" ").append(user->nick);
        if ((Ptr->GetUserCounter() > 1) && (ms.length()))
-               Ptr->WriteAllExceptSender(user, true, 0, "MODE %s +%s", Ptr->name.c_str(), ms.c_str());
+               Ptr->WriteAllExceptSender(user, ServerInstance->Config->CycleHostsFromUser, 0, "MODE %s +%s", Ptr->name.c_str(), ms.c_str());
 
-       /* Major improvement by Brain - we dont need to be calculating all this pointlessly for remote users */
        if (IS_LOCAL(user))
        {
                if (Ptr->topicset)
@@ -525,11 +525,19 @@ void Channel::KickUser(User *src, User *user, const char* reason)
 
                if (res == MOD_RES_PASSTHRU)
                {
-                       int them = this->GetPrefixValue(src);
-                       int us = this->GetPrefixValue(user);
-                       if ((them < HALFOP_VALUE) || (them < us))
+                       unsigned int them = this->GetPrefixValue(src);
+                       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 %s :You must be a channel %soperator",src->nick.c_str(), this->name.c_str(), them >= HALFOP_VALUE ? "" : "half-");
+                               src->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s %s :You must be a channel %soperator",
+                                       src->nick.c_str(), this->name.c_str(), req > HALFOP_VALUE ? "" : "half-");
                                return;
                        }
                }