diff options
Diffstat (limited to 'modules/webcpanel/webcpanel.h')
-rw-r--r-- | modules/webcpanel/webcpanel.h | 46 |
1 files changed, 30 insertions, 16 deletions
diff --git a/modules/webcpanel/webcpanel.h b/modules/webcpanel/webcpanel.h index 3aaf19ef6..d82efaf3b 100644 --- a/modules/webcpanel/webcpanel.h +++ b/modules/webcpanel/webcpanel.h @@ -1,8 +1,20 @@ /* - * (C) 2003-2017 Anope Team - * Contact us at team@anope.org + * Anope IRC Services * - * Please read COPYING and README for further details. + * Copyright (C) 2012-2017 Anope Team <team@anope.org> + * + * This file is part of Anope. Anope is free software; you can + * redistribute it and/or modify it under the terms of the GNU + * General Public License as published by the Free Software + * Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see see <http://www.gnu.org/licenses/>. */ #include "module.h" @@ -31,11 +43,13 @@ struct Section class Panel : public Section, public Service { public: - Panel(Module *c, const Anope::string &n) : Service(c, "Panel", n) { } + static constexpr const char *NAME = "panel"; + + Panel(Module *c, const Anope::string &n) : Service(c, NAME, "") { } std::vector<Section> sections; - NickAlias *GetNickFromSession(HTTPClient *client, HTTPMessage &msg) + NickServ::Nick *GetNickFromSession(HTTPClient *client, HTTPMessage &msg) { if (!client) return NULL; @@ -45,7 +59,7 @@ class Panel : public Section, public Service if (acc.empty() || id.empty()) return NULL; - NickAlias *na = NickAlias::Find(acc); + NickServ::Nick *na = NickServ::FindNick(acc); if (na == NULL) return NULL; @@ -68,22 +82,22 @@ class WebPanelPage : public HTTPPage { } - virtual bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &) = 0; + virtual bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &) anope_abstract; }; class WebPanelProtectedPage : public WebPanelPage { Anope::string category; + ServiceReference<Panel> panel; public: WebPanelProtectedPage(const Anope::string &cat, const Anope::string &u, const Anope::string &ct = "text/html") : WebPanelPage(u, ct), category(cat) { } - bool OnRequest(HTTPProvider *provider, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply) anope_override anope_final + bool OnRequest(HTTPProvider *provider, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply) override final { - ServiceReference<Panel> panel("Panel", "webcpanel"); - NickAlias *na; + NickServ::Nick *na; if (!panel || !(na = panel->GetNickFromSession(client, message))) { @@ -95,10 +109,10 @@ class WebPanelProtectedPage : public WebPanelPage TemplateFileServer::Replacements replacements; replacements["TITLE"] = page_title; - replacements["ACCOUNT"] = na->nc->display; + replacements["ACCOUNT"] = na->GetAccount()->GetDisplay(); replacements["PAGE_NAME"] = page_name; replacements["CATEGORY"] = category; - if (na->nc->IsServicesOper()) + if (na->GetAccount()->GetOper() != nullptr) replacements["IS_OPER"]; Anope::string sections, get; @@ -134,7 +148,7 @@ class WebPanelProtectedPage : public WebPanelPage return this->OnRequest(provider, page_name, client, message, reply, na, replacements); } - virtual bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) = 0; + virtual bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickServ::Nick *, TemplateFileServer::Replacements &) anope_abstract; /* What get data should be appended to links in the navbar */ virtual std::set<Anope::string> GetData() { return std::set<Anope::string>(); } @@ -143,7 +157,7 @@ class WebPanelProtectedPage : public WebPanelPage namespace WebPanel { /** Run a command - * @param User name to run command as, probably nc->display unless nc == NULL + * @param User name to run command as, probably nc->GetDisplay() unless nc == NULL * @param nc Nick core to run command from * @param service Service for source.owner and source.service * @param c Command to run (as a service name) @@ -151,9 +165,9 @@ namespace WebPanel * @param r Replacements, reply from command goes back here into key * @param key The key to put the replies into r */ - extern void RunCommand(const Anope::string &user, NickCore *nc, const Anope::string &service, const Anope::string &c, std::vector<Anope::string> ¶ms, TemplateFileServer::Replacements &r, const Anope::string &key = "MESSAGES"); + extern void RunCommand(const Anope::string &user, NickServ::Account *nc, const Anope::string &service, const Anope::string &c, std::vector<Anope::string> ¶ms, TemplateFileServer::Replacements &r, const Anope::string &key = "MESSAGES"); - extern void RunCommandWithName(NickCore *nc, const Anope::string &service, const Anope::string &c, const Anope::string &cmdname, std::vector<Anope::string> ¶ms, TemplateFileServer::Replacements &r, const Anope::string &key = "MESSAGES"); + extern void RunCommandWithName(NickServ::Account *nc, const Anope::string &service, const Anope::string &c, const Anope::string &cmdname, std::vector<Anope::string> ¶ms, TemplateFileServer::Replacements &r, const Anope::string &key = "MESSAGES"); } #include "pages/index.h" |