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,13 +9,15 @@
|
||||
|
||||
#include "editticket.h"
|
||||
#include "functions/functions.h"
|
||||
|
||||
#include "sessiondata.h"
|
||||
|
||||
|
||||
|
||||
namespace Ticket
|
||||
{
|
||||
|
||||
|
||||
|
||||
EditTicket::EditTicket()
|
||||
{
|
||||
fun.url = L"editticket";
|
||||
@@ -34,27 +36,15 @@ void EditTicket::SetTicketInfo(TicketInfo * pinfo)
|
||||
}
|
||||
|
||||
|
||||
void EditTicket::Clear()
|
||||
{
|
||||
ticket_info->Clear();
|
||||
}
|
||||
|
||||
|
||||
bool EditTicket::HasAccess()
|
||||
{
|
||||
// not logged users cannot edit tickets
|
||||
// !! we are waiting for the sticky bit
|
||||
if( !request->session->puser )
|
||||
return false;
|
||||
|
||||
if( request->dir_tab.empty() )
|
||||
return false;
|
||||
|
||||
ticket_info->ReadTicket(request->dir_tab.back()->id);
|
||||
|
||||
if( request->is_item || !ticket_info->is_ticket )
|
||||
return false;
|
||||
|
||||
if( !system->HasWriteAccess(*request->dir_tab.back()) )
|
||||
if( !request->is_item || !system->HasWriteAccess(request->item) )
|
||||
return false;
|
||||
|
||||
if( !system->mounts.pmount || system->mounts.pmount->type != ticket_info->mount_type_ticket )
|
||||
@@ -66,89 +56,43 @@ return true;
|
||||
|
||||
|
||||
|
||||
|
||||
void EditTicket::GetFirstItem(Item & item)
|
||||
void EditTicket::ChangeTicket(Ticket & ticket, Item & item)
|
||||
{
|
||||
if( request->status != WINIX_ERR_OK )
|
||||
return;
|
||||
request->status = tdb->RemoveAddTicket(ticket);
|
||||
|
||||
DbItemQuery iq;
|
||||
iq.Limit(1);
|
||||
iq.WhereParentId(request->dir_tab.back()->id);
|
||||
db->GetItems(item_tab, iq); // !! chwilowo GetItems() nie zwraca zadnych kodow bledow
|
||||
|
||||
if( request->status != WINIX_ERR_OK )
|
||||
return;
|
||||
|
||||
if( item_tab.empty() )
|
||||
{
|
||||
// creating a new item (the item was deleted by a user)
|
||||
|
||||
item.parent_id = request->dir_tab.back()->id;
|
||||
item.subject = request->dir_tab.back()->subject;
|
||||
item.type = Item::file;
|
||||
item.privileges = 0644; // !! tymczasowo
|
||||
functions->SetUser(item);
|
||||
functions->PrepareUrl(item);
|
||||
|
||||
request->status = system->AddFile(item);
|
||||
|
||||
if( request->status == WINIX_ERR_OK )
|
||||
log << log2 << "EditTicket: added the first item with content for the ticket, item.id: "
|
||||
<< item.id << logend;
|
||||
}
|
||||
else
|
||||
{
|
||||
item = item_tab[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void EditTicket::ModifyTicket()
|
||||
{
|
||||
if( request->status != WINIX_ERR_OK )
|
||||
return;
|
||||
|
||||
ticket_info->ReadTicketParams();
|
||||
request->status = tdb->RemoveAddTicket(ticket_info->ticket);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void EditTicket::ModifyLastDir()
|
||||
{
|
||||
if( request->status != WINIX_ERR_OK )
|
||||
return;
|
||||
|
||||
// we don't modify the url
|
||||
Item & dir = *request->dir_tab.back();
|
||||
|
||||
if( dir.subject != ticket_info->item.subject )
|
||||
{
|
||||
dir.subject = ticket_info->item.subject;
|
||||
request->status = db->EditItemById(dir, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void EditTicket::ModifyFirstItem()
|
||||
{
|
||||
if( request->status != WINIX_ERR_OK )
|
||||
return;
|
||||
|
||||
// we don't modify the url and don't use notifications
|
||||
system->EditFile(ticket_info->item, false, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void EditTicket::LogAndRedirect()
|
||||
{
|
||||
if( request->status == WINIX_ERR_OK )
|
||||
{
|
||||
log << log2 << "EditTicket: edited a ticket" << logend;
|
||||
system->RedirectToLastDir();
|
||||
// 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 EditTicket::Submit(Ticket & ticket, Item & item)
|
||||
{
|
||||
if( functions->CheckAbuse() )
|
||||
return;
|
||||
|
||||
// adding without notificating
|
||||
request->status = system->EditFile(item, old_url != item.url);
|
||||
|
||||
if( request->status == WINIX_ERR_OK )
|
||||
ChangeTicket(ticket, item);
|
||||
|
||||
if( request->status == WINIX_ERR_OK )
|
||||
{
|
||||
log << log2 << "EditTicket: ticket modified" << logend;
|
||||
RemoveTicket();
|
||||
system->RedirectTo(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -159,29 +103,65 @@ void EditTicket::LogAndRedirect()
|
||||
|
||||
|
||||
|
||||
|
||||
void EditTicket::RemoveTicket()
|
||||
{
|
||||
SessionData * session_data = reinterpret_cast<SessionData*>(
|
||||
request->session->plugin_data.Get(ticket_info->plugin_id) );
|
||||
|
||||
long file_id = request->item.id;
|
||||
session_data->create_ticket_map.erase(file_id);
|
||||
session_data->new_file_map.erase(file_id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Ticket & EditTicket::PrepareTicket()
|
||||
{
|
||||
SessionData * session_data = reinterpret_cast<SessionData*>(
|
||||
request->session->plugin_data.Get(ticket_info->plugin_id) );
|
||||
|
||||
bool is_new;
|
||||
long file_id = request->item.id;
|
||||
Ticket & ticket = session_data->GetTicket(file_id, session_data->edit_ticket_map, &is_new);
|
||||
|
||||
if( is_new )
|
||||
tdb->GetTicket(file_id, ticket);
|
||||
else
|
||||
ticket.file_id = file_id;
|
||||
|
||||
return ticket;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::vector<long> & EditTicket::PrepareFileMap()
|
||||
{
|
||||
SessionData * session_data = reinterpret_cast<SessionData*>(
|
||||
request->session->plugin_data.Get(ticket_info->plugin_id) );
|
||||
|
||||
long file_id = request->item.id;
|
||||
std::vector<long> & file_map = session_data->GetFileTab(file_id, session_data->new_file_map);
|
||||
|
||||
return file_map;
|
||||
}
|
||||
|
||||
|
||||
void EditTicket::MakePost()
|
||||
{
|
||||
ticket_info->FindCurrentConf();
|
||||
|
||||
// reading the first item from the db or creating it if not exists
|
||||
GetFirstItem(ticket_info->item);
|
||||
Ticket & ticket = PrepareTicket();
|
||||
Item & item = request->item;
|
||||
old_url = item.url;
|
||||
std::vector<long> & file_map = PrepareFileMap();
|
||||
ticket_info->ticket = &ticket;
|
||||
|
||||
// reading information from POST
|
||||
functions->ReadItem(ticket_info->item, Item::file);
|
||||
ticket_info->ReadTicketParams(ticket, false, &file_map);
|
||||
functions->ReadItem(item, Item::file);
|
||||
|
||||
if( functions->CheckAbuse() )
|
||||
return;
|
||||
|
||||
if( tdb->GetTicket(request->dir_tab.back()->id, ticket_info->ticket) != WINIX_ERR_OK )
|
||||
{
|
||||
request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
return;
|
||||
}
|
||||
|
||||
ModifyTicket();
|
||||
ModifyLastDir();
|
||||
ModifyFirstItem();
|
||||
LogAndRedirect();
|
||||
if( !request->IsPostVar(L"fileuploadsubmit") )
|
||||
Submit(ticket, item);
|
||||
}
|
||||
|
||||
|
||||
@@ -190,19 +170,8 @@ void EditTicket::MakeGet()
|
||||
{
|
||||
ticket_info->FindCurrentConf();
|
||||
|
||||
DbItemQuery iq;
|
||||
iq.Limit(1);
|
||||
iq.WhereParentId(request->dir_tab.back()->id);
|
||||
db->GetItems(item_tab, iq); // !! chwilowo GetItems() nie zwraca kodow bledow
|
||||
|
||||
if( request->status != WINIX_ERR_OK )
|
||||
{
|
||||
request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
return;
|
||||
}
|
||||
|
||||
if( !item_tab.empty() )
|
||||
ticket_info->item = item_tab[0];
|
||||
Ticket & ticket = PrepareTicket();
|
||||
ticket_info->ticket = &ticket;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user