summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2011-08-07 19:04:27 -0400
committerAdam <Adam@anope.org>2011-08-07 19:04:27 -0400
commitc6741d3765d0a8dbf34e80a34573333e45b5ec6b (patch)
tree552e5b4f2e6f2819ed7686b3c9aa4b2fce5382d4
parent25e3408ff654a9cb8ac15af41e3e015cbe85a444 (diff)
Always reset the levels of newly created channels, fixed DetermineLevel matching ACCESS_INVALID levels, and added in a disabled config option for levels
-rw-r--r--include/modules.h7
-rw-r--r--modules/commands/cs_access.cpp13
-rw-r--r--src/regchannel.cpp2
3 files changed, 18 insertions, 4 deletions
diff --git a/include/modules.h b/include/modules.h
index 7fd477b32..df4fd0323 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -692,6 +692,11 @@ class CoreExport Module : public Extensible
*/
virtual void OnChanUnsuspend(ChannelInfo *ci) { }
+ /** Called when a channel is being created, for any reason
+ * @param ci The channel
+ */
+ virtual void OnCreateChan(ChannelInfo *ci) { }
+
/** Called when a channel is being deleted, for any reason
* @param ci The channel
*/
@@ -1030,7 +1035,7 @@ enum Implementation
/* ChanServ */
I_OnChanForbidden, I_OnChanSuspend, I_OnChanDrop, I_OnPreChanExpire, I_OnChanExpire, I_OnAccessAdd,
- I_OnAccessDel, I_OnAccessClear, I_OnLevelChange, I_OnChanRegistered, I_OnChanUnsuspend, I_OnDelChan, I_OnChannelCreate,
+ I_OnAccessDel, I_OnAccessClear, I_OnLevelChange, I_OnChanRegistered, I_OnChanUnsuspend, I_OnCreateChan, I_OnDelChan, I_OnChannelCreate,
I_OnChannelDelete, I_OnAkickAdd, I_OnAkickDel, I_OnCheckKick,
I_OnChanInfo, I_OnFindChan, I_OnCheckPriv,
diff --git a/modules/commands/cs_access.cpp b/modules/commands/cs_access.cpp
index 777b0c176..fa23658c8 100644
--- a/modules/commands/cs_access.cpp
+++ b/modules/commands/cs_access.cpp
@@ -94,7 +94,7 @@ class AccessChanAccess : public ChanAccess
{
for (int i = 0; defaultLevels[i].priv != CA_SIZE; ++i)
if (defaultLevels[i].priv == priv)
- return DetermineLevel(this) >= this->ci->levels[priv];
+ return this->ci->levels[priv] != ACCESS_INVALID && DetermineLevel(this) >= this->ci->levels[priv];
return false;
}
@@ -884,8 +884,8 @@ class CSAccess : public Module
ModuleManager::RegisterService(&commandcsaccess);
ModuleManager::RegisterService(&commandcslevels);
- Implementation i[] = { I_OnReload, I_OnChanRegistered };
- ModuleManager::Attach(i, this, 2);
+ Implementation i[] = { I_OnReload, I_OnChanRegistered, I_OnCreateChan };
+ ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
this->OnReload();
}
@@ -901,6 +901,8 @@ class CSAccess : public Module
const Anope::string &value = config.ReadValue("chanserv", l.config_name, "", 0);
if (value.equals_ci("founder"))
l.default_level = ACCESS_FOUNDER;
+ else if (value.equals_ci("disabled"))
+ l.default_level = ACCESS_INVALID;
else
l.default_level = config.ReadInteger("chanserv", l.config_name, 0, false);
}
@@ -910,6 +912,11 @@ class CSAccess : public Module
{
reset_levels(ci);
}
+
+ void OnCreateChan(ChannelInfo *ci)
+ {
+ reset_levels(ci);
+ }
};
MODULE_INIT(CSAccess)
diff --git a/src/regchannel.cpp b/src/regchannel.cpp
index a13e47009..ce5bef71c 100644
--- a/src/regchannel.cpp
+++ b/src/regchannel.cpp
@@ -56,6 +56,8 @@ ChannelInfo::ChannelInfo(const Anope::string &chname) : Flags<ChannelInfoFlag, C
this->ttb[i] = 0;
RegisteredChannelList[this->name] = this;
+
+ FOREACH_MOD(I_OnCreateChan, OnCreateChan(this));
}
/** Copy constructor