/* * This file is a part of CMSLU -- Content Management System like Unix * and is not publicly distributed * * Copyright (c) 2008-2009, 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 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 = Error::permission_denied; return; } bool asc = true; if( data.mounts.pmount->IsArg(Mount::par_thread, "sort_desc") ) asc = false; db.GetItems(request.item_table, request.dir_table.back()->id, Item::file, true, true, asc); db.GetThreads(request.dir_table.back()->id, request.thread_tab); CheckAccessToItems(); std::sort(request.thread_tab.begin(), request.thread_tab.end(), FunThreadSort); }