From 4c48adf20367bba99a5d343ef491220cc9e1f542 Mon Sep 17 00:00:00 2001 From: brain Date: Sat, 2 Sep 2006 16:44:38 +0000 Subject: Allow unloading of +qa git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5109 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_chanprotect.cpp | 49 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) (limited to 'src/modules/m_chanprotect.cpp') diff --git a/src/modules/m_chanprotect.cpp b/src/modules/m_chanprotect.cpp index 4127f0eb3..2eabc70a8 100644 --- a/src/modules/m_chanprotect.cpp +++ b/src/modules/m_chanprotect.cpp @@ -26,6 +26,12 @@ const char* fakevalue = "on"; +/* When this is set to true, no restrictions apply to setting or + * removal of +qa. This is used while unloading so that the server + * can freely clear all of its users of the modes. + */ +bool unload_kludge = false; + class FounderProtectBase { private: @@ -65,6 +71,27 @@ class FounderProtectBase return std::make_pair(false, parameter); } + void RemoveMode(chanrec* channel, char mc) + { + unload_kludge = true; + CUList* cl = channel->GetUsers(); + std::string item = extend+std::string(channel->name); + char moderemove[MAXBUF]; + userrec* n = new userrec(MyInstance); + n->SetFd(FD_MAGIC_NUMBER); + for (CUList::iterator i = cl->begin(); i != cl->end(); i++) + { + if (i->second->GetExt(item, dummyptr)) + { + sprintf(moderemove,"-%c",mc); + const char* parameters[] = { channel->name, moderemove, i->second->nick }; + MyInstance->SendMode(parameters, 3, n); + } + } + delete n; + unload_kludge = false; + } + void DisplayList(userrec* user, chanrec* channel) { CUList* cl = channel->GetUsers(); @@ -134,6 +161,15 @@ class ChanFounder : public ModeHandler, public FounderProtectBase return FounderProtectBase::ModeSet(source, dest, channel, parameter); } + void RemoveMode(chanrec* channel) + { + FounderProtectBase::RemoveMode(channel, this->GetModeChar()); + } + + void RemoveMode(userrec* user) + { + } + ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding) { userrec* theuser = FounderProtectBase::FindAndVerify(parameter, channel); @@ -144,7 +180,7 @@ class ChanFounder : public ModeHandler, public FounderProtectBase } // source is a server, or ulined, we'll let them +-q the user. - if ((ServerInstance->ULine(source->nick)) || (ServerInstance->ULine(source->server)) || (!*source->server) || (!IS_LOCAL(source))) + if ((unload_kludge) || (ServerInstance->ULine(source->nick)) || (ServerInstance->ULine(source->server)) || (!*source->server) || (!IS_LOCAL(source))) { return FounderProtectBase::HandleChange(source, theuser, adding, channel, parameter); } @@ -181,6 +217,15 @@ class ChanProtect : public ModeHandler, public FounderProtectBase return FounderProtectBase::ModeSet(source, dest, channel, parameter); } + void RemoveMode(chanrec* channel) + { + FounderProtectBase::RemoveMode(channel, this->GetModeChar()); + } + + void RemoveMode(userrec* user) + { + } + ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding) { userrec* theuser = FounderProtectBase::FindAndVerify(parameter, channel); @@ -191,7 +236,7 @@ class ChanProtect : public ModeHandler, public FounderProtectBase std::string founder = "cm_founder_"+std::string(channel->name); // source has +q, is a server, or ulined, we'll let them +-a the user. - if ((ServerInstance->ULine(source->nick)) || (ServerInstance->ULine(source->server)) || (!*source->server) || (source->GetExt(founder,dummyptr)) || (!IS_LOCAL(source))) + if ((unload_kludge) || (ServerInstance->ULine(source->nick)) || (ServerInstance->ULine(source->server)) || (!*source->server) || (source->GetExt(founder,dummyptr)) || (!IS_LOCAL(source))) { return FounderProtectBase::HandleChange(source, theuser, adding, channel, parameter); } -- cgit v1.2.3