we can create links (hard links, symbolic links) now

added winix functions: ln

winix function 'default' can be used without redirecting now

added new tickets types: TypeProgress, TypeString, TypeMultistring, TypeImages, TypeFiles
now tickets are combined with files
added winix functions: showtickets

fixed mountpoints:
when the default root mount was created its parameter table was empty
and it caused accessing to a non-existing objects

fixed logger:
modifiers (log1, log2, log3) were incorrectly treated
added modifier: log4 (debug info)

now we are moving threads to a new plugin 'thread'
created directory: plugins/thread
(not finished yet)




git-svn-id: svn://ttmath.org/publicrep/winix/trunk@704 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2011-01-05 21:24:11 +00:00
parent bb83aed20d
commit 8154c403d8
113 changed files with 5840 additions and 2972 deletions

975
db/db.cpp

File diff suppressed because it is too large Load Diff

35
db/db.h
View File

@@ -48,17 +48,13 @@ public:
Error AddItem(Item & item);
Error EditItemById(Item & item, bool with_url = true);
Error EditItemByUrl(Item & item, bool with_url = true);
void CheckAllUrlSubject();
// !! nie zwracac zadnych kodow bledow?
void GetItems(std::vector<Item> & item_tab, const DbItemQuery & item_query);
void GetItems(std::vector<long> & item_tab, const DbItemQuery & item_query);
// !! pobiera tylko jeden item (cos wymyslec innego z nazwa albo argumentem)
void GetItem(std::vector<Item> & item_tab, long id);
Error GetItem(Item & item, const DbItemQuery & item_query);
bool GetPriv(Item & item, long id);
Error EditPrivById(Item & item, long id);
@@ -70,7 +66,7 @@ public:
Error EditSubjectById(Item & item, long id);
bool DelItem(const Item & item);
Error DelItem(const Item & item);
void GetDirs(DirContainer & dir_tab);
void GetUsers(UGContainer<User> & user_tab);
void GetGroups(UGContainer<Group> & group_tab);
@@ -80,21 +76,15 @@ public:
Error GetItemById(long item_id, Item & item);
Error GetItem(long parent_id, const std::wstring & url, Item & item);
Error EditDefaultItem(long id, long new_default_item);
Error EditLinkItem(long id, const std::wstring & link_to, int link_redirect);
Error EditTemplateItemById(long id, const std::wstring & new_html_template);
long GetItemId(long parent_id, const std::wstring & url, Item::Type type);
long GetFileId(long parent_id, const std::wstring & url);
long GetDirId(long parent_id, const std::wstring & url);
Error AddHardLink(Item & item);
Error AddThread(Thread & thread);
Error GetThreadByDirId(long dir_id, Thread & thread);
Error GetThreads(long parent_id, std::vector<Thread> & thread_tab);
Error EditThreadAddItem(long dir_id, long item_id);
Error EditThreadRemoveItem(long dir_id);
Error RemoveThread(long dir_id);
@@ -102,6 +92,7 @@ protected:
DbTextStream query, query_create_url;
std::wstring temp_url;
Item dir_temp;
bool AddItemCreateUrlSubject(Item & item);
@@ -110,18 +101,16 @@ protected:
Error EditItemInItem(Item & item, bool with_url);
Error EditItemInContent(Item & item);
Error EditItemGetId(Item & item);
Error EditItemGetContentId(Item & item);
void CheckAllUrlSubjectModifyItem(Item & item);
Error EditItemGetIdsByUrl(Item & item);
long GetContentId(long item_id);
PGresult * GetItemsQuery(const DbItemQuery & iq, bool skip_other_sel = false);
bool DelItemDelItem(const Item & item);
void DelItemDelContent(const Item & item);
Error DelItemCountContents(const Item & item, long & contents);
Error DelItemDelItem(const Item & item);
Error DelItemDelContent(const Item & item);
Error IncrementContentRef(long content_id);
Error DecrementContentRef(long content_id);
};

View File

