69 lines
1.2 KiB
C++
Executable File
69 lines
1.2 KiB
C++
Executable File
/*
|
|
* This file is a part of Winix
|
|
* 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"
|
|
|
|
|
|
|
|
|
|
void Content::TicketDeleteFirst()
|
|
{
|
|
if( !request.is_ticket )
|
|
return;
|
|
|
|
for(size_t i=0 ; i<request.item_table.size() ; ++i)
|
|
{
|
|
if( request.item_table[i].id == request.ticket.item_id )
|
|
{
|
|
// this is the first item with the content for the ticket
|
|
|
|
if( !request.HasReadAccess(request.item_table[i]) )
|
|
{
|
|
request.status = WINIX_ERR_PERMISSION_DENIED;
|
|
}
|
|
|
|
request.item_table.erase(request.item_table.begin() + i);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Content::FunTicket()
|
|
{
|
|
if( request.is_item || data.mounts.pmount->type != Mount::ticket )
|
|
{
|
|
request.status = WINIX_ERR_PERMISSION_DENIED;
|
|
return;
|
|
}
|
|
|
|
Db::ItemQuery iq;
|
|
|
|
iq.WhereParentId(request.dir_table.back()->id);
|
|
iq.WhereType(Item::file);
|
|
iq.WhereAuth(Item::auth_none);
|
|
|
|
db.GetItems(request.item_table, iq);
|
|
db.GetTickets(request.dir_table.back()->id, request.ticket_tab);
|
|
|
|
TicketDeleteFirst();
|
|
CheckAccessToItems();
|
|
}
|
|
|
|
|
|
|
|
|