76 lines
1.3 KiB
C++
76 lines
1.3 KiB
C++
|
/*
|
||
|
* 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";
|
||
|
}
|
||
|
|
||
|
|
||
|
void FunThread::CreateSortIndexByDate()
|
||
|
{
|
||
|
size_t i;
|
||
|
|
||
|
for(i = 0; i < request->thread_tab.size() ; ++i)
|
||
|
{
|
||
|
Item * pdir = system->dirs.GetDir(request->thread_tab[i].dir_id);
|
||
|
|
||
|
if( pdir )
|
||
|
request->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()
|
||
|
{
|
||
|
// !! dac do hasaccess()
|
||
|
if( request->is_item )
|
||
|
{
|
||
|
request->status = WINIX_ERR_PERMISSION_DENIED;
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
Db::ItemQuery iq;
|
||
|
|
||
|
if( system->mounts.pmount->IsArg(Mount::par_thread, "sort_desc") )
|
||
|
iq.sort_asc = false;
|
||
|
|
||
|
iq.WhereParentId(request->dir_table.back()->id);
|
||
|
iq.WhereType(Item::file);
|
||
|
iq.WhereAuth(Item::auth_none);
|
||
|
|
||
|
db->GetItems(request->item_table, iq);
|
||
|
db->GetThreads(request->dir_table.back()->id, request->thread_tab);
|
||
|
|
||
|
system->CheckAccessToItems(request->item_table);
|
||
|
|
||
|
CreateSortIndexByDate();
|
||
|
std::sort(request->thread_tab.begin(), request->thread_tab.end(), FunThreadSort);
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
} // namespace
|