summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2016-02-13 14:16:29 -0500
committerAdam <Adam@anope.org>2016-02-13 14:16:29 -0500
commit4e2ca31cf5fc874ab928dc4d3735f4345a910d0d (patch)
tree1590da2a86eb164389dd781870648d8f3824f9a3 /modules
parentaddd2a1987dccff6ad4c8a68f5c48c9f850912ec (diff)
Rewrite access path system to be simplier and use recursion
Show where access is "from" in chanserv/status
Diffstat (limited to 'modules')
-rw-r--r--modules/commands/cs_access.cpp4
-rw-r--r--modules/commands/cs_seen.cpp9
-rw-r--r--modules/commands/cs_status.cpp21
-rw-r--r--modules/commands/ns_alist.cpp13
-rw-r--r--modules/cs_statusupdate.cpp8
-rw-r--r--modules/webcpanel/pages/nickserv/alist.cpp7
6 files changed, 45 insertions, 17 deletions
diff --git a/modules/commands/cs_access.cpp b/modules/commands/cs_access.cpp
index 543082a2d..6e9b79c6a 100644
--- a/modules/commands/cs_access.cpp
+++ b/modules/commands/cs_access.cpp
@@ -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";
}
diff --git a/modules/commands/cs_seen.cpp b/modules/commands/cs_seen.cpp
index 41f8ee97c..80bc8e548 100644
--- a/modules/commands/cs_seen.cpp
+++ b/modules/commands/cs_seen.cpp
@@ -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;
diff --git a/modules/commands/cs_status.cpp b/modules/commands/cs_status.cpp
index 28fe60619..b984d5952 100644
--- a/modules/commands/cs_status.cpp
+++ b/modules/commands/cs_status.cpp
@@ -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());
+ }
}
}
diff --git a/modules/commands/ns_alist.cpp b/modules/commands/ns_alist.cpp
index d273ec59f..6ccbe94ba 100644
--- a/modules/commands/ns_alist.cpp
+++ b/modules/commands/ns_alist.cpp
@@ -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);
diff --git a/modules/cs_statusupdate.cpp b/modules/cs_statusupdate.cpp
index b5febbe76..ffdbec3e7 100644
--- a/modules/cs_statusupdate.cpp
+++ b/modules/cs_statusupdate.cpp
@@ -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);
diff --git a/modules/webcpanel/pages/nickserv/alist.cpp b/modules/webcpanel/pages/nickserv/alist.cpp
index fbb37224e..d5b331f4f 100644
--- a/modules/webcpanel/pages/nickserv/alist.cpp
+++ b/modules/webcpanel/pages/nickserv/alist.cpp
@@ -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");