we can create links (hard links, symbolic links) now
added winix functions: ln winix function 'default' can be used without redirecting now added new tickets types: TypeProgress, TypeString, TypeMultistring, TypeImages, TypeFiles now tickets are combined with files added winix functions: showtickets fixed mountpoints: when the default root mount was created its parameter table was empty and it caused accessing to a non-existing objects fixed logger: modifiers (log1, log2, log3) were incorrectly treated added modifier: log4 (debug info) now we are moving threads to a new plugin 'thread' created directory: plugins/thread (not finished yet) git-svn-id: svn://ttmath.org/publicrep/winix/trunk@704 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
@@ -9,6 +9,8 @@
|
||||
|
||||
#include "createticket.h"
|
||||
#include "functions/functions.h"
|
||||
#include "sessiondata.h"
|
||||
|
||||
|
||||
|
||||
namespace Ticket
|
||||
@@ -36,76 +38,61 @@ void CreateTicket::SetTicketInfo(TicketInfo * pinfo)
|
||||
|
||||
|
||||
|
||||
void CreateTicket::Clear()
|
||||
bool CreateTicket::HasAccess()
|
||||
{
|
||||
ticket_info->Clear();
|
||||
}
|
||||
|
||||
|
||||
// returning true if we can create a ticket in the current directory
|
||||
bool CreateTicket::HasAccess(bool check_root)
|
||||
{
|
||||
if( request->dir_tab.empty() )
|
||||
return false;
|
||||
|
||||
if( request->is_item )
|
||||
return false;
|
||||
|
||||
if( !system->HasWriteAccess(*request->dir_tab.back()) )
|
||||
if( request->is_item || !system->HasWriteAccess(*request->dir_tab.back()) )
|
||||
return false;
|
||||
|
||||
if( !system->mounts.pmount || system->mounts.pmount->type != ticket_info->mount_type_ticket )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CreateTicket::AddTicket(Ticket & ticket, Item & item)
|
||||
{
|
||||
ticket.file_id = item.id;
|
||||
request->status = tdb->AddTicket(ticket);
|
||||
|
||||
if( request->status == WINIX_ERR_OK )
|
||||
{
|
||||
// sending notification
|
||||
notify_msg.code = WINIX_NOTIFY_CODE_USER1;
|
||||
notify_msg.template_index = ticket_info->template_index;
|
||||
notify_msg.dir_link = config->base_url;
|
||||
system->dirs.MakePath(item.parent_id, notify_msg.dir_link, false);
|
||||
notify_msg.item_link = notify_msg.dir_link;
|
||||
notify_msg.item_link += item.url;
|
||||
|
||||
system->notify.ItemChanged(notify_msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void CreateTicket::Submit(Ticket & ticket, Item & item)
|
||||
{
|
||||
if( functions->CheckAbuse() )
|
||||
return;
|
||||
|
||||
functions->SetUser(item);
|
||||
item.privileges = 0644; // !! tymczasowo
|
||||
item.parent_id = request->dir_tab.back()->id;
|
||||
|
||||
// adding without notificating
|
||||
request->status = system->AddFile(item, false);
|
||||
|
||||
if( request->status == WINIX_ERR_OK )
|
||||
AddTicket(ticket, item);
|
||||
|
||||
|
||||
// checking for par_createticket_on mount option
|
||||
|
||||
if( !check_root && request->session && request->session->puser && request->session->puser->super_user )
|
||||
// super can create tickets regardless of the createticket_on option
|
||||
return true;
|
||||
|
||||
if( !system->mounts.pmount->IsPar(ticket_info->mount_par_createticket_on) )
|
||||
return true;
|
||||
|
||||
if( system->mounts.pmount->IsArg(ticket_info->mount_par_createticket_on, request->dir_tab.size()) )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool CreateTicket::HasAccess()
|
||||
{
|
||||
return HasAccess(false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CreateTicket::AddTicket()
|
||||
{
|
||||
// a new directory created by system->AddDir()
|
||||
ticket_info->ticket.dir_id = request->dir_tab.back()->id;
|
||||
request->status = tdb->AddTicket(ticket_info->ticket);
|
||||
|
||||
// sending notification
|
||||
notify_msg.code = WINIX_NOTIFY_CODE_USER1;
|
||||
notify_msg.template_index = ticket_info->template_index;
|
||||
|
||||
system->dirs.MakePath(ticket_info->item.parent_id, tmp_path);
|
||||
notify_msg.item_link = config->base_url;
|
||||
notify_msg.item_link += tmp_path;
|
||||
notify_msg.dir_link = notify_msg.item_link;
|
||||
|
||||
system->notify.ItemChanged(notify_msg);
|
||||
}
|
||||
|
||||
|
||||
void CreateTicket::LogAndRedirect()
|
||||
{
|
||||
if( request->status == WINIX_ERR_OK )
|
||||
{
|
||||
log << log2 << "CreateTicket: added a new ticket" << logend;
|
||||
system->RedirectToLastDir();
|
||||
RemoveTicket();
|
||||
system->RedirectTo(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -116,41 +103,55 @@ void CreateTicket::LogAndRedirect()
|
||||
|
||||
|
||||
|
||||
void CreateTicket::RemoveTicket()
|
||||
{
|
||||
SessionData * session_data = reinterpret_cast<SessionData*>(
|
||||
request->session->plugin_data.Get(ticket_info->plugin_id) );
|
||||
|
||||
long dir_id = request->dir_tab.back()->id;
|
||||
session_data->create_ticket_map.erase(dir_id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Ticket & CreateTicket::PrepareTicket()
|
||||
{
|
||||
SessionData * session_data = reinterpret_cast<SessionData*>(
|
||||
request->session->plugin_data.Get(ticket_info->plugin_id) );
|
||||
|
||||
long dir_id = request->dir_tab.back()->id;
|
||||
Ticket & ticket = session_data->GetTicket(dir_id, session_data->create_ticket_map);
|
||||
|
||||
return ticket;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CreateTicket::MakePost()
|
||||
{
|
||||
ticket_info->Clear();
|
||||
ticket_info->FindCurrentConf();
|
||||
functions->ReadItem(ticket_info->item, Item::file);
|
||||
functions->SetUser(ticket_info->item);
|
||||
ticket_info->item.privileges = request->dir_tab.back()->privileges; // !! tymczasowo takie same jak z katalogu nadrzednego
|
||||
|
||||
ticket_info->ReadTicketParams();
|
||||
Ticket & ticket = PrepareTicket();
|
||||
Item & item = request->item;
|
||||
ticket_info->ticket = &ticket;
|
||||
|
||||
if( functions->CheckAbuse() )
|
||||
return;
|
||||
ticket_info->ReadTicketParams(ticket, false);
|
||||
functions->ReadItem(item, Item::file);
|
||||
|
||||
ticket_info->item.type = Item::dir;
|
||||
request->status = system->dirs.AddDirectory(ticket_info->item, true);
|
||||
|
||||
if( request->status == WINIX_ERR_OK )
|
||||
{
|
||||
ticket_info->item.type = Item::file;
|
||||
ticket_info->item.privileges = 0644; // !! tymczasowo
|
||||
ticket_info->item.parent_id = request->dir_tab.back()->id;
|
||||
|
||||
// adding without notificating
|
||||
request->status = system->AddFile(ticket_info->item, false);
|
||||
|
||||
if( request->status == WINIX_ERR_OK )
|
||||
AddTicket();
|
||||
}
|
||||
|
||||
LogAndRedirect();
|
||||
if( !request->IsPostVar(L"fileuploadsubmit") )
|
||||
Submit(ticket, item);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CreateTicket::MakeGet()
|
||||
{
|
||||
ticket_info->Clear();
|
||||
ticket_info->FindCurrentConf();
|
||||
|
||||
Ticket & ticket = PrepareTicket();
|
||||
ticket_info->ticket = &ticket;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user