changed organization of static files

removed: item.auth item.auth_path
added:   item.file_path, item.file_fs, item.file_type
now the path to a static file is a relative path
added: thumbnails (not finished yet)
fixed: db didn't correctly return the number of deleted items /DelItem() method/




git-svn-id: svn://ttmath.org/publicrep/winix/trunk@696 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2010-12-10 21:07:01 +00:00
parent 9b29cce1a4
commit 36c8822e6c
41 changed files with 435 additions and 364 deletions

View File

@@ -239,7 +239,7 @@ Error Db::AddItemIntoItem(Item & item)
{
query.Clear();
query << R("insert into core.item (user_id, modification_user_id, group_id, privileges, "
"date_creation, date_modification, type, parent_id, content_id, auth, auth_path, "
"date_creation, date_modification, type, parent_id, content_id, file_path, file_fs, file_type, "
"default_item, subject, guest_name, template, url) values (")
<< item.user_id
<< item.modification_user_id
@@ -250,8 +250,9 @@ Error Db::AddItemIntoItem(Item & item)
<< static_cast<int>(item.type)
<< item.parent_id
<< item.content_id
<< static_cast<int>(item.auth)
<< item.auth_path
<< item.file_path
<< item.file_fs
<< item.file_type
<< item.default_item
<< item.subject
<< item.guest_name
@@ -346,7 +347,7 @@ Error Db::EditItemInItem(Item & item, bool with_url)
query.Clear();
query << R("update core.item set (user_id, modification_user_id, group_id, privileges, "
"date_creation, date_modification, type, default_item, parent_id, subject, "
"guest_name, auth, auth_path, template");
"guest_name, file_path, file_fs, file_type, template");
if( with_url )
query << R(", url");
@@ -363,8 +364,9 @@ Error Db::EditItemInItem(Item & item, bool with_url)
<< item.parent_id
<< item.subject
<< item.guest_name
<< static_cast<int>(item.auth)
<< item.auth_path
<< item.file_path
<< item.file_fs
<< item.file_type
<< item.html_template;
if( with_url )
@@ -626,7 +628,7 @@ PGresult * Db::GetItemsQuery(const DbItemQuery & iq, bool skip_other_sel)
if( iq.sel_url ) query << R(" ,url");
if( iq.sel_type ) query << R(" ,type");
if( iq.sel_default_item ) query << R(" ,default_item");
if( iq.sel_auth ) query << R(" ,auth, auth_path");
if( iq.sel_file ) query << R(" ,file_path, file_fs, file_type");
if( iq.sel_html_template ) query << R(" ,template");
}
@@ -635,7 +637,7 @@ PGresult * Db::GetItemsQuery(const DbItemQuery & iq, bool skip_other_sel)
if( iq.sel_content )
query << R(" left join core.content on item.content_id = content.id");
if( iq.where_id || iq.where_parent_id || iq.where_type || iq.where_auth )
if( iq.where_id || iq.where_parent_id || iq.where_type || iq.where_file_type )
{
query << R(" where ");
const char * add_and = " and ";
@@ -645,16 +647,16 @@ PGresult * Db::GetItemsQuery(const DbItemQuery & iq, bool skip_other_sel)
if( iq.where_parent_id ){ query << R(if_and) << R("parent_id=") << iq.parent_id ; if_and = add_and; }
if( iq.where_type ) { query << R(if_and) << R("type=") << int(iq.type) ; if_and = add_and; }
if( iq.where_auth )
if( iq.where_file_type )
{
query << R(if_and) << R("auth");
query << R(if_and) << R("file_type");
if( iq.auth_equal )
if( iq.file_type_equal )
query << R("=");
else
query << R("!=");
query << static_cast<int>(iq.auth);
query << iq.file_type;
if_and = add_and;
}
}
@@ -1038,7 +1040,7 @@ return result;
Error Db::EditAuthById(Item & item, long id)
Error Db::EditFileById(Item & item, long id)
{
PGresult * r = 0;
Error result = WINIX_ERR_OK;
@@ -1046,12 +1048,11 @@ Error Db::EditAuthById(Item & item, long id)
try
{
query.Clear();
query << R("update core.item set (auth, auth_path) = (")
<< static_cast<int>(item.auth)
<< item.auth_path
<< R(") where id=")
<< id
<< R(";");
query << R("update core.item set (file_path, file_fs, file_type) = (")
<< item.file_path
<< item.file_fs
<< item.file_type
<< R(") where id=") << id << R(";");
r = AssertQuery(query);
AssertResult(r, PGRES_COMMAND_OK);
@@ -1142,8 +1143,8 @@ return result;
bool Db::DelItemDelItem(const Item & item)
{
long rows = 0;
PGresult * r = 0;
long affected = 0;
PGresult * r = 0;
try
{
@@ -1155,7 +1156,7 @@ bool Db::DelItemDelItem(const Item & item)
r = AssertQuery(query);
AssertResult(r, PGRES_COMMAND_OK);
long affected = AffectedRows(r);
affected = AffectedRows(r);
if( affected > 1 )
log << log1 << "Db: more than one item were deleted" << logend;
@@ -1169,7 +1170,7 @@ bool Db::DelItemDelItem(const Item & item)
ClearResult(r);
return rows != 0;
return affected != 0;
}
@@ -1240,9 +1241,9 @@ return result;
bool Db::DelItem(const Item & item)
{
long contents;
Error result = DelItemCountContents(item, contents);
if( result == WINIX_ERR_OK && contents == 1 )
DelItemDelContent(item);