@@ -346,6 +346,29 @@ size_t buffer_len = sizeof(buffer) / sizeof(wchar_t);
Error DbBase::DoCommand(const DbTextStream & command)
{
PGresult * r = 0;
Error status = WINIX_ERR_OK;
try
{
r = AssertQuery(command);
AssertResult(r, PGRES_COMMAND_OK);
}
catch(const Error & e)
{
status = e;
}
ClearResult(r);
return status;
}
Error DbBase::DoCommand(const char * command)
{
PGresult * r = 0;
@@ -353,9 +376,7 @@ Error DbBase::DoCommand(const char * command)
try
{
bquery.Clear();
bquery << R(command);
r = AssertQuery(bquery);
r = AssertQuery(command);
AssertResult(r, PGRES_COMMAND_OK);
}
catch(const Error & e)
@@ -391,4 +412,18 @@ Error DbBase::CommitTrans()
Error DbBase::EndTrans(Error err)
{
if( err == WINIX_ERR_OK )
{
err = CommitTrans();
}
else
{
// we returned the old err code
RollbackTrans();
}
return err;
}

View File

@@ -58,10 +58,12 @@ public:
static const char * ConvertTime(const tm & t); // warning: it uses its own static buffer
void CreateIdList(const std::vector<long> & id_tab, std::wstring & list, bool add_parentheses = true);
Error DoCommand(const DbTextStream & command);
Error DoCommand(const char * command);
Error BeginTrans();
Error RollbackTrans();
Error CommitTrans();
Error EndTrans(Error err);
protected:

View File

@@ -25,7 +25,8 @@ void DbItemColumns::SetColumns(PGresult * r)
type = PQfnumber(r, "type");
parent_id = PQfnumber(r, "parent_id");
content_id = PQfnumber(r, "content_id");
default_item = PQfnumber(r, "default_item");
link_to = PQfnumber(r, "link_to");
link_redirect = PQfnumber(r, "link_redirect");
subject = PQfnumber(r, "subject");
content = PQfnumber(r, "content");
content_type = PQfnumber(r, "content_type");
@@ -36,6 +37,8 @@ void DbItemColumns::SetColumns(PGresult * r)
file_fs = PQfnumber(r, "file_fs");
file_type = PQfnumber(r, "file_type");
has_thumb = PQfnumber(r, "has_thumb");
ref = PQfnumber(r, "ref");
modify_index = PQfnumber(r, "modify_index");
}
@@ -48,21 +51,25 @@ void DbItemColumns::SetItem(PGresult * r, long row, Item & item)
if( privileges != -1 ) item.privileges = DbBase::AssertValueInt(r, row, privileges);
if( date_creation != -1 ) item.date_creation = DbBase::AssertValueTm(r, row, date_creation);
if( date_modification != -1 ) item.date_modification = DbBase::AssertValueTm(r, row, date_modification);
if( url != -1 ) item.url = DbBase::AssertValueWide(r, row, url);
if( type != -1 ) item.type = static_cast<Item::Type>( DbBase::AssertValueInt(r, row, type) );
if( parent_id != -1 ) item.parent_id = DbBase::AssertValueLong(r, row, parent_id);
if( content_id != -1 ) item.content_id = DbBase::AssertValueLong(r, row, content_id);
if( default_item != -1 ) item.default_item = DbBase::AssertValueLong(r, row, default_item);
if( subject != -1 ) item.subject = DbBase::AssertValueWide(r, row, subject);
if( content != -1 ) item.content = DbBase::AssertValueWide(r, row, content);
if( link_redirect != -1 ) item.link_redirect = DbBase::AssertValueInt(r, row, link_redirect);
if( content_type != -1 ) item.content_type = static_cast<Item::ContentType>( DbBase::AssertValueInt(r, row, content_type) );
if( guest_name != -1 ) item.guest_name = DbBase::AssertValueWide(r, row, guest_name);
if( html_template != -1 ) item.html_template = DbBase::AssertValueWide(r, row, html_template);
if( modification_user_id != -1 ) item.modification_user_id = DbBase::AssertValueLong(r, row, modification_user_id);
if( file_path != -1 ) item.file_path = DbBase::AssertValueWide(r, row, file_path);
if( file_fs != -1 ) item.file_fs = DbBase::AssertValueInt(r, row, file_fs);
if( file_type != -1 ) item.file_type = DbBase::AssertValueInt(r, row, file_type);
if( has_thumb != -1 ) item.has_thumb = DbBase::AssertValueBool(r, row, has_thumb);
if( ref != -1 ) item.ref = DbBase::AssertValueInt(r, row, ref);
if( modify_index != -1 ) item.modify_index = DbBase::AssertValueInt(r, row, modify_index);
if( url != -1 ) DbBase::AssertValueWide(r, row, url, item.url);
if( content != -1 ) DbBase::AssertValueWide(r, row, content, item.content);
if( subject != -1 ) DbBase::AssertValueWide(r, row, subject, item.subject);
if( file_path != -1 ) DbBase::AssertValueWide(r, row, file_path, item.file_path);
if( link_to != -1 ) DbBase::AssertValueWide(r, row, link_to, item.link_to);
if( guest_name != -1 ) DbBase::AssertValueWide(r, row, guest_name, item.guest_name);
if( html_template != -1 ) DbBase::AssertValueWide(r, row, html_template, item.html_template);
}

