From 3ad285243d282270f7195c6efc8a3a7df32b9658 Mon Sep 17 00:00:00 2001 From: Vasily Fomin Date: Thu, 29 May 2014 17:49:41 +0200 Subject: [PATCH] Add "Loaded" flag to the user page. --- modules/data/webadmin/tmpl/add_edit_user.tmpl | 18 +++++++++++++++++ modules/webadmin.cpp | 20 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/modules/data/webadmin/tmpl/add_edit_user.tmpl b/modules/data/webadmin/tmpl/add_edit_user.tmpl index f410b47c9e..0c177bdb5b 100644 --- a/modules/data/webadmin/tmpl/add_edit_user.tmpl +++ b/modules/data/webadmin/tmpl/add_edit_user.tmpl @@ -172,6 +172,8 @@ Name Arguments Description + Loaded globally + Loaded by networks @@ -191,6 +193,22 @@ + + + + + + + + + + + + + diff --git a/modules/webadmin.cpp b/modules/webadmin.cpp index 0dce9048d2..e27a0d35bb 100644 --- a/modules/webadmin.cpp +++ b/modules/webadmin.cpp @@ -1225,6 +1225,26 @@ class CWebAdminMod : public CModule { } } + // Check if module is loaded globally + l["LoadedGlobally"] = CString(CZNC::Get().GetModules().FindModule(Info.GetName()) != NULL); + + // Check if module is loaded by all or some networks + const vector& userNetworks = pUser->GetNetworks(); + unsigned int networksWithRenderedModuleCount = 0; + for (unsigned int networkIndex = 0; networkIndex < userNetworks.size(); ++networkIndex) { + const CIRCNetwork* pCurrentNetwork = userNetworks[networkIndex]; + const CModules& networkModules = pCurrentNetwork->GetModules(); + for (unsigned int networkModuleIndex = 0; networkModuleIndex < networkModules.size(); ++networkModuleIndex) { + const CModule* pCurModule = networkModules[networkModuleIndex]; + if (Info.GetName() == pCurModule->GetModName()) { + networksWithRenderedModuleCount++; + } + } + } + l["LoadedByAllNetworks"] = CString(networksWithRenderedModuleCount == userNetworks.size()); + const bool isLoadedBySomeNetworks = (networksWithRenderedModuleCount != 0) && (networksWithRenderedModuleCount < userNetworks.size()); + l["LoadedBySomeNetworks"] = CString(isLoadedBySomeNetworks); + if (!spSession->IsAdmin() && pUser && pUser->DenyLoadMod()) { l["Disabled"] = "true"; }