X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_hidelist.cpp;h=d076e2e639a79ac0d398cfba7b4657de7f48db30;hb=3151d60c1ecc9462e4c335282ee6c31672f45111;hp=f7a05ed0abdf471abf1bff3fd801d2d16bc75bf3;hpb=c2fb4e4b9d7dc6f2ecc5d8f0054350ae8c9be986;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_hidelist.cpp b/src/modules/m_hidelist.cpp index f7a05ed0a..d076e2e63 100644 --- a/src/modules/m_hidelist.cpp +++ b/src/modules/m_hidelist.cpp @@ -1,7 +1,9 @@ /* * InspIRCd -- Internet Relay Chat Daemon * - * Copyright (C) 2014 Attila Molnar + * Copyright (C) 2018 linuxdaemon + * Copyright (C) 2017-2018 Sadie Powell + * Copyright (C) 2014, 2016 Attila Molnar * * This file is part of InspIRCd. InspIRCd is free software: you can * redistribute it and/or modify it under the terms of the GNU General Public @@ -21,13 +23,17 @@ class ListWatcher : public ModeWatcher { + // Minimum rank required to view the list + const unsigned int minrank; + public: - ListWatcher(Module* mod, const std::string& modename) + ListWatcher(Module* mod, const std::string& modename, unsigned int rank) : ModeWatcher(mod, modename, MODETYPE_CHANNEL) + , minrank(rank) { } - bool BeforeMode(User* user, User* destuser, Channel* chan, std::string& param, bool adding) + bool BeforeMode(User* user, User* destuser, Channel* chan, std::string& param, bool adding) CXX11_OVERRIDE { // Only handle listmode list requests if (!param.empty()) @@ -36,13 +42,13 @@ class ListWatcher : public ModeWatcher // If the user requesting the list is a member of the channel see if they have the // rank required to view the list Membership* memb = chan->GetUser(user); - if ((memb) && (memb->getRank() >= HALFOP_VALUE)) + if ((memb) && (memb->getRank() >= minrank)) return true; if (user->HasPrivPermission("channels/auspex")) return true; - user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s :You do not have access to view the %s list", chan->name.c_str(), GetModeName().c_str()); + user->WriteNumeric(ERR_CHANOPRIVSNEEDED, chan->name, InspIRCd::Format("You do not have access to view the %s list", GetModeName().c_str())); return false; } }; @@ -54,16 +60,26 @@ class ModuleHideList : public Module public: void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { - stdalgo::delete_all(watchers); - watchers.clear(); - ConfigTagList tags = ServerInstance->Config->ConfTags("hidelist"); + typedef std::vector > NewConfigs; + NewConfigs newconfigs; for (ConfigIter i = tags.first; i != tags.second; ++i) { ConfigTag* tag = i->second; std::string modename = tag->getString("mode"); - watchers.push_back(new ListWatcher(this, modename)); + if (modename.empty()) + throw ModuleException("Empty at " + tag->getTagLocation()); + // If rank is set to 0 everyone inside the channel can view the list, + // but non-members may not + unsigned int rank = tag->getUInt("rank", HALFOP_VALUE); + newconfigs.push_back(std::make_pair(modename, rank)); } + + stdalgo::delete_all(watchers); + watchers.clear(); + + for (NewConfigs::const_iterator i = newconfigs.begin(); i != newconfigs.end(); ++i) + watchers.push_back(new ListWatcher(this, i->first, i->second)); } ~ModuleHideList() @@ -73,7 +89,7 @@ class ModuleHideList : public Module Version GetVersion() CXX11_OVERRIDE { - return Version("Provides support for hiding the list of listmodes", VF_VENDOR); + return Version("Allows list mode lists to be hidden from users without a prefix mode ranked equal to or higher than a defined level.", VF_VENDOR); } };