added: now plugin ticket uses a new horizontal table (plugins.ticket)

columns: dir_id, param, value
we are able to build complicated tickets 



git-svn-id: svn://ttmath.org/publicrep/winix/trunk@664 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2010-10-19 00:31:20 +00:00
parent 33057acd62
commit 1b053c03ba
53 changed files with 1680 additions and 1902 deletions

View File

@@ -1,15 +1,16 @@
# DO NOT DELETE
db.o: db.h dbbase.h dbconn.h dbtextstream.h ../core/textstream.h
db.o: dbitemquery.h ../core/item.h dbitemcolumns.h ../core/user.h
db.o: ../core/group.h ../core/thread.h ../core/error.h ../core/log.h
db.o: ../core/error.h ../core/log.h dbitemquery.h ../core/item.h
db.o: dbitemcolumns.h ../core/user.h ../core/group.h ../core/thread.h
db.o: ../core/dircontainer.h ../core/item.h ../core/ugcontainer.h
db.o: ../core/log.h ../core/misc.h
dbbase.o: dbbase.h dbconn.h dbtextstream.h ../core/textstream.h ../core/log.h
dbbase.o: ../core/error.h ../core/log.h
dbbase.o: dbbase.h dbconn.h dbtextstream.h ../core/textstream.h
dbbase.o: ../core/error.h ../core/log.h ../core/log.h
dbconn.o: dbconn.h dbtextstream.h ../core/textstream.h ../core/log.h
dbconn.o: ../core/error.h ../core/log.h
dbitemcolumns.o: dbitemcolumns.h ../core/item.h dbbase.h dbconn.h
dbitemcolumns.o: dbtextstream.h ../core/textstream.h
dbitemcolumns.o: dbtextstream.h ../core/textstream.h ../core/error.h
dbitemcolumns.o: ../core/log.h
dbitemquery.o: dbitemquery.h ../core/item.h
dbtextstream.o: dbtextstream.h ../core/textstream.h

View File

@@ -659,13 +659,20 @@ PGresult * Db::GetItemsQuery(const DbItemQuery & iq, bool skip_other_sel)
}
}
query << R(" order by item.date_creation");
if( iq.sort_asc )
query << R(" asc;");
query << R(" asc");
else
query << R(" desc;");
query << R(" desc");
if( iq.limit != 0 )
query << R(" limit ") << iq.limit;
if( iq.offset != 0 )
query << R(" offset ") << iq.offset;
query << R(";");
return AssertQuery(query);
}
@@ -875,6 +882,7 @@ return result;
long Db::GetItemId(long parent_id, const std::string & url, Item::Type type)
{
PGresult * r = 0;

View File

@@ -24,7 +24,6 @@
#include "core/user.h"
#include "core/group.h"
#include "core/thread.h"
#include "core/error.h"
#include "core/dircontainer.h"
#include "core/ugcontainer.h"
@@ -52,7 +51,7 @@ public:
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);

View File

@@ -300,7 +300,72 @@ return buffer;
void DbBase::CreateIdList(const std::vector<long> & id_tab, std::string & list, bool add_parentheses)
{
char buffer[50];
list.clear();
if( add_parentheses )
list += '(';
for(size_t i=0 ; i<id_tab.size() ; ++i)
{
sprintf(buffer, "%lu", (unsigned long)id_tab[i]);
list += buffer;
if( i+1 < id_tab.size() )
list += ',';
}
if( add_parentheses )
list += ')';
}
Error DbBase::DoCommand(const char * command)
{
PGresult * r = 0;
Error status = WINIX_ERR_OK;
try
{
bquery.Clear();
bquery << R(command);
r = AssertQuery(bquery);
AssertResult(r, PGRES_COMMAND_OK);
}
catch(const Error & e)
{
status = e;
}
ClearResult(r);
return status;
}
Error DbBase::BeginTrans()
{
return DoCommand("BEGIN;");
}
Error DbBase::RollbackTrans()
{
return DoCommand("ROLLBACK;");
}
Error DbBase::CommitTrans()
{
return DoCommand("COMMIT;");
}

View File

@@ -13,6 +13,9 @@
#include "dbconn.h"
#include "dbtextstream.h"
#include <vector>
#include <string>
#include "core/error.h"
class DbBase
@@ -50,6 +53,12 @@ public:
static tm ConvertTime(const char * str);
static const char * ConvertTime(const tm & t); // warning: it uses its own static buffer
void CreateIdList(const std::vector<long> & id_tab, std::string & list, bool add_parentheses = true);
Error DoCommand(const char * command);
Error BeginTrans();
Error RollbackTrans();
Error CommitTrans();
protected:

View File

@@ -23,6 +23,9 @@ DbItemQuery::DbItemQuery()
parent_id = -1;
type = Item::none;
auth = Item::auth_none;
limit = 0; // limit and offset not used by default
offset = 0;
}
@@ -95,3 +98,15 @@ void DbItemQuery::WhereAuth(Item::Auth st, bool equal)
auth_equal = equal;
}
void DbItemQuery::Limit(long l)
{
limit = l;
}
void DbItemQuery::Offset(long o)
{
offset = o;
}

View File

@@ -45,6 +45,8 @@ struct DbItemQuery
bool auth_equal; // if true means auth should be equal
bool sort_asc;
long limit;
long offset;
DbItemQuery();
@@ -56,6 +58,9 @@ struct DbItemQuery
void WhereParentId(long parent_id_);
void WhereType(Item::Type type_);
void WhereAuth(Item::Auth st, bool equal = true);
void Limit(long l); // setting 0 turns off
void Offset(long o); // setting 0 turns off
};