62 lines
1.1 KiB
C++
Executable File
62 lines
1.1 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 "content.h"
|
|
#include "../core/request.h"
|
|
#include "../core/db.h"
|
|
#include "../core/data.h"
|
|
#include "../core/mount.h"
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
bool Content::FunThreadSort(const Thread & t1, const Thread & t2)
|
|
{
|
|
Item * pdir1 = data.dirs.GetDir(t1.dir_id);
|
|
Item * pdir2 = data.dirs.GetDir(t2.dir_id);
|
|
|
|
if( !pdir1 || !pdir2 )
|
|
return false;
|
|
|
|
time_t time1 = mktime(&pdir1->date_creation);
|
|
time_t time2 = mktime(&pdir2->date_creation);
|
|
|
|
return time1 > time2;
|
|
}
|
|
|
|
|
|
void Content::FunThread()
|
|
{
|
|
if( request.is_item )
|
|
{
|
|
request.status = WINIX_ERR_PERMISSION_DENIED;
|
|
return;
|
|
}
|
|
|
|
Db::ItemQuery iq;
|
|
|
|
if( data.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);
|
|
|
|
CheckAccessToItems();
|
|
|
|
std::sort(request.thread_tab.begin(), request.thread_tab.end(), FunThreadSort);
|
|
}
|
|
|
|
|
|
|
|
|