From 54e89b822e36b36eb9b080bbb4befe097471cec2 Mon Sep 17 00:00:00 2001 From: danieldg Date: Wed, 2 Sep 2009 00:51:33 +0000 Subject: Change SAMODE to source from the acting user, not the server This is a merge of the OOMODE command into SAMODE. This fixes SAMODE not working because of mode merging. An additional access check for umode changes is added for this command. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11647 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_samode.cpp | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_samode.cpp b/src/modules/m_samode.cpp index ccd40a3e7..584199345 100644 --- a/src/modules/m_samode.cpp +++ b/src/modules/m_samode.cpp @@ -20,34 +20,21 @@ class CommandSamode : public Command { public: + bool active; CommandSamode (InspIRCd* Instance, Module* Creator) : Command(Instance, Creator,"SAMODE", "o", 2, false, 0) { syntax = " {}"; + active = false; } CmdResult Handle (const std::vector& parameters, User *user) { - /* - * Handles an SAMODE request. Notifies all +s users. - */ - ServerInstance->SendMode(parameters, ServerInstance->FakeClient); - + this->active = true; + ServerInstance->Parser->CallHandler("MODE", parameters, user); if (ServerInstance->Modes->GetLastParse().length()) - { - ServerInstance->SNO->WriteToSnoMask('a', std::string(user->nick) + " used SAMODE: " + ServerInstance->Modes->GetLastParse()); - ServerInstance->PI->SendSNONotice("A", user->nick + " used SAMODE: " + ServerInstance->Modes->GetLastParse()); - - std::string channel = parameters[0]; - ServerInstance->PI->SendMode(channel, ServerInstance->Modes->GetLastParseParams(), ServerInstance->Modes->GetLastParseTranslate()); - - return CMD_LOCALONLY; - } - else - { - user->WriteServ("NOTICE %s :*** Invalid SAMODE sequence.", user->nick.c_str()); - } - - return CMD_FAILURE; + ServerInstance->SNO->WriteGlobalSno('a', std::string(user->nick) + " used SAMODE: " +ServerInstance->Modes->GetLastParse()); + this->active = false; + return CMD_LOCALONLY; } }; @@ -59,6 +46,7 @@ class ModuleSaMode : public Module : Module(Me), cmd(Me, this) { ServerInstance->AddCommand(&cmd); + ServerInstance->Modules->Attach(I_OnAccessCheck, this); } virtual ~ModuleSaMode() @@ -69,6 +57,19 @@ class ModuleSaMode : public Module { return Version("$Id$", VF_VENDOR, API_VERSION); } + + virtual ModResult OnAccessCheck(User* source,User* dest,Channel* channel,int access_type) + { + if (cmd.active) + return MOD_RES_ALLOW; + return MOD_RES_PASSTHRU; + } + + void Prioritize() + { + Module *override = ServerInstance->Modules->Find("m_override.so"); + ServerInstance->Modules->SetPriority(this, I_OnAccessCheck, PRIORITY_BEFORE, &override); + } }; MODULE_INIT(ModuleSaMode) -- cgit v1.2.3