]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/channels.cpp
Update NICKLOCK to route using unicast
[user/henk/code/inspircd.git] / src / channels.cpp
index 99b118d0dc90e1cb15c0d8e100fa2af2cd0c2803..532953db3489e47a19089feb61f0373035298019 100644 (file)
@@ -36,7 +36,7 @@ void Channel::SetMode(char mode,bool mode_on)
        modes[mode-65] = mode_on;
 }
 
-void Channel::SetMode(char mode, std::string parameter)
+void Channel::SetModeParam(char mode, std::string parameter)
 {
        CustomModeList::iterator n = custom_mode_params.find(mode);
        // always erase, even if changing, so that the map gets the new value
@@ -243,7 +243,8 @@ void Channel::SetDefaultModes()
  */
 Channel* Channel::JoinUser(InspIRCd* Instance, User *user, const char* cn, bool override, const char* key, bool bursting, time_t TS)
 {
-       if (!user || !cn)
+       // Fix: unregistered users could be joined using /SAJOIN
+       if (!user || !cn || user->registered != REG_ALL)
                return NULL;
 
        char cname[MAXBUF];
@@ -260,15 +261,7 @@ Channel* Channel::JoinUser(InspIRCd* Instance, User *user, const char* cn, bool
        if (IS_LOCAL(user) && !override)
        {
                // Checking MyClass exists because we *may* get here with NULL, not 100% sure.
-               if (user->MyClass && user->MyClass->GetMaxChans())
-               {
-                       if (user->chans.size() >= user->MyClass->GetMaxChans())
-                       {
-                               user->WriteNumeric(ERR_TOOMANYCHANNELS, "%s %s :You are on too many channels",user->nick.c_str(), cn);
-                               return NULL;
-                       }
-               }
-               else
+               if (user->MyClass && user->MyClass->maxchans)
                {
                        if (user->HasPrivPermission("channels/high-join-limit"))
                        {
@@ -280,7 +273,7 @@ Channel* Channel::JoinUser(InspIRCd* Instance, User *user, const char* cn, bool
                        }
                        else
                        {
-                               if (user->chans.size() >= Instance->Config->MaxChans)
+                               if (user->chans.size() >= user->MyClass->maxchans)
                                {
                                        user->WriteNumeric(ERR_TOOMANYCHANNELS, "%s %s :You are on too many channels",user->nick.c_str(), cn);
                                        return NULL;
@@ -412,10 +405,10 @@ Channel* Channel::JoinUser(InspIRCd* Instance, User *user, const char* cn, bool
                Ptr->SetDefaultModes();
        }
 
-       return Channel::ForceChan(Instance, Ptr, user, privs, bursting);
+       return Channel::ForceChan(Instance, Ptr, user, privs, bursting, created_by_local);
 }
 
-Channel* Channel::ForceChan(InspIRCd* Instance, Channel* Ptr, User* user, const std::string &privs, bool bursting)
+Channel* Channel::ForceChan(InspIRCd* Instance, Channel* Ptr, User* user, const std::string &privs, bool bursting, bool created)
 {
        std::string nick = user->nick;
        bool silent = false;
@@ -455,7 +448,7 @@ Channel* Channel::ForceChan(InspIRCd* Instance, Channel* Ptr, User* user, const
                }
        }
 
-       FOREACH_MOD_I(Instance,I_OnUserJoin,OnUserJoin(user, Ptr, bursting, silent));
+       FOREACH_MOD_I(Instance,I_OnUserJoin,OnUserJoin(user, Ptr, bursting, silent, created));
 
        if (!silent)
                Ptr->WriteChannel(user,"JOIN :%s",Ptr->name.c_str());
@@ -482,9 +475,11 @@ Channel* Channel::ForceChan(InspIRCd* Instance, Channel* Ptr, User* user, const
 bool Channel::IsBanned(User* user)
 {
        int result = 0;
-       FOREACH_RESULT_MAP(I_OnCheckBan, OnCheckBan(user, this),
-               result = banmatch_reduce(result, MOD_RESULT);
-       );
+       DO_EACH_HOOK(ServerInstance, OnCheckBan, int modresult, (user, this))
+       {
+               result = banmatch_reduce(result, modresult);
+       }
+       WHILE_EACH_HOOK(ServerInstance, OnCheckBan);
 
        if (result)
                return (result < 0);
@@ -506,9 +501,11 @@ bool Channel::IsBanned(User* user)
 int Channel::GetExtBanStatus(const std::string &str, char type)
 {
        int result = 0;
-       FOREACH_RESULT_MAP(I_OnCheckStringExtBan, OnCheckStringExtBan(str, this, type),
-               result = banmatch_reduce(result, MOD_RESULT);
-       );
+       DO_EACH_HOOK(ServerInstance, OnCheckStringExtBan, int modresult, (str, this, type))
+       {
+               result = banmatch_reduce(result, modresult);
+       }
+       WHILE_EACH_HOOK(ServerInstance, OnCheckStringExtBan);
 
        if (result)
                return result;
@@ -532,9 +529,11 @@ int Channel::GetExtBanStatus(const std::string &str, char type)
 int Channel::GetExtBanStatus(User *user, char type)
 {
        int result = 0;
-       FOREACH_RESULT_MAP(I_OnCheckExtBan, OnCheckExtBan(user, this, type),
-               result = banmatch_reduce(result, MOD_RESULT);
-       );
+       DO_EACH_HOOK(ServerInstance, OnCheckExtBan, int modresult, (user, this, type))
+       {
+               result = banmatch_reduce(result, modresult);
+       }
+       WHILE_EACH_HOOK(ServerInstance, OnCheckExtBan);
 
        if (result)
                return result;
@@ -592,57 +591,13 @@ long Channel::PartUser(User *user, std::string &reason)
        return this->GetUserCounter();
 }
 
-long Channel::ServerKickUser(User* user, const char* reason, bool triggerevents, const char* servername)
+long Channel::ServerKickUser(User* user, const char* reason, const char* servername)
 {
-       bool silent = false;
-
-       if (!user || !reason)
-               return this->GetUserCounter();
-
-       if (IS_LOCAL(user))
-       {
-               if (!this->HasUser(user))
-               {
-                       /* Not on channel */
-                       return this->GetUserCounter();
-               }
-       }
-
        if (servername == NULL || *ServerInstance->Config->HideWhoisServer)
                servername = ServerInstance->Config->ServerName;
 
-       if (triggerevents)
-       {
-               FOREACH_MOD(I_OnUserKick,OnUserKick(NULL, user, this, reason, silent));
-       }
-
-       UCListIter i = user->chans.find(this);
-       if (i != user->chans.end())
-       {
-               if (!silent)
-                       this->WriteChannelWithServ(servername, "KICK %s %s :%s", this->name.c_str(), user->nick.c_str(), reason);
-
-               user->chans.erase(i);
-               this->RemoveAllPrefixes(user);
-       }
-
-       if (!this->DelUser(user))
-       {
-               chan_hash::iterator iter = ServerInstance->chanlist->find(this->name);
-               /* kill the record */
-               if (iter != ServerInstance->chanlist->end())
-               {
-                       int MOD_RESULT = 0;
-                       FOREACH_RESULT_I(ServerInstance,I_OnChannelPreDelete, OnChannelPreDelete(this));
-                       if (MOD_RESULT == 1)
-                               return 1; // delete halted by module
-                       FOREACH_MOD(I_OnChannelDelete, OnChannelDelete(this));
-                       ServerInstance->chanlist->erase(iter);
-               }
-               return 0;
-       }
-
-       return this->GetUserCounter();
+       ServerInstance->FakeClient->server = servername;
+       return this->KickUser(ServerInstance->FakeClient, user, reason);
 }
 
 long Channel::KickUser(User *src, User *user, const char* reason)