From 8da03ef9ce894b5434a094da1dadbfd4e704c64f Mon Sep 17 00:00:00 2001 From: Daniel De Graaf Date: Fri, 6 Aug 2010 20:34:04 -0400 Subject: Add config tag --- src/modules/m_opflags.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/modules/m_opflags.cpp') diff --git a/src/modules/m_opflags.cpp b/src/modules/m_opflags.cpp index 1d7a4d56d..e3781d03a 100644 --- a/src/modules/m_opflags.cpp +++ b/src/modules/m_opflags.cpp @@ -84,6 +84,8 @@ class FlagCmd : public Command { public: OpFlagProviderImpl prov; + unsigned int conflevel; + unsigned int usermax; FlagCmd(Module* parent) : Command(parent, "OPFLAGS", 2), prov(parent) { syntax = " {+-=}[]"; @@ -117,7 +119,9 @@ class FlagCmd : public Command if (IS_LOCAL(src)) { ModResult res = ServerInstance->CheckExemption(src,chan,"opflags"); - if (!res.check(chan->GetPrefixValue(src) >= OP_VALUE)) + PermissionData perm(src, "opflags", chan, user); + + if (!perm.result.check(chan->GetPrefixValue(src) >= conflevel)) { src->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s %s :You cannot change opflags on this channel.", src->nick.c_str(), chan->name.c_str()); @@ -155,6 +159,12 @@ class FlagCmd : public Command else flags.erase(flag); } + if (IS_LOCAL(src) && flags.size() > usermax) + { + src->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s %s :Users cannot have more than %d opflags set.", + src->nick.c_str(), chan->name.c_str(), usermax); + return CMD_FAILURE; + } if (flags.empty()) { prov.ext.unset(memb); @@ -199,8 +209,9 @@ class ModuleOpFlags : public Module void OnRehash(User*) { - // ConfigTag* tag = ServerInstance->Config->ConfValue("opflags"); - // TODO maxflags? + ConfigTag* tag = ServerInstance->Config->ConfValue("opflags"); + cmd.conflevel = tag->getInt("level", OP_VALUE); + cmd.usermax = tag->getInt("maxflags", 15); } void OnSyncChannel(Channel* channel, SyncTarget* target) -- cgit v1.3.1-10-gc9f91