diff options
author | Adam <Adam@anope.org> | 2013-08-22 01:13:28 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2013-08-22 01:13:28 -0400 |
commit | ce7a32a994136fa4ffd8489f8e56dde7b678ee07 (patch) | |
tree | 935122b9d5b38067dc3759f618f24c9b8705b72c | |
parent | 0c1cc08e2832dbe59b5aaa9b654a11bafb373ab6 (diff) |
Do not have cs_access try to represent non levels access entries as levels access entries. Sometimes it cant accurately be done and it confuses people.
-rw-r--r-- | modules/commands/cs_access.cpp | 30 | ||||
-rw-r--r-- | modules/commands/cs_flags.cpp | 15 | ||||
-rw-r--r-- | modules/commands/cs_xop.cpp | 18 |
3 files changed, 21 insertions, 42 deletions
diff --git a/modules/commands/cs_access.cpp b/modules/commands/cs_access.cpp index 5d361043d..ab13b6e7d 100644 --- a/modules/commands/cs_access.cpp +++ b/modules/commands/cs_access.cpp @@ -43,32 +43,6 @@ class AccessChanAccess : public ChanAccess { this->level = convertTo<int>(data); } - - static int DetermineLevel(const ChanAccess *access) - { - if (access->provider->name == "access/access") - { - const AccessChanAccess *aaccess = anope_dynamic_static_cast<const AccessChanAccess *>(access); - return aaccess->level; - } - else - { - int highest = 1; - const std::vector<Privilege> &privs = PrivilegeManager::GetPrivileges(); - - for (unsigned i = 0; i < privs.size(); ++i) - { - const Privilege &p = privs[i]; - if (access->ci->GetLevel(p.name) > highest && access->HasPriv(p.name)) - highest = access->ci->GetLevel(p.name); - } - - if (highest >= ACCESS_FOUNDER) - highest = ACCESS_FOUNDER - 1; - - return highest; - } - } }; class AccessAccessProvider : public AccessProvider @@ -380,7 +354,7 @@ class CommandCSAccess : public Command ListFormatter::ListEntry entry; entry["Number"] = stringify(number); - entry["Level"] = stringify(AccessChanAccess::DetermineLevel(access)); + entry["Level"] = access->AccessSerialize(); entry["Mask"] = access->mask; entry["By"] = access->creator; entry["Last seen"] = timebuf; @@ -417,7 +391,7 @@ class CommandCSAccess : public Command ListFormatter::ListEntry entry; entry["Number"] = stringify(i + 1); - entry["Level"] = stringify(AccessChanAccess::DetermineLevel(access)); + entry["Level"] = access->AccessSerialize(); entry["Mask"] = access->mask; entry["By"] = access->creator; entry["Last seen"] = timebuf; diff --git a/modules/commands/cs_flags.cpp b/modules/commands/cs_flags.cpp index 9b1721648..cc0f6798f 100644 --- a/modules/commands/cs_flags.cpp +++ b/modules/commands/cs_flags.cpp @@ -254,7 +254,7 @@ class CommandCSFlags : public Command source.Reply(_("Privilege \2%s\2 removed from \2%s\2 on \2%s\2, new flags are +\2%s\2"), p->name.c_str(), access->mask.c_str(), ci->name.c_str(), access->AccessSerialize().c_str()); } else - source.Reply(_("Access for \002%s\002 on %s set to +\002%s\002"), access->mask.c_str(), ci->name.c_str(), access->AccessSerialize().c_str()); + source.Reply(_("Flags for \002%s\002 on %s set to +\002%s\002"), access->mask.c_str(), ci->name.c_str(), access->AccessSerialize().c_str()); } void DoList(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms) @@ -275,11 +275,10 @@ class CommandCSFlags : public Command for (unsigned i = 0, end = ci->GetAccessCount(); i < end; ++i) { const ChanAccess *access = ci->GetAccess(i); + const Anope::string &flags = FlagsChanAccess::DetermineFlags(access); if (!arg.empty()) { - const Anope::string &flags = FlagsChanAccess::DetermineFlags(access); - if (arg[0] == '+') { bool pass = true; @@ -297,7 +296,7 @@ class CommandCSFlags : public Command ++count; entry["Number"] = stringify(i + 1); entry["Mask"] = access->mask; - entry["Flags"] = FlagsChanAccess::DetermineFlags(access); + entry["Flags"] = flags; entry["Creator"] = access->creator; entry["Created"] = Anope::strftime(access->created, source.nc, true); list.AddEntry(entry); @@ -340,7 +339,7 @@ class CommandCSFlags : public Command } public: - CommandCSFlags(Module *creator) : Command(creator, "chanserv/flags", 2, 4) + CommandCSFlags(Module *creator) : Command(creator, "chanserv/flags", 1, 4) { this->SetDesc(_("Modify the list of privileged users")); this->SetSyntax(_("\037channel\037 MODIFY \037mask\037 \037changes\037")); @@ -351,7 +350,7 @@ class CommandCSFlags : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { const Anope::string &chan = params[0]; - const Anope::string &cmd = params[1]; + const Anope::string &cmd = params.size() > 1 ? params[1] : ""; ChannelInfo *ci = ChannelInfo::Find(chan); if (ci == NULL) @@ -360,7 +359,7 @@ class CommandCSFlags : public Command return; } - bool is_list = cmd.equals_ci("LIST"); + bool is_list = cmd.empty() || cmd.equals_ci("LIST"); bool has_access = false; if (source.HasPriv("chanserv/access/modify")) has_access = true; @@ -375,7 +374,7 @@ class CommandCSFlags : public Command source.Reply(_("Sorry, channel access list modification is temporarily disabled.")); else if (cmd.equals_ci("MODIFY")) this->DoModify(source, ci, params); - else if (cmd.equals_ci("LIST")) + else if (is_list) this->DoList(source, ci, params); else if (cmd.equals_ci("CLEAR")) this->DoClear(source, ci); diff --git a/modules/commands/cs_xop.cpp b/modules/commands/cs_xop.cpp index 10d28fc03..cd08a33a9 100644 --- a/modules/commands/cs_xop.cpp +++ b/modules/commands/cs_xop.cpp @@ -315,7 +315,7 @@ class CommandCSXOP : public Command ChanAccess *caccess = ci->GetAccess(number - 1); - if (this->source.command.upper() != XOPChanAccess::DetermineLevel(caccess)) + if (caccess->provider->name != "access/xop" || this->source.command.upper() != caccess->AccessSerialize()) return; ++deleted; @@ -338,7 +338,10 @@ class CommandCSXOP : public Command { ChanAccess *a = ci->GetAccess(i); - if (a->mask.equals_ci(mask) && XOPChanAccess::DetermineLevel(a) == source.command.upper()) + if (a->provider->name != "access/xop" || source.command.upper() != a->AccessSerialize()) + continue; + + if (a->mask.equals_ci(mask)) { Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to delete " << a->mask; @@ -397,7 +400,7 @@ class CommandCSXOP : public Command const ChanAccess *a = ci->GetAccess(Number - 1); - if (this->source.command.upper() != XOPChanAccess::DetermineLevel(a)) + if (a->provider->name != "access/xop" || this->source.command.upper() != a->AccessSerialize()) return; ListFormatter::ListEntry entry; @@ -414,7 +417,7 @@ class CommandCSXOP : public Command { const ChanAccess *a = ci->GetAccess(i); - if (XOPChanAccess::DetermineLevel(a) != source.command.upper()) + if (a->provider->name != "access/xop" || source.command.upper() != a->AccessSerialize()) continue; else if (!nick.empty() && !Anope::Match(a->mask, nick)) continue; @@ -465,8 +468,11 @@ class CommandCSXOP : public Command for (unsigned i = ci->GetAccessCount(); i > 0; --i) { const ChanAccess *access = ci->GetAccess(i - 1); - if (XOPChanAccess::DetermineLevel(access) == source.command.upper()) - delete ci->EraseAccess(i - 1); + + if (access->provider->name != "access/xop" || source.command.upper() != access->AccessSerialize()) + continue; + + delete ci->EraseAccess(i - 1); } FOREACH_MOD(OnAccessClear, (ci, source)); |