Permalink
Browse files

Show list of timezones in webadmin.

  • Loading branch information...
1 parent 1d4d657 commit 30b99d58f3e45ee277374f33dd2e37daab7ee355 @DarthGandalf DarthGandalf committed Mar 22, 2012
Showing with 46 additions and 2 deletions.
  1. +1 −0 include/znc/Utils.h
  2. +9 −2 modules/data/webadmin/tmpl/add_edit_user.tmpl
  3. +6 −0 modules/webadmin.cpp
  4. +30 −0 src/Utils.cpp
View
@@ -75,6 +75,7 @@ class CUtils {
static CString CTime(time_t t, const CString& sTZ);
static CString FormatTime(time_t t, const CString& sFormat, const CString& sTZ);
+ static SCString GetTimezones();
private:
protected:
@@ -213,11 +213,18 @@
<div class="sectionbody">
<div class="subsection">
<div class="inputlabel">Timestamp Format:</div>
- <div><input type="text" name="timestampformat" value="<? VAR TimestampFormat ?>" class="half" /></div>
+ <div><input type="text" name="timestampformat" value="<? VAR TimestampFormat ?>" class="full" /></div>
</div>
<div class="subsection">
<div class="inputlabel">Timezone:</div>
- <div><input type="text" name="timezone" value="<? VAR Timezone ?>" class="half" /></div>
+ <div>
+ <input type="text" name="timezone" value="<? VAR Timezone ?>" class="half" list="timezone_list" />
+ <datalist id="timezone_list">
+ <? LOOP TZLoop ?>
+ <option value="<? VAR TZ ?>"/>
+ <? ENDLOOP ?>
+ </datalist>
+ </div>
</div>
<div class="subsection">
<div class="inputlabel">Join Tries:</div>
@@ -945,6 +945,12 @@ class CWebAdminMod : public CModule {
Tmpl["StatusPrefix"] = "*";
}
+ SCString ssTimezones = CUtils::GetTimezones();
+ for (SCString::iterator i = ssTimezones.begin(); i != ssTimezones.end(); ++i) {
+ CTemplate& l = Tmpl.AddRow("TZLoop");
+ l["TZ"] = *i;
+ }
+
// To change BindHosts be admin or don't have DenySetBindHost
if (spSession->IsAdmin() || !spSession->GetUser()->DenySetBindHost()) {
const VCString& vsBindHosts = CZNC::Get().GetBindHosts();
View
@@ -10,6 +10,7 @@
#include <znc/MD5.h>
#include <znc/main.h>
#include <znc/ZNCDebug.h>
+#include <znc/FileUtils.h>
#include <errno.h>
#ifdef HAVE_LIBSSL
#include <openssl/ssl.h>
@@ -397,6 +398,35 @@ CString CUtils::FormatTime(time_t t, const CString& sFormat, const CString& sTZ)
return s;
}
+namespace {
+ void FillTimezones(const CString& sPath, SCString& result, const CString& sPrefix) {
+ CDir Dir;
+ Dir.Fill(sPath);
+ for (unsigned int a = 0; a < Dir.size(); ++a) {
+ CFile& File = *Dir[a];
+ CString sName = File.GetShortName();
+ CString sFile = File.GetLongName();
+ if (sName == "posix" || sName == "right") continue; // these 2 dirs contain the same filenames
+ if (sName.Right(4) == ".tab" || sName == "posixrules" || sName == "localtime") continue;
+ if (File.IsDir()) {
+ if (sName == "Etc") {
+ FillTimezones(sFile, result, sPrefix);
+ } else {
+ FillTimezones(sFile, result, sPrefix + sName + "/");
+ }
+ } else {
+ result.insert(sPrefix + sName);
+ }
+ }
+ }
+}
+
+SCString CUtils::GetTimezones() {
+ SCString result;
+ FillTimezones("/usr/share/zoneinfo", result, "");
+ return result;
+}
+
bool CTable::AddColumn(const CString& sName) {
for (unsigned int a = 0; a < m_vsHeaders.size(); a++) {
if (m_vsHeaders[a].Equals(sName)) {

0 comments on commit 30b99d5

Please sign in to comment.