summaryrefslogtreecommitdiff
path: root/modules/webcpanel/pages/nickserv/info.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/webcpanel/pages/nickserv/info.cpp')
-rw-r--r--modules/webcpanel/pages/nickserv/info.cpp96
1 files changed, 54 insertions, 42 deletions
diff --git a/modules/webcpanel/pages/nickserv/info.cpp b/modules/webcpanel/pages/nickserv/info.cpp
index b1c1e2afa..f3c353044 100644
--- a/modules/webcpanel/pages/nickserv/info.cpp
+++ b/modules/webcpanel/pages/nickserv/info.cpp
@@ -1,8 +1,20 @@
/*
- * (C) 2003-2016 Anope Team
- * Contact us at team@anope.org
+ * Anope IRC Services
*
- * Please read COPYING and README for further details.
+ * Copyright (C) 2012-2016 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 "../../webcpanel.h"
@@ -11,83 +23,83 @@ WebCPanel::NickServ::Info::Info(const Anope::string &cat, const Anope::string &u
{
}
-bool WebCPanel::NickServ::Info::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
+bool WebCPanel::NickServ::Info::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, ::NickServ::Nick *na, TemplateFileServer::Replacements &replacements)
{
if (message.post_data.empty() == false)
{
if (message.post_data.count("email") > 0)
{
- if (message.post_data["email"] != na->nc->email)
+ if (message.post_data["email"] != na->GetAccount()->GetEmail())
{
if (!message.post_data["email"].empty() && !Mail::Validate(message.post_data["email"]))
replacements["ERRORS"] = "Invalid email";
else
{
- na->nc->email = message.post_data["email"];
+ na->GetAccount()->SetEmail(message.post_data["email"]);
replacements["MESSAGES"] = "Email updated";
}
}
}
if (message.post_data.count("greet") > 0)
{
- Anope::string *greet = na->nc->GetExt<Anope::string>("greet");
+ Anope::string *greet = na->GetAccount()->GetExt<Anope::string>("greet");
const Anope::string &post_greet = HTTPUtils::URLDecode(message.post_data["greet"].replace_all_cs("+", " "));
if (post_greet.empty())
- na->nc->Shrink<Anope::string>("greet");
+ na->GetAccount()->Shrink<Anope::string>("greet");
else if (!greet || post_greet != *greet)
- na->nc->Extend<Anope::string>("greet", post_greet);
+ na->GetAccount()->Extend<Anope::string>("greet", post_greet);
replacements["MESSAGES"] = "Greet updated";
}
- if (na->nc->HasExt("AUTOOP") != message.post_data.count("autoop"))
+ if (na->GetAccount()->HasFieldS("AUTOOP") != message.post_data.count("autoop"))
{
- if (!na->nc->HasExt("AUTOOP"))
- na->nc->Extend<bool>("AUTOOP");
+ if (!na->GetAccount()->HasFieldS("AUTOOP"))
+ na->GetAccount()->SetS<bool>("AUTOOP", true);
else
- na->nc->Shrink<bool>("AUTOOP");
+ na->GetAccount()->UnsetS<bool>("AUTOOP");
replacements["MESSAGES"] = "Autoop updated";
}
- if (na->nc->HasExt("NS_PRIVATE") != message.post_data.count("private"))
+ if (na->GetAccount()->HasFieldS("NS_PRIVATE") != message.post_data.count("private"))
{
- if (!na->nc->HasExt("NS_PRIVATE"))
- na->nc->Extend<bool>("NS_PRIVATE");
+ if (!na->GetAccount()->HasFieldS("NS_PRIVATE"))
+ na->GetAccount()->SetS<bool>("NS_PRIVATE", true);
else
- na->nc->Shrink<bool>("NS_PRIVATE");
+ na->GetAccount()->UnsetS<bool>("NS_PRIVATE");
replacements["MESSAGES"] = "Private updated";
}
- if (na->nc->HasExt("NS_SECURE") != message.post_data.count("secure"))
+ if (na->GetAccount()->HasFieldS("NS_SECURE") != message.post_data.count("secure"))
{
- if (!na->nc->HasExt("NS_SECURE"))
- na->nc->Extend<bool>("NS_SECURE");
+ if (!na->GetAccount()->HasFieldS("NS_SECURE"))
+ na->GetAccount()->SetS<bool>("NS_SECURE", true);
else
- na->nc->Shrink<bool>("NS_SECURE");
+ na->GetAccount()->UnsetS<bool>("NS_SECURE");
replacements["MESSAGES"] = "Secure updated";
}
- if (message.post_data["kill"] == "on" && !na->nc->HasExt("KILLPROTECT"))
+ if (message.post_data["kill"] == "on" && !na->GetAccount()->HasFieldS("KILLPROTECT"))
{
- na->nc->Extend<bool>("KILLPROTECT");
- na->nc->Shrink<bool>("KILL_QUICK");
+ na->GetAccount()->SetS<bool>("KILLPROTECT", true);
+ na->GetAccount()->UnsetS<bool>("KILL_QUICK");
replacements["MESSAGES"] = "Kill updated";
}
- else if (message.post_data["kill"] == "quick" && !na->nc->HasExt("KILL_QUICK"))
+ else if (message.post_data["kill"] == "quick" && !na->GetAccount()->HasFieldS("KILL_QUICK"))
{
- na->nc->Shrink<bool>("KILLPROTECT");
- na->nc->Extend<bool>("KILL_QUICK");
+ na->GetAccount()->UnsetS<bool>("KILLPROTECT");
+ na->GetAccount()->SetS<bool>("KILL_QUICK", true);
replacements["MESSAGES"] = "Kill updated";
}
- else if (message.post_data["kill"] == "off" && (na->nc->HasExt("KILLPROTECT") || na->nc->HasExt("KILL_QUICK")))
+ else if (message.post_data["kill"] == "off" && (na->GetAccount()->HasFieldS("KILLPROTECT") || na->GetAccount()->HasFieldS("KILL_QUICK")))
{
- na->nc->Shrink<bool>("KILLPROTECT");
- na->nc->Shrink<bool>("KILL_QUICK");
+ na->GetAccount()->UnsetS<bool>("KILLPROTECT");
+ na->GetAccount()->UnsetS<bool>("KILL_QUICK");
replacements["MESSAGES"] = "Kill updated";
}
}
- replacements["DISPLAY"] = HTTPUtils::Escape(na->nc->display);
- if (na->nc->email.empty() == false)
- replacements["EMAIL"] = HTTPUtils::Escape(na->nc->email);
- replacements["TIME_REGISTERED"] = Anope::strftime(na->time_registered, na->nc);
+ replacements["DISPLAY"] = HTTPUtils::Escape(na->GetAccount()->GetDisplay());
+ if (na->GetAccount()->GetEmail().empty() == false)
+ replacements["EMAIL"] = HTTPUtils::Escape(na->GetAccount()->GetEmail());
+ replacements["TIME_REGISTERED"] = Anope::strftime(na->GetTimeRegistered(), na->GetAccount());
if (na->HasVhost())
{
if (na->GetVhostIdent().empty() == false)
@@ -95,22 +107,22 @@ bool WebCPanel::NickServ::Info::OnRequest(HTTPProvider *server, const Anope::str
else
replacements["VHOST"] = na->GetVhostHost();
}
- Anope::string *greet = na->nc->GetExt<Anope::string>("greet");
+ Anope::string *greet = na->GetAccount()->GetExt<Anope::string>("greet");
if (greet)
replacements["GREET"] = HTTPUtils::Escape(*greet);
- if (na->nc->HasExt("AUTOOP"))
+ if (na->GetAccount()->HasFieldS("AUTOOP"))
replacements["AUTOOP"];
- if (na->nc->HasExt("NS_PRIVATE"))
+ if (na->GetAccount()->HasFieldS("NS_PRIVATE"))
replacements["PRIVATE"];
- if (na->nc->HasExt("NS_SECURE"))
+ if (na->GetAccount()->HasFieldS("NS_SECURE"))
replacements["SECURE"];
- if (na->nc->HasExt("KILLPROTECT"))
+ if (na->GetAccount()->HasFieldS("KILLPROTECT"))
replacements["KILL_ON"];
- if (na->nc->HasExt("KILL_QUICK"))
+ if (na->GetAccount()->HasFieldS("KILL_QUICK"))
replacements["KILL_QUICK"];
- if (!na->nc->HasExt("KILLPROTECT") && !na->nc->HasExt("KILL_QUICK"))
+ if (!na->GetAccount()->HasFieldS("KILLPROTECT") && !na->GetAccount()->HasFieldS("KILL_QUICK"))
replacements["KILL_OFF"];
-
+
TemplateFileServer page("nickserv/info.html");
page.Serve(server, page_name, client, message, reply, replacements);
return true;