2009-01-31 07:53:36 +01:00
|
|
|
/*
|
2010-02-28 01:08:10 +01:00
|
|
|
* This file is a part of Winix
|
2009-01-31 07:53:36 +01:00
|
|
|
* and is not publicly distributed
|
|
|
|
*
|
2010-02-28 22:33:06 +01:00
|
|
|
* Copyright (c) 2008-2010, Tomasz Sowa
|
2009-01-31 07:53:36 +01:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2008-12-21 22:17:09 +01:00
|
|
|
#include "db.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-12-14 06:28:28 +01:00
|
|
|
void Db::ItemColumns::SetColumns(PGresult * r)
|
|
|
|
{
|
|
|
|
// PQfnumber returns -1 if there is no such a column
|
2009-03-23 00:54:15 +01:00
|
|
|
id = PQfnumber(r, "id");
|
|
|
|
user_id = PQfnumber(r, "user_id");
|
|
|
|
group_id = PQfnumber(r, "group_id");
|
|
|
|
privileges = PQfnumber(r, "privileges");
|
|
|
|
date_creation = PQfnumber(r, "date_creation");
|
|
|
|
date_modification = PQfnumber(r, "date_modification");
|
|
|
|
url = PQfnumber(r, "url");
|
|
|
|
type = PQfnumber(r, "type");
|
|
|
|
parent_id = PQfnumber(r, "parent_id");
|
|
|
|
content_id = PQfnumber(r, "content_id");
|
|
|
|
default_item = PQfnumber(r, "default_item");
|
|
|
|
subject = PQfnumber(r, "subject");
|
|
|
|
content = PQfnumber(r, "content");
|
|
|
|
content_type = PQfnumber(r, "content_type");
|
2009-06-07 04:40:27 +02:00
|
|
|
guest_name = PQfnumber(r, "guest_name");
|
2010-03-15 02:47:26 +01:00
|
|
|
auth = PQfnumber(r, "auth");
|
|
|
|
auth_path = PQfnumber(r, "auth_path");
|
2010-06-22 23:09:37 +02:00
|
|
|
modification_user_id = PQfnumber(r, "modification_user_id");
|
2008-12-14 06:28:28 +01:00
|
|
|
}
|
2008-12-21 22:17:09 +01:00
|
|
|
|
2008-12-14 06:28:28 +01:00
|
|
|
|
|
|
|
|
|
|
|
void Db::ItemColumns::SetItem(PGresult * r, long row, Item & item)
|
|
|
|
{
|
2009-03-23 00:54:15 +01:00
|
|
|
if( id != -1 ) item.id = atol( Db::AssertValue(r, row, id) );
|
|
|
|
if( user_id != -1 ) item.user_id = atol( Db::AssertValue(r, row, user_id) );
|
|
|
|
if( group_id != -1 ) item.group_id = atol( Db::AssertValue(r, row, group_id) );
|
|
|
|
if( privileges != -1 ) item.privileges = atoi( Db::AssertValue(r, row, privileges) );
|
|
|
|
if( date_creation != -1 ) item.date_creation = ConvertTime( Db::AssertValue(r, row, date_creation) );
|
|
|
|
if( date_modification != -1 ) item.date_modification = ConvertTime( Db::AssertValue(r, row, date_modification) );
|
|
|
|
if( url != -1 ) item.url = Db::AssertValue(r, row, url);
|
2009-12-30 21:46:12 +01:00
|
|
|
if( type != -1 ) item.type = static_cast<Item::Type>( atoi(Db::AssertValue(r, row, type)) );
|
2009-03-23 00:54:15 +01:00
|
|
|
if( parent_id != -1 ) item.parent_id = atol( Db::AssertValue(r, row, parent_id) );
|
|
|
|
if( content_id != -1 ) item.content_id = atol( Db::AssertValue(r, row, content_id) );
|
|
|
|
if( default_item != -1 ) item.default_item = atol( Db::AssertValue(r, row, default_item) );
|
|
|
|
if( subject != -1 ) item.subject = Db::AssertValue(r, row, subject);
|
|
|
|
if( content != -1 ) item.content = Db::AssertValue(r, row, content);
|
2010-01-11 15:47:52 +01:00
|
|
|
if( content_type != -1 ) item.content_type = static_cast<Item::ContentType>( atoi(Db::AssertValue(r, row, content_type)) );
|
2009-06-07 04:40:27 +02:00
|
|
|
if( guest_name != -1 ) item.guest_name = Db::AssertValue(r, row, guest_name);
|
2010-02-22 23:52:09 +01:00
|
|
|
if( auth != -1 ) item.auth = static_cast<Item::Auth>( atoi(Db::AssertValue(r, row, auth)) );
|
2010-03-15 02:47:26 +01:00
|
|
|
if( auth_path != -1 ) item.auth_path = Db::AssertValue(r, row, auth_path);
|
2010-06-22 23:09:37 +02:00
|
|
|
if( modification_user_id != -1 ) item.modification_user_id = atol( Db::AssertValue(r, row, modification_user_id) );
|
2008-12-14 06:28:28 +01:00
|
|
|
}
|
2008-12-21 22:17:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-01-25 05:52:17 +01:00
|
|
|
void Db::TicketColumns::SetColumns(PGresult * r)
|
|
|
|
{
|
|
|
|
// PQfnumber returns -1 if there is no such a column
|
|
|
|
id = PQfnumber(r, "id");
|
|
|
|
dir_id = PQfnumber(r, "dir_id");
|
|
|
|
parent_id = PQfnumber(r, "parent_id");
|
|
|
|
type = PQfnumber(r, "type");
|
|
|
|
status = PQfnumber(r, "status");
|
|
|
|
priority = PQfnumber(r, "priority");
|
|
|
|
category = PQfnumber(r, "category");
|
|
|
|
expected = PQfnumber(r, "expected");
|
|
|
|
progress = PQfnumber(r, "progress");
|
|
|
|
item_id = PQfnumber(r, "item_id");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Db::TicketColumns::SetTicket(PGresult * r, long row, Ticket & ticket)
|
|
|
|
{
|
|
|
|
if( id != -1 ) ticket.id = atol( Db::AssertValue(r, row, id) );
|
|
|
|
if( dir_id != -1 ) ticket.dir_id = atol( Db::AssertValue(r, row, dir_id) );
|
|
|
|
if( parent_id != -1 ) ticket.parent_id = atol( Db::AssertValue(r, row, parent_id) );
|
|
|
|
if( type != -1 ) ticket.type = atoi( Db::AssertValue(r, row, type) );
|
|
|
|
if( status != -1 ) ticket.status = atoi( Db::AssertValue(r, row, status) );
|
|
|
|
if( priority != -1 ) ticket.priority = atoi( Db::AssertValue(r, row, priority) );
|
|
|
|
if( category != -1 ) ticket.category = atoi( Db::AssertValue(r, row, category) );
|
|
|
|
if( expected != -1 ) ticket.expected = atoi( Db::AssertValue(r, row, expected) );
|
|
|
|
if( progress != -1 ) ticket.progress = atoi( Db::AssertValue(r, row, progress) );
|
|
|
|
if( item_id != -1 ) ticket.item_id = atol( Db::AssertValue(r, row, item_id) );
|
|
|
|
}
|
|
|
|
|
2008-12-21 22:17:09 +01:00
|
|
|
|
|
|
|
|