Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge commit 'refs/pull/557/head' of github.com:znc/znc

  • Loading branch information...
commit a3f4f1ebd93f93d4b6dfa62b0b7c2c8c92848728 2 parents 66fecf8 + 4338ae5
@DarthGandalf DarthGandalf authored
View
2  include/znc/Modules.h
@@ -203,7 +203,7 @@ class CModInfo {
return (GetName() < Info.GetName());
}
- bool SupportsType(EModuleType eType) {
+ bool SupportsType(EModuleType eType) const {
return m_seType.find(eType) != m_seType.end();
}
View
20 modules/data/webadmin/tmpl/add_edit_network.tmpl
@@ -162,6 +162,8 @@
<td>Name</td>
<td>Arguments</td>
<td>Description</td>
+ <td>Loaded globally</td>
+ <td>Loaded by user</td>
</tr>
</thead>
<tbody>
@@ -181,6 +183,24 @@
<? ENDIF ?>
</td>
<td class="mod_descr"><? VAR Description ?></td>
+ <td align="center">
+ <? IF CanBeLoadedGlobally ?>
+ <input type="checkbox" name="loaded_globally" id="loaded_globally_<? VAR Name ?>"
+ <? IF LoadedGlobally ?>
+ checked="checked"
+ <? ENDIF ?>
+ disabled="disabled"/>
+ <? ENDIF ?>
+ </td>
+ <td align="center">
+ <? IF CanBeLoadedByUser ?>
+ <input type="checkbox" name="loaded_by_user" id="loaded_by_user_<? VAR Name ?>"
+ <? IF LoadedByUser ?>
+ checked="checked"
+ <? ENDIF ?>
+ disabled="disabled"/>
+ <? ENDIF ?>
+ </td>
</tr>
<? ENDLOOP ?>
View
25 modules/data/webadmin/tmpl/add_edit_user.tmpl
@@ -172,6 +172,8 @@
<td>Name</td>
<td>Arguments</td>
<td>Description</td>
+ <td>Loaded globally</td>
+ <td>Loaded by networks</td>
</tr>
</thead>
<tbody>
@@ -191,6 +193,29 @@
<? ENDIF ?>
</td>
<td class="mod_descr"><? VAR Description ?></td>
+ <td align="center">
+ <? IF CanBeLoadedGlobally ?>
+ <input type="checkbox" name="loaded_globally" id="loaded_globally_<? VAR Name ?>"
+ <? IF LoadedGlobally ?>
+ checked="checked"
+ <? ENDIF ?>
+ disabled="disabled"/>
+ <? ENDIF ?>
+ </td>
+ <td align="center">
+ <? IF CanBeLoadedByNetwork ?>
+ <input type="checkbox" name="loaded_by_network" id="loaded_by_net_<? VAR Name ?>"
+ <? IF LoadedByAllNetworks ?>
+ checked="checked"
+ <? ENDIF ?>
+ disabled="disabled"/>
+ <? IF LoadedBySomeNetworks && !LoadedByAllNetworks ?>
+ <script type="text/javascript">
+ document.getElementById("loaded_by_net_<? VAR Name ?>").indeterminate = true;
+ </script>
+ <? ENDIF ?>
+ <? ENDIF ?>
+ </td>
</tr>
<? ENDLOOP ?>
View
30 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,34 @@
<? IF ArgsHelpText ?> title="<? VAR ArgsHelpText ?>"<? ENDIF ?> />
</td>
<td class="mod_descr"><? VAR Description ?></td>
+ <td align="center">
+ <? IF CanBeLoadedByNetwork ?>
+ <input type="checkbox" name="loaded_by_network" id="loaded_by_net_<? VAR Name ?>"
+ <? IF LoadedByAllNetworks ?>
+ checked="checked"
+ <? ENDIF ?>
+ disabled="disabled"/>
+ <? IF LoadedBySomeNetworks && !LoadedByAllNetworks ?>
+ <script type="text/javascript">
+ document.getElementById("loaded_by_net_<? VAR Name ?>").indeterminate = true;
+ </script>
+ <? ENDIF ?>
+ <? ENDIF ?>
+ </td>
+ <td align="center">
+ <? IF CanBeLoadedByUser ?>
+ <input type="checkbox" name="loaded_by_user" id="loaded_by_user_<? VAR Name ?>"
+ <? IF LoadedByAllUsers ?>
+ checked="checked"
+ <? ENDIF ?>
+ disabled="disabled"/>
+ <? IF LoadedBySomeUsers && !LoadedByAllUsers ?>
+ <script type="text/javascript">
+ document.getElementById("loaded_by_user_<? VAR Name ?>").indeterminate = true;
+ </script>
+ <? ENDIF ?>
+ <? ENDIF ?>
+ </td>
</tr>
<? ENDLOOP ?>
</tbody>
View
59 modules/webadmin.cpp
@@ -752,6 +752,14 @@ class CWebAdminMod : public CModule {
}
}
+ // Check if module is loaded globally
+ l["CanBeLoadedGlobally"] = CString(Info.SupportsType(CModInfo::GlobalModule));
+ l["LoadedGlobally"] = CString(CZNC::Get().GetModules().FindModule(Info.GetName()) != NULL);
+
+ // Check if module is loaded by user
+ l["CanBeLoadedByUser"] = CString(Info.SupportsType(CModInfo::UserModule));
+ l["LoadedByUser"] = CString(pUser->GetModules().FindModule(Info.GetName()) != NULL);
+
if (!spSession->IsAdmin() && pUser->DenyLoadMod()) {
l["Disabled"] = "true";
}
@@ -1209,8 +1217,22 @@ class CWebAdminMod : public CModule {
l["ArgsHelpText"] = Info.GetArgsHelpText();
CModule *pModule = NULL;
- if (pUser)
+ if (pUser) {
pModule = pUser->GetModules().FindModule(Info.GetName());
+ // Check if module is loaded by all or some networks
+ const vector<CIRCNetwork*>& 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();
+ if (networkModules.FindModule(Info.GetName())) {
+ networksWithRenderedModuleCount++;
+ }
+ }
+ l["CanBeLoadedByNetwork"] = CString(Info.SupportsType(CModInfo::NetworkModule));
+ l["LoadedByAllNetworks"] = CString(networksWithRenderedModuleCount == userNetworks.size());
+ l["LoadedBySomeNetworks"] = CString(networksWithRenderedModuleCount != 0);
+ }
if (pModule) {
l["Checked"] = "true";
l["Args"] = pModule->GetArgs();
@@ -1218,6 +1240,9 @@ class CWebAdminMod : public CModule {
l["Disabled"] = "true";
}
}
+ l["CanBeLoadedGlobally"] = CString(Info.SupportsType(CModInfo::GlobalModule));
+ // Check if module is loaded globally
+ l["LoadedGlobally"] = CString(CZNC::Get().GetModules().FindModule(Info.GetName()) != NULL);
if (!spSession->IsAdmin() && pUser && pUser->DenyLoadMod()) {
l["Disabled"] = "true";
@@ -1626,6 +1651,38 @@ 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/or by all or some networks
+ unsigned int usersWithRenderedModuleCount = 0;
+ unsigned int networksWithRenderedModuleCount = 0;
+ unsigned int networksCount = 0;
+ const map<CString,CUser*>& allUsers = CZNC::Get().GetUserMap();
+ for (map<CString,CUser*>::const_iterator usersIt = allUsers.begin(); usersIt != allUsers.end(); ++usersIt) {
+ const CUser& User = *usersIt->second;
+
+ // Count users which has loaded a render module
+ const CModules& userModules = User.GetModules();
+ if (userModules.FindModule(Info.GetName())) {
+ usersWithRenderedModuleCount++;
+ }
+ // Count networks which has loaded a render module
+ const vector<CIRCNetwork*>& userNetworks = User.GetNetworks();
+ networksCount += userNetworks.size();
+ for (unsigned int networkIndex = 0; networkIndex < userNetworks.size(); ++networkIndex)
+ {
+ const CIRCNetwork *pCurrentNetwork = userNetworks[networkIndex];
+ if (pCurrentNetwork->GetModules().FindModule(Info.GetName())) {
+ networksWithRenderedModuleCount++;
+ }
+ }
+ }
+ l["CanBeLoadedByNetwork"] = CString(Info.SupportsType(CModInfo::NetworkModule));
+ l["LoadedByAllNetworks"] = CString(networksWithRenderedModuleCount == networksCount);
+ l["LoadedBySomeNetworks"] = CString(networksWithRenderedModuleCount != 0);
+
+ l["CanBeLoadedByUser"] = CString(Info.SupportsType(CModInfo::UserModule));
+ l["LoadedByAllUsers"] = CString(usersWithRenderedModuleCount == allUsers.size());
+ l["LoadedBySomeUsers"] = CString(usersWithRenderedModuleCount != 0);
}
return true;
Please sign in to comment.
Something went wrong with that request. Please try again.