]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/mode.cpp
Remove unneeded "fd" member of issl_session
[user/henk/code/inspircd.git] / src / mode.cpp
index c3946af2e1b18c8fcc41dccd90509b8fed146664..e7f918e62dad0c4f80ae53f1c3a25dacf7dfb249 100644 (file)
@@ -2,7 +2,7 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
+ *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
  * See: http://www.inspircd.org/wiki/index.php/Credits
  *
  * This program is free but copyrighted software; see
@@ -174,10 +174,6 @@ SimpleChannelModeHandler::SimpleChannelModeHandler(InspIRCd* Instance, char mode
 
 ModeAction SimpleUserModeHandler::OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool servermode)
 {
-       /* Only opers can change other users modes */
-       if (source != dest)
-               return MODEACTION_DENY;
-
        if (adding)
        {
                if (!dest->IsModeSet(this->GetModeChar()))
@@ -341,7 +337,7 @@ void ModeParser::DisplayCurrentModes(User *user, User* targetuser, Channel* targ
                        return;
                }
 
-               if ((targetuser == user) || (IS_OPER(user)))
+               if (targetuser == user || user->HasPrivPermission("users/auspex"))
                {
                        /* Display user's current mode string */
                        user->WriteNumeric(RPL_UMODEIS, "%s :+%s",targetuser->nick.c_str(),targetuser->FormatModes());
@@ -382,7 +378,7 @@ void ModeParser::Process(const std::vector<std::string>& parameters, User *user,
                seq++;
 
                mask = MASK_CHANNEL;
-               
+
                while (mode && *mode)
                {
                        unsigned char mletter = *mode;
@@ -392,7 +388,7 @@ void ModeParser::Process(const std::vector<std::string>& parameters, User *user,
                                mode++;
                                continue;
                        }
-                       
+
                        /* Ensure the user doesnt request the same mode twice,
                         * so they cant flood themselves off out of idiocy.
                         */
@@ -419,7 +415,7 @@ void ModeParser::Process(const std::vector<std::string>& parameters, User *user,
                                        continue;
                                }
 
-                               if (!IS_OPER(user))
+                               if (!user->HasPrivPermission("channels/auspex"))
                                {
                                        if (ServerInstance->Config->HideModeLists[mletter] && (targetchannel->GetStatus(user) < STATUS_HOP))
                                        {
@@ -436,7 +432,7 @@ void ModeParser::Process(const std::vector<std::string>& parameters, User *user,
                                for(ModeWatchIter watchers = modewatchers[handler_id].begin(); watchers != modewatchers[handler_id].end(); watchers++)
                                {
                                        std::string dummyparam;
-                                       
+
                                        if (!((*watchers)->BeforeMode(user, NULL, targetchannel, dummyparam, true, MODETYPE_CHANNEL)))
                                                display = false;
                                }
@@ -486,7 +482,7 @@ void ModeParser::Process(const std::vector<std::string>& parameters, User *user,
                {
                        type = MODETYPE_USER;
                        mask = MASK_USER;
-                       if ((user != targetuser) && (!ServerInstance->ULine(user->server)))
+                       if (user != targetuser && IS_LOCAL(user) && !ServerInstance->ULine(user->server))
                        {
                                user->WriteNumeric(ERR_USERSDONTMATCH, "%s :Can't change mode for other users", user->nick.c_str());
                                return;
@@ -609,7 +605,7 @@ void ModeParser::Process(const std::vector<std::string>& parameters, User *user,
                                                                         */
                                                                        if (needed && !prefixmode)
                                                                                prefixmode = FindPrefix('%');
-                                               
+
                                                                        unsigned int neededrank = prefixmode->GetPrefixRank();
                                                                        /* Compare our rank on the channel against the rank of the required prefix,
                                                                         * allow if >= ours. Because mIRC and xchat throw a tizz if the modes shown
@@ -630,7 +626,7 @@ void ModeParser::Process(const std::vector<std::string>& parameters, User *user,
                                                        }
 
                                                        bool had_parameter = !parameter.empty();
-                                                               
+
                                                        for (ModeWatchIter watchers = modewatchers[handler_id].begin(); watchers != modewatchers[handler_id].end(); watchers++)
                                                        {
                                                                if ((*watchers)->BeforeMode(user, targetuser, targetchannel, parameter, adding, type, servermode) == false)
@@ -704,7 +700,7 @@ void ModeParser::Process(const std::vector<std::string>& parameters, User *user,
                                                                                output_sequence.append(adding ? "+" : "-");
                                                                        last_successful_state_change = adding;
                                                                }
-                                                               
+
                                                                /* Add the mode letter */
                                                                output_sequence.push_back(modechar);
 
@@ -935,9 +931,6 @@ std::string ModeParser::ChannelModeList()
 
        for (unsigned char mode = 'A'; mode <= 'z'; mode++)
        {
-               if ((!ServerInstance->Config->AllowHalfop) && (mode == 'h'))
-                       continue;
-
                unsigned char pos = (mode-65) | MASK_CHANNEL;
 
                if (modehandlers[pos])
@@ -954,9 +947,6 @@ std::string ModeParser::ParaModeList()
 
        for (unsigned char mode = 'A'; mode <= 'z'; mode++)
        {
-               if ((!ServerInstance->Config->AllowHalfop) && (mode == 'h'))
-                       continue;
-
                unsigned char pos = (mode-65) | MASK_CHANNEL;
 
                if ((modehandlers[pos]) && (modehandlers[pos]->GetNumParams(true)))
@@ -1014,7 +1004,7 @@ std::string ModeParser::ModeString(User* user, Channel* channel, bool nick_suffi
                return types;
 }
 
-std::string ModeParser::ChanModes()
+std::string ModeParser::GiveModeList(ModeMasks m)
 {
        std::string type1;      /* Listmodes EXCEPT those with a prefix */
        std::string type2;      /* Modes that take a param when adding or removing */
@@ -1023,13 +1013,10 @@ std::string ModeParser::ChanModes()
 
        for (unsigned char mode = 'A'; mode <= 'z'; mode++)
        {
-               if ((!ServerInstance->Config->AllowHalfop) && (mode == 'h'))
-                       continue;
-
-               unsigned char pos = (mode-65) | MASK_CHANNEL;
+               unsigned char pos = (mode-65) | m;
                 /* One parameter when adding */
                if (modehandlers[pos])
-               {       
+               {
                        if (modehandlers[pos]->GetNumParams(true))
                        {
                                if ((modehandlers[pos]->IsListMode()) && (!modehandlers[pos]->GetPrefix()))
@@ -1059,14 +1046,13 @@ std::string ModeParser::ChanModes()
                                type4 += modehandlers[pos]->GetModeChar();
                        }
                }
-                        
        }
 
        return type1 + "," + type2 + "," + type3 + "," + type4;
 }
 
 bool ModeParser::PrefixComparison(prefixtype one, prefixtype two)
-{       
+{
        return one.second > two.second;
 }
 
@@ -1079,9 +1065,6 @@ std::string ModeParser::BuildPrefixes()
 
        for (unsigned char mode = 'A'; mode <= 'z'; mode++)
        {
-               if ((!ServerInstance->Config->AllowHalfop) && (mode == 'h'))
-                       continue;
-
                unsigned char pos = (mode-65) | MASK_CHANNEL;
 
                if ((modehandlers[pos]) && (modehandlers[pos]->GetPrefix()))
@@ -1165,7 +1148,7 @@ void ModeHandler::RemoveMode(User* user, irc::modestacker* stack)
                        sprintf(moderemove,"-%c",this->GetModeChar());
                        parameters.push_back(user->nick);
                        parameters.push_back(moderemove);
-                       ServerInstance->Parser->CallHandler("MODE", parameters, user);
+                       ServerInstance->Modes->Process(parameters, ServerInstance->FakeClient, false);
                }
        }
 }