Fix #624: Can´t rename network via webinterface

This commit is contained in:
J-P Nurmi
2014-08-19 20:59:19 +02:00
parent 0065506ff6
commit 2e42f3103c
5 changed files with 36 additions and 24 deletions
@@ -10,19 +10,17 @@
<div class="section">
<input type="hidden" name="submitted" value="1" />
<input type="hidden" name="user" value="<? VAR Username ?>" />
<? IF Edit ?><input type="hidden" name="network" value="<? VAR Name ?>" /><? ENDIF ?>
<input type="hidden" name="network" value="<? VAR Name ?>" />
<h3>Network Info</h3>
<span class="info">Nick, AltNick, Ident, RealName, BindHost can be left empty to use the value from the user.</span>
<div class="sectionbg">
<div class="sectionbody">
<? IF !Edit ?>
<div class="subsection">
<div class="inputlabel">Network Name:</div>
<input type="text" name="network" value="<? VAR Name ?>" class="half" maxlength="128"
<input type="text" name="name" value="<? VAR Name ?>" class="half" maxlength="128"
title="The name of the IRC network." />
</div>
<? ENDIF ?>
</div>
<div class="subsection">
<div class="inputlabel">Nickname:</div>
+15 -11
View File
@@ -867,27 +867,31 @@ public:
return true;
}
CString sName = WebSock.GetParam("network").Trim_n();
CString sName = WebSock.GetParam("name").Trim_n();
if (sName.empty()) {
WebSock.PrintErrorPage("Network name is a required argument");
return true;
}
if (!pNetwork) {
if (!spSession->IsAdmin() && !pUser->HasSpaceForNewNetwork()) {
WebSock.PrintErrorPage("Network number limit reached. Ask an admin to increase the limit for you, or delete few old ones from Your Settings");
return true;
}
if (!CIRCNetwork::IsValidNetwork(sName)) {
WebSock.PrintErrorPage("Network name should be alphanumeric");
return true;
}
if (!pNetwork && !spSession->IsAdmin() && !pUser->HasSpaceForNewNetwork()) {
WebSock.PrintErrorPage("Network number limit reached. Ask an admin to increase the limit for you, or delete few old ones from Your Settings");
return true;
}
if (!pNetwork || pNetwork->GetName() != sName) {
CString sNetworkAddError;
CIRCNetwork* pOldNetwork = pNetwork;
pNetwork = pUser->AddNetwork(sName, sNetworkAddError);
if (!pNetwork) {
WebSock.PrintErrorPage(sNetworkAddError);
return true;
}
if (pOldNetwork) {
for (CModule* pModule : pOldNetwork->GetModules()) {
CString sPath = pUser->GetUserPath() + "/networks/" + sName + "/moddata/" + pModule->GetModName();
pModule->MoveRegistry(sPath);
}
pNetwork->Clone(*pOldNetwork, false);
pUser->DeleteNetwork(pOldNetwork->GetName());
}
}
CString sArg;