'tickets' can use 'threads' now
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@706 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
@@ -6,16 +6,142 @@
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <algorithm>
|
||||
#include "showthreads.h"
|
||||
#include "functions.h"
|
||||
|
||||
|
||||
|
||||
namespace Thread
|
||||
{
|
||||
|
||||
ShowThreads::ShowThreads()
|
||||
{
|
||||
fun.url = L"showthreads";
|
||||
}
|
||||
|
||||
|
||||
void ShowThreads::SetTDb(TDb * ptdb)
|
||||
{
|
||||
tdb = ptdb;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ShowThreads::SetThreadInfo(ThreadInfo * pthread_info)
|
||||
{
|
||||
thread_info = pthread_info;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool ShowThreads::HasAccess()
|
||||
{
|
||||
if( request->is_item )
|
||||
return false;
|
||||
|
||||
if( system->mounts.pmount->type != thread_info->mount_type_thread )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool ShowThreads::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 ShowThreads::ReadFiles()
|
||||
{
|
||||
// reading files
|
||||
DbItemQuery iq;
|
||||
iq.SetAll(false, false);
|
||||
iq.sel_url = true;
|
||||
iq.sel_subject = true;
|
||||
iq.sel_date = true;
|
||||
iq.sel_user_id = true;
|
||||
iq.sel_group_id = true;
|
||||
iq.sel_guest_name = true;
|
||||
iq.sel_privileges = true;
|
||||
iq.sel_date = true;
|
||||
iq.WhereParentId(request->dir_tab.back()->id);
|
||||
iq.WhereType(Item::file);
|
||||
iq.WhereFileType(WINIX_ITEM_FILETYPE_NONE);
|
||||
|
||||
db->GetItems(thread_info->item_tab, iq);
|
||||
system->CheckAccessToItems(thread_info->item_tab);
|
||||
}
|
||||
|
||||
|
||||
void ShowThreads::ReadThreads()
|
||||
{
|
||||
// reading threads for the files
|
||||
file_id_tab.resize(thread_info->item_sort_tab.size());
|
||||
|
||||
for(size_t i=0 ; i<thread_info->item_sort_tab.size() ; ++i)
|
||||
file_id_tab[i] = thread_info->item_sort_tab[i]->id;
|
||||
|
||||
tdb->GetThreads(file_id_tab, thread_info->thread_tab);
|
||||
}
|
||||
|
||||
|
||||
void ShowThreads::CreatePointers()
|
||||
{
|
||||
// creating a pointers table
|
||||
thread_info->item_sort_tab.resize(thread_info->item_tab.size());
|
||||
|
||||
for(size_t i=0 ; i<thread_info->item_tab.size() ; ++i)
|
||||
thread_info->item_sort_tab[i] = &thread_info->item_tab[i];
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ShowThreads::SortPointers()
|
||||
{
|
||||
int sort_type = 1;
|
||||
|
||||
if( request->ParamValue(L"sort") == L"url" )
|
||||
sort_type = 0;
|
||||
|
||||
std::vector<Item*> & table = thread_info->item_sort_tab;
|
||||
std::sort(table.begin(), table.end(), Sort(this, sort_type));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ShowThreads::MakeGet()
|
||||
{
|
||||
thread_info->Clear();
|
||||
|
||||
ReadFiles();
|
||||
CreatePointers();
|
||||
SortPointers();
|
||||
ReadThreads();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user