diff options
author | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2010-01-16 15:13:21 +0000 |
---|---|---|
committer | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2010-01-16 15:13:21 +0000 |
commit | 8b96626119ecdcece7541e5debdf7e234edbee3a (patch) | |
tree | 46cbc8e1cbcc9eb54a3652400ade9faf93b89cb2 /src/mode.cpp | |
parent | 57e51adaf1b1e30b06bebf5fe8fb13e937e96c5e (diff) |
Search for correct access level for mode changes, remove hardcoded halfop references
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@12265 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/mode.cpp')
-rw-r--r-- | src/mode.cpp | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/src/mode.cpp b/src/mode.cpp index ef82cccdc..6dea66464 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -288,11 +288,23 @@ ModeAction ModeParser::TryMode(User* user, User* targetuser, Channel* chan, bool unsigned int ourrank = chan->GetPrefixValue(user); if (ourrank < neededrank) { - /* Bog off */ - // TODO replace with a real search for the proper prefix - char needed = neededrank > HALFOP_VALUE ? '@' : '%'; - user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s %s :You must have channel privilege %c or above to %sset channel mode %c", - user->nick.c_str(), chan->name.c_str(), needed, adding ? "" : "un", modechar); + ModeHandler* neededmh = NULL; + for(char c='A'; c <= 'z'; c++) + { + ModeHandler *privmh = FindMode(modechar, type); + if (privmh->GetPrefixRank() >= neededrank) + { + // this mode is sufficient to allow this action + if (!neededmh || privmh->GetPrefixRank() < neededmh->GetPrefixRank()) + neededmh = privmh; + } + } + if (neededmh) + user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s %s :You must have channel %s access or above to %sset channel mode %c", + user->nick.c_str(), chan->name.c_str(), neededmh->name.c_str(), adding ? "" : "un", modechar); + else + user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s %s :You cannot %sset channel mode %c", + user->nick.c_str(), chan->name.c_str(), adding ? "" : "un", modechar); return MODEACTION_DENY; } } @@ -551,13 +563,11 @@ void ModeParser::DisplayListModes(User* user, Channel* chan, std::string &mode_s bool display = true; if (!user->HasPrivPermission("channels/auspex") && ServerInstance->Config->HideModeLists[mletter] && (chan->GetPrefixValue(user) < HALFOP_VALUE)) { - user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s %s :Only half-operators and above may view the +%c list", + user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s %s :You do not have access to view the +%c list", user->nick.c_str(), chan->name.c_str(), mletter); display = false; } - /** See below for a description of what craq this is :D - */ unsigned char handler_id = (mletter - 'A') | MASK_CHANNEL; for(ModeWatchIter watchers = modewatchers[handler_id].begin(); watchers != modewatchers[handler_id].end(); watchers++) @@ -937,7 +947,6 @@ struct builtin_modes ModeChannelBan b; ModeChannelOp o; - // halfop is added by configreader ModeChannelVoice v; ModeUserWallops uw; |