anope- supernets anope source code & configuration |
git clone git://git.acid.vegas/anope.git |
Log | Files | Refs | Archive | README |
alist.cpp (1573B)
1 /* 2 * (C) 2003-2022 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 15 WebCPanel::NickServ::Alist::Alist(const Anope::string &cat, const Anope::string &u) : WebPanelProtectedPage(cat, u) 16 { 17 } 18 19 bool WebCPanel::NickServ::Alist::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements) 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 50 const ChanAccess *highest = access.Highest(); 51 replacements["ACCESSES"] = highest ? highest->AccessSerialize() : ""; 52 } 53 54 TemplateFileServer page("nickserv/alist.html"); 55 page.Serve(server, page_name, client, message, reply, replacements); 56 return true; 57 }