summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-09-02 16:44:38 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-09-02 16:44:38 +0000
commit4c48adf20367bba99a5d343ef491220cc9e1f542 (patch)
treea9797fc60567b04bf751a1b022eaf286ef274547 /src
parentf82e1e9de4a0c7e7293094f1e54c9bd209b1cde5 (diff)
Allow unloading of +qa
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5109 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/modules/m_chanprotect.cpp49
1 files changed, 47 insertions, 2 deletions
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 &parameter, 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 &parameter, 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);
}