diff --git a/configure.ac b/configure.ac index 5083c8aa..43a41c56 100644 --- a/configure.ac +++ b/configure.ac @@ -148,9 +148,6 @@ AC_ARG_ENABLE( [poll], AS_HELP_STRING([--disable-poll], [use select() instead of poll()]), [POLL="$enableval"], [POLL="yes"]) -AC_ARG_ENABLE([add-networks], - AS_HELP_STRING([--enable-add-networks], [allow non-admins to add networks]), - [ if test x"$enableval" = "xyes" ; then appendCXX "-DENABLE_ADD_NETWORK" ; fi ]) AC_ARG_WITH([systemdsystemunitdir], AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]), diff --git a/include/znc/User.h b/include/znc/User.h index 2991a93a..6e3cac09 100644 --- a/include/znc/User.h +++ b/include/znc/User.h @@ -69,6 +69,7 @@ public: void RemoveNetwork(CIRCNetwork *pNetwork); CIRCNetwork* FindNetwork(const CString& sNetwork) const; const std::vector& GetNetworks() const; + bool HasSpaceForNewNetwork() const; // !Networks bool PutUser(const CString& sLine, CClient* pClient = NULL, CClient* pSkipClient = NULL); @@ -124,6 +125,7 @@ public: void SetTimezone(const CString& s) { m_sTimezone = s; } void SetJoinTries(unsigned int i) { m_uMaxJoinTries = i; } void SetSkinName(const CString& s) { m_sSkinName = s; } + void SetMaxNetworks(unsigned int i) { m_uMaxNetworks = i; } // !Setters // Getters @@ -164,6 +166,7 @@ public: unsigned long long BytesWritten() const { return m_uBytesWritten; } unsigned int JoinTries() const { return m_uMaxJoinTries; } CString GetSkinName() const; + unsigned int MaxNetworks() const { return m_uMaxNetworks; } // !Getters protected: @@ -208,6 +211,7 @@ protected: unsigned long long m_uBytesRead; unsigned long long m_uBytesWritten; unsigned int m_uMaxJoinTries; + unsigned int m_uMaxNetworks; CString m_sSkinName; CModules* m_pModules; diff --git a/modules/controlpanel.cpp b/modules/controlpanel.cpp index 58715691..682b80f9 100644 --- a/modules/controlpanel.cpp +++ b/modules/controlpanel.cpp @@ -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 "); + return; + } + if (pUser->FindNetwork(sNetwork)) { PutModule(pUser->GetUserName() + " already has a network named [" + sNetwork + "]"); return; diff --git a/modules/data/webadmin/tmpl/add_edit_user.tmpl b/modules/data/webadmin/tmpl/add_edit_user.tmpl index 5fe9c988..eb85cddf 100644 --- a/modules/data/webadmin/tmpl/add_edit_user.tmpl +++ b/modules/data/webadmin/tmpl/add_edit_user.tmpl @@ -260,6 +260,11 @@ +
+
Max IRC Networks Number:
+ disabled="disabled" /> +
CTCP Replies: