added: now plugin ticket uses a new horizontal table (plugins.ticket)
columns: dir_id, param, value we are able to build complicated tickets git-svn-id: svn://ttmath.org/publicrep/winix/trunk@664 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
@@ -8,7 +8,6 @@
|
||||
*/
|
||||
|
||||
#include "editticket.h"
|
||||
#include "readticket.h"
|
||||
#include "functions/functions.h"
|
||||
|
||||
|
||||
@@ -68,17 +67,23 @@ return true;
|
||||
|
||||
|
||||
|
||||
void EditTicket::EditTicketCheckFirstItem()
|
||||
void EditTicket::GetFirstItem(Item & item)
|
||||
{
|
||||
if( request->status != WINIX_ERR_OK )
|
||||
return;
|
||||
|
||||
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( ticket_info->ticket.item_id == -1 )
|
||||
if( request->status != WINIX_ERR_OK )
|
||||
return;
|
||||
|
||||
if( item_tab.empty() )
|
||||
{
|
||||
// creating a new item (the item was deleted by a user)
|
||||
|
||||
Item item;
|
||||
item.parent_id = request->dir_tab.back()->id;
|
||||
item.subject = request->dir_tab.back()->subject;
|
||||
item.type = Item::file;
|
||||
@@ -86,146 +91,118 @@ void EditTicket::EditTicketCheckFirstItem()
|
||||
functions->SetUser(item);
|
||||
functions->PrepareUrl(item);
|
||||
|
||||
request->status = db->AddItem(item); // !! moze system->AddFile() tutaj?
|
||||
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;
|
||||
ticket_info->ticket.item_id = item.id;
|
||||
}
|
||||
log << log2 << "EditTicket: added the first item with content for the ticket, item.id: "
|
||||
<< item.id << logend;
|
||||
}
|
||||
else
|
||||
{
|
||||
item = item_tab[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void EditTicket::EditTicketModTicket()
|
||||
void EditTicket::ModifyTicket()
|
||||
{
|
||||
if( request->status != WINIX_ERR_OK )
|
||||
return;
|
||||
|
||||
Ticket ticket;
|
||||
ReadTicket read_ticket;
|
||||
read_ticket.Read(system, request, ticket_info, &ticket);
|
||||
|
||||
ticket_info->ticket.type = ticket.type;
|
||||
ticket_info->ticket.status = ticket.status;
|
||||
ticket_info->ticket.priority = ticket.priority;
|
||||
ticket_info->ticket.category = ticket.category;
|
||||
ticket_info->ticket.expected = ticket.expected;
|
||||
ticket_info->ticket.progress = ticket.progress;
|
||||
|
||||
request->status = tdb->EditTicketById(ticket_info->ticket);
|
||||
ticket_info->ReadTicketParams();
|
||||
request->status = tdb->RemoveAddTicket(ticket_info->ticket);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void EditTicket::EditTicketModDir()
|
||||
void EditTicket::ModifyLastDir()
|
||||
{
|
||||
if( request->status != WINIX_ERR_OK )
|
||||
return;
|
||||
|
||||
// we don't modify the url
|
||||
|
||||
Item & dir = *request->dir_tab.back();
|
||||
bool edit_dir_subject = (dir.subject != request->item.subject);
|
||||
|
||||
if( edit_dir_subject )
|
||||
if( dir.subject != ticket_info->item.subject )
|
||||
{
|
||||
dir.subject = request->item.subject;
|
||||
dir.subject = ticket_info->item.subject;
|
||||
request->status = db->EditItemById(dir, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void EditTicket::EditTicketModFirstItem()
|
||||
void EditTicket::ModifyFirstItem()
|
||||
{
|
||||
if( request->status != WINIX_ERR_OK )
|
||||
return;
|
||||
|
||||
// modyfing the first item (the one with content)
|
||||
functions->ReadItemContentWithType(request->item);
|
||||
|
||||
Item item;
|
||||
db->GetItemById(ticket_info->ticket.item_id, item);
|
||||
item.subject = request->item.subject;
|
||||
item.content = request->item.content;
|
||||
item.content_type = request->item.content_type;
|
||||
// the url doesn't matter
|
||||
|
||||
db->EditItemById(item, false);
|
||||
// we don't modify the url and don't use notifications
|
||||
system->EditFile(ticket_info->item, false, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void EditTicket::PostFunEditTicketLogAndRedirect()
|
||||
void EditTicket::LogAndRedirect()
|
||||
{
|
||||
if( request->status == WINIX_ERR_OK )
|
||||
{
|
||||
log << log2 << "Content: edited a ticket" << logend;
|
||||
log << log2 << "EditTicket: edited a ticket" << logend;
|
||||
system->RedirectToLastDir();
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Content: problem with editing a ticket, error code: "
|
||||
log << log1 << "EditTicket: problem with editing a ticket, error code: "
|
||||
<< request->status << logend;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool EditTicket::FunCreateTicketCheckAbuse()
|
||||
{
|
||||
if( !system->rebus.CheckRebus() )
|
||||
{
|
||||
request->status = WINIX_ERR_INCORRECT_REBUS;
|
||||
return false;
|
||||
}
|
||||
|
||||
functions->CheckGetPostTimes();
|
||||
|
||||
if( request->session->spam_score > 0 )
|
||||
{
|
||||
request->status = WINIX_ERR_SPAM;
|
||||
log << log1 << "Content: ignoring due to suspected spamming" << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void EditTicket::MakePost()
|
||||
{
|
||||
functions->ReadItem(request->item, Item::dir);
|
||||
// co z uzytkownikiem i grup<75>? chyba nie wczytane? !!! (wczesniej bylo SetUser() w ReadItem() - teraz nie ma)
|
||||
// dodac informacje o modyfikacji !!!
|
||||
ticket_info->FindCurrentConf();
|
||||
|
||||
if( !FunCreateTicketCheckAbuse() )
|
||||
{
|
||||
functions->ReadItemContentWithType(request->item); // for correctly displaying the form
|
||||
// reading the first item from the db or creating it if not exists
|
||||
GetFirstItem(ticket_info->item);
|
||||
|
||||
// reading information from POST
|
||||
functions->ReadItem(ticket_info->item, Item::file);
|
||||
|
||||
if( functions->CheckAbuse() )
|
||||
return;
|
||||
}
|
||||
|
||||
if( tdb->GetTicketByDirId(request->dir_tab.back()->id, ticket_info->ticket) != WINIX_ERR_OK )
|
||||
if( tdb->GetTicket(request->dir_tab.back()->id, ticket_info->ticket) != WINIX_ERR_OK )
|
||||
{
|
||||
request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
return;
|
||||
}
|
||||
|
||||
EditTicketCheckFirstItem();
|
||||
EditTicketModTicket();
|
||||
EditTicketModDir();
|
||||
EditTicketModFirstItem();
|
||||
PostFunEditTicketLogAndRedirect();
|
||||
ModifyTicket();
|
||||
ModifyLastDir();
|
||||
ModifyFirstItem();
|
||||
LogAndRedirect();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void EditTicket::MakeGet()
|
||||
{
|
||||
db->GetItemById(ticket_info->ticket.item_id, request->item);
|
||||
ticket_info->FindCurrentConf();
|
||||
|
||||
// the subject we get from the last directory
|
||||
request->item.subject = request->dir_tab.back()->subject;
|
||||
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];
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user