Skip to content

Commit

Permalink
Add "Loaded" flag to the user page.
Browse files Browse the repository at this point in the history
  • Loading branch information
VasilyFomin committed May 29, 2014
1 parent 78f7897 commit 3ad2852
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
18 changes: 18 additions & 0 deletions modules/data/webadmin/tmpl/add_edit_user.tmpl
Expand Up @@ -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>
Expand All @@ -191,6 +193,22 @@
<? ENDIF ?>
</td>
<td class="mod_descr"><? VAR Description ?></td>
<td align="center">
<? IF LoadedGlobally ?>
<input type="checkbox" name="loaded_globally" id="loaded_globally_<? VAR Name ?>" checked="checked" disabled="disabled"/>
<? ENDIF ?>
</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>
</tr>
<? ENDLOOP ?>

Expand Down
20 changes: 20 additions & 0 deletions modules/webadmin.cpp
Expand Up @@ -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<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();
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";
}
Expand Down

0 comments on commit 3ad2852

Please sign in to comment.