Implement setting "Max number of networks" for user.

Fix #226
This commit is contained in:
Alexey Sokolov
2012-09-20 01:24:47 +07:00
parent 50e6c1bfab
commit 9b2898f603
8 changed files with 33 additions and 31 deletions
+6 -7
View File
@@ -698,13 +698,6 @@ class CAdminMod : public CModule {
}
void AddNetwork(const CString& sLine) {
#ifndef ENABLE_ADD_NETWORK
if (!m_pUser->IsAdmin()) {
PutModule("Permission denied");
return;
}
#endif
CString sUser = sLine.Token(1);
CString sNetwork = sLine.Token(2);
CUser *pUser = m_pUser;
@@ -714,6 +707,7 @@ class CAdminMod : public CModule {
} else {
pUser = GetUser(sUser);
if (!pUser) {
PutModule("User not found");
return;
}
}
@@ -723,6 +717,11 @@ class CAdminMod : public CModule {
return;
}
if (!m_pUser->IsAdmin() && !pUser->HasSpaceForNewNetwork()) {
PutStatus("Network number limit reached. Ask an admin to increase the limit for you, or delete few old ones using /znc DelNetwork <name>");
return;
}
if (pUser->FindNetwork(sNetwork)) {
PutModule(pUser->GetUserName() + " already has a network named [" + sNetwork + "]");
return;