diff options
| author | Adam <Adam@anope.org> | 2014-11-24 14:27:23 -0500 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2014-11-24 14:27:23 -0500 |
| commit | 42238034490fb5479d787bd1695750387d508200 (patch) | |
| tree | c93c62e0e1c936e656ae5b9ee1b62380ce2a194c /modules/webcpanel/pages/nickserv/info.cpp | |
| parent | d492923610d9c9146b2a2b63de38deab2cfd4ca7 (diff) | |
Rewrite serializable to have field level granularity
Represent serializable objects in a digraph, and as a result made most
object relationships implicitly defined, and use the graph to trace
references between objects to determine relationships. Edges may
also be marked as having a dependency of the object they point to,
which allows for automatic cleanup and deletion of most objects when
no longer needed.
Additionally, this allows not having to require in-memory copies of
everything when using external databases. db_sql has been rewritten
for this and now always requires a database to function. db_sql with
MySQL now requires InnoDB to make use of transactions and foreign
key constraints.
Diffstat (limited to 'modules/webcpanel/pages/nickserv/info.cpp')
| -rw-r--r-- | modules/webcpanel/pages/nickserv/info.cpp | 74 |
1 files changed, 37 insertions, 37 deletions
diff --git a/modules/webcpanel/pages/nickserv/info.cpp b/modules/webcpanel/pages/nickserv/info.cpp index 1e9e660b4..b3c743ed3 100644 --- a/modules/webcpanel/pages/nickserv/info.cpp +++ b/modules/webcpanel/pages/nickserv/info.cpp @@ -17,77 +17,77 @@ bool WebCPanel::NickServ::Info::OnRequest(HTTPProvider *server, const Anope::str { 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()->ShrinkOK<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,20 +95,20 @@ 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"); |
