added: to Rm function:

bool Rm::RemoveFileOrSymlink(long item_id, bool check_access)
added: in ticket plugin: possibility to remove a file/image
       (not finished yet)




git-svn-id: svn://ttmath.org/publicrep/winix/trunk@924 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2013-05-06 07:23:44 +00:00
parent 0e9eb30b5d
commit 1c401eae3b
11 changed files with 125 additions and 21 deletions

View File

@@ -2,7 +2,7 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2012, Tomasz Sowa
* Copyright (c) 2008-2013, Tomasz Sowa
* All rights reserved.
*
*/
@@ -157,12 +157,14 @@ void CreateTicket::MakePost()
ticket_info->ticket = &ticket;
ticket_info->item = &item;
ticket_info->ReadTicketParams(ticket, false, meta);
bool file_was_deleted;
ticket_info->ReadTicketParams(ticket, false, meta, file_was_deleted);
functions->ReadItem(item, Item::file);
ticket_info->CopyTicketSpace(meta, item);
if( !cur->request->IsPostVar(L"fileuploadsubmit") )
if( !cur->request->IsPostVar(L"fileuploadsubmit") && !file_was_deleted )
{
Submit(ticket, item);
ticket_info->ticket = ticket_info->GetEmptyTicket(); // ticket was deleted by Submit() method -- RemoveTmpTicket() was used

View File

@@ -2,7 +2,7 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2012, Tomasz Sowa
* Copyright (c) 2008-2013, Tomasz Sowa
* All rights reserved.
*
*/
@@ -209,12 +209,13 @@ void EditTicket::MakePost()
}
else
{
ticket_info->ReadTicketParams(ticket, false, meta);
bool file_was_deleted;
ticket_info->ReadTicketParams(ticket, false, meta, file_was_deleted);
functions->ReadItem(item, Item::file);
ticket_info->CopyTicketSpace(meta, item);
if( !cur->request->IsPostVar(L"fileuploadsubmit") )
if( !cur->request->IsPostVar(L"fileuploadsubmit") && !file_was_deleted )
{
Submit(ticket, item);
ticket_info->ticket = ticket_info->GetEmptyTicket(); // ticket was deleted by Submit() method -- RemoveTmpTicket() was used

View File

@@ -86,7 +86,7 @@ void SessionData::RemoveAllStaleFiles(PT::Space & new_space, PT::Space & old_spa
{
if( new_file_tab[n] < old_file_tab[o] )
{
fun_rm->RemoveItemById(new_file_tab[n], false);
fun_rm->RemoveFileOrSymlink(new_file_tab[n], false);
n += 1;
}
else
@@ -103,7 +103,7 @@ void SessionData::RemoveAllStaleFiles(PT::Space & new_space, PT::Space & old_spa
while( n < new_file_tab.size() )
{
fun_rm->RemoveItemById(new_file_tab[n], false);
fun_rm->RemoveFileOrSymlink(new_file_tab[n], false);
n += 1;
}
}

View File

@@ -298,13 +298,9 @@ void ticket_param_value_for_param_id(Info & i)
for( ; conf_index < space.spaces.size() ; ++conf_index)
{
log << log1 << "analizuje: " << space.spaces[conf_index]->Text(L"name") << logend;
if( space.spaces[conf_index]->name == L"param" &&
space.spaces[conf_index]->Int(L"id") == id )
{
log << log1 << "znalazlem: " << space.spaces[conf_index]->Text(L"name") << logend;
value_for_param_id.Clear();
value_for_param_id.is_param = true;
value_for_param_id.config_par = space.spaces[conf_index];

View File

@@ -2,7 +2,7 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2010-2012, Tomasz Sowa
* Copyright (c) 2010-2013, Tomasz Sowa
* All rights reserved.
*
*/
@@ -17,6 +17,8 @@
#include "pluginmsg.h"
#include "sessiondata.h"
namespace Ticket
{
@@ -473,18 +475,76 @@ void TicketInfo::ReadTicketParam(long param_id, const PostFile & value, PT::Spac
void TicketInfo::ReadTicketParams(Ticket & ticket, bool clear_ticket, PT::Space & meta)
bool TicketInfo::DeleteTicketFile(Ticket & ticket, long file_id, PT::Space & meta)
{
for(size_t i=0 ; i<meta.spaces.size() ; ++i)
{
PT::Space & param = *meta.spaces[i];
if( param.name == L"param" )
{
for(size_t z=0 ; z<param.spaces.size() ; ++z)
{
PT::Space & file = *param.spaces[z];
if( file.name == L"file" )
{
if( file.Long(L"itemid") == file_id )
{
param.RemoveSpace(z);
// !! IMPROVE ME
// temporarily we delete the file here
// but it should be really deleted when the user will press
// the submit button
//functions->fun_rm.RemoveFileOrSymlink(file_id, true);
return true;
}
}
}
}
}
return false;
}
void TicketInfo::ReadTicketParams(Ticket & ticket, bool clear_ticket, PT::Space & meta, bool & file_was_deleted)
{
PostTab::iterator i;
PostFileTab::iterator i2;
file_was_deleted = false;
if( clear_ticket )
ticket.Clear();
// !! IMPROVE ME move me somewhere
std::wstring ticket_delete_prefix = L"ticketdeletefile_";
for(i=cur->request->post_tab.begin() ; i!=cur->request->post_tab.end() ; ++i)
{
// !! CHECKME why ticket_form_prefix is in the global config?
// (this is a plugin variable)
if( IsSubString(config->ticket_form_prefix, i->first) )
ReadTicketParam(ticket, Tol(i->first.c_str() + config->ticket_form_prefix.size()), i->second, meta);
{
long param_id = Tol(i->first.c_str() + config->ticket_form_prefix.size());
ReadTicketParam(ticket, param_id, i->second, meta);
}
if( IsSubString(ticket_delete_prefix, i->first) )
{
long file_id = Tol(i->first.c_str() + ticket_delete_prefix.size());
if( DeleteTicketFile(ticket, file_id, meta) )
{
file_was_deleted = true;
}
}
}
for(i2=cur->request->post_file_tab.begin() ; i2!=cur->request->post_file_tab.end() ; ++i2)

View File

@@ -2,7 +2,7 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2010-2012, Tomasz Sowa
* Copyright (c) 2010-2013, Tomasz Sowa
* All rights reserved.
*
*/
@@ -99,7 +99,7 @@ public:
void ReadTicketConf(bool skip_existing_configs = false);
void FindCurrentConf(long dir_id);
void FindCurrentConf();
void ReadTicketParams(Ticket & ticket, bool clear_ticket, PT::Space & meta);
void ReadTicketParams(Ticket & ticket, bool clear_ticket, PT::Space & meta, bool & file_was_deleted);
void RemoveTicket(long file_id);
void CopyTicketSpace(PT::Space & ticket_space, Item & item);
@@ -156,6 +156,8 @@ private:
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);
bool DeleteTicketFile(Ticket & ticket, long file_id, PT::Space & meta);
};