From 46f962748b28d7f00dcb5a5acf5f13608a5d9bfc Mon Sep 17 00:00:00 2001 From: brain Date: Sat, 1 May 2004 13:11:06 +0000 Subject: Added access checks. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@762 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_chanprotect.cpp | 62 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) (limited to 'src/modules') diff --git a/src/modules/m_chanprotect.cpp b/src/modules/m_chanprotect.cpp index 83dc2fd6f..93aae23a5 100644 --- a/src/modules/m_chanprotect.cpp +++ b/src/modules/m_chanprotect.cpp @@ -36,6 +36,68 @@ class ModuleChanProtect : public Module } } + virtual int OnAccessCheck(userrec* source,userrec* dest,chanrec* channel,int access_type) + { + // don't allow action if: + // (A) Theyre founder (no matter what) + // (B) Theyre protected, and you're not + switch (access_type) + { + case AC_DEOP: + if (dest->GetExt("cm_founder_"+std::string(channel->name))) + { + Srv->SendServ(source->fd,"482 "+std::string(source->nick)+" "+std::string(channel->name)+" :Can't deop "+std::string(dest->nick)+" as the're a channel founder"); + return ACR_DENY; + } + if ((dest->GetExt("cm_protect_"+std::string(channel->name))) && (!source->GetExt("cm_protect_"+std::string(channel->name)))) + { + Srv->SendServ(source->fd,"482 "+std::string(source->nick)+" "+std::string(channel->name)+" :Can't deop "+std::string(dest->nick)+" as the're protected (+a)"); + return ACR_DENY; + } + break; + + case AC_KICK: + if (dest->GetExt("cm_founder_"+std::string(channel->name))) + { + Srv->SendServ(source->fd,"482 "+std::string(source->nick)+" "+std::string(channel->name)+" :Can't kick "+std::string(dest->nick)+" as the're a channel founder"); + return ACR_DENY; + } + if ((dest->GetExt("cm_protect_"+std::string(channel->name))) && (!source->GetExt("cm_protect_"+std::string(channel->name)))) + { + Srv->SendServ(source->fd,"482 "+std::string(source->nick)+" "+std::string(channel->name)+" :Can't kick "+std::string(dest->nick)+" as the're protected (+a)"); + return ACR_DENY; + } + break; + + case AC_DEHALFOP: + if (dest->GetExt("cm_founder_"+std::string(channel->name))) + { + Srv->SendServ(source->fd,"482 "+std::string(source->nick)+" "+std::string(channel->name)+" :Can't de-halfop "+std::string(dest->nick)+" as the're a channel founder"); + return ACR_DENY; + } + if ((dest->GetExt("cm_protect_"+std::string(channel->name))) && (!source->GetExt("cm_protect_"+std::string(channel->name)))) + { + Srv->SendServ(source->fd,"482 "+std::string(source->nick)+" "+std::string(channel->name)+" :Can't de-halfop "+std::string(dest->nick)+" as the're protected (+a)"); + return ACR_DENY; + } + break; + + case AC_DEVOICE: + if (dest->GetExt("cm_founder_"+std::string(channel->name))) + { + Srv->SendServ(source->fd,"482 "+std::string(source->nick)+" "+std::string(channel->name)+" :Can't devoice "+std::string(dest->nick)+" as the're a channel founder"); + return ACR_DENY; + } + if ((dest->GetExt("cm_protect_"+std::string(channel->name))) && (!source->GetExt("cm_protect_"+std::string(channel->name)))) + { + Srv->SendServ(source->fd,"482 "+std::string(source->nick)+" "+std::string(channel->name)+" :Can't devoice "+std::string(dest->nick)+" as the're protected (+a)"); + return ACR_DENY; + } + break; + } + return ACR_DEFAULT; + } + virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list ¶ms) { // not out mode, bail -- cgit v1.2.3