plugin ticket: rewritten templates ezc functions
(now images/files are working fine) git-svn-id: svn://ttmath.org/publicrep/winix/trunk@795 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
parent
424618de38
commit
631ca4f8a3
|
@ -45,29 +45,36 @@
|
|||
|
||||
|
||||
[if ticket_tab_type_is "multistring"]
|
||||
<textarea name="ticketparam[ticket_tab_param_id]">[ticket_tab_value]</textarea>
|
||||
<textarea name="ticketparam[ticket_tab_param_id]" rows="10" cols="60">[ticket_tab_value]</textarea>
|
||||
[end]
|
||||
|
||||
|
||||
[if ticket_tab_type_is "images"]
|
||||
[for ticket_tab_files_tab]
|
||||
<img src="[doc_base_url][ticket_tab_value]/-/thumb" alt="[ticket_tab_value]" height="150">
|
||||
[for ticket_tab_file_tab]
|
||||
<img src="[doc_base_url][ticket_tab_file_tab_path]/-/thumb" alt="[ticket_tab_file_tab_path]" height="150">
|
||||
[end]
|
||||
|
||||
<input size="30" class="edit" type="file" name="ticketparam[ticket_tab_param_id]">
|
||||
<input size="30" class="edit" type="file" name="ticketparam[ticket_tab_param_id]" multiple>
|
||||
<input class="filesubmit" type="submit" name="fileuploadsubmit" value="{add}">
|
||||
[end]
|
||||
|
||||
|
||||
[if ticket_tab_type_is "files"]
|
||||
[for ticket_tab_files_tab]
|
||||
<a href="[doc_base_url][ticket_tab_value]/download">[ticket_tab_value]</a>
|
||||
[if ticket_tab_file_tab]
|
||||
<ul>
|
||||
[for ticket_tab_file_tab]
|
||||
<li><a href="[doc_base_url][ticket_tab_file_tab_path]/download">[ticket_tab_file_tab_path]</a></li>
|
||||
[end]
|
||||
</ul>
|
||||
[end]
|
||||
|
||||
<input size="30" class="edit" type="file" name="ticketparam[ticket_tab_param_id]">
|
||||
<input size="30" class="edit" type="file" name="ticketparam[ticket_tab_param_id]" multiple>
|
||||
<input class="filesubmit" type="submit" name="fileuploadsubmit" value="{add}">
|
||||
[end]
|
||||
|
||||
[if-any-no ticket_tab_type_is "images" ticket_tab_type_is "files" ticket_is_creating_new ticket_tab_has_value]
|
||||
{ticket_value_not_set}
|
||||
[end]
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<th>{tickets_header_name}</th>
|
||||
[for ticket_tab]
|
||||
[if-any-no ticket_tab_type_is "images" ticket_tab_type_is "files"]
|
||||
<th>[ticket_tab_param_name]</th>
|
||||
<th>[filter fil_firstup][ticket_tab_param_name][end]</th>
|
||||
[end]
|
||||
[end]
|
||||
|
||||
|
|
|
@ -7,30 +7,38 @@
|
|||
[if ticket_can_edit]<p class="edit"><a href="[doc_base_url][dir][item_url]/editticket" rel="nofollow">\[{edit}\]</a></p>[end]
|
||||
<table>
|
||||
[for ticket_tab]
|
||||
[if ticket_tab_has_value]
|
||||
|
||||
<tr>
|
||||
<th>[filter fil_firstup][ticket_tab_param_name]:[end]</th>
|
||||
<td>
|
||||
|
||||
[if ticket_tab_type_is "images"]
|
||||
[for ticket_tab_files_tab]
|
||||
<a href="[doc_base_url][ticket_tab_value]" rel="lightbox\[a\]" class="picture"><img src="[doc_base_url][ticket_tab_value]/-/thumb" alt="[ticket_tab_value]" height="150"></a>
|
||||
[if ticket_tab_type_is "images"]
|
||||
[for ticket_tab_file_tab]
|
||||
<a href="[doc_base_url][ticket_tab_file_tab_path]" rel="lightbox\[a\]" class="picture">
|
||||
<img src="[doc_base_url][ticket_tab_file_tab_path]/-/thumb" alt="[ticket_tab_file_tab_path]" height="150">
|
||||
</a>
|
||||
[end]
|
||||
[end]
|
||||
|
||||
[if ticket_tab_type_is "files"]
|
||||
[if ticket_tab_file_tab]
|
||||
<ul>
|
||||
[for ticket_tab_file_tab]
|
||||
<li><a href="[doc_base_url][ticket_tab_file_tab_path]/download">[ticket_tab_file_tab_path]</a></li>
|
||||
[end]
|
||||
</ul>
|
||||
[end]
|
||||
[end]
|
||||
|
||||
[if ticket_tab_type_is "files"]
|
||||
[for ticket_tab_files_tab]
|
||||
<a href="[doc_base_url][ticket_tab_value]/download">[ticket_tab_value]</a>
|
||||
[end]
|
||||
[end]
|
||||
|
||||
[if-any-no ticket_tab_type_is "images" ticket_tab_type_is "files"]
|
||||
[ticket_tab_value]
|
||||
[end]
|
||||
[if-any-no ticket_tab_type_is "images" ticket_tab_type_is "files"]
|
||||
[ticket_tab_value]
|
||||
[end]
|
||||
|
||||
</td>
|
||||
</th>
|
||||
</tr>
|
||||
[end]
|
||||
[end]
|
||||
</table>
|
||||
[item_print_content]
|
||||
</div>
|
||||
|
|
|
@ -205,6 +205,8 @@ ticket_info_category = Category
|
|||
ticket_info_expected = Expected in
|
||||
ticket_info_progress = Progress
|
||||
ticket_reply_in_this_thread = Replay in this thread
|
||||
ticket_value_not_set = this ticket doesn't have such a value yet
|
||||
|
||||
|
||||
template_header = Template
|
||||
template_info_file = Current html template for this file
|
||||
|
|
|
@ -223,6 +223,7 @@ ticket_info_category = Kategoria
|
|||
ticket_info_expected = Oczekiwany w
|
||||
ticket_info_progress = Postęp prac
|
||||
ticket_reply_in_this_thread = Odpowiedz w tym wątku
|
||||
ticket_value_not_set = to zgłoszenie nie ma jeszcze ustawionej tej wartości
|
||||
|
||||
template_header = Szablon
|
||||
template_info_file = Bieżący szablon dla tego pliku
|
||||
|
|
|
@ -111,7 +111,7 @@ void CreateTicket::RemoveTmpTicket()
|
|||
|
||||
long dir_id = cur->request->dir_tab.back()->id;
|
||||
session_data->create_ticket_map.erase(dir_id);
|
||||
session_data->create_file_map.erase(dir_id);
|
||||
session_data->create_space_map.erase(dir_id);
|
||||
}
|
||||
|
||||
|
||||
|
@ -121,22 +121,24 @@ Ticket & CreateTicket::PrepareTicket()
|
|||
SessionData * session_data = reinterpret_cast<SessionData*>(
|
||||
cur->session->plugin_data.Get(ticket_info->plugin_id) );
|
||||
|
||||
bool is_new;
|
||||
long dir_id = cur->request->dir_tab.back()->id;
|
||||
Ticket & ticket = session_data->GetTicket(dir_id, session_data->create_ticket_map);
|
||||
Ticket & ticket = session_data->GetTicket(dir_id, session_data->create_ticket_map, &is_new);
|
||||
ticket_info->create_new_ticket = is_new;
|
||||
|
||||
return ticket;
|
||||
}
|
||||
|
||||
|
||||
std::vector<long> & CreateTicket::PrepareFileMap()
|
||||
PT::Space & CreateTicket::PrepareSpace()
|
||||
{
|
||||
SessionData * session_data = reinterpret_cast<SessionData*>(
|
||||
cur->session->plugin_data.Get(ticket_info->plugin_id) );
|
||||
|
||||
long dir_id = cur->request->dir_tab.back()->id;
|
||||
std::vector<long> & file_map = session_data->GetFileTab(dir_id, session_data->create_file_map);
|
||||
PT::Space & space = session_data->GetSpace(dir_id, session_data->create_space_map);
|
||||
|
||||
return file_map;
|
||||
return space;
|
||||
}
|
||||
|
||||
|
||||
|
@ -145,15 +147,17 @@ void CreateTicket::MakePost()
|
|||
ticket_info->Clear();
|
||||
ticket_info->FindCurrentConf();
|
||||
|
||||
Ticket & ticket = PrepareTicket();
|
||||
Item & item = cur->request->item;
|
||||
Ticket & ticket = PrepareTicket();
|
||||
PT::Space & meta = PrepareSpace();
|
||||
Item & item = cur->request->item;
|
||||
ticket_info->ticket = &ticket;
|
||||
ticket_info->item = &item;
|
||||
std::vector<long> & file_map = PrepareFileMap();
|
||||
|
||||
ticket_info->ReadTicketParams(ticket, false, file_map, item.meta);
|
||||
ticket_info->ReadTicketParams(ticket, false, meta);
|
||||
functions->ReadItem(item, Item::file);
|
||||
|
||||
ticket_info->CopyTicketSpace(meta, item);
|
||||
|
||||
if( !cur->request->IsPostVar(L"fileuploadsubmit") )
|
||||
Submit(ticket, item);
|
||||
}
|
||||
|
@ -165,9 +169,12 @@ void CreateTicket::MakeGet()
|
|||
ticket_info->Clear();
|
||||
ticket_info->FindCurrentConf();
|
||||
|
||||
Ticket & ticket = PrepareTicket();
|
||||
Ticket & ticket = PrepareTicket();
|
||||
PT::Space & meta = PrepareSpace();
|
||||
ticket_info->ticket = &ticket;
|
||||
ticket_info->item = &cur->request->item;
|
||||
|
||||
ticket_info->CopyTicketSpace(meta, *ticket_info->item);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ private:
|
|||
void Submit(Ticket & ticket, Item & item);
|
||||
void RemoveTmpTicket();
|
||||
Ticket & PrepareTicket();
|
||||
std::vector<long> & PrepareFileMap();
|
||||
PT::Space & PrepareSpace();
|
||||
|
||||
TDb * tdb;
|
||||
TicketInfo * ticket_info;
|
||||
|
|
|
@ -113,7 +113,7 @@ void EditTicket::RemoveTmpTicket()
|
|||
|
||||
long file_id = cur->request->item.id;
|
||||
session_data->edit_ticket_map.erase(file_id);
|
||||
session_data->edit_file_map.erase(file_id);
|
||||
session_data->edit_space_map.erase(file_id);
|
||||
}
|
||||
|
||||
|
||||
|
@ -137,15 +137,24 @@ return ticket;
|
|||
|
||||
|
||||
|
||||
std::vector<long> & EditTicket::PrepareFileMap()
|
||||
PT::Space & EditTicket::PrepareSpace()
|
||||
{
|
||||
SessionData * session_data = reinterpret_cast<SessionData*>(
|
||||
cur->session->plugin_data.Get(ticket_info->plugin_id) );
|
||||
|
||||
bool is_new;
|
||||
long file_id = cur->request->item.id;
|
||||
std::vector<long> & file_map = session_data->GetFileTab(file_id, session_data->edit_file_map);
|
||||
PT::Space & space = session_data->GetSpace(file_id, session_data->edit_space_map, &is_new);
|
||||
|
||||
return file_map;
|
||||
if( is_new )
|
||||
{
|
||||
PT::Space * ticket_space = cur->request->item.meta.FindSpace(L"ticket");
|
||||
|
||||
if( ticket_space )
|
||||
space = *ticket_space;
|
||||
}
|
||||
|
||||
return space;
|
||||
}
|
||||
|
||||
|
||||
|
@ -154,16 +163,18 @@ void EditTicket::MakePost()
|
|||
ticket_info->Clear();
|
||||
ticket_info->FindCurrentConf();
|
||||
|
||||
Ticket & ticket = PrepareTicket();
|
||||
Item & item = cur->request->item;
|
||||
old_url = item.url;
|
||||
std::vector<long> & file_map = PrepareFileMap();
|
||||
Ticket & ticket = PrepareTicket();
|
||||
PT::Space & meta = PrepareSpace();
|
||||
Item & item = cur->request->item;
|
||||
old_url = item.url;
|
||||
ticket_info->ticket = &ticket;
|
||||
ticket_info->item = &item;
|
||||
|
||||
ticket_info->ReadTicketParams(ticket, false, file_map, item.meta);
|
||||
ticket_info->ReadTicketParams(ticket, false, meta);
|
||||
functions->ReadItem(item, Item::file);
|
||||
|
||||
ticket_info->CopyTicketSpace(meta, item);
|
||||
|
||||
if( !cur->request->IsPostVar(L"fileuploadsubmit") )
|
||||
Submit(ticket, item);
|
||||
}
|
||||
|
@ -175,9 +186,12 @@ void EditTicket::MakeGet()
|
|||
ticket_info->Clear();
|
||||
ticket_info->FindCurrentConf();
|
||||
|
||||
Ticket & ticket = PrepareTicket();
|
||||
Ticket & ticket = PrepareTicket();
|
||||
PT::Space & meta = PrepareSpace();
|
||||
ticket_info->ticket = &ticket;
|
||||
ticket_info->item = &cur->request->item;
|
||||
|
||||
ticket_info->CopyTicketSpace(meta, *ticket_info->item);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ private:
|
|||
|
||||
void RemoveTmpTicket();
|
||||
Ticket & PrepareTicket();
|
||||
std::vector<long> & PrepareFileMap();
|
||||
PT::Space & PrepareSpace();
|
||||
void ChangeTicket(Ticket & ticket, Item & item);
|
||||
void Submit(Ticket & ticket, Item & item);
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010, Tomasz Sowa
|
||||
* Copyright (c) 2010-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
@ -21,32 +21,56 @@ SessionData::SessionData()
|
|||
|
||||
SessionData::~SessionData()
|
||||
{
|
||||
RemoveFileMap(create_file_map);
|
||||
RemoveFileMap(edit_file_map);
|
||||
RemoveFiles(create_space_map);
|
||||
RemoveFiles(edit_space_map);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SessionData::RemoveFileMap(SessionData::FileMap & file_map)
|
||||
|
||||
|
||||
void SessionData::RemoveFiles(SessionData::SpaceMap & space_map)
|
||||
{
|
||||
FileMap::iterator i;
|
||||
SpaceMap::iterator i;
|
||||
|
||||
if( fun_rm )
|
||||
{
|
||||
for(i=file_map.begin() ; i!=file_map.end() ; ++i)
|
||||
{
|
||||
for(size_t a=0 ; a<i->second.size() ; ++a)
|
||||
{
|
||||
long file_id = i->second[a];
|
||||
fun_rm->RemoveItemById(file_id);
|
||||
}
|
||||
}
|
||||
for(i=space_map.begin() ; i!=space_map.end() ; ++i)
|
||||
RemoveFiles(i->second);
|
||||
|
||||
file_map.clear();
|
||||
space_map.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SessionData::RemoveFiles(PT::Space & space)
|
||||
{
|
||||
for(size_t i=0 ; i<space.spaces.size() ; ++i)
|
||||
{
|
||||
PT::Space & sp = *space.spaces[i];
|
||||
|
||||
if( sp.name == L"param" )
|
||||
{
|
||||
// !! wywalic to do osobnej metody
|
||||
for(size_t a=0 ; a<sp.spaces.size() ; ++a)
|
||||
{
|
||||
PT::Space & subsp = *sp.spaces[a];
|
||||
|
||||
if( subsp.name == L"file" )
|
||||
{
|
||||
std::wstring * file_id_str = subsp.GetValue(L"itemid");
|
||||
|
||||
if( file_id_str )
|
||||
{
|
||||
long file_id = Tol(*file_id_str);
|
||||
fun_rm->RemoveItemById(file_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Ticket & SessionData::GetTicket(long id, SessionData::TicketMap & ticket_map, bool * is_new)
|
||||
{
|
||||
|
@ -60,9 +84,12 @@ return res.first->second;
|
|||
|
||||
|
||||
|
||||
std::vector<long> & SessionData::GetFileTab(long id, FileMap & file_map)
|
||||
PT::Space & SessionData::GetSpace(long id, SpaceMap & space_map, bool * is_new)
|
||||
{
|
||||
std::pair<FileMap::iterator, bool> res = file_map.insert( std::make_pair(id, std::vector<long>()) );
|
||||
std::pair<SpaceMap::iterator, bool> res = space_map.insert( std::make_pair(id, PT::Space()) );
|
||||
|
||||
if( is_new )
|
||||
*is_new = res.second;
|
||||
|
||||
return res.first->second;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "core/plugindata.h"
|
||||
#include "ticket.h"
|
||||
#include "functions/rm.h"
|
||||
#include "confparser/space.h"
|
||||
|
||||
|
||||
namespace Ticket
|
||||
|
@ -28,8 +29,8 @@ struct SessionData : public PluginDataBase
|
|||
~SessionData();
|
||||
|
||||
|
||||
typedef std::map<long, Ticket> TicketMap;
|
||||
typedef std::map<long, std::vector<long> > FileMap;
|
||||
typedef std::map<long, Ticket> TicketMap;
|
||||
typedef std::map<long, PT::Space> SpaceMap;
|
||||
|
||||
|
||||
// temporary tickets for 'createticket' function
|
||||
|
@ -41,28 +42,34 @@ struct SessionData : public PluginDataBase
|
|||
TicketMap edit_ticket_map;
|
||||
|
||||
|
||||
// temporary files for 'createticket' function
|
||||
// temporary spaces for 'createticket' function
|
||||
// these files should be deleted if a user will not click on the submit button
|
||||
FileMap create_file_map;
|
||||
SpaceMap create_space_map;
|
||||
|
||||
// temporary files for 'editticket' function
|
||||
// temporary spaces for 'editticket' function
|
||||
// these files should be deleted if a user will not click on the submit button
|
||||
// !! zmienic nazwe na edit_file_map albo podobnie
|
||||
FileMap edit_file_map;
|
||||
SpaceMap edit_space_map;
|
||||
|
||||
|
||||
// inserting and returning a new ticket or just returning the ticket if it exists
|
||||
Ticket & GetTicket(long id, TicketMap & ticket_map, bool * is_new = 0);
|
||||
|
||||
std::vector<long> & GetFileTab(long id, FileMap & file_map);
|
||||
// inserting and returning a new space or just returning the space if it exists
|
||||
PT::Space & GetSpace(long id, SpaceMap & space_map, bool * is_new = 0);
|
||||
|
||||
// for deleting edit_file_map files
|
||||
// for deleting files
|
||||
// !! IMPROVE ME: when the program exits there can be a situation that
|
||||
// fun_rm was finished and then an object of this class exits and call fun_rm
|
||||
// so we should guarantee that all sessions object are removed first
|
||||
Fun::Rm * fun_rm;
|
||||
|
||||
void RemoveFileMap(FileMap & file_map);
|
||||
void RemoveFiles(SpaceMap & space_map);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
void RemoveFiles(PT::Space & space);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -24,7 +24,7 @@ struct Ticket
|
|||
{
|
||||
long param;
|
||||
long intv;
|
||||
std::wstring decv; // !! temporarily as a string (in the future there'll be a Dec type from ttmath)
|
||||
std::wstring decv; // !! temporarily as a string (in the future there'll be a Dec type from ttmath)
|
||||
|
||||
void Clear()
|
||||
{
|
||||
|
@ -40,16 +40,19 @@ struct Ticket
|
|||
};
|
||||
|
||||
long file_id;
|
||||
std::vector<TicketParam> par_tab;
|
||||
|
||||
// auxiliary object used during sorting
|
||||
//unsigned long sort_id;
|
||||
typedef std::vector<TicketParam> ParTab;
|
||||
ParTab par_tab;
|
||||
|
||||
|
||||
Ticket()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
file_id = -1;
|
||||
file_id = -1;
|
||||
par_tab.clear();
|
||||
//sort_id = 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -61,19 +64,11 @@ struct Ticket
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
void SortParTab()
|
||||
{
|
||||
std::sort(par_tab.begin(), par_tab.end(), Sort());
|
||||
}
|
||||
|
||||
|
||||
|
||||
Ticket()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -67,15 +67,19 @@ void TicketInfo::Clear()
|
|||
{
|
||||
ticket = &ticket_empty;
|
||||
item = &item_empty;
|
||||
ticket->Clear();
|
||||
item->Clear();
|
||||
// we use meta from item which should not be const
|
||||
|
||||
cur_conf_wrap = &cur_conf_wrap_empty;
|
||||
cur_conf = &cur_conf_empty;
|
||||
cur_conf->Clear();
|
||||
|
||||
item_tab.clear();
|
||||
ticket_tab.clear();
|
||||
item_sort_tab.clear();
|
||||
|
||||
create_new_ticket = false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -333,7 +337,6 @@ return false;
|
|||
void TicketInfo::ReadTicketValue(PT::Space & space,
|
||||
long param_id,
|
||||
const PostFile & value,
|
||||
std::vector<long> & file_map,
|
||||
PT::Space & meta,
|
||||
Item & upload_dir)
|
||||
{
|
||||
|
@ -349,20 +352,17 @@ void TicketInfo::ReadTicketValue(PT::Space & space,
|
|||
|
||||
if( cur->request->status == WINIX_ERR_OK )
|
||||
{
|
||||
PT::Space & sp = meta.AddSpace(L"param");
|
||||
|
||||
sp.Add(L"id", param_id);
|
||||
PT::Space & space = FindAddMetaByParam(meta, param_id);
|
||||
PT::Space & file_space = space.AddSpace(L"file");
|
||||
|
||||
if( file.file_type == WINIX_ITEM_FILETYPE_IMAGE )
|
||||
sp.Add(L"type", L"image");
|
||||
file_space.Add(L"type", L"image");
|
||||
else
|
||||
sp.Add(L"type", L"file");
|
||||
file_space.Add(L"type", L"file");
|
||||
|
||||
sp.Add(L"file_id", file.id);
|
||||
file_space.Add(L"itemid", file.id);
|
||||
system->MakePath(file, file_path);
|
||||
sp.Add(L"path", file_path);
|
||||
|
||||
file_map.push_back(file.id);
|
||||
file_space.Add(L"path", file_path);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -372,21 +372,24 @@ void TicketInfo::ReadTicketValue(PT::Space & space,
|
|||
|
||||
|
||||
void TicketInfo::ReadTicketValue(PT::Space & space,
|
||||
long param_id, const PostFile & value, std::vector<long> & file_map, PT::Space & meta)
|
||||
long param_id, const PostFile & value, PT::Space & meta)
|
||||
{
|
||||
if( space.Text(L"type") == L"images" ||
|
||||
space.Text(L"type") == L"files" )
|
||||
if( space.Text(L"type") == L"images" || space.Text(L"type") == L"files" )
|
||||
{
|
||||
std::wstring & upload_path = space.Text(L"upload_dir");
|
||||
Item * upload_dir = system->dirs.GetDir(upload_path);
|
||||
|
||||
if( upload_dir )
|
||||
if( !upload_path.empty() )
|
||||
{
|
||||
ReadTicketValue(space, param_id, value, file_map, meta, *upload_dir);
|
||||
Item * upload_dir = system->dirs.GetDir(upload_path);
|
||||
|
||||
if( upload_dir )
|
||||
ReadTicketValue(space, param_id, value, meta, *upload_dir);
|
||||
else
|
||||
log << log1 << "Ticket: there is no an upload directory: " << upload_path << logend;
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Ticket: there is no an upload directory: " << upload_path << logend;
|
||||
log << log1 << "Ticket: you must set 'upload_dir' directory in the config" << logend;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -439,15 +442,15 @@ void TicketInfo::ReadTicketParam(Ticket & ticket, long param_id, const std::wstr
|
|||
|
||||
|
||||
// always adds a new parameter
|
||||
void TicketInfo::ReadTicketParam(Ticket & ticket, long param_id, const PostFile & value, std::vector<long> & file_map, PT::Space & meta)
|
||||
void TicketInfo::ReadTicketParam(long param_id, const PostFile & value, PT::Space & meta)
|
||||
{
|
||||
for(size_t i=0 ; i<cur_conf->spaces.size() ; ++i)
|
||||
{
|
||||
PT::Space & space = *cur_conf->spaces[i];
|
||||
|
||||
if( space.name == L"param" && Tol(space.Text(L"id")) == param_id )
|
||||
if( space.name == L"param" && space.Long(L"id") == param_id )
|
||||
{
|
||||
ReadTicketValue(space, param_id, value, file_map, meta);
|
||||
ReadTicketValue(space, param_id, value, meta);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -457,7 +460,7 @@ void TicketInfo::ReadTicketParam(Ticket & ticket, long param_id, const PostFile
|
|||
|
||||
|
||||
|
||||
void TicketInfo::ReadTicketParams(Ticket & ticket, bool clear_ticket, std::vector<long> & file_map, PT::Space & meta)
|
||||
void TicketInfo::ReadTicketParams(Ticket & ticket, bool clear_ticket, PT::Space & meta)
|
||||
{
|
||||
PostTab::iterator i;
|
||||
PostFileTab::iterator i2;
|
||||
|
@ -465,18 +468,16 @@ PostFileTab::iterator i2;
|
|||
if( clear_ticket )
|
||||
ticket.Clear();
|
||||
|
||||
PT::Space & ticket_meta = meta.FindAddSpace(L"ticket");
|
||||
|
||||
for(i=cur->request->post_tab.begin() ; i!=cur->request->post_tab.end() ; ++i)
|
||||
{
|
||||
if( IsSubString(config->ticket_form_prefix, i->first) )
|
||||
ReadTicketParam(ticket, Tol(i->first.c_str() + config->ticket_form_prefix.size()), i->second, ticket_meta);
|
||||
ReadTicketParam(ticket, Tol(i->first.c_str() + config->ticket_form_prefix.size()), i->second, meta);
|
||||
}
|
||||
|
||||
for(i2=cur->request->post_file_tab.begin() ; i2!=cur->request->post_file_tab.end() ; ++i2)
|
||||
{
|
||||
if( IsSubString(config->ticket_form_prefix, i2->first) )
|
||||
ReadTicketParam(ticket, Tol(i2->first.c_str() + config->ticket_form_prefix.size()), i2->second, file_map, ticket_meta);
|
||||
ReadTicketParam(Tol(i2->first.c_str() + config->ticket_form_prefix.size()), i2->second, meta);
|
||||
}
|
||||
|
||||
ticket.SortParTab();
|
||||
|
@ -505,5 +506,12 @@ void TicketInfo::RemoveTicket(long file_id)
|
|||
}
|
||||
|
||||
|
||||
void TicketInfo::CopyTicketSpace(PT::Space & ticket_space, Item & item)
|
||||
{
|
||||
PT::Space & ticket_meta = item.meta.FindAddSpace(L"ticket");
|
||||
ticket_meta = ticket_space;
|
||||
ticket_meta.name = L"ticket";
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -55,11 +55,16 @@ public:
|
|||
void Clear();
|
||||
|
||||
// current ticket for templates
|
||||
const Ticket * ticket;
|
||||
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;
|
||||
|
@ -93,8 +98,9 @@ public:
|
|||
|
||||
void ReadTicketConf(bool skip_existing_configs = false);
|
||||
void FindCurrentConf();
|
||||
void ReadTicketParams(Ticket & ticket, bool clear_ticket, std::vector<long> & file_map, PT::Space & meta);
|
||||
void ReadTicketParams(Ticket & ticket, bool clear_ticket, PT::Space & meta);
|
||||
void RemoveTicket(long file_id);
|
||||
void CopyTicketSpace(PT::Space & ticket_space, Item & item);
|
||||
|
||||
private:
|
||||
|
||||
|
@ -121,8 +127,8 @@ private:
|
|||
// (we don't want to use empty pointers)
|
||||
TicketConfWrap cur_conf_wrap_empty;
|
||||
PT::Space cur_conf_empty;
|
||||
const Ticket ticket_empty;
|
||||
Item item_empty;
|
||||
Ticket ticket_empty;
|
||||
Item item_empty;
|
||||
|
||||
// for removing a ticket
|
||||
Ticket rm_ticket;
|
||||
|
@ -138,11 +144,11 @@ private:
|
|||
|
||||
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, std::vector<long> & file_map, PT::Space & meta, Item & upload_dir);
|
||||
void ReadTicketValue(PT::Space & space, long param_id, const PostFile & value, std::vector<long> & file_map, 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(Ticket & ticket, long param_id, const PostFile & value, std::vector<long> & file_map, PT::Space & meta);
|
||||
void ReadTicketParam(long param_id, const PostFile & value, PT::Space & meta);
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue