summaryrefslogtreecommitdiff
path: root/modules/commands
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2013-02-13 17:42:01 -0500
committerAdam <Adam@anope.org>2013-02-14 01:20:18 -0500
commit9e544a6443117861c3d6406e435043f1cf0f7099 (patch)
treee7449fb01e377576e8a09f386117d2c251de0596 /modules/commands
parent225b7c38c127fbc6aac6724012f71c9483a4da77 (diff)
Store what channels have references to accounts in NickCore to prevent having to iterate over all channels and then all access entries when nicks expire or from nickserv/alist
Diffstat (limited to 'modules/commands')
-rw-r--r--modules/commands/cs_info.cpp4
-rw-r--r--modules/commands/cs_set.cpp4
-rw-r--r--modules/commands/ns_alist.cpp31
3 files changed, 30 insertions, 9 deletions
diff --git a/modules/commands/cs_info.cpp b/modules/commands/cs_info.cpp
index c37a74dd5..9485e81fd 100644
--- a/modules/commands/cs_info.cpp
+++ b/modules/commands/cs_info.cpp
@@ -59,8 +59,8 @@ class CommandCSInfo : public Command
if (ci->GetFounder())
info["Founder"] = ci->GetFounder()->display;
- if (show_all && ci->successor)
- info["Successor"] = ci->successor->display;
+ if (show_all && ci->GetSuccessor())
+ info["Successor"] = ci->GetSuccessor()->display;
if (!ci->desc.empty())
info["Description"] = ci->desc;
diff --git a/modules/commands/cs_set.cpp b/modules/commands/cs_set.cpp
index 8c6aa48c1..730f31deb 100644
--- a/modules/commands/cs_set.cpp
+++ b/modules/commands/cs_set.cpp
@@ -1057,9 +1057,9 @@ class CommandCSSetSuccessor : public Command
else
nc = NULL;
- Log(!source.permission.empty() ? LOG_ADMIN : LOG_COMMAND, source, this, ci) << "to change the successor from " << (ci->successor ? ci->successor->display : "(none)") << " to " << (nc ? nc->display : "(none)");
+ Log(!source.permission.empty() ? LOG_ADMIN : LOG_COMMAND, source, this, ci) << "to change the successor from " << (ci->GetSuccessor() ? ci->GetSuccessor()->display : "(none)") << " to " << (nc ? nc->display : "(none)");
- ci->successor = nc;
+ ci->SetSuccessor(nc);
if (nc)
source.Reply(_("Successor for \002%s\002 changed to \002%s\002."), ci->name.c_str(), nc->display.c_str());
diff --git a/modules/commands/ns_alist.cpp b/modules/commands/ns_alist.cpp
index bd3a22281..c8d7eef0f 100644
--- a/modules/commands/ns_alist.cpp
+++ b/modules/commands/ns_alist.cpp
@@ -46,12 +46,21 @@ class CommandNSAList : public Command
source.Reply(_("Channels that \002%s\002 has access on:"), nc->display.c_str());
- for (registered_channel_map::const_iterator it = RegisteredChannelList->begin(), it_end = RegisteredChannelList->end(); it != it_end; ++it)
+ std::deque<ChannelInfo *> queue;
+ nc->GetChannelReferences(queue);
+
+ if (queue.empty())
+ {
+ source.Reply(_("\2%s\2 has no access in any channels."), nc->display.c_str());
+ return;
+ }
+
+ for (unsigned i = 0; i < queue.size(); ++i)
{
- ChannelInfo *ci = it->second;
+ ChannelInfo *ci = queue[i];
ListFormatter::ListEntry entry;
- if (ci->GetFounder() && ci->GetFounder() == nc)
+ if (ci->GetFounder() == nc)
{
++chan_count;
entry["Number"] = stringify(chan_count);
@@ -61,6 +70,16 @@ class CommandNSAList : public Command
continue;
}
+ if (ci->GetSuccessor() == nc)
+ {
+ ++chan_count;
+ entry["Number"] = stringify(chan_count);
+ entry["Channel"] = (ci->HasExt("NO_EXPIRE") ? "!" : "") + ci->name;
+ entry["Access"] = "Successor";
+ list.AddEntry(entry);
+ continue;
+ }
+
AccessGroup access = ci->AccessFor(nc);
if (access.empty())
continue;
@@ -69,8 +88,8 @@ class CommandNSAList : public Command
entry["Number"] = stringify(chan_count);
entry["Channel"] = (ci->HasExt("NO_EXPIRE") ? "!" : "") + ci->name;
- for (unsigned i = 0; i < access.size(); ++i)
- entry["Access"] = entry["Access"] + ", " + access[i]->AccessSerialize();
+ for (unsigned j = 0; j < access.size(); ++j)
+ entry["Access"] = entry["Access"] + ", " + access[j]->AccessSerialize();
entry["Access"] = entry["Access"].substr(2);
list.AddEntry(entry);
}
@@ -79,6 +98,8 @@ class CommandNSAList : public Command
list.Process(replies);
for (unsigned i = 0; i < replies.size(); ++i)
source.Reply(replies[i]);
+
+ source.Reply(_("End of list - %d channels shown."), chan_count);
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override