the first part of reimplementing has been done
now we have app object and singletons are only: log logn plugin and app git-svn-id: svn://ttmath.org/publicrep/winix/trunk@628 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
75
functions/funthread.cpp
Executable file
75
functions/funthread.cpp
Executable file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* 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
|
||||
Reference in New Issue
Block a user