added: winix functions: locale, timezone

changed: time zones -- now we have the daylight saving time
       different for each year (start, end)
added: config option: time_zone_id (size_t)
       time zone identifier for not logged users
       or for newly created accounts
       those identifiers you can see in etc/time_zones.conf file
       or by using timezone winix function with 'a' parameter (timezone/a) (!!IMPROVE ME NOT IMPLEMENTED YET)
       default: 34 (Coordinated Universal Time UTC+00:00)
added: config option: locale_default_id (size_t)
       locale for not logged users
       or for newly created accounts
added: config option: locale_max_id (size_t)
       a maximum value of a locale identifier
       default: 100 (maximum: 1000)
       each locale files should have its own identifier (in "winix_locale_id" field)
       from zero to this value
added: config option: time_zone_max_id (size_t)
       maximum value of a time zone identifier
       time zones with an id greater than this will be skipped
       default: 130 (maximum: 1000)
removed: config option: locale_default



git-svn-id: svn://ttmath.org/publicrep/winix/trunk@852 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2012-06-26 23:19:19 +00:00
parent 54e6c07efc
commit b8ff5d4cfc
53 changed files with 4618 additions and 3053 deletions

View File

@@ -77,7 +77,7 @@ Error Db::AddUser(User & user, const UserPass & up)
{
query.Clear();
query << R("insert into core.user (login, password, pass_encrypted, super_user, email,"
"notify, pass_type, pass_hash_salted, env, aenv, status) values (")
"notify, pass_type, pass_hash_salted, env, aenv, status, locale_id, time_zone_id) values (")
<< user.name;
// for safety we put up.pass only if there is not an encrypted version
@@ -97,6 +97,8 @@ Error Db::AddUser(User & user, const UserPass & up)
<< user.env
<< user.aenv
<< user.status
<< user.locale_id
<< user.time_zone_id
<< R(");");
r = AssertQuery(query);
@@ -194,6 +196,32 @@ return DoCommand(query);
}
Error Db::ChangeUserLocale(long user_id, size_t locale_id)
{
query.Clear();
query << R("update core.user set(locale_id) = (")
<< locale_id
<< R(") where id = ")
<< user_id
<< R(";");
return DoCommand(query);
}
Error Db::ChangeUserTimeZone(long user_id, size_t time_zone_id)
{
query.Clear();
query << R("update core.user set(time_zone_id) = (")
<< time_zone_id
<< R(") where id = ")
<< user_id
<< R(";");
return DoCommand(query);
}
Error Db::RemoveUser(long user_id)
{
query.Clear();
@@ -1566,7 +1594,8 @@ void Db::GetUsers(UGContainer<User> & user_tab)
try
{
query.Clear();
query << R("select id, login, super_user, group_id, email, notify, env, aenv, status"
query << R("select id, login, super_user, group_id, email, notify,"
" env, aenv, status, locale_id, time_zone_id"
" from core.user left outer join core.group_mem on"
" core.user.id = core.group_mem.user_id order by id asc;");
@@ -1584,6 +1613,8 @@ void Db::GetUsers(UGContainer<User> & user_tab)
int cenv = AssertColumn(r, "env");
int caenv = AssertColumn(r, "aenv");
int cstatus = AssertColumn(r, "status");
int clocale_id = AssertColumn(r, "locale_id");
int ctzone_id = AssertColumn(r, "time_zone_id");
User u;
long last_id = -1;
@@ -1595,11 +1626,13 @@ void Db::GetUsers(UGContainer<User> & user_tab)
if( u.id != last_id )
{
u.name = AssertValueWide(r, i, cname);
u.super_user = AssertValueBool(r, i, csuper_user);
u.email = AssertValueWide(r, i, cemail);
u.notify = AssertValueInt(r, i, cnotify);
u.status = AssertValueInt(r, i, cstatus);
u.name = AssertValueWide(r, i, cname);
u.super_user = AssertValueBool(r, i, csuper_user);
u.email = AssertValueWide(r, i, cemail);
u.notify = AssertValueInt(r, i, cnotify);
u.status = AssertValueInt(r, i, cstatus);
u.locale_id = (size_t)AssertValueInt(r, i, clocale_id);
u.time_zone_id = (size_t)AssertValueInt(r, i, ctzone_id);
AssertValueSpace(r, i, cenv, u.env);
AssertValueSpace(r, i, caenv, u.aenv);