1
0
mirror of https://github.com/anope/anope.git synced 2026-07-01 00:46:38 +02:00

Rewrite access path system to be simplier and use recursion

Show where access is "from" in chanserv/status
This commit is contained in:
Adam
2016-02-13 14:16:29 -05:00
parent addd2a1987
commit 4e2ca31cf5
9 changed files with 165 additions and 113 deletions
+2 -2
View File
@@ -370,7 +370,7 @@ class CommandCSAccess : public Command
if (ci->c)
for (Channel::ChanUserList::const_iterator cit = ci->c->users.begin(), cit_end = ci->c->users.end(); cit != cit_end; ++cit)
{
ChanAccess::Path p;
ChannelInfo *p;
if (access->Matches(cit->second->user, cit->second->user->Account(), p))
timebuf = "Now";
}
@@ -407,7 +407,7 @@ class CommandCSAccess : public Command
if (ci->c)
for (Channel::ChanUserList::const_iterator cit = ci->c->users.begin(), cit_end = ci->c->users.end(); cit != cit_end; ++cit)
{
ChanAccess::Path p;
ChannelInfo *p;
if (access->Matches(cit->second->user, cit->second->user->Account(), p))
timebuf = "Now";
}
+7 -2
View File
@@ -236,9 +236,14 @@ class CommandSeen : public Command
AccessGroup ag = source.c->ci->AccessFor(na->nc);
time_t last = 0;
for (unsigned i = 0; i < ag.size(); ++i)
for (unsigned int i = 0; i < ag.paths.size(); ++i)
{
ChanAccess *a = ag[i];
ChanAccess::Path &p = ag.paths[i];
if (p.empty())
continue;
ChanAccess *a = p[p.size() - 1];
if (a->GetAccount() == na->nc && a->last_seen > last)
last = a->last_seen;
+18 -3
View File
@@ -57,11 +57,26 @@ public:
{
source.Reply(_("Access for \002%s\002 on \002%s\002:"), nick.c_str(), ci->name.c_str());
for (unsigned i = 0; i < ag.size(); ++i)
for (unsigned i = 0; i < ag.paths.size(); ++i)
{
ChanAccess *acc = ag[i];
ChanAccess::Path &p = ag.paths[i];
source.Reply(_("\002%s\002 matches access entry %s, which has privilege %s."), nick.c_str(), acc->Mask().c_str(), acc->AccessSerialize().c_str());
if (p.empty())
continue;
if (p.size() == 1)
{
ChanAccess *acc = p[0];
source.Reply(_("\002%s\002 matches access entry %s, which has privilege %s."), nick.c_str(), acc->Mask().c_str(), acc->AccessSerialize().c_str());
}
else
{
ChanAccess *first = p[0];
ChanAccess *acc = p[p.size() - 1];
source.Reply(_("\002%s\002 matches access entry %s (from entry %s), which has privilege %s."), nick.c_str(), acc->Mask().c_str(), first->Mask().c_str(), acc->AccessSerialize().c_str());
}
}
}
+11 -2
View File
@@ -86,8 +86,17 @@ class CommandNSAList : public Command
entry["Number"] = stringify(chan_count);
entry["Channel"] = (ci->HasExt("CS_NO_EXPIRE") ? "!" : "") + ci->name;
for (unsigned j = 0; j < access.size(); ++j)
entry["Access"] = entry["Access"] + ", " + access[j]->AccessSerialize();
for (unsigned j = 0; j < access.paths.size(); ++j)
{
ChanAccess::Path &p = access.paths[i];
// not interested in indirect access
if (p.size() != 1)
continue;
ChanAccess *a = p[0];
entry["Access"] = entry["Access"] + ", " + a->AccessSerialize();
}
entry["Access"] = entry["Access"].substr(2);
entry["Description"] = ci->desc;
list.AddEntry(entry);
+4 -4
View File
@@ -23,8 +23,8 @@ class StatusUpdate : public Module
{
User *user = it->second->user;
ChanAccess::Path p;
if (user->server != Me && access->Matches(user, user->Account(), p))
ChannelInfo *next;
if (user->server != Me && access->Matches(user, user->Account(), next))
{
AccessGroup ag = ci->AccessFor(user);
@@ -46,8 +46,8 @@ class StatusUpdate : public Module
{
User *user = it->second->user;
ChanAccess::Path p;
if (user->server != Me && access->Matches(user, user->Account(), p))
ChannelInfo *next;
if (user->server != Me && access->Matches(user, user->Account(), next))
{
AccessGroup ag = ci->AccessFor(user);
+3 -4
View File
@@ -46,10 +46,9 @@ bool WebCPanel::NickServ::Alist::OnRequest(HTTPProvider *server, const Anope::st
replacements["NUMBERS"] = stringify(chan_count);
replacements["CHANNELS"] = (ci->HasExt("CS_NO_EXPIRE") ? "!" : "") + ci->name;
Anope::string access_str;
for (unsigned i = 0; i < access.size(); ++i)
access_str += ", " + access[i]->AccessSerialize();
replacements["ACCESSES"] = access_str.substr(2);
const ChanAccess *highest = access.Highest();
replacements["ACCESSES"] = highest ? highest->AccessSerialize() : "";
}
TemplateFileServer page("nickserv/alist.html");