Skip to content
Browse files

Show empty checkbox if module can be loaded by the topic column.

Fix const correctnes of the CModInfo::SupportsType method.
  • Loading branch information...
1 parent 16b268d commit 4338ae5cc521a5348a4dfc9574d05cd33e12bfa0 @devfom devfom committed Jun 1, 2014
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
16 modules/data/webadmin/tmpl/add_edit_network.tmpl
@@ -184,13 +184,21 @@
</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"/>
+ <? 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 LoadedByUser ?>
- <input type="checkbox" name="loaded_by_user" id="loaded_by_user_<? VAR Name ?>" checked="checked" disabled="disabled"/>
+ <? 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>
View
20 modules/data/webadmin/tmpl/add_edit_user.tmpl
@@ -194,14 +194,22 @@
</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 ?>
+ <? 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 LoadedBySomeNetworks ?>
- <input type="checkbox" name="loaded_by_network" id="loaded_by_net_<? VAR Name ?>" checked="checked" disabled="disabled"/>
- <? IF !LoadedByAllNetworks ?>
+ <? 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>
View
20 modules/data/webadmin/tmpl/settings.tmpl
@@ -189,19 +189,27 @@
</td>
<td class="mod_descr"><? VAR Description ?></td>
<td align="center">
- <? IF LoadedBySomeNetworks ?>
- <input type="checkbox" name="loaded_by_network" id="loaded_by_net_<? VAR Name ?>" checked="checked" disabled="disabled"/>
- <? IF !LoadedByAllNetworks ?>
+ <? 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 LoadedBySomeUsers ?>
- <input type="checkbox" name="loaded_by_user" id="loaded_by_user_<? VAR Name ?>" checked="checked" disabled="disabled"/>
- <? IF !LoadedByAllUsers ?>
+ <? 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>
View
12 modules/webadmin.cpp
@@ -753,9 +753,11 @@ 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()) {
@@ -1227,6 +1229,7 @@ class CWebAdminMod : public CModule {
networksWithRenderedModuleCount++;
}
}
+ l["CanBeLoadedByNetwork"] = CString(Info.SupportsType(CModInfo::NetworkModule));
l["LoadedByAllNetworks"] = CString(networksWithRenderedModuleCount == userNetworks.size());
l["LoadedBySomeNetworks"] = CString(networksWithRenderedModuleCount != 0);
}
@@ -1237,7 +1240,7 @@ 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);
@@ -1673,10 +1676,13 @@ class CWebAdminMod : public CModule {
}
}
}
- l["LoadedByAllUsers"] = CString(usersWithRenderedModuleCount == allUsers.size());
- l["LoadedBySomeUsers"] = CString(usersWithRenderedModuleCount != 0);
+ 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;

0 comments on commit 4338ae5

Please sign in to comment.
Something went wrong with that request. Please try again.