fixed: find_ticket_value (in plugins/ticket/templates.cpp)
should find the first item (can be more than one item with the same 'param') fixed: added sorting tickets params in ReadTicketParams() (in plugins/ticket/ticketinfo.cpp) fixed: plugin should have its own 'PluginInfo info' struct a plugin's function can call another plugin's functions added: removing tickets files/images added: removing threads changed: rm function will call WINIX_FILE_REMOVED now when deleting directories git-svn-id: svn://ttmath.org/publicrep/winix/trunk@710 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
50
db/db.cpp
50
db/db.cpp
@@ -433,9 +433,8 @@ long Db::GetContentId(long item_id)
|
||||
if( Rows(r) == 1 && Cols(r) == 1 )
|
||||
result = AssertValueLong(r, 0, 0);
|
||||
}
|
||||
catch(const Error & e)
|
||||
catch(const Error)
|
||||
{
|
||||
result = e;
|
||||
}
|
||||
|
||||
ClearResult(r);
|
||||
@@ -1204,16 +1203,18 @@ return EndTrans(result);
|
||||
|
||||
|
||||
|
||||
Error Db::DelItemDelItem(const Item & item)
|
||||
Error Db::DelItemDelItem(long item_id, int type)
|
||||
{
|
||||
PGresult * r = 0;
|
||||
PGresult * r = 0;
|
||||
Error result = WINIX_ERR_OK;
|
||||
|
||||
try
|
||||
{
|
||||
query.Clear();
|
||||
query << R("delete from core.item where id=")
|
||||
<< item.id
|
||||
<< item_id
|
||||
<< R(" and type=")
|
||||
<< type
|
||||
<< R(";");
|
||||
|
||||
r = AssertQuery(query);
|
||||
@@ -1234,20 +1235,20 @@ return result;
|
||||
|
||||
|
||||
|
||||
Error Db::DelItemDelContent(const Item & item)
|
||||
Error Db::DelItemDelContent(long content_id)
|
||||
{
|
||||
PGresult * r = 0;
|
||||
Error result = WINIX_ERR_OK;
|
||||
|
||||
try
|
||||
{
|
||||
result = DecrementContentRef(item.content_id);
|
||||
result = DecrementContentRef(content_id);
|
||||
|
||||
if( result == WINIX_ERR_OK )
|
||||
{
|
||||
query.Clear();
|
||||
query << R("delete from core.content where ref=0 and id=")
|
||||
<< item.content_id
|
||||
<< content_id
|
||||
<< R(";");
|
||||
|
||||
r = AssertQuery(query);
|
||||
@@ -1278,17 +1279,17 @@ Error result = WINIX_ERR_NO_ITEM;
|
||||
if( item.type == Item::file )
|
||||
{
|
||||
BeginTrans();
|
||||
result = DelItemDelContent(item);
|
||||
result = DelItemDelContent(item.content_id);
|
||||
|
||||
if( result == WINIX_ERR_OK )
|
||||
result = DelItemDelItem(item);
|
||||
result = DelItemDelItem(item.id, 1);
|
||||
|
||||
result = EndTrans(result);
|
||||
}
|
||||
else
|
||||
if( item.type == Item::symlink )
|
||||
{
|
||||
result = DelItemDelItem(item);
|
||||
result = DelItemDelItem(item.id, 2);
|
||||
}
|
||||
else
|
||||
if( item.type == Item::dir )
|
||||
@@ -1302,6 +1303,33 @@ return result;
|
||||
|
||||
|
||||
|
||||
Error Db::DelFileById(long file_id)
|
||||
{
|
||||
Error result = WINIX_ERR_NO_ITEM;
|
||||
|
||||
BeginTrans();
|
||||
|
||||
long content_id = GetContentId(file_id);
|
||||
|
||||
if( content_id != -1 )
|
||||
{
|
||||
result = DelItemDelContent(content_id);
|
||||
|
||||
if( result == WINIX_ERR_OK )
|
||||
result = DelItemDelItem(file_id, 1);
|
||||
}
|
||||
|
||||
result = EndTrans(result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Error Db::DelSymlinkById(long symlink_id)
|
||||
{
|
||||
return DelItemDelItem(symlink_id, 2);
|
||||
}
|
||||
|
||||
|
||||
void Db::GetDirs(DirContainer & dir_tab)
|
||||
|
7
db/db.h
7
db/db.h
@@ -60,7 +60,10 @@ public:
|
||||
Error EditParentUrlById(Item & item, long id);
|
||||
Error EditFileById(const Item & item, long id); // file_path, file_fs, file_type
|
||||
Error EditHasThumbById(bool has_thumb, long id);
|
||||
|
||||
Error DelDirById(long id);
|
||||
Error DelFileById(long file_id);
|
||||
Error DelSymlinkById(long symlink_id);
|
||||
|
||||
Error EditSubjectById(Item & item, long id);
|
||||
|
||||
@@ -106,8 +109,8 @@ protected:
|
||||
|
||||
PGresult * GetItemsQuery(const DbItemQuery & iq, bool skip_other_sel = false);
|
||||
|
||||
Error DelItemDelItem(const Item & item);
|
||||
Error DelItemDelContent(const Item & item);
|
||||
Error DelItemDelItem(long item_id, int type);
|
||||
Error DelItemDelContent(long content_id);
|
||||
|
||||
Error IncrementContentRef(long content_id);
|
||||
Error DecrementContentRef(long content_id);
|
||||
|
@@ -422,7 +422,7 @@ Error DbBase::EndTrans(Error err)
|
||||
}
|
||||
else
|
||||
{
|
||||
// we returned the old err code
|
||||
// we return the old err code
|
||||
RollbackTrans();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user