161 lines
3.8 KiB
C++
Executable File
161 lines
3.8 KiB
C++
Executable File
/*
|
|
* This file is a part of Winix
|
|
* and is not publicly distributed
|
|
*
|
|
* Copyright (c) 2010-2012, Tomasz Sowa
|
|
* All rights reserved.
|
|
*
|
|
*/
|
|
|
|
#ifndef headerfile_winix_plugins_ticket_ticketinfo
|
|
#define headerfile_winix_plugins_ticket_ticketinfo
|
|
|
|
|
|
#include <vector>
|
|
#include "ticket.h"
|
|
#include "core/item.h"
|
|
#include "core/system.h"
|
|
#include "functions/functions.h"
|
|
#include "db/db.h"
|
|
#include "tdb.h"
|
|
#include "space/spaceparser.h"
|
|
|
|
|
|
|
|
namespace Ticket
|
|
{
|
|
|
|
|
|
struct TicketConfWrap
|
|
{
|
|
bool to_delete;
|
|
std::wstring file_name;
|
|
PT::Space conf;
|
|
|
|
TicketConfWrap()
|
|
{
|
|
to_delete = false;
|
|
}
|
|
};
|
|
|
|
|
|
class TicketInfo
|
|
{
|
|
public:
|
|
|
|
TicketInfo();
|
|
|
|
void SetTDb(TDb * ptdb);
|
|
void SetDb(Db * pdb);
|
|
void SetConfig(Config * pconfig);
|
|
void SetSystem(System * psystem);
|
|
void SetCur(Cur * pcur);
|
|
void SetFunctions(Functions * pfunctions);
|
|
|
|
void Clear();
|
|
|
|
// current ticket for templates
|
|
Ticket * ticket;
|
|
|
|
// current item for templates
|
|
// !! zobaczyc czy sie da na conts zamienic
|
|
// teraz zmieniona obsluga templatow wiec moze sie da
|
|
Item * item;
|
|
|
|
// true if 'createticket' function is creating a new ticket
|
|
bool create_new_ticket;
|
|
|
|
// for displaying all tickets in a directory
|
|
std::vector<Item> item_tab; // !! in the future we'll use cur->request->item_tab[number] (an array of arrays)
|
|
std::vector<Ticket> ticket_tab;
|
|
std::vector<Item*> item_sort_tab;
|
|
|
|
|
|
// <dir_id, TicketConfWrap>
|
|
typedef std::map<long, TicketConfWrap> ConfTab;
|
|
ConfTab conf_tab;
|
|
|
|
// current ticket config
|
|
// will be set by FindCurrentConf()
|
|
TicketConfWrap * cur_conf_wrap;
|
|
PT::Space * cur_conf;
|
|
|
|
// default: "progress"
|
|
// can be set in config in option: ticket_form_progress_prefix
|
|
std::wstring progress_prefix;
|
|
|
|
// ticket plugin id
|
|
int plugin_id;
|
|
|
|
|
|
int mount_type_ticket;
|
|
int mount_par_ticket_conf;
|
|
|
|
|
|
// template index for notifications
|
|
size_t template_index;
|
|
|
|
|
|
void ReadTicketConf(bool skip_existing_configs = false);
|
|
void FindCurrentConf();
|
|
void ReadTicketParams(Ticket & ticket, bool clear_ticket, PT::Space & meta);
|
|
void RemoveTicket(long file_id);
|
|
void CopyTicketSpace(PT::Space & ticket_space, Item & item);
|
|
|
|
private:
|
|
|
|
Db * db;
|
|
TDb * tdb;
|
|
Config * config;
|
|
System * system;
|
|
Cur * cur;
|
|
Functions * functions;
|
|
|
|
// for reading parameters
|
|
Ticket::TicketParam ticket_param;
|
|
|
|
// for adding a new image/file to a ticket
|
|
Item file;
|
|
std::wstring file_path;
|
|
|
|
// for reading config file
|
|
PT::SpaceParser conf_parser;
|
|
std::vector<Item*> config_dir_tab;
|
|
Item config_file;
|
|
|
|
// for Clearing
|
|
// (we don't want to use empty pointers)
|
|
TicketConfWrap cur_conf_wrap_empty;
|
|
PT::Space cur_conf_empty;
|
|
Ticket ticket_empty;
|
|
Item item_empty;
|
|
|
|
// for removing a ticket
|
|
Ticket rm_ticket;
|
|
|
|
bool GetConfContent(const std::wstring & path);
|
|
bool ParseTicketConf(long mount_dir_id, const std::wstring & path);
|
|
void ReadTicketConf(Mounts & mounts, bool skip_existing_configs);
|
|
void MarkAllConfToDelete();
|
|
void DeleteAllMarkedConf();
|
|
void ReadTicketConf(const Mount & mount, bool skip_existing_configs);
|
|
PT::Space & FindAddMetaByParam(PT::Space & meta, long param);
|
|
|
|
|
|
void CheckMinMaxValue(PT::Space & space, Ticket::TicketParam & par);
|
|
bool ReadTicketValue(PT::Space & space, long param_id, Ticket::TicketParam & par, const std::wstring & value, PT::Space & meta);
|
|
void ReadTicketValue(PT::Space & space, long param_id, const PostFile & value, PT::Space & meta, Item & upload_dir);
|
|
void ReadTicketValue(PT::Space & space, long param_id, const PostFile & value, PT::Space & meta);
|
|
void ReadTicketParam(PT::Space & space, Ticket & ticket, long param_id, const std::wstring & value, PT::Space & meta);
|
|
void ReadTicketParam(Ticket & ticket, long param_id, const std::wstring & value, PT::Space & meta);
|
|
void ReadTicketParam(long param_id, const PostFile & value, PT::Space & meta);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|