summaryrefslogtreecommitdiff
path: root/modules/extra/webcpanel/pages/chanserv/set.cpp
diff options
context:
space:
mode:
authorDukePyrolator <DukePyrolator@anope.org>2013-09-03 04:37:09 +0200
committerDukePyrolator <DukePyrolator@anope.org>2013-09-03 04:37:09 +0200
commit404debf78925f86e94cfd71334433bc1eb423115 (patch)
tree6388a371c610d67dbee46bd7a898bb18359765e8 /modules/extra/webcpanel/pages/chanserv/set.cpp
parent752a5ca1b7d89044728a045622b3f3db5fb94f7e (diff)
updated the chanserv section in webcpanel
Diffstat (limited to 'modules/extra/webcpanel/pages/chanserv/set.cpp')
-rw-r--r--modules/extra/webcpanel/pages/chanserv/set.cpp75
1 files changed, 45 insertions, 30 deletions
diff --git a/modules/extra/webcpanel/pages/chanserv/set.cpp b/modules/extra/webcpanel/pages/chanserv/set.cpp
index d0b54d15a..42a3fcfe6 100644
--- a/modules/extra/webcpanel/pages/chanserv/set.cpp
+++ b/modules/extra/webcpanel/pages/chanserv/set.cpp
@@ -6,6 +6,7 @@
*/
#include "../../webcpanel.h"
+#include "utils.h"
WebCPanel::ChanServ::Set::Set(const Anope::string &cat, const Anope::string &u) : WebPanelProtectedPage(cat, u)
{
@@ -14,20 +15,32 @@ WebCPanel::ChanServ::Set::Set(const Anope::string &cat, const Anope::string &u)
bool WebCPanel::ChanServ::Set::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
{
const Anope::string &chname = message.get_data["channel"];
+ bool can_set = false;
+
+ BuildChanlist(page_name, na, replacements);
if (chname.empty())
{
- reply.error = HTTP_FOUND;
- reply.headers["Location"] = Anope::string("http") + (server->IsSSL() ? "s" : "") + "://" + message.headers["Host"] + "/chanserv/info";
- return true;
+ replacements["STOP"];
+ return ServePage("chanserv/set.html", server, page_name, client, message, reply, replacements);
}
ChannelInfo *ci = ChannelInfo::Find(chname);
- if (!ci || !ci->AccessFor(na->nc).HasPriv("SET"))
- return true;
+ if (!ci)
+ {
+ replacements["STOP"];
+ return ServePage("chanserv/set.html", server, page_name, client, message, reply, replacements);
+ }
- if (message.post_data.empty() == false)
+
+ if (ci->AccessFor(na->nc).HasPriv("SET"))
+ {
+ replacements["CAN_SET"];
+ can_set = true;
+ }
+
+ if (can_set && message.post_data.empty() == false)
{
if (ci->HasExt("KEEPTOPIC") != message.post_data.count("keeptopic"))
{
@@ -102,30 +115,32 @@ bool WebCPanel::ChanServ::Set::OnRequest(HTTPProvider *server, const Anope::stri
replacements["LAST_TOPIC_SETTER"] = HTTPUtils::Escape(ci->last_topic_setter);
}
- if (ci->HasExt("KEEPTOPIC"))
- replacements["KEEPTOPIC"];
-
- if (ci->HasExt("PEACE"))
- replacements["PEACE"];
-
- if (ci->HasExt("CS_PRIVATE"))
- replacements["PRIVATE"];
-
- if (ci->HasExt("RESTRICTED"))
- replacements["RESTRICTED"];
-
- if (ci->HasExt("CS_SECURE"))
- replacements["SECURE"];
-
- if (ci->HasExt("SECUREOPS"))
- replacements["SECUREOPS"];
-
- if (ci->HasExt("TOPICLOCK"))
- replacements["TOPICLOCK"];
-
- TemplateFileServer page("chanserv/set.html");
- page.Serve(server, page_name, client, message, reply, replacements);
- return true;
+ if (can_set)
+ {
+ if (ci->HasExt("KEEPTOPIC"))
+ replacements["KEEPTOPIC"];
+
+ if (ci->HasExt("PEACE"))
+ replacements["PEACE"];
+
+ if (ci->HasExt("CS_PRIVATE"))
+ replacements["PRIVATE"];
+
+ if (ci->HasExt("RESTRICTED"))
+ replacements["RESTRICTED"];
+
+ if (ci->HasExt("CS_SECURE"))
+ replacements["SECURE"];
+
+ if (ci->HasExt("SECUREOPS"))
+ replacements["SECUREOPS"];
+
+ if (ci->HasExt("TOPICLOCK"))
+ replacements["TOPICLOCK"];
+ }
+
+ return ServePage("chanserv/set.html", server, page_name, client, message, reply, replacements);
+
}
std::set<Anope::string> WebCPanel::ChanServ::Set::GetData()