Anope IRC Services  Version 2.0
alist.cpp
Go to the documentation of this file.
1 /*
2  * (C) 2003-2014 Anope Team
3  * Contact us at team@anope.org
4  *
5  * Please read COPYING and README for further details.
6  */
7 
8 #include "../../webcpanel.h"
9 
10 static bool ChannelSort(ChannelInfo *ci1, ChannelInfo *ci2)
11 {
12  return ci::less()(ci1->name, ci2->name);
13 }
14 
16 {
17 }
18 
20 {
21  std::deque<ChannelInfo *> queue;
22  na->nc->GetChannelReferences(queue);
23  std::sort(queue.begin(), queue.end(), ChannelSort);
24 
25  int chan_count = 0;
26 
27  for (unsigned q = 0; q < queue.size(); ++q)
28  {
29  ChannelInfo *ci = queue[q];
30 
31  if (ci->GetFounder() == na->nc)
32  {
33  ++chan_count;
34 
35  replacements["NUMBERS"] = stringify(chan_count);
36  replacements["CHANNELS"] = (ci->HasExt("CS_NO_EXPIRE") ? "!" : "") + ci->name;
37  replacements["ACCESSES"] = "Founder";
38  continue;
39  }
40 
41  AccessGroup access = ci->AccessFor(na->nc);
42  if (access.empty())
43  continue;
44 
45  ++chan_count;
46 
47  replacements["NUMBERS"] = stringify(chan_count);
48  replacements["CHANNELS"] = (ci->HasExt("CS_NO_EXPIRE") ? "!" : "") + ci->name;
49  Anope::string access_str;
50  for (unsigned i = 0; i < access.size(); ++i)
51  access_str += ", " + access[i]->AccessSerialize();
52  replacements["ACCESSES"] = access_str.substr(2);
53  }
54 
55  TemplateFileServer page("nickserv/alist.html");
56  page.Serve(server, page_name, client, message, reply, replacements);
57  return true;
58 }
59 
Serialize::Reference< NickCore > nc
Definition: account.h:47
void Serve(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, Replacements &)
Definition: hashcomp.h:84
Anope::string name
Definition: regchannel.h:63
static bool ChannelSort(ChannelInfo *ci1, ChannelInfo *ci2)
Definition: alist.cpp:10
bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) anope_override
Definition: alist.cpp:19
Alist(const Anope::string &cat, const Anope::string &u)
Definition: alist.cpp:15
NickCore * GetFounder() const
Definition: regchannel.cpp:364
AccessGroup AccessFor(const User *u)
Definition: regchannel.cpp:413
Anope::string stringify(const T &x)
Definition: anope.h:710
bool HasExt(const Anope::string &name) const
Definition: extensible.cpp:31