added: to IsWhite (core/misc)
other unicode white characters
25 characters -- without a new line character (10)
added: config option: account_need_email_verification
if true then when creating an account a user has to provide
his email address and a message with an activation link will be sent
back to him
added: 'pw' winix function (not finished yet)
at the moment only one parameter 'activate'
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@810 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
@@ -18,7 +18,7 @@ notify.o: ../core/mount.h ../core/lastcontainer.h ../db/db.h ../db/dbbase.h
|
||||
notify.o: ../db/dbconn.h ../db/dbtextstream.h ../core/error.h
|
||||
notify.o: ../db/dbitemquery.h ../core/item.h ../db/dbitemcolumns.h
|
||||
notify.o: ../core/user.h ../core/group.h ../core/dircontainer.h
|
||||
notify.o: ../core/ugcontainer.h ../templates/misc.h ../templates/templates.h
|
||||
notify.o: ../core/ugcontainer.h ../templates/templates.h
|
||||
notify.o: ../templates/patterncacher.h ../templates/indexpatterns.h
|
||||
notify.o: ../templates/patterns.h ../templates/changepatterns.h ../core/cur.h
|
||||
notify.o: ../core/system.h ../core/dirs.h ../core/dircontainer.h
|
||||
@@ -39,9 +39,10 @@ notify.o: ../functions/env.h ../functions/last.h ../functions/login.h
|
||||
notify.o: ../functions/logout.h ../functions/ln.h ../functions/ls.h
|
||||
notify.o: ../functions/man.h ../functions/meta.h ../functions/mkdir.h
|
||||
notify.o: ../functions/mv.h ../functions/nicedit.h ../functions/node.h
|
||||
notify.o: ../functions/passwd.h ../functions/priv.h ../functions/reload.h
|
||||
notify.o: ../functions/rm.h ../functions/sort.h ../functions/specialdefault.h
|
||||
notify.o: ../functions/stat.h ../functions/subject.h ../functions/template.h
|
||||
notify.o: ../functions/passwd.h ../functions/priv.h ../functions/pw.h
|
||||
notify.o: ../functions/reload.h ../functions/rm.h ../functions/sort.h
|
||||
notify.o: ../functions/specialdefault.h ../functions/stat.h
|
||||
notify.o: ../functions/subject.h ../functions/template.h
|
||||
notify.o: ../functions/tinymce.h ../functions/uname.h ../functions/upload.h
|
||||
notify.o: ../functions/uptime.h ../functions/who.h ../functions/vim.h
|
||||
notifypool.o: notifypool.h ../templates/locale.h
|
||||
@@ -104,7 +105,7 @@ templatesnotify.o: ../functions/ln.h ../functions/ls.h ../functions/man.h
|
||||
templatesnotify.o: ../functions/meta.h ../functions/mkdir.h ../functions/mv.h
|
||||
templatesnotify.o: ../functions/nicedit.h ../functions/node.h
|
||||
templatesnotify.o: ../functions/passwd.h ../functions/priv.h
|
||||
templatesnotify.o: ../functions/reload.h ../functions/rm.h
|
||||
templatesnotify.o: ../functions/pw.h ../functions/reload.h ../functions/rm.h
|
||||
templatesnotify.o: ../functions/sort.h ../functions/specialdefault.h
|
||||
templatesnotify.o: ../functions/stat.h ../functions/subject.h
|
||||
templatesnotify.o: ../functions/template.h ../functions/tinymce.h
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2011, Tomasz Sowa
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -68,7 +68,8 @@ void Notify::Init()
|
||||
patterns.SetLocale(&TemplatesFunctions::locale);
|
||||
patterns.SetLocaleFilter(&TemplatesFunctions::locale_filter);
|
||||
|
||||
notify_template_cms = AddTemplate(L"notify_email_cms.txt");
|
||||
notify_template_cms = AddTemplate(L"notify_email_cms.txt");
|
||||
notify_template_activate_account = AddTemplate(L"notify_confirm_account.txt");
|
||||
|
||||
plugin.Call(WINIX_NOTIFY_ADD_TEMPLATE);
|
||||
}
|
||||
@@ -89,6 +90,7 @@ void Notify::ItemChanged(int notify_code, const Item & item)
|
||||
if( notify_code == 0 )
|
||||
return;
|
||||
|
||||
msg.Clear();
|
||||
msg.code = notify_code;
|
||||
msg.template_index = notify_template_cms;
|
||||
CreateItemLink(item, msg.item_link, msg.dir_link);
|
||||
@@ -106,6 +108,22 @@ void Notify::ItemChanged(const NotifyMsg & msg)
|
||||
}
|
||||
|
||||
|
||||
void Notify::ActivateAccount(const std::wstring & name, const std::wstring & email, long code)
|
||||
{
|
||||
msg.Clear();
|
||||
msg.code = WINIX_NOTIFY_CODE_CONFIRM_ACCOUNT;
|
||||
msg.name = name;
|
||||
msg.email = email;
|
||||
msg.lang = 0;
|
||||
msg.activate_code = code;
|
||||
msg.template_index = notify_template_activate_account;
|
||||
CreateActivateLink(name, code, msg.item_link);
|
||||
|
||||
notify_pool.Add(msg);
|
||||
notify_thread.WakeUpThread(); // we are in the first locked thread
|
||||
}
|
||||
|
||||
|
||||
|
||||
size_t Notify::AddTemplate(const std::wstring & file_name)
|
||||
{
|
||||
@@ -118,7 +136,7 @@ size_t Notify::AddTemplate(const std::wstring & file_name)
|
||||
|
||||
void Notify::CreateItemLink(const Item & item, std::wstring & item_link, std::wstring & dir_link)
|
||||
{
|
||||
static std::wstring tmp_path;
|
||||
tmp_path.clear();
|
||||
|
||||
if( item.type == Item::dir )
|
||||
{
|
||||
@@ -141,3 +159,15 @@ static std::wstring tmp_path;
|
||||
|
||||
|
||||
|
||||
void Notify::CreateActivateLink(const std::wstring & name, long code, std::wstring & link)
|
||||
{
|
||||
wchar_t buff[50];
|
||||
|
||||
link = config->url_proto;
|
||||
link += config->base_url;
|
||||
link += L"/pw/activate/login:";
|
||||
UrlEncode(name, link, false);
|
||||
link += L"/code:";
|
||||
Toa(code, buff, sizeof(buff)/sizeof(wchar_t));
|
||||
link += buff;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010-2011, Tomasz Sowa
|
||||
* Copyright (c) 2010-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -16,9 +16,6 @@
|
||||
#include "templates/patterns.h"
|
||||
#include "notifythread.h"
|
||||
|
||||
// !! skasowac?
|
||||
#include "templates/misc.h"
|
||||
|
||||
|
||||
class Request;
|
||||
class Config;
|
||||
@@ -47,6 +44,7 @@ public:
|
||||
|
||||
void ItemChanged(int notify_code, const Item & item);
|
||||
void ItemChanged(const NotifyMsg & msg);
|
||||
void ActivateAccount(const std::wstring & name, const std::wstring & email, long code);
|
||||
|
||||
private:
|
||||
|
||||
@@ -60,12 +58,15 @@ private:
|
||||
NotifyThread notify_thread;
|
||||
NotifyMsg msg;
|
||||
NotifyPool notify_pool;
|
||||
std::wstring tmp_path;
|
||||
|
||||
size_t notify_template_cms;
|
||||
size_t notify_template_activate_account;
|
||||
|
||||
Patterns patterns;
|
||||
|
||||
void CreateItemLink(const Item & item, std::wstring & link, std::wstring & dir_link);
|
||||
void CreateActivateLink(const std::wstring & name, long code, std::wstring & link);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010, Tomasz Sowa
|
||||
* Copyright (c) 2010-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -15,33 +15,47 @@
|
||||
#include "templates/locale.h"
|
||||
|
||||
|
||||
#define WINIX_NOTIFY_CODE_ADD 1
|
||||
#define WINIX_NOTIFY_CODE_EDIT 2
|
||||
#define WINIX_NOTIFY_CODE_DELETE 4
|
||||
#define WINIX_NOTIFY_CODE_REPLY 8
|
||||
#define WINIX_NOTIFY_CODE_ADD 1
|
||||
#define WINIX_NOTIFY_CODE_EDIT 2
|
||||
#define WINIX_NOTIFY_CODE_DELETE 4
|
||||
#define WINIX_NOTIFY_CODE_REPLY 8
|
||||
#define WINIX_NOTIFY_CODE_CONFIRM_ACCOUNT 16
|
||||
|
||||
|
||||
|
||||
// additional codes, use it of your own
|
||||
// you should prepare NotifyMsg structure and use it with ItemChanged method of notify object
|
||||
/* temporarily not used
|
||||
#define WINIX_NOTIFY_CODE_USER1 1024
|
||||
#define WINIX_NOTIFY_CODE_USER2 2048
|
||||
#define WINIX_NOTIFY_CODE_USER3 4096
|
||||
#define WINIX_NOTIFY_CODE_USER4 8192
|
||||
#define WINIX_NOTIFY_CODE_USER5 16384
|
||||
#define WINIX_NOTIFY_CODE_USER6 32768
|
||||
#define WINIX_NOTIFY_CODE_USER7 65536
|
||||
#define WINIX_NOTIFY_CODE_USER8 131072
|
||||
*/
|
||||
|
||||
|
||||
// !! IMPROVE ME
|
||||
// may now we can use PT::Space instead of NotifyMsg?
|
||||
struct NotifyMsg
|
||||
{
|
||||
int code;
|
||||
std::wstring item_link; // link to a file or a dir (can be the same as dir_link if the item is a directory)
|
||||
std::wstring dir_link; // link to a dir
|
||||
size_t template_index;
|
||||
|
||||
// used in account activations
|
||||
// we send one email directly to one user
|
||||
std::wstring email;
|
||||
std::wstring name;
|
||||
size_t lang;
|
||||
long activate_code;
|
||||
|
||||
|
||||
NotifyMsg()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
code = -1;
|
||||
item_link.clear();
|
||||
dir_link.clear();
|
||||
template_index = 0;
|
||||
email.clear();
|
||||
name.clear();
|
||||
lang = 0;
|
||||
activate_code = 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -94,16 +94,28 @@ bool res = false;
|
||||
TemplatesNotifyFunctions::notify_msg = notify_pool->GetFirst();
|
||||
notify_pool->DeleteFirst();
|
||||
|
||||
for(i=users->Begin() ; i != users->End() ; ++i)
|
||||
if( TemplatesNotifyFunctions::notify_msg.code == WINIX_NOTIFY_CODE_CONFIRM_ACCOUNT )
|
||||
{
|
||||
if( ((*i)->notify & TemplatesNotifyFunctions::notify_msg.code) != 0 )
|
||||
{
|
||||
msg.name = (*i)->name;
|
||||
msg.email = (*i)->email;
|
||||
msg.lang = config->locale_default_index; // !! bedzie osobno dla kazdego uzytkownika
|
||||
msg.email = TemplatesNotifyFunctions::notify_msg.email;
|
||||
msg.name = TemplatesNotifyFunctions::notify_msg.name;
|
||||
msg.lang = TemplatesNotifyFunctions::notify_msg.lang;
|
||||
|
||||
notify_user.insert(notify_user.end(), msg);
|
||||
res = true;
|
||||
notify_user.push_back(msg);
|
||||
res = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
for(i=users->Begin() ; i != users->End() ; ++i)
|
||||
{
|
||||
if( ((*i)->notify & TemplatesNotifyFunctions::notify_msg.code) != 0 )
|
||||
{
|
||||
msg.name = (*i)->name;
|
||||
msg.email = (*i)->email;
|
||||
msg.lang = config->locale_default_index; // !! bedzie osobno dla kazdego uzytkownika
|
||||
|
||||
notify_user.push_back(msg);
|
||||
res = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user