diff options
author | Adam <Adam@anope.org> | 2012-01-07 03:44:43 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2012-01-07 03:44:43 -0500 |
commit | dd64eac782b3ee5acc6d1068a0ef42142a035254 (patch) | |
tree | 556f4bdf91bdf1b3066dee0308a7e72bcc01d35c /modules/commands/cs_xop.cpp | |
parent | 4204ece7a885dbe965f0adea57b3e3c017b4f5e2 (diff) |
Fixed users not being able to delete their own access with /cs access when using numbers, and clean up cs_xop slightly
Diffstat (limited to 'modules/commands/cs_xop.cpp')
-rw-r--r-- | modules/commands/cs_xop.cpp | 105 |
1 files changed, 52 insertions, 53 deletions
diff --git a/modules/commands/cs_xop.cpp b/modules/commands/cs_xop.cpp index 201d80855..ec43ccebc 100644 --- a/modules/commands/cs_xop.cpp +++ b/modules/commands/cs_xop.cpp @@ -194,57 +194,6 @@ class XOPAccessProvider : public AccessProvider } }; -class XOPDelCallback : public NumberList -{ - CommandSource &source; - ChannelInfo *ci; - Command *c; - unsigned Deleted; - Anope::string Nicks; - bool override; - XOPType type; - public: - XOPDelCallback(CommandSource &_source, ChannelInfo *_ci, Command *_c, bool _override, XOPType _type, const Anope::string &numlist) : NumberList(numlist, true), source(_source), ci(_ci), c(_c), Deleted(0), override(_override), type(_type) - { - } - - ~XOPDelCallback() - { - if (!Deleted) - source.Reply(_("No matching entries on %s %s list."), ci->name.c_str(), source.command.c_str()); - else - { - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source.u, c, ci) << "deleted access of users " << Nicks; - - if (Deleted == 1) - source.Reply(_("Deleted one entry from %s %s list."), ci->name.c_str(), source.command.c_str()); - else - source.Reply(_("Deleted %d entries from %s %s list."), Deleted, ci->name.c_str(), source.command.c_str()); - } - } - - void HandleNumber(unsigned Number) - { - if (!Number || Number > ci->GetAccessCount()) - return; - - ChanAccess *access = ci->GetAccess(Number - 1); - - if (this->type != XOPChanAccess::DetermineLevel(access)) - return; - - ++Deleted; - if (!Nicks.empty()) - Nicks += ", " + access->mask; - else - Nicks = access->mask; - - FOREACH_MOD(I_OnAccessDel, OnAccessDel(ci, source.u, access)); - - ci->EraseAccess(Number - 1); - } -}; - class XOPBase : public Command { private: @@ -362,8 +311,58 @@ class XOPBase : public Command /* Special case: is it a number/list? Only do search if it isn't. */ if (isdigit(mask[0]) && mask.find_first_not_of("1234567890,-") == Anope::string::npos) { - XOPDelCallback list(source, ci, this, override, level, mask); - list.Process(); + class XOPDelCallback : public NumberList + { + CommandSource &source; + ChannelInfo *ci; + Command *c; + unsigned Deleted; + Anope::string Nicks; + bool override; + XOPType type; + public: + XOPDelCallback(CommandSource &_source, ChannelInfo *_ci, Command *_c, bool _override, XOPType _type, const Anope::string &numlist) : NumberList(numlist, true), source(_source), ci(_ci), c(_c), Deleted(0), override(_override), type(_type) + { + } + + ~XOPDelCallback() + { + if (!Deleted) + source.Reply(_("No matching entries on %s %s list."), ci->name.c_str(), source.command.c_str()); + else + { + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source.u, c, ci) << "deleted access of users " << Nicks; + + if (Deleted == 1) + source.Reply(_("Deleted one entry from %s %s list."), ci->name.c_str(), source.command.c_str()); + else + source.Reply(_("Deleted %d entries from %s %s list."), Deleted, ci->name.c_str(), source.command.c_str()); + } + } + + void HandleNumber(unsigned Number) + { + if (!Number || Number > ci->GetAccessCount()) + return; + + ChanAccess *caccess = ci->GetAccess(Number - 1); + + if (this->type != XOPChanAccess::DetermineLevel(caccess)) + return; + + ++Deleted; + if (!Nicks.empty()) + Nicks += ", " + caccess->mask; + else + Nicks = caccess->mask; + + FOREACH_MOD(I_OnAccessDel, OnAccessDel(ci, source.u, caccess)); + + ci->EraseAccess(Number - 1); + } + } + delcallback(source, ci, this, override, level, mask); + delcallback.Process(); } else { |