added: to the Item: auth_path - a path to a static file (if auth is different from auth_none)
added: function 'mv' (move) git-svn-id: svn://ttmath.org/publicrep/winix/trunk@596 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
94
core/db.cpp
94
core/db.cpp
@@ -301,7 +301,8 @@ return status;
|
||||
|
||||
|
||||
|
||||
|
||||
//!! wywalic z nazwy 'Subject' nic nie jest robione z tytulem
|
||||
// ta metoda uzywana tez jest w EditParentUrlById()
|
||||
bool Db::AddItemCreateUrlSubject(Item & item)
|
||||
{
|
||||
bool is_that_url;
|
||||
@@ -455,7 +456,7 @@ Error Db::AddItemIntoItem(Item & item)
|
||||
AssertConnection();
|
||||
std::ostringstream query;
|
||||
query << "insert into core.item (user_id, group_id, privileges, date_creation, date_modification, type, "
|
||||
"parent_id, content_id, auth, default_item, subject, guest_name, url) values (";
|
||||
"parent_id, content_id, auth, auth_path, default_item, subject, guest_name, url) values (";
|
||||
query << '\'' << item.user_id << "', ";
|
||||
query << '\'' << item.group_id << "', ";
|
||||
query << '\'' << item.privileges << "', ";
|
||||
@@ -464,7 +465,8 @@ Error Db::AddItemIntoItem(Item & item)
|
||||
query << '\'' << static_cast<int>(item.type) << "', ";
|
||||
query << '\'' << item.parent_id << "', ";
|
||||
query << '\'' << item.content_id << "', ";
|
||||
query << '\'' << static_cast<int>(item.auth) << "', ";
|
||||
query << '\'' << static_cast<int>(item.auth) << "', ";
|
||||
query << '\'' << Escape(item.auth_path) << "', ";
|
||||
query << '\'' << item.default_item << "', ";
|
||||
query << '\'' << Escape(item.subject) << "', ";
|
||||
query << '\'' << Escape(item.guest_name) << "', ";
|
||||
@@ -561,7 +563,7 @@ Error Db::EditItemInItem(Item & item, bool with_url)
|
||||
AssertConnection();
|
||||
std::ostringstream query;
|
||||
query << "update core.item set (user_id, group_id, privileges, date_creation, date_modification, type, "
|
||||
"default_item, parent_id, subject, guest_name, auth";
|
||||
"default_item, parent_id, subject, guest_name, auth, auth_path";
|
||||
|
||||
if( with_url )
|
||||
query << ", url";
|
||||
@@ -577,7 +579,8 @@ Error Db::EditItemInItem(Item & item, bool with_url)
|
||||
query << '\'' << item.parent_id << "', ";
|
||||
query << '\'' << Escape(item.subject) << "', ";
|
||||
query << '\'' << Escape(item.guest_name) << "', ";
|
||||
query << '\'' << static_cast<int>(item.auth) << "' ";
|
||||
query << '\'' << static_cast<int>(item.auth) << "', ";
|
||||
query << '\'' << Escape(item.auth_path) << "' ";
|
||||
|
||||
if( with_url )
|
||||
{
|
||||
@@ -802,7 +805,7 @@ PGresult * Db::GetItemsQuery(const ItemQuery & iq)
|
||||
if( iq.sel_url ) query << " ,url";
|
||||
if( iq.sel_type ) query << " ,type";
|
||||
if( iq.sel_default_item ) query << " ,default_item";
|
||||
if( iq.sel_auth ) query << " ,auth";
|
||||
if( iq.sel_auth ) query << " ,auth, auth_path";
|
||||
|
||||
query << " from core.item";
|
||||
|
||||
@@ -818,7 +821,19 @@ PGresult * Db::GetItemsQuery(const ItemQuery & iq)
|
||||
if( iq.where_id ) { query << if_and << "id='" << iq.id << "'" ; if_and = add_and; }
|
||||
if( iq.where_parent_id ) { query << if_and << "parent_id='" << iq.parent_id << "'" ; if_and = add_and; }
|
||||
if( iq.where_type ) { query << if_and << "type='" << static_cast<int>(iq.type) << "'" ; if_and = add_and; }
|
||||
if( iq.where_auth ) { query << if_and << "auth='" << static_cast<int>(iq.auth) << "'" ; if_and = add_and; }
|
||||
|
||||
if( iq.where_auth )
|
||||
{
|
||||
query << if_and << "auth";
|
||||
|
||||
if(iq.auth_equal )
|
||||
query << "=";
|
||||
else
|
||||
query << "!=";
|
||||
|
||||
query << "'" << static_cast<int>(iq.auth) << "'";
|
||||
if_and = add_and;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1138,6 +1153,71 @@ return result;
|
||||
|
||||
|
||||
|
||||
Error Db::EditParentUrlById(Item & item, long id)
|
||||
{
|
||||
PGresult * r = 0;
|
||||
Error result = WINIX_ERR_OK;
|
||||
bool url_without_id = false;
|
||||
|
||||
try
|
||||
{
|
||||
AssertConnection();
|
||||
std::ostringstream query;
|
||||
query << "update core.item set (parent_id, url) = (";
|
||||
query << '\'' << item.parent_id << "', ";
|
||||
|
||||
url_without_id = AddItemCreateUrlSubject(item);
|
||||
|
||||
if( url_without_id )
|
||||
query << '\'' << Escape(item.url) << "'";
|
||||
else
|
||||
query << '\'' << item.id << "'"; ;
|
||||
|
||||
query << ") where id='" << id << "';";
|
||||
|
||||
r = AssertQuery(query.str());
|
||||
AssertResultStatus(r, PGRES_COMMAND_OK);
|
||||
}
|
||||
catch(const Error & e)
|
||||
{
|
||||
result = e;
|
||||
}
|
||||
|
||||
ClearResult(r);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Error Db::EditAuthById(Item & item, long id)
|
||||
{
|
||||
PGresult * r = 0;
|
||||
Error result = WINIX_ERR_OK;
|
||||
|
||||
try
|
||||
{
|
||||
AssertConnection();
|
||||
std::ostringstream query;
|
||||
query << "update core.item set (auth, auth_path) = (";
|
||||
query << '\'' << static_cast<int>(item.auth) << "', ";
|
||||
query << '\'' << Escape(item.auth_path) << "') ";
|
||||
query << " where id='" << id << "';";
|
||||
|
||||
r = AssertQuery(query.str());
|
||||
AssertResultStatus(r, PGRES_COMMAND_OK);
|
||||
}
|
||||
catch(const Error & e)
|
||||
{
|
||||
result = e;
|
||||
}
|
||||
|
||||
ClearResult(r);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Error Db::DelDirById(long id)
|
||||
{
|
||||
Error result = WINIX_ERR_OK;
|
||||
|
||||
Reference in New Issue
Block a user