]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/mode.cpp
Show config warnings/errors regardless of loglevel on startup.
[user/henk/code/inspircd.git] / src / mode.cpp
index 40bd7096371679ce3b95a884296f30ab757da0e5..78993caad8799a76d1d70e968a4e83a7908701ca 100644 (file)
@@ -3,7 +3,7 @@
  *       +------------------------------------+
  *
  *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
- * See: http://www.inspircd.org/wiki/index.php/Credits
+ * See: http://wiki.inspircd.org/Credits
  *
  * This program is free but copyrighted software; see
  *            the file COPYING for details.
@@ -12,9 +12,6 @@
  */
 
 /* $Core */
-/* $ExtraDeps: $(RELCPPFILES) */
-/* $ExtraObjects: modes/modeclasses.a */
-/* $ExtraBuild: @${MAKE} -C "modes" DIRNAME="src/modes" CC="$(CC)" $(MAKEARGS) CPPFILES="$(CPPFILES)" */
 
 #include "inspircd.h"
 #include "inspstring.h"
@@ -68,6 +65,8 @@ bool ModeHandler::IsListMode()
 
 char ModeHandler::GetNeededPrefix()
 {
+       if (prefixneeded == '%' && !ServerInstance->Config->AllowHalfop)
+               return '@';
        return prefixneeded;
 }
 
@@ -477,9 +476,12 @@ void ModeParser::Process(const std::vector<std::string>& parameters, User *user,
 
                        if ((IS_LOCAL(user)) && (!ServerInstance->ULine(user->server)) && (!servermode))
                        {
+                               /* Make modes that are being changed visible to OnAccessCheck */
+                               LastParse = parameters[1];
                                /* We don't have halfop */
                                int MOD_RESULT = 0;
                                FOREACH_RESULT(I_OnAccessCheck,OnAccessCheck(user, NULL, targetchannel, AC_GENERAL_MODE));
+                               LastParse.clear();
                                if (MOD_RESULT == ACR_DENY)
                                        return;
                                SkipAccessChecks = (MOD_RESULT == ACR_ALLOW);
@@ -609,10 +611,10 @@ void ModeParser::Process(const std::vector<std::string>& parameters, User *user,
                                                                        /* If the mode defined by the handler is not '\0', but the handler for it
                                                                         * cannot be found, they probably dont have the right module loaded to implement
                                                                         * the prefix they want to compare the mode against, e.g. '&' for m_chanprotect.
-                                                                        * Revert to checking against the minimum core prefix, '%'.
+                                                                        * Revert to checking against the minimum core prefix, '%' or '@'.
                                                                         */
                                                                        if (needed && !prefixmode)
-                                                                               prefixmode = FindPrefix('%');
+                                                                               prefixmode = ServerInstance->Config->AllowHalfop ? FindPrefix('%') : FindPrefix('@');
 
                                                                        unsigned int neededrank = prefixmode->GetPrefixRank();
                                                                        /* Compare our rank on the channel against the rank of the required prefix,
@@ -760,7 +762,8 @@ void ModeParser::Process(const std::vector<std::string>& parameters, User *user,
                /* Was there at least one valid mode in the sequence? */
                if (!output_sequence.empty())
                {
-                       if (servermode)
+                       LastParseParams.push_front(output_sequence);
+                       if (!user)
                        {
                                if (type == MODETYPE_CHANNEL)
                                {
@@ -775,7 +778,6 @@ void ModeParser::Process(const std::vector<std::string>& parameters, User *user,
                        }
                        else
                        {
-                               LastParseParams.push_front(output_sequence);
                                if (type == MODETYPE_CHANNEL)
                                {
                                        targetchannel->WriteChannel(user, "MODE %s %s%s", targetchannel->name.c_str(), output_sequence.c_str(), parameter_list.str().c_str());
@@ -1159,7 +1161,7 @@ void ModeHandler::RemoveMode(User* user, irc::modestacker* stack)
                        sprintf(moderemove,"-%c",this->GetModeChar());
                        parameters.push_back(user->nick);
                        parameters.push_back(moderemove);
-                       ServerInstance->Modes->Process(parameters, ServerInstance->FakeClient, false);
+                       ServerInstance->Modes->Process(parameters, ServerInstance->FakeClient, true);
                }
        }
 }