2011-01-05 22:24:11 +01:00
|
|
|
/*
|
|
|
|
* This file is a part of Winix
|
2014-10-04 20:04:03 +02:00
|
|
|
* and is distributed under the 2-Clause BSD licence.
|
|
|
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2021-02-24 01:19:47 +01:00
|
|
|
* Copyright (c) 2010-2021, Tomasz Sowa
|
2011-01-05 22:24:11 +01:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
2014-10-04 20:04:03 +02:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
|
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
2011-01-05 22:24:11 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <ctime>
|
|
|
|
#include <algorithm>
|
|
|
|
#include "showtickets.h"
|
2011-01-27 13:24:45 +01:00
|
|
|
#include "pluginmsg.h"
|
2011-01-20 19:37:51 +01:00
|
|
|
#include "plugins/thread/pluginmsg.h"
|
2018-11-21 18:51:15 +01:00
|
|
|
|
2011-01-05 22:24:11 +01:00
|
|
|
|
2014-02-12 17:30:49 +01:00
|
|
|
namespace Winix
|
|
|
|
{
|
|
|
|
|
|
|
|
|
2011-01-05 22:24:11 +01:00
|
|
|
|
|
|
|
namespace Ticket
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ShowTickets::ShowTickets()
|
|
|
|
{
|
|
|
|
fun.url = L"showtickets";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ShowTickets::SetTDb(TDb * ptdb)
|
|
|
|
{
|
|
|
|
tdb = ptdb;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ShowTickets::SetTicketInfo(TicketInfo * pinfo)
|
|
|
|
{
|
|
|
|
ticket_info = pinfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool ShowTickets::HasAccess()
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
return !cur->request->is_item;
|
2011-01-05 22:24:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool ShowTickets::Sort::operator()(const Item * item1, const Item * item2)
|
|
|
|
{
|
|
|
|
if( sort_type == 0 )
|
|
|
|
{
|
|
|
|
// sorting by url
|
|
|
|
return item1->url < item2->url;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-08 16:42:14 +02:00
|
|
|
// sorting by sort_index and if equal then by date
|
|
|
|
|
|
|
|
if( item1->sort_index != item2->sort_index )
|
|
|
|
return item1->sort_index < item2->sort_index;
|
|
|
|
|
2021-02-24 01:19:47 +01:00
|
|
|
return item1->item_content.date_creation > item2->item_content.date_creation;
|
2011-01-05 22:24:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-09-15 01:48:39 +02:00
|
|
|
void ShowTickets::ReadFiles(long dir_id)
|
2011-01-05 22:24:11 +01:00
|
|
|
{
|
|
|
|
// reading files
|
2021-02-24 01:19:47 +01:00
|
|
|
// DbItemQuery iq;
|
|
|
|
// iq.SetAll(false, false);
|
|
|
|
// iq.sel_url = true;
|
|
|
|
// iq.sel_subject = true;
|
|
|
|
// iq.sel_date = true;
|
|
|
|
// iq.sel_user_id = true;
|
|
|
|
// iq.sel_group_id = true;
|
|
|
|
// iq.sel_guest_name = true;
|
|
|
|
// iq.sel_privileges = true;
|
|
|
|
// iq.sel_date = true;
|
|
|
|
// iq.sel_meta = true;
|
|
|
|
// iq.sel_sort_index = true;
|
|
|
|
// iq.WhereParentId(dir_id);
|
|
|
|
// iq.WhereType(Item::file);
|
|
|
|
// iq.WhereFileType(WINIX_ITEM_FILETYPE_NONE);
|
|
|
|
|
|
|
|
morm::Finder<Item> finder(model_connector);
|
|
|
|
|
|
|
|
finder.
|
|
|
|
select().
|
|
|
|
where().
|
|
|
|
eq(L"parent_id", dir_id).
|
|
|
|
eq(L"type", static_cast<int>(Item::file)).
|
2021-05-13 19:33:19 +02:00
|
|
|
eq(L"content", L"file_type", WINIX_ITEM_FILETYPE_NONE).
|
2021-02-24 01:19:47 +01:00
|
|
|
get_vector(ticket_info->item_tab);
|
|
|
|
|
|
|
|
//db->GetItems(ticket_info->item_tab, iq);
|
2011-01-05 22:24:11 +01:00
|
|
|
system->CheckAccessToItems(ticket_info->item_tab);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ShowTickets::CreatePointers()
|
|
|
|
{
|
|
|
|
// creating a pointers table
|
|
|
|
ticket_info->item_sort_tab.resize(ticket_info->item_tab.size());
|
|
|
|
|
|
|
|
for(size_t i=0 ; i<ticket_info->item_tab.size() ; ++i)
|
|
|
|
ticket_info->item_sort_tab[i] = &ticket_info->item_tab[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ShowTickets::SortPointers()
|
|
|
|
{
|
2018-11-21 18:51:15 +01:00
|
|
|
PluginRes res = plugin->Call(WINIX_PL_TICKET_SORT_POINTERS, &ticket_info->item_sort_tab);
|
2011-01-27 13:24:45 +01:00
|
|
|
|
2012-04-22 15:30:07 +02:00
|
|
|
if( res.res_true > 0 )
|
2011-01-27 13:24:45 +01:00
|
|
|
return;
|
|
|
|
|
2011-01-05 22:24:11 +01:00
|
|
|
int sort_type = 1;
|
|
|
|
|
2011-01-23 15:15:30 +01:00
|
|
|
if( cur->request->ParamValue(L"sort") == L"url" )
|
2011-01-05 22:24:11 +01:00
|
|
|
sort_type = 0;
|
|
|
|
|
|
|
|
std::vector<Item*> & table = ticket_info->item_sort_tab;
|
|
|
|
std::sort(table.begin(), table.end(), Sort(this, sort_type));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-24 00:23:24 +01:00
|
|
|
void ShowTickets::ReadTickets()
|
|
|
|
{
|
|
|
|
// reading tickets for the files
|
|
|
|
file_id_tab.resize(ticket_info->item_sort_tab.size());
|
|
|
|
|
|
|
|
for(size_t i=0 ; i<ticket_info->item_sort_tab.size() ; ++i)
|
|
|
|
file_id_tab[i] = ticket_info->item_sort_tab[i]->id;
|
|
|
|
|
|
|
|
tdb->GetTickets(file_id_tab, ticket_info->ticket_tab);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-09-15 01:48:39 +02:00
|
|
|
void ShowTickets::ShowTicketsFromDir(long dir_id)
|
2011-01-05 22:24:11 +01:00
|
|
|
{
|
|
|
|
ticket_info->Clear();
|
2012-09-15 01:48:39 +02:00
|
|
|
ticket_info->FindCurrentConf(dir_id);
|
2011-01-05 22:24:11 +01:00
|
|
|
|
2012-09-15 01:48:39 +02:00
|
|
|
ReadFiles(dir_id);
|
2011-01-05 22:24:11 +01:00
|
|
|
CreatePointers();
|
|
|
|
SortPointers();
|
2011-01-20 19:37:51 +01:00
|
|
|
ReadTickets();
|
|
|
|
|
2018-11-21 18:51:15 +01:00
|
|
|
plugin->Call(WINIX_PL_TICKET_TICKETS_LOADED, &ticket_info->ticket_tab, &ticket_info->item_sort_tab);
|
2013-10-10 13:59:21 +02:00
|
|
|
|
2012-09-15 01:48:39 +02:00
|
|
|
// !! IMPROVE ME may a better name instead of WINIX_PL_THREAD_SET_SORTTAB?
|
2018-11-21 18:51:15 +01:00
|
|
|
plugin->Call(WINIX_PL_THREAD_SET_SORTTAB, &ticket_info->item_sort_tab);
|
|
|
|
plugin->Call(WINIX_PL_THREAD_READ_THREADS);
|
2011-01-05 22:24:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-09-15 01:48:39 +02:00
|
|
|
void ShowTickets::MakeGet()
|
|
|
|
{
|
|
|
|
ShowTicketsFromDir(cur->request->dir_tab.back()->id);
|
|
|
|
}
|
|
|
|
|
2011-01-05 22:24:11 +01:00
|
|
|
|
|
|
|
|
|
|
|
} // namespace
|
2014-02-12 17:30:49 +01:00
|
|
|
|
|
|
|
} // namespace Winix
|
|
|
|
|