added winix functions: ln winix function 'default' can be used without redirecting now added new tickets types: TypeProgress, TypeString, TypeMultistring, TypeImages, TypeFiles now tickets are combined with files added winix functions: showtickets fixed mountpoints: when the default root mount was created its parameter table was empty and it caused accessing to a non-existing objects fixed logger: modifiers (log1, log2, log3) were incorrectly treated added modifier: log4 (debug info) now we are moving threads to a new plugin 'thread' created directory: plugins/thread (not finished yet) git-svn-id: svn://ttmath.org/publicrep/winix/trunk@704 e52654a7-88a9-db11-a3e9-0013d4bc506e
139 lines
2.1 KiB
C++
Executable File
139 lines
2.1 KiB
C++
Executable File
/*
|
|
* This file is a part of Winix
|
|
* and is not publicly distributed
|
|
*
|
|
* Copyright (c) 2010, Tomasz Sowa
|
|
* All rights reserved.
|
|
*
|
|
*/
|
|
|
|
#include <ctime>
|
|
#include <algorithm>
|
|
#include "showtickets.h"
|
|
|
|
|
|
|
|
namespace Ticket
|
|
{
|
|
|
|
|
|
|
|
ShowTickets::ShowTickets()
|
|
{
|
|
fun.url = L"showtickets";
|
|
}
|
|
|
|
|
|
void ShowTickets::SetTDb(TDb * ptdb)
|
|
{
|
|
tdb = ptdb;
|
|
}
|
|
|
|
|
|
void ShowTickets::SetTicketInfo(TicketInfo * pinfo)
|
|
{
|
|
ticket_info = pinfo;
|
|
}
|
|
|
|
|
|
|
|
bool ShowTickets::HasAccess()
|
|
{
|
|
return !request->is_item;
|
|
}
|
|
|
|
|
|
|
|
bool ShowTickets::Sort::operator()(const Item * item1, const Item * item2)
|
|
{
|
|
if( sort_type == 0 )
|
|
{
|
|
// sorting by url
|
|
return item1->url < item2->url;
|
|
}
|
|
else
|
|
{
|
|
// sorting by date
|
|
tm tm1 = item1->date_creation;
|
|
tm tm2 = item2->date_creation;
|
|
|
|
time_t time1 = Time(tm1);
|
|
time_t time2 = Time(tm2);
|
|
|
|
return time1 < time2;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
void ShowTickets::ReadFiles()
|
|
{
|
|
// reading files
|
|
DbItemQuery iq;
|
|
iq.SetAll(false, false);
|
|
iq.sel_url = true;
|
|
iq.sel_subject = true;
|
|
iq.sel_date = true;
|
|
iq.WhereParentId(request->dir_tab.back()->id);
|
|
iq.WhereType(Item::file);
|
|
iq.WhereFileType(WINIX_ITEM_FILETYPE_NONE);
|
|
|
|
db->GetItems(ticket_info->item_tab, iq);
|
|
system->CheckAccessToItems(ticket_info->item_tab);
|
|
}
|
|
|
|
|
|
void ShowTickets::ReadTickets()
|
|
{
|
|
// reading tickets for the files
|
|
file_id_tab.resize(ticket_info->item_tab.size());
|
|
|
|
for(size_t i=0 ; i<ticket_info->item_tab.size() ; ++i)
|
|
file_id_tab[i] = ticket_info->item_tab[i].id;
|
|
|
|
tdb->GetTickets(file_id_tab, ticket_info->ticket_tab);
|
|
}
|
|
|
|
|
|
void ShowTickets::CreatePointers()
|
|
{
|
|
// creating a pointers table
|
|
ticket_info->item_sort_tab.resize(ticket_info->item_tab.size());
|
|
|
|
for(size_t i=0 ; i<ticket_info->item_tab.size() ; ++i)
|
|
ticket_info->item_sort_tab[i] = &ticket_info->item_tab[i];
|
|
}
|
|
|
|
|
|
|
|
void ShowTickets::SortPointers()
|
|
{
|
|
int sort_type = 1;
|
|
|
|
if( request->PostVar(L"sort") == L"url" )
|
|
sort_type = 0;
|
|
|
|
std::vector<Item*> & table = ticket_info->item_sort_tab;
|
|
std::sort(table.begin(), table.end(), Sort(this, sort_type));
|
|
}
|
|
|
|
|
|
|
|
void ShowTickets::MakeGet()
|
|
{
|
|
ticket_info->Clear();
|
|
ticket_info->FindCurrentConf();
|
|
|
|
ReadFiles();
|
|
ReadTickets();
|
|
CreatePointers();
|
|
SortPointers();
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace
|