Browse files

Add "Loaded" flag to the global settings page.

  • Loading branch information...
1 parent 5d001cd commit 4bdaa3cc22d813fbe3fe9666e75b2991dfde5a01 @devfom devfom committed May 29, 2014
Showing with 61 additions and 0 deletions.
  1. +24 −0 modules/data/webadmin/tmpl/settings.tmpl
  2. +37 −0 modules/webadmin.cpp
View
24 modules/data/webadmin/tmpl/settings.tmpl
@@ -167,6 +167,8 @@
<td>Name</td>
<td>Arguments</td>
<td>Description</td>
+ <td>Loaded by networks</td>
+ <td>Loaded by users</td>
</tr>
</thead>
<tbody>
@@ -186,6 +188,28 @@
<? IF ArgsHelpText ?> title="<? VAR ArgsHelpText ?>"<? ENDIF ?> />
</td>
<td class="mod_descr"><? VAR Description ?></td>
+ <td align="center">
+ <? IF LoadedByAllNetworks ?>
+ <input type="checkbox" name="loaded_by_network" id="loaded_by_net_<? VAR Name ?>" checked="checked" disabled="disabled"/>
+ <? ELSE IF LoadedBySomeNetworks ?>
+ <input type="checkbox" name="loaded_by_network" id="loaded_by_net_<? VAR Name ?>" checked="checked" disabled="disabled"/>
+ <script type="text/javascript">
+ var checkbox = document.getElementById("loaded_by_net_<? VAR Name ?>");
+ checkbox.indeterminate = true;
+ </script>
+ <? ENDIF ?>
+ </td>
+ <td align="center">
+ <? IF LoadedByAllUsers ?>
+ <input type="checkbox" name="loaded_by_user" id="loaded_by_user_<? VAR Name ?>" checked="checked" disabled="disabled"/>
+ <? ELSE IF LoadedBySomeUsers ?>
+ <input type="checkbox" name="loaded_by_user" id="loaded_by_user_<? VAR Name ?>" checked="checked" disabled="disabled"/>
+ <script type="text/javascript">
+ var checkbox = document.getElementById("loaded_by_user_<? VAR Name ?>");
+ checkbox.indeterminate = true;
+ </script>
+ <? ENDIF ?>
+ </td>
</tr>
<? ENDLOOP ?>
</tbody>
View
37 modules/webadmin.cpp
@@ -1626,6 +1626,43 @@ class CWebAdminMod : public CModule {
l["Wiki"] = Info.GetWikiPage();
l["HasArgs"] = CString(Info.GetHasArgs());
l["ArgsHelpText"] = Info.GetArgsHelpText();
+
+ // Check if the module is loaded by all or some users and collect all available networks for future processing
+ vector<CIRCNetwork*> allNetworks;
+ unsigned int usersWithRenderedModuleCount = 0;
+ const map<CString,CUser*>& allUsers = CZNC::Get().GetUserMap();
+ allNetworks.reserve(allUsers.size()); // Reserve for at least one network per scene
+ for (map<CString,CUser*>::const_iterator usersIt = allUsers.begin(); usersIt != allUsers.end(); ++usersIt) {
+ const CUser& User = *usersIt->second;
+ const vector<CIRCNetwork*>& userNetworks = User.GetNetworks();
+ allNetworks.insert(allNetworks.end(), userNetworks.begin(), userNetworks.end());
+ const CModules& userModules = User.GetModules();
+ for (unsigned int userModuleIndex = 0; userModuleIndex < userModules.size(); ++userModuleIndex) {
+ const CModule* pCurModule = userModules[userModuleIndex];
+ if (Info.GetName() == pCurModule->GetModName()) {
+ usersWithRenderedModuleCount++;
+ }
+ }
+ }
+ l["LoadedByAllUsers"] = CString(usersWithRenderedModuleCount == allUsers.size());
+ const bool isLoadedBySomeUsers = (usersWithRenderedModuleCount != 0) && (usersWithRenderedModuleCount < allUsers.size());
+ l["LoadedBySomeUsers"] = CString(isLoadedBySomeUsers);
+
+ // Check if module is loaded by all or some networks
+ unsigned int networksWithRenderedModuleCount = 0;
+ for (unsigned int networkIndex = 0; networkIndex < allNetworks.size(); ++networkIndex) {
+ const CIRCNetwork* pCurrentNetwork = allNetworks[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 == allNetworks.size());
+ const bool isLoadedBySomeNetworks = (networksWithRenderedModuleCount != 0) && (networksWithRenderedModuleCount < allNetworks.size());
+ l["LoadedBySomeNetworks"] = CString(isLoadedBySomeNetworks);
}
return true;

0 comments on commit 4bdaa3c

Please sign in to comment.