added: 'rm' function can work with tickets

git-svn-id: svn://ttmath.org/publicrep/winix/trunk@565 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2010-02-06 14:08:44 +00:00
parent ed9feaf542
commit 0e50977779
16 changed files with 137 additions and 38 deletions

View File

@@ -1103,6 +1103,7 @@ Error Db::DelDirById(long id)
AssertConnection();
std::ostringstream query, query2;
// !! trzeba poprawic to usuwanie gdy beda hard linki
query << "delete from core.content where content.id in (select content_id from core.item where parent_id='" << id << "');";
r = AssertQuery( query.str() );
AssertResultStatus(r, PGRES_COMMAND_OK);
@@ -1226,7 +1227,7 @@ Error Db::DelItemCountContents(const Item & item, long & contents)
contents = atol( AssertValue(r, 0, 0) );
log << log1 << "counters: " << contents << logend; // !!
log << log2 << "counters: " << contents << logend; // !! nie potrzebne w logach
}
catch(const Error & e)
{
@@ -1909,3 +1910,61 @@ Error Db::EditTicketById(Ticket & ticket)
return status;
}
Error Db::EditTicketRemoveItem(long item_id)
{
PGresult * r = 0;
Error status = Error::ok;
try
{
AssertConnection();
std::ostringstream query;
query << "update core.ticket set item_id = '-1' where item_id='" << item_id << "';";
r = AssertQuery(query.str());
AssertResultStatus(r, PGRES_COMMAND_OK);
}
catch(const Error & e)
{
status = e;
}
ClearResult(r);
return status;
}
Error Db::RemoveTicket(long dir_id)
{
PGresult * r = 0;
Error status = Error::ok;
try
{
AssertConnection();
std::ostringstream query;
query << "delete from core.ticket where dir_id='" << dir_id << "';";
const char * crows = PQcmdTuples(r);
if( crows )
log << log2 << "Db: deleted " << atol(crows) << " rows from core.ticket" << logend;
r = AssertQuery(query.str());
AssertResultStatus(r, PGRES_COMMAND_OK);
}
catch(const Error & e)
{
status = e;
}
ClearResult(r);
return status;
}

View File

@@ -96,6 +96,8 @@ public:
//bool IsTicket(long dir_id);
Error AddTicket(Ticket & ticket);
Error EditTicketById(Ticket & ticket);
Error EditTicketRemoveItem(long item_id);
Error RemoveTicket(long dir_id);
protected:

View File

@@ -271,6 +271,7 @@ void Dirs::DeleteDir(long id)
dir_table.DelById(id);
db.RemoveThread(id);
db.RemoveTicket(id);
}

View File

@@ -65,7 +65,6 @@ long default_item;
// used by the database
// !! moze da sie w ogole z tego zrezygnowac?
long content_id;

View File

@@ -41,7 +41,7 @@ void Session::Clear()
new_session = true;
spam_score = 0;
dir_old.clear();
// dir_old.clear();
}

View File

@@ -60,7 +60,7 @@ struct Session
Rebus::Item * rebus_item;
bool rebus_checked;
std::string dir_old;
//std::string dir_old;
int spam_score;