View File

@@ -29,7 +29,8 @@ struct DbItemColumns
int type;
int parent_id;
int content_id;
int default_item;
int link_to;
int link_redirect;
int subject;
int content;
int content_type;
@@ -40,6 +41,8 @@ struct DbItemColumns
int file_fs;
int file_type;
int has_thumb;
int ref;
int modify_index;
void SetColumns(PGresult * r);
void SetItem(PGresult * r, long row, Item & item);

View File

@@ -12,10 +12,10 @@
DbItemQuery::DbItemQuery()
{
sort_asc = true;
file_type_equal = true;
SetAll(true, false);
@@ -24,6 +24,9 @@ DbItemQuery::DbItemQuery()
type = Item::none;
file_type = WINIX_ITEM_FILETYPE_NONE;
type_equal = true;
file_type_equal = true;
limit = 0; // limit and offset not used by default
offset = 0;
}
@@ -42,7 +45,7 @@ void DbItemQuery::SetAllSel(bool sel)
sel_content = sel;
sel_url = sel;
sel_type = sel;
sel_default_item = sel;
sel_link = sel;
sel_file = sel;
sel_html_template = sel;
}
@@ -83,10 +86,11 @@ void DbItemQuery::WhereParentId(long parent_id_)
void DbItemQuery::WhereType(Item::Type type_)
void DbItemQuery::WhereType(Item::Type type_, bool equal)
{
where_type = true;
type = type_;
type_equal = equal;
}

View File

@@ -18,7 +18,7 @@
struct DbItemQuery
{
// id is selected always
// id and content_id is selected always
bool sel_parent_id; // parent_id
bool sel_user_id; // user_id, modification_user_id
bool sel_group_id; // group_id
@@ -26,10 +26,10 @@ struct DbItemQuery
bool sel_privileges; // privileges
bool sel_date; // date_creation, date_modification
bool sel_subject; // subject
bool sel_content; // content, content_type, (content_id)
bool sel_content; // content, content_type, ref, modify_index
bool sel_url; // url
bool sel_type; // type (dir, file, none)
bool sel_default_item; // default_item
bool sel_link; // link_to, link_redirect
bool sel_file; // file_path, file_fs, file_type, has_thumb
bool sel_html_template; // template
@@ -41,6 +41,7 @@ struct DbItemQuery
long id; // if where_id is true
long parent_id; // if where_parent_id is true
Item::Type type;
bool type_equal;
int file_type;
bool file_type_equal; // if true means file_type should be equal
bool sort_asc;
@@ -56,7 +57,7 @@ struct DbItemQuery
void WhereId(long id_);
void WhereParentId(long parent_id_);
void WhereType(Item::Type type_);
void WhereType(Item::Type type_, bool equal = true);
void WhereFileType(int file_t, bool equal = true);
void Limit(long l); // setting 0 turns off