2010-09-29 23:24:34 +02:00
|
|
|
/*
|
|
|
|
* This file is a part of Winix
|
2014-10-04 20:04:03 +02:00
|
|
|
* and is distributed under the 2-Clause BSD licence.
|
|
|
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2018-11-21 18:51:15 +01:00
|
|
|
* Copyright (c) 2010-2018, Tomasz Sowa
|
2010-09-29 23:24:34 +02:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
2014-10-04 20:04:03 +02:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
|
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
2010-09-29 23:24:34 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "tdb.h"
|
|
|
|
#include "funticket.h"
|
|
|
|
#include "editticket.h"
|
|
|
|
#include "createticket.h"
|
2011-01-05 22:24:11 +01:00
|
|
|
#include "showtickets.h"
|
|
|
|
#include "sessiondata.h"
|
2011-01-20 19:37:51 +01:00
|
|
|
#include "plugins/thread/showthreads.h"
|
|
|
|
#include "plugins/thread/pluginmsg.h"
|
2012-09-15 01:48:39 +02:00
|
|
|
#include "pluginmsg.h"
|
2011-01-20 19:37:51 +01:00
|
|
|
|
2014-02-12 17:30:49 +01:00
|
|
|
namespace Winix
|
|
|
|
{
|
|
|
|
|
2010-09-29 23:24:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
extern "C" void Init(PluginInfo &);
|
|
|
|
|
|
|
|
|
|
|
|
namespace Ticket
|
|
|
|
{
|
2010-11-21 01:19:17 +01:00
|
|
|
const wchar_t plugin_name[] = L"ticket";
|
2010-09-29 23:24:34 +02:00
|
|
|
|
|
|
|
TDb tdb;
|
|
|
|
TicketInfo ticket_info;
|
|
|
|
|
|
|
|
FunTicket fun_ticket;
|
|
|
|
CreateTicket fun_create_ticket;
|
|
|
|
EditTicket fun_edit_ticket;
|
2011-01-05 22:24:11 +01:00
|
|
|
ShowTickets fun_show_tickets;
|
2010-09-29 23:24:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
void AddFunctions(PluginInfo & info)
|
|
|
|
{
|
|
|
|
info.functions->Add(fun_ticket);
|
|
|
|
info.functions->Add(fun_create_ticket);
|
|
|
|
info.functions->Add(fun_edit_ticket);
|
2011-01-05 22:24:11 +01:00
|
|
|
info.functions->Add(fun_show_tickets);
|
2010-09-29 23:24:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SelectDefaultFunction(PluginInfo & info)
|
|
|
|
{
|
|
|
|
if( info.system->mounts.pmount->type == ticket_info.mount_type_ticket )
|
2011-01-05 22:24:11 +01:00
|
|
|
{
|
2012-01-19 21:50:42 +01:00
|
|
|
// !! moze dac fun_ticket tylko dla itemow ktore nie sa plikami statycznymi...
|
|
|
|
|
2011-01-23 15:15:30 +01:00
|
|
|
if( info.cur->request->is_item )
|
|
|
|
info.cur->request->function = &fun_ticket;
|
2011-01-05 22:24:11 +01:00
|
|
|
else
|
2011-01-23 15:15:30 +01:00
|
|
|
info.cur->request->function = &fun_show_tickets;
|
2011-01-05 22:24:11 +01:00
|
|
|
}
|
2010-09-29 23:24:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void AddMounts(PluginInfo & info)
|
|
|
|
{
|
|
|
|
Mounts & m = info.system->mounts;
|
|
|
|
|
2011-01-05 22:24:11 +01:00
|
|
|
ticket_info.mount_type_ticket = m.AddMountType(L"ticket");
|
|
|
|
ticket_info.mount_par_ticket_conf = m.AddMountPar(L"ticket_conf");
|
2010-09-29 23:24:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-11 22:42:49 +02:00
|
|
|
|
|
|
|
|
|
|
|
void FstabChanged(PluginInfo & info)
|
|
|
|
{
|
|
|
|
ticket_info.ReadTicketConf(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-24 01:51:44 +02:00
|
|
|
void ProcessRequest(PluginInfo & info)
|
2010-10-11 22:42:49 +02:00
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( info.cur->request->function == &info.functions->fun_reload )
|
2010-10-11 22:42:49 +02:00
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( info.cur->request->IsParam(L"tickets") )
|
2010-10-11 22:42:49 +02:00
|
|
|
ticket_info.ReadTicketConf();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-05 22:24:11 +01:00
|
|
|
|
|
|
|
|
2011-09-30 03:33:42 +02:00
|
|
|
void RemoveTicket(PluginInfo & info)
|
2010-10-24 01:51:44 +02:00
|
|
|
{
|
2012-01-16 11:12:38 +01:00
|
|
|
// !! dodac nowy komunikat PREPERE_TO_REMOVE
|
|
|
|
// i tam korzystajac z meta informacji w item
|
|
|
|
// usunac odpowiednie pliki
|
2011-09-30 03:33:42 +02:00
|
|
|
const Item * item = reinterpret_cast<Item*>(info.p1);
|
|
|
|
|
|
|
|
if( item )
|
|
|
|
ticket_info.RemoveTicket(item->id);
|
2010-10-24 01:51:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-19 02:31:20 +02:00
|
|
|
void InitTicket(PluginInfo & info)
|
|
|
|
{
|
2010-11-21 01:19:17 +01:00
|
|
|
ticket_info.progress_prefix = info.config->Text(L"ticket_form_progress_prefix", L"progress");
|
2010-10-19 02:31:20 +02:00
|
|
|
}
|
|
|
|
|
2010-12-06 01:25:46 +01:00
|
|
|
|
|
|
|
void AddNotifyTemplate(PluginInfo & info)
|
|
|
|
{
|
2011-01-05 22:24:11 +01:00
|
|
|
ticket_info.template_index = info.system->notify.AddTemplate(L"notify_email_ticket.txt");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CreateSession(PluginInfo & info)
|
|
|
|
{
|
|
|
|
SessionData * p = new SessionData();
|
2011-01-24 00:23:24 +01:00
|
|
|
|
|
|
|
p->fun_rm = &info.functions->fun_rm;
|
2018-11-21 12:03:53 +01:00
|
|
|
info.session->plugin_data.Assign(info.plugin->current_plugin, p);
|
2018-11-21 18:51:15 +01:00
|
|
|
info.log << log4 << "Ticket: created ticket plugin data: " << (void*)p << logend;
|
2011-01-05 22:24:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void RemoveSession(PluginInfo & info)
|
|
|
|
{
|
2012-01-21 13:29:44 +01:00
|
|
|
if( info.plugin_data_base )
|
|
|
|
{
|
|
|
|
info.plugin_data_base->Clear();
|
|
|
|
delete info.plugin_data_base;
|
2018-11-21 18:51:15 +01:00
|
|
|
info.log << log4 << "Ticket: removed ticket plugin data: " << (void*)info.plugin_data_base << logend;
|
2012-01-21 13:29:44 +01:00
|
|
|
}
|
2011-01-20 19:37:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-27 13:24:45 +01:00
|
|
|
void EndRequest(PluginInfo & info)
|
|
|
|
{
|
|
|
|
ticket_info.Clear();
|
|
|
|
}
|
|
|
|
|
2011-01-20 19:37:51 +01:00
|
|
|
|
2012-09-15 01:48:39 +02:00
|
|
|
void ShowTicketsFromDir(PluginInfo & info)
|
|
|
|
{
|
|
|
|
fun_show_tickets.ShowTicketsFromDir(info.l1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-10-10 13:59:21 +02:00
|
|
|
|
2011-01-20 19:37:51 +01:00
|
|
|
// defined in templates.cpp
|
2010-09-29 23:24:34 +02:00
|
|
|
void AddEzcFunctions(PluginInfo & info);
|
|
|
|
|
|
|
|
} // namespace Ticket
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Init(PluginInfo & info)
|
|
|
|
{
|
|
|
|
using namespace Ticket;
|
|
|
|
|
2018-11-21 18:51:15 +01:00
|
|
|
info.plugin->Assign(WINIX_PLUGIN_INIT, InitTicket);
|
|
|
|
info.plugin->Assign(WINIX_TEMPLATES_CREATEFUNCTIONS, AddEzcFunctions);
|
|
|
|
info.plugin->Assign(WINIX_CREATE_FUNCTIONS, AddFunctions);
|
|
|
|
info.plugin->Assign(WINIX_SELECT_DEFAULT_FUNCTION, SelectDefaultFunction);
|
|
|
|
info.plugin->Assign(WINIX_ADD_MOUNTS, AddMounts);
|
|
|
|
info.plugin->Assign(WINIX_FSTAB_CHANGED, FstabChanged);
|
|
|
|
info.plugin->Assign(WINIX_PROCESS_REQUEST, ProcessRequest);
|
|
|
|
info.plugin->Assign(WINIX_FILE_REMOVED, RemoveTicket);
|
|
|
|
info.plugin->Assign(WINIX_NOTIFY_ADD_TEMPLATE, AddNotifyTemplate);
|
|
|
|
info.plugin->Assign(WINIX_SESSION_CREATED, CreateSession);
|
|
|
|
info.plugin->Assign(WINIX_PLUGIN_SESSION_DATA_REMOVE, RemoveSession);
|
|
|
|
info.plugin->Assign(WINIX_END_REQUEST, EndRequest);
|
|
|
|
info.plugin->Assign(WINIX_PL_TICKET_LOAD_TICKETS, ShowTicketsFromDir);
|
2010-09-29 23:24:34 +02:00
|
|
|
|
2013-10-10 13:59:21 +02:00
|
|
|
|
2010-09-29 23:24:34 +02:00
|
|
|
tdb.SetConn(info.db->GetConn());
|
2010-10-19 02:31:20 +02:00
|
|
|
tdb.LogQueries(info.config->log_db_query);
|
2010-09-29 23:24:34 +02:00
|
|
|
|
2018-11-21 18:51:15 +01:00
|
|
|
info.set_dependency_for(ticket_info);
|
2010-09-29 23:24:34 +02:00
|
|
|
ticket_info.SetDb(info.db);
|
|
|
|
ticket_info.SetTDb(&tdb);
|
2019-01-02 12:33:19 +01:00
|
|
|
//ticket_info.SetConfig(info.config);
|
2010-09-30 22:58:20 +02:00
|
|
|
ticket_info.SetSystem(info.system);
|
2011-01-23 15:15:30 +01:00
|
|
|
ticket_info.SetCur(info.cur);
|
2011-01-05 22:24:11 +01:00
|
|
|
ticket_info.SetFunctions(info.functions);
|
|
|
|
ticket_info.plugin_id = info.plugin_id;
|
2010-09-29 23:24:34 +02:00
|
|
|
|
|
|
|
fun_ticket.SetTDb(&tdb);
|
|
|
|
fun_ticket.SetTicketInfo(&ticket_info);
|
|
|
|
|
|
|
|
fun_edit_ticket.SetTDb(&tdb);
|
|
|
|
fun_edit_ticket.SetTicketInfo(&ticket_info);
|
|
|
|
|
|
|
|
fun_create_ticket.SetTDb(&tdb);
|
|
|
|
fun_create_ticket.SetTicketInfo(&ticket_info);
|
|
|
|
|
2011-01-05 22:24:11 +01:00
|
|
|
fun_show_tickets.SetTDb(&tdb);
|
|
|
|
fun_show_tickets.SetTicketInfo(&ticket_info);
|
|
|
|
|
2010-12-06 01:25:46 +01:00
|
|
|
info.p1 = (void*)(plugin_name);
|
2010-09-29 23:24:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-02-12 17:30:49 +01:00
|
|
|
|
|
|
|
} // namespace Winix
|
|
|
|
|