Web-enabled the stickychan module. You can now stick+unstick channels from the web.

git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1918 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
cflakes
2010-04-15 14:10:56 +00:00
parent 56fb03622b
commit 057da383ea
2 changed files with 67 additions and 1 deletions
+40 -1
View File
@@ -100,7 +100,46 @@ public:
}
}
}
private:
virtual bool WebRequiresLogin() { return true; }
virtual bool WebRequiresAdmin() { return false; }
virtual CString GetWebMenuTitle() { return "Sticky Chans"; }
virtual bool OnWebRequest(CWebSock& WebSock, const CString& sPageName, CTemplate& Tmpl) {
if (sPageName.empty() || sPageName == "index") {
bool bSubmitted = (WebSock.GetParam("submitted").ToInt() != 0);
const vector<CChan*>& Channels = m_pUser->GetChans();
for (unsigned int c = 0; c < Channels.size(); c++) {
const CString sChan = Channels[c]->GetName();
bool bStick = FindNV(sChan) != EndNV();
if(bSubmitted) {
bool bNewStick = WebSock.GetParam("stick_" + sChan).ToBool();
if(bNewStick && !bStick)
SetNV(sChan, ""); // no password support for now unless chansaver is active too
else if(!bNewStick && bStick) {
MCString::iterator it = FindNV(sChan);
if(it != EndNV())
DelNV(it);
}
bStick = bNewStick;
}
CTemplate& Row = Tmpl.AddRow("ChannelLoop");
Row["Name"] = sChan;
Row["Sticky"] = CString(bStick);
}
if(bSubmitted) {
WebSock.GetSession()->AddSuccess("Changes have been saved!");
}
return true;
}
return false;
}
};
+27
View File
@@ -0,0 +1,27 @@
<? INC Header.tmpl ?>
<form action="" method="post">
<table class="data">
<thead>
<tr>
<td>Name</td>
<td>Sticky</td>
</tr>
</thead>
<tbody>
<? LOOP ChannelLoop ?>
<tr class="<? IF __EVEN__ ?>evenrow<? ELSE ?>oddrow<? ENDIF ?>">
<td><? VAR Name ?></td>
<td><input type="checkbox" name="stick_<? VAR Name ?>"<? IF Sticky ?> checked="checked"<? ENDIF ?> /></td>
</tr>
<? ENDLOOP ?>
</tbody>
</table>
<div class="submitline">
<input type="hidden" name="submitted" value="1" />
<input type="submit" value="Save" />
</div>
</form>
<? INC Footer.tmpl ?>