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

File diff suppressed because it is too large Load Diff

View File

@@ -1 +1 @@
o = adduser.o cat.o chmod.o chown.o ckeditor.o cp.o default.o download.o emacs.o env.o functionbase.o functionparser.o functions.o last.o ln.o login.o logout.o ls.o man.o meta.o mkdir.o mount.o mv.o nicedit.o node.o passwd.o priv.o privchanger.o pw.o reload.o rm.o rmuser.o run.o sort.o specialdefault.o stat.o subject.o template.o tinymce.o uname.o upload.o uptime.o vim.o who.o
o = adduser.o cat.o chmod.o chown.o ckeditor.o cp.o default.o download.o emacs.o env.o functionbase.o functionparser.o functions.o last.o ln.o locale.o login.o logout.o ls.o man.o meta.o mkdir.o mount.o mv.o nicedit.o node.o passwd.o priv.o privchanger.o pw.o reload.o rm.o rmuser.o run.o sort.o specialdefault.o stat.o subject.o template.o timezone.o tinymce.o uname.o upload.o uptime.o vim.o who.o

View File

@@ -183,11 +183,13 @@ bool AddUser::AddNewUser(const std::wstring & login,
bool use_ses_log)
{
user.Clear();
user.name = login;
user.email = email;
user.super_user = false;
user.notify = 0;
user.status = (config->account_need_email_verification)? WINIX_ACCOUNT_NOT_ACTIVATED : WINIX_ACCOUNT_READY;
user.name = login;
user.email = email;
user.super_user = false;
user.notify = 0;
user.locale_id = config->locale_default_id;
user.time_zone_id = config->time_zone_default_id;
user.status = (config->account_need_email_verification)? WINIX_ACCOUNT_NOT_ACTIVATED : WINIX_ACCOUNT_READY;
long code = 0;
if( autoactivate )

View File

@@ -187,6 +187,7 @@ void Functions::CreateFunctions()
Add(fun_emacs);
Add(fun_env);
Add(fun_last);
Add(fun_locale);
Add(fun_login);
Add(fun_logout);
Add(fun_ln);
@@ -210,6 +211,7 @@ void Functions::CreateFunctions()
Add(fun_stat);
Add(fun_subject);
Add(fun_template);
Add(fun_time_zone);
Add(fun_tinymce);
Add(fun_uname);
Add(fun_upload);
@@ -435,7 +437,7 @@ void Functions::CheckGetPostTimes(time_t difference)
// !!uwaga zwracana warto<74><6F> zmieniona (true/false)
// !!uwaga zwracana warto<74><6F> zmieniona (true/false)
bool Functions::CheckAbuse()
{
if( !system->rebus.CheckRebus() )

View File

@@ -24,6 +24,7 @@
#include "emacs.h"
#include "env.h"
#include "last.h"
#include "locale.h"
#include "login.h"
#include "logout.h"
#include "ln.h"
@@ -47,6 +48,7 @@
#include "stat.h"
#include "subject.h"
#include "template.h"
#include "timezone.h"
#include "tinymce.h"
#include "uname.h"
#include "upload.h"
@@ -75,6 +77,7 @@ public:
Fun::Emacs fun_emacs;
Fun::Env fun_env;
Fun::Last fun_last;
Fun::Locale fun_locale;
Fun::Login fun_login;
Fun::Logout fun_logout;
Fun::Ln fun_ln;
@@ -98,6 +101,7 @@ public:
Fun::Stat fun_stat;
Fun::Subject fun_subject;
Fun::Template fun_template;
Fun::TimeZone fun_time_zone;
Fun::Tinymce fun_tinymce;
Fun::Uname fun_uname;
Fun::Upload fun_upload;

60
functions/locale.cpp Executable file
View File

@@ -0,0 +1,60 @@
/*
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2012, Tomasz Sowa
* All rights reserved.
*
*/
#include "locale.h"
#include "templates/templates.h"
namespace Fun
{
Locale::Locale()
{
fun.url = L"locale";
}
bool Locale::HasAccess()
{
return cur->session->puser != 0;
}
void Locale::MakePost()
{
if( cur->session->puser )
{
size_t locale_id = size_t(Toi(cur->request->PostVar(L"localeid")));
if( TemplatesFunctions::locale.HasLanguage(locale_id) )
{
cur->session->puser->locale_id = locale_id;
db->ChangeUserLocale(cur->session->puser->id, locale_id);
TemplatesFunctions::locale.SetCurLang(locale_id);
}
else
{
log << log1 << "Locale: incorrect locale id: " << locale_id << logend;
}
}
}
void Locale::MakeGet()
{
}
} // namespace

38
functions/locale.h Executable file
View File

@@ -0,0 +1,38 @@
/*
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2012, Tomasz Sowa
* All rights reserved.
*
*/
#ifndef headerfile_winix_functions_locale
#define headerfile_winix_functions_locale
#include "functionbase.h"
namespace Fun
{
class Locale : public FunctionBase
{
public:
Locale();
bool HasAccess();
void MakePost();
void MakeGet();
private:
};
} // namespace
#endif

56
functions/timezone.cpp Executable file
View File

@@ -0,0 +1,56 @@
/*
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2012, Tomasz Sowa
* All rights reserved.
*
*/
#include "timezone.h"
namespace Fun
{
TimeZone::TimeZone()
{
fun.url = L"timezone";
}
bool TimeZone::HasAccess()
{
return cur->session->puser != 0;
}
void TimeZone::MakePost()
{
if( cur->session->puser )
{
size_t tz_id = size_t(Toi(cur->request->PostVar(L"timezoneid")));
if( system->time_zones.HasZone(tz_id) )
{
cur->session->puser->time_zone_id = tz_id;
db->ChangeUserTimeZone(cur->session->puser->id, tz_id);
}
else
{
log << log1 << "TimeZone: incorrect time zone id: " << tz_id << logend;
}
}
}
void TimeZone::MakeGet()
{
}
} // namespace

39
functions/timezone.h Executable file
View File

@@ -0,0 +1,39 @@
/*
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2012, Tomasz Sowa
* All rights reserved.
*
*/
#ifndef headerfile_winix_functions_timezone
#define headerfile_winix_functions_timezone
#include "functionbase.h"
namespace Fun
{
class TimeZone : public FunctionBase
{
public:
TimeZone();
bool HasAccess();
void MakePost();
void MakeGet();
private:
};
} // namespace
#endif

View File

@@ -309,8 +309,7 @@ void Upload::MakePost()
void Upload::CreateJSON()
{
// !! locale beda w zaleznosci od uzytkownika
size_t loc = TemplatesFunctions::locale.GetLang();
size_t loc = TemplatesFunctions::locale.GetCurLang();
Ezc::Pattern * pat = TemplatesFunctions::patterns.Get(template_index, loc);
if( pat )