Permalink
Browse files

webadmin: allow edit bindhost without global list.

  • Loading branch information...
DarthGandalf committed Apr 1, 2012
1 parent ba99a64 commit b8822b8bfbfc765a54d35071767094c2e6409f9f
Showing with 51 additions and 39 deletions.
  1. +18 −12 modules/data/webadmin/tmpl/add_edit_user.tmpl
  2. +33 −27 modules/webadmin.cpp
@@ -74,27 +74,33 @@
</div>
<div style="clear: both;"></div>
- <? IF BindHostLoop ?>
+ <? IF BindHostEdit ?>
<div class="subsection">
<div class="inputlabel">BindHost:</div>
- <select name="bindhost">
- <option value="">- Default -</option>
- <? LOOP BindHostLoop ?><option value="<? VAR BindHost ?>"<? IF Checked ?> selected="selected"<? ENDIF ?>><? VAR BindHost ?></option><? ENDLOOP ?>
- </select>
+ <? IF BindHostLoop ?>
+ <select name="bindhost">
+ <option value="">- Default -</option>
+ <? LOOP BindHostLoop ?><option value="<? VAR BindHost ?>"<? IF Checked ?> selected="selected"<? ENDIF ?>><? VAR BindHost ?></option><? ENDLOOP ?>
+ </select>
+ <? ELSE ?>
+ <input type="text" name="bindhost" value="<? VAR BindHost ?>"/>
+ <? ENDIF ?>
</div>
<div style="clear: both;"></div>
- <? ENDIF ?>
- <? IF DCCBindHostLoop ?>
<div class="subsection">
<div class="inputlabel">DCCBindHost:</div>
- <select name="dccbindhost">
- <option value="">- Default -</option>
- <? LOOP DCCBindHostLoop ?><option value="<? VAR BindHost ?>"<? IF Checked ?> selected="selected"<? ENDIF ?>><? VAR BindHost ?></option><? ENDLOOP ?>
- </select>
+ <? IF DCCBindHostLoop ?>
+ <select name="dccbindhost">
+ <option value="">- Default -</option>
+ <? LOOP DCCBindHostLoop ?><option value="<? VAR BindHost ?>"<? IF Checked ?> selected="selected"<? ENDIF ?>><? VAR BindHost ?></option><? ENDLOOP ?>
+ </select>
+ <? ELSE ?>
+ <input type="text" name="dccbindhost" value="<? VAR DCCBindHost ?>"/>
+ <? ENDIF ?>
</div>
<div style="clear: both;"></div>
- <? ENDIF ?>
+ <? ENDIF ?>
<div class="subsection">
<div class="inputlabel">Quit Message:</div>
View
@@ -967,41 +967,47 @@ class CWebAdminMod : public CModule {
// To change BindHosts be admin or don't have DenySetBindHost
if (spSession->IsAdmin() || !spSession->GetUser()->DenySetBindHost()) {
+ Tmpl["BindHostEdit"] = "true";
const VCString& vsBindHosts = CZNC::Get().GetBindHosts();
- bool bFoundBindHost = false;
- bool bFoundDCCBindHost = false;
- for (unsigned int b = 0; b < vsBindHosts.size(); b++) {
- const CString& sBindHost = vsBindHosts[b];
- CTemplate& l = Tmpl.AddRow("BindHostLoop");
- CTemplate& k = Tmpl.AddRow("DCCBindHostLoop");
+ if (vsBindHosts.empty()) {
+ Tmpl["BindHost"] = pUser->GetBindHost();
+ Tmpl["DCCBindHost"] = pUser->GetDCCBindHost();
+ } else {
+ bool bFoundBindHost = false;
+ bool bFoundDCCBindHost = false;
+ for (unsigned int b = 0; b < vsBindHosts.size(); b++) {
+ const CString& sBindHost = vsBindHosts[b];
+ CTemplate& l = Tmpl.AddRow("BindHostLoop");
+ CTemplate& k = Tmpl.AddRow("DCCBindHostLoop");
+
+ l["BindHost"] = sBindHost;
+ k["BindHost"] = sBindHost;
+
+ if (pUser && pUser->GetBindHost() == sBindHost) {
+ l["Checked"] = "true";
+ bFoundBindHost = true;
+ }
+
+ if (pUser && pUser->GetDCCBindHost() == sBindHost) {
+ k["Checked"] = "true";
+ bFoundDCCBindHost = true;
+ }
+ }
- l["BindHost"] = sBindHost;
- k["BindHost"] = sBindHost;
+ // If our current bindhost is not in the global list...
+ if (pUser && !bFoundBindHost && !pUser->GetBindHost().empty()) {
+ CTemplate& l = Tmpl.AddRow("BindHostLoop");
- if (pUser && pUser->GetBindHost() == sBindHost) {
+ l["BindHost"] = pUser->GetBindHost();
l["Checked"] = "true";
- bFoundBindHost = true;
}
+ if (pUser && !bFoundDCCBindHost && !pUser->GetDCCBindHost().empty()) {
+ CTemplate& l = Tmpl.AddRow("DCCBindHostLoop");
- if (pUser && pUser->GetDCCBindHost() == sBindHost) {
- k["Checked"] = "true";
- bFoundDCCBindHost = true;
+ l["BindHost"] = pUser->GetDCCBindHost();
+ l["Checked"] = "true";
}
}
-
- // If our current bindhost is not in the global list...
- if (pUser && !bFoundBindHost && !pUser->GetBindHost().empty()) {
- CTemplate& l = Tmpl.AddRow("BindHostLoop");
-
- l["BindHost"] = pUser->GetBindHost();
- l["Checked"] = "true";
- }
- if (pUser && !bFoundDCCBindHost && !pUser->GetDCCBindHost().empty()) {
- CTemplate& l = Tmpl.AddRow("DCCBindHostLoop");
-
- l["BindHost"] = pUser->GetDCCBindHost();
- l["Checked"] = "true";
- }
}
vector<CString> vDirs;

0 comments on commit b8822b8

Please sign in to comment.