96 lines
1.4 KiB
C++
Executable File
96 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 Fun
|
|
{
|
|
|
|
FunTicket::FunTicket()
|
|
{
|
|
fun.url = "ticket";
|
|
Clear();
|
|
}
|
|
|
|
|
|
bool FunTicket::HasAccess()
|
|
{
|
|
if( request->is_item || system->mounts.pmount->type != Mount::ticket )
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
void FunTicket::Clear()
|
|
{
|
|
item.Clear();
|
|
is_ticket = false;
|
|
ticket.Clear();
|
|
ticket_tab.clear();
|
|
}
|
|
|
|
|
|
void FunTicket::ReadTicket()
|
|
{
|
|
if( db->GetTicketByDirId(request->dir_tab.back()->id, ticket) == WINIX_ERR_OK )
|
|
{
|
|
is_ticket = true;
|
|
db->GetItemById(ticket.item_id, item);
|
|
}
|
|
}
|
|
|
|
|
|
void FunTicket::TicketDeleteFirst()
|
|
{
|
|
if( !is_ticket )
|
|
return;
|
|
|
|
for(size_t i=0 ; i<request->item_tab.size() ; ++i)
|
|
{
|
|
if( request->item_tab[i].id == 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()
|
|
{
|
|
ReadTicket();
|
|
|
|
Db::ItemQuery iq;
|
|
|
|
iq.WhereParentId(request->dir_tab.back()->id);
|
|
iq.WhereType(Item::file);
|
|
iq.WhereAuth(Item::auth_none);
|
|
|
|
db->GetItems(request->item_tab, iq);
|
|
db->GetTickets(request->dir_tab.back()->id, ticket_tab);
|
|
|
|
TicketDeleteFirst();
|
|
system->CheckAccessToItems(request->item_tab);
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace
|