2009-04-20 00:13:21 +02:00
|
|
|
/*
|
2010-02-28 01:08:10 +01:00
|
|
|
* This file is a part of Winix
|
2009-04-20 00:13:21 +02:00
|
|
|
* and is not publicly distributed
|
|
|
|
*
|
2010-02-28 22:33:06 +01:00
|
|
|
* Copyright (c) 2008-2010, Tomasz Sowa
|
2009-04-20 00:13:21 +02:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "content.h"
|
2009-04-21 22:50:55 +02:00
|
|
|
#include "../core/request.h"
|
|
|
|
#include "../core/db.h"
|
|
|
|
#include "../core/data.h"
|
|
|
|
#include "../core/mount.h"
|
2009-04-20 00:13:21 +02:00
|
|
|
|
2009-06-05 22:29:06 +02:00
|
|
|
#include <algorithm>
|
2009-04-20 00:13:21 +02:00
|
|
|
|
|
|
|
|
2009-06-05 22:29:06 +02:00
|
|
|
bool Content::FunThreadSort(const Thread & t1, const Thread & t2)
|
2009-04-20 00:13:21 +02:00
|
|
|
{
|
2009-06-05 22:29:06 +02:00
|
|
|
Item * pdir1 = data.dirs.GetDir(t1.dir_id);
|
|
|
|
Item * pdir2 = data.dirs.GetDir(t2.dir_id);
|
|
|
|
|
|
|
|
if( !pdir1 || !pdir2 )
|
|
|
|
return false;
|
2009-04-20 00:13:21 +02:00
|
|
|
|
2009-06-05 22:29:06 +02:00
|
|
|
time_t time1 = mktime(&pdir1->date_creation);
|
|
|
|
time_t time2 = mktime(&pdir2->date_creation);
|
2009-04-20 00:13:21 +02:00
|
|
|
|
2009-06-05 22:29:06 +02:00
|
|
|
return time1 > time2;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Content::FunThread()
|
|
|
|
{
|
2010-01-25 05:52:17 +01:00
|
|
|
if( request.is_item )
|
|
|
|
{
|
2010-02-28 01:08:10 +01:00
|
|
|
request.status = WINIX_ERR_PERMISSION_DENIED;
|
2010-01-25 05:52:17 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-02-22 23:52:09 +01:00
|
|
|
Db::ItemQuery iq;
|
|
|
|
|
2010-01-25 05:52:17 +01:00
|
|
|
if( data.mounts.pmount->IsArg(Mount::par_thread, "sort_desc") )
|
2010-02-22 23:52:09 +01:00
|
|
|
iq.sort_asc = false;
|
2010-01-25 05:52:17 +01:00
|
|
|
|
2010-02-22 23:52:09 +01:00
|
|
|
iq.WhereParentId(request.dir_table.back()->id);
|
|
|
|
iq.WhereType(Item::file);
|
|
|
|
iq.WhereAuth(Item::auth_none);
|
2010-01-25 05:52:17 +01:00
|
|
|
|
2010-02-22 23:52:09 +01:00
|
|
|
db.GetItems(request.item_table, iq);
|
2009-06-05 22:29:06 +02:00
|
|
|
db.GetThreads(request.dir_table.back()->id, request.thread_tab);
|
2010-02-16 01:37:00 +01:00
|
|
|
|
2010-01-25 05:52:17 +01:00
|
|
|
CheckAccessToItems();
|
2010-02-16 01:37:00 +01:00
|
|
|
|
2009-06-05 22:29:06 +02:00
|
|
|
std::sort(request.thread_tab.begin(), request.thread_tab.end(), FunThreadSort);
|
2009-04-20 00:13:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|