X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fsiteconfig.c;h=7a93d44af096e10b43b155c49a502584d88cc3bc;hb=329fae6737e16938ee440d79bc89a03e4eb5268c;hp=a18bbd18e56602a5064b329de0d90d85454e15a0;hpb=6af728cfac4414a7b937d2b5658e03a75710c59b;p=citadel.git diff --git a/webcit/siteconfig.c b/webcit/siteconfig.c index a18bbd18e..7a93d44af 100644 --- a/webcit/siteconfig.c +++ b/webcit/siteconfig.c @@ -1,849 +1,509 @@ /* - * $Id$ - * * Administrative screen for site-wide configuration + * + * Copyright (c) 1996-2012 by the citadel.org team + * + * This program is open source software. You can redistribute it and/or + * modify it under the terms of the GNU General Public License, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. */ - #include "webcit.h" #include "webserver.h" +HashList *ZoneHash = NULL; + +ConstStr ExpirePolicyString = {CStrOf(roompolicy) }; + +ConstStr ExpirePolicyStrings[][2] = { + { { CStrOf(roompolicy) } , { strof(roompolicy) "_value", sizeof(strof(roompolicy) "_value") - 1 } }, + { { CStrOf(floorpolicy) } , { strof(floorpolicy) "_value", sizeof(strof(floorpolicy) "_value") - 1 } }, + { { CStrOf(sitepolicy) } , { strof(sitepolicy) "_value", sizeof(strof(sitepolicy) "_value") - 1 } }, + { { CStrOf(mailboxespolicy)} , { strof(mailboxespolicy)"_value", sizeof(strof(mailboxespolicy)"_value") - 1 } } +}; + +void LoadExpirePolicy(GPEXWhichPolicy which) +{ + StrBuf *Buf; + wcsession *WCC = WC; + long State; + const char *Pos = NULL; + + serv_printf("GPEX %s", ExpirePolicyStrings[which][0].Key); + Buf = NewStrBuf(); + StrBuf_ServGetln(Buf); + WCC->Policy[which].loaded = 1; + if (GetServerStatus(Buf, &State) == 2) { + Pos = ChrPtr(Buf) + 4; + WCC->Policy[which].expire_mode = StrBufExtractNext_long(Buf, &Pos, '|'); + WCC->Policy[which].expire_value = StrBufExtractNext_long(Buf, &Pos, '|'); + } + else if (State == 550) + AppendImportantMessage(_("Higher access is required to access this function."), -1); + FreeStrBuf(&Buf); +} + +void SaveExpirePolicyFromHTTP(GPEXWhichPolicy which) +{ + StrBuf *Buf; + long State; + + serv_printf("SPEX %s|%d|%d", + ExpirePolicyStrings[which][0].Key, + ibcstr( ExpirePolicyStrings[which][1] ), + ibcstr( ExpirePolicyStrings[which][1] ) ); + + Buf = NewStrBuf(); + StrBuf_ServGetln(Buf); + GetServerStatus(Buf, &State); + if (State == 550) + AppendImportantMessage(_("Higher access is required to access this function."), -1); + FreeStrBuf(&Buf); +} + +int ConditionalExpire(StrBuf *Target, WCTemplputParams *TP) +{ + wcsession *WCC = WC; + GPEXWhichPolicy which; + int CompareWith; + + which = GetTemplateTokenNumber(Target, TP, 2, 0); + CompareWith = GetTemplateTokenNumber(Target, TP, 3, 0); + + LoadExpirePolicy(which); + + return WCC->Policy[which].expire_mode == CompareWith; +} + +void tmplput_ExpireValue(StrBuf *Target, WCTemplputParams *TP) +{ + GPEXWhichPolicy which; + wcsession *WCC = WC; + + which = GetTemplateTokenNumber(Target, TP, 0, 0); + LoadExpirePolicy(which); + StrBufAppendPrintf(Target, "%d", WCC->Policy[which].expire_value); +} + + +void tmplput_ExpireMode(StrBuf *Target, WCTemplputParams *TP) +{ + GPEXWhichPolicy which; + wcsession *WCC = WC; + + which = GetTemplateTokenNumber(Target, TP, 2, 0); + LoadExpirePolicy(which); + StrBufAppendPrintf(Target, "%d", WCC->Policy[which].expire_mode); +} + + +void LoadZoneFiles(void) +{ + icalarray *zones; + int z; + long len; + const char *this_zone; + StrBuf *ZName; + + ZoneHash = NewHash(1, NULL); + ZName = NewStrBufPlain(HKEY("UTC")); + Put(ZoneHash, HKEY("UTC"), ZName, HFreeStrBuf); + zones = icaltimezone_get_builtin_timezones(); + for (z = 0; z < zones->num_elements; ++z) { + /* syslog(9, "Location: %-40s tzid: %s\n", + icaltimezone_get_location(icalarray_element_at(zones, z)), + icaltimezone_get_tzid(icalarray_element_at(zones, z)) + ); */ + this_zone = icaltimezone_get_location(icalarray_element_at(zones, z)); + len = strlen(this_zone); + ZName = NewStrBufPlain(this_zone, len); + Put(ZoneHash, this_zone, len, ZName, HFreeStrBuf); + } + SortByHashKey(ZoneHash, 0); +} + + +typedef struct _CfgMapping { + int type; + const char *Key; + long len; +} CfgMapping; + +#define CFG_STR 1 +#define CFG_YES 2 +#define CFG_NO 3 + +CfgMapping ServerConfig[] = { + {CFG_STR, HKEY("c_nodename")}, + {CFG_STR, HKEY("c_fqdn")}, + {CFG_STR, HKEY("c_humannode")}, + {CFG_STR, HKEY("c_phonenum")}, + {CFG_YES, HKEY("c_creataide")}, + {CFG_STR, HKEY("c_sleeping")}, + {CFG_STR, HKEY("c_initax")}, + {CFG_YES, HKEY("c_regiscall")}, + {CFG_YES, HKEY("c_twitdetect")}, + {CFG_STR, HKEY("c_twitroom")}, + {CFG_STR, HKEY("c_moreprompt")}, + {CFG_YES, HKEY("c_restrict")}, + {CFG_STR, HKEY("c_bbs_city")}, + {CFG_STR, HKEY("c_sysadm")}, + {CFG_STR, HKEY("c_maxsessions")}, + {CFG_STR, HKEY("reserved1")}, + {CFG_STR, HKEY("c_userpurge")}, + {CFG_STR, HKEY("c_roompurge")}, + {CFG_STR, HKEY("c_logpages")}, + {CFG_STR, HKEY("c_createax")}, + {CFG_STR, HKEY("c_maxmsglen")}, + {CFG_STR, HKEY("c_min_workers")}, + {CFG_STR, HKEY("c_max_workers")}, + {CFG_STR, HKEY("c_pop3_port")}, + {CFG_STR, HKEY("c_smtp_port")}, + {CFG_NO , HKEY("c_rfc822_strict_from")}, /* note: reverse bool */ + {CFG_YES, HKEY("c_aide_zap")}, + {CFG_STR, HKEY("c_imap_port")}, + {CFG_STR, HKEY("c_net_freq")}, + {CFG_YES, HKEY("c_disable_newu")}, + {CFG_STR, HKEY("reserved2")}, + {CFG_STR, HKEY("c_purge_hour")}, + {CFG_STR, HKEY("c_ldap_host")}, + {CFG_STR, HKEY("c_ldap_port")}, + {CFG_STR, HKEY("c_ldap_base_dn")}, + {CFG_STR, HKEY("c_ldap_bind_dn")}, + {CFG_STR, HKEY("c_ldap_bind_pw")}, + {CFG_STR, HKEY("c_ip_addr")}, + {CFG_STR, HKEY("c_msa_port")}, + {CFG_STR, HKEY("c_imaps_port")}, + {CFG_STR, HKEY("c_pop3s_port")}, + {CFG_STR, HKEY("c_smtps_port")}, + {CFG_YES, HKEY("c_enable_fulltext")}, + {CFG_YES, HKEY("c_auto_cull")}, + {CFG_YES, HKEY("c_instant_expunge")}, + {CFG_YES, HKEY("c_allow_spoofing")}, + {CFG_YES, HKEY("c_journal_email")}, + {CFG_YES, HKEY("c_journal_pubmsgs")}, + {CFG_STR, HKEY("c_journal_dest")}, + {CFG_STR, HKEY("c_default_cal_zone")}, + {CFG_STR, HKEY("c_pftcpdict_port")}, + {CFG_STR, HKEY("c_mgesve_port")}, + {CFG_STR, HKEY("c_auth_mode")}, + {CFG_STR, HKEY("c_funambol_host")}, + {CFG_STR, HKEY("c_funambol_port")}, + {CFG_STR, HKEY("c_funambol_source")}, + {CFG_STR, HKEY("c_funambol_auth")}, + {CFG_YES, HKEY("c_rbl_at_greeting")}, + {CFG_STR, HKEY("c_master_user")}, + {CFG_STR, HKEY("c_master_pass")}, + {CFG_STR, HKEY("c_pager_program")}, + {CFG_YES, HKEY("c_imap_keep_from")}, + {CFG_STR, HKEY("c_xmpp_c2s_port")}, + {CFG_STR, HKEY("c_xmpp_s2s_port")}, + {CFG_STR, HKEY("c_pop3_fetch")}, + {CFG_STR, HKEY("c_pop3_fastest")}, + {CFG_YES, HKEY("c_spam_flag_only")}, + {CFG_YES, HKEY("c_guest_logins")} +}; + + + /* - * \brief display all configuration items + * display all configuration items */ -void display_siteconfig(void) +void load_siteconfig(void) { - char buf[SIZ]; + wcsession *WCC = WC; + StrBuf *Buf; + HashList *Cfg; + long len; int i, j; - - char general[65536]; - char access[SIZ]; - char network[SIZ]; - char tuning[SIZ]; - char directory[SIZ]; - char purger[SIZ]; - char idxjnl[SIZ]; - char funambol[SIZ]; - char pop3[SIZ]; - /** expire policy settings */ - int sitepolicy = 0; - int sitevalue = 0; - int mboxpolicy = 0; - int mboxvalue = 0; - - output_headers(1, 1, 2, 0, 0, 0); - wprintf("
\n"); + if (WCC->ServCfg == NULL) + WCC->ServCfg = NewHash(1, NULL); + Cfg = WCC->ServCfg; - wprintf("");
-
- char *tabnames[] = {
- _("General"),
- _("Access"),
- _("Network"),
- _("Tuning"),
- _("Directory"),
- _("Auto-purger"),
- _("Indexing/Journaling"),
- _("Push Email"),
- _("Pop3")
- };
-
- sprintf(general, "%s");
- wprintf("", _("Save changes"));
- wprintf(" ");
- wprintf("\n", _("Cancel"));
- wprintf(" \n");
- wprintf(" |