1
0
mirror of https://github.com/anope/anope.git synced 2026-07-08 06:03:13 +02:00

Fixed users not being able to delete their own access with /cs access when using numbers, and clean up cs_xop slightly

This commit is contained in:
Adam
2012-01-07 03:44:43 -05:00
parent 4204ece7a8
commit dd64eac782
2 changed files with 53 additions and 54 deletions
+1 -1
View File
@@ -223,7 +223,7 @@ class CommandCSAccess : public Command
AccessGroup u_access = ci->AccessFor(user);
ChanAccess *u_highest = u_access.Highest();
if (u_highest ? AccessChanAccess::DetermineLevel(u_highest) : 0 <= AccessChanAccess::DetermineLevel(access) && !u_access.Founder && !user->HasPriv("chanserv/access/modify"))
if ((u_highest ? AccessChanAccess::DetermineLevel(u_highest) : 0) <= AccessChanAccess::DetermineLevel(access) && !u_access.Founder && !this->override && !access->mask.equals_ci(user->Account()->display))
{
Denied = true;
return;
+52 -53
View File
@@ -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
{