Files
winix/plugins/ticket/funticket.cpp
Tomasz Sowa 7bc17a9202 fixed: ticket sets a default function only for directories
fixed: reading a new url and subject in Functions::ReadItem()
added: tickets are sorted now (by date)



git-svn-id: svn://ttmath.org/publicrep/winix/trunk@659 e52654a7-88a9-db11-a3e9-0013d4bc506e
2010-09-30 20:58:20 +00:00

99 lines
1.4 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 "funticket.h"
namespace Ticket
{
FunTicket::FunTicket()
{
fun.url = "ticket";
}
void FunTicket::SetTDb(TDb * ptdb)
{
tdb = ptdb;
}
void FunTicket::SetTicketInfo(TicketInfo * pinfo)
{
ticket_info = pinfo;
}
void FunTicket::Clear()
{
ticket_info->Clear();
}
bool FunTicket::HasAccess()
{
if( request->is_item || system->mounts.pmount->type != ticket_info->mount_type_ticket )
return false;
return true;
}
void FunTicket::TicketDeleteFirst()
{
if( !ticket_info->is_ticket )
return;
for(size_t i=0 ; i<request->item_tab.size() ; ++i)
{
if( request->item_tab[i].id == ticket_info->ticket.item_id )
{
// this is the first item with the content for the ticket
if( !system->HasReadAccess(request->item_tab[i]) )
request->status = WINIX_ERR_PERMISSION_DENIED;
request->item_tab.erase(request->item_tab.begin() + i);
break;
}
}
}
void FunTicket::MakeGet()
{
ticket_info->ReadTicket(request->dir_tab.back()->id);
DbItemQuery iq;
iq.WhereParentId(request->dir_tab.back()->id);
iq.WhereType(Item::file);
iq.WhereAuth(Item::auth_none);
db->GetItems(request->item_tab, iq);
tdb->GetTickets(request->dir_tab.back()->id, ticket_info->ticket_tab);
ticket_info->SortTickets();
TicketDeleteFirst();
system->CheckAccessToItems(request->item_tab);
}
} // namespace