87 lines
1.3 KiB
C++
Executable File
87 lines
1.3 KiB
C++
Executable File
/*
|
|
* This file is a part of Winix
|
|
* and is not publicly distributed
|
|
*
|
|
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
* All rights reserved.
|
|
*
|
|
*/
|
|
|
|
#include <algorithm>
|
|
#include "funthread.h"
|
|
|
|
|
|
|
|
namespace Fun
|
|
{
|
|
|
|
FunThread::FunThread()
|
|
{
|
|
fun.url = "thread";
|
|
Clear();
|
|
}
|
|
|
|
|
|
|
|
bool FunThread::HasAccess()
|
|
{
|
|
return !request->is_item;
|
|
}
|
|
|
|
|
|
void FunThread::Clear()
|
|
{
|
|
is_thread = false;
|
|
thread.Clear();
|
|
thread_tab.clear();
|
|
}
|
|
|
|
|
|
void FunThread::CreateSortIndexByDate()
|
|
{
|
|
size_t i;
|
|
|
|
for(i = 0; i < thread_tab.size() ; ++i)
|
|
{
|
|
Item * pdir = system->dirs.GetDir(thread_tab[i].dir_id);
|
|
|
|
if( pdir )
|
|
thread_tab[i].sort = (long)mktime(&pdir->date_creation);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
bool FunThread::FunThreadSort(const Thread & t1, const Thread & t2)
|
|
{
|
|
return t1.sort > t2.sort;
|
|
}
|
|
|
|
|
|
void FunThread::MakeGet()
|
|
{
|
|
is_thread = (db->GetThreadByDirId(request->dir_tab.back()->id, thread) == WINIX_ERR_OK);
|
|
|
|
Db::ItemQuery iq;
|
|
|
|
if( system->mounts.pmount->IsArg(Mount::par_thread, "sort_desc") )
|
|
iq.sort_asc = false;
|
|
|
|
iq.WhereParentId(request->dir_tab.back()->id);
|
|
iq.WhereType(Item::file);
|
|
iq.WhereAuth(Item::auth_none);
|
|
|
|
db->GetItems(request->item_tab, iq);
|
|
db->GetThreads(request->dir_tab.back()->id, thread_tab);
|
|
|
|
system->CheckAccessToItems(request->item_tab);
|
|
|
|
CreateSortIndexByDate();
|
|
std::sort(thread_tab.begin(), thread_tab.end(), FunThreadSort);
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace
|