122 lines
2.1 KiB
C++
Executable File
122 lines
2.1 KiB
C++
Executable File
/*
|
|
* This file is a part of Winix
|
|
* and is not publicly distributed
|
|
*
|
|
* Copyright (c) 2012-2013, Tomasz Sowa
|
|
* All rights reserved.
|
|
*
|
|
*/
|
|
|
|
|
|
#include "funexport.h"
|
|
|
|
|
|
|
|
|
|
namespace Export
|
|
{
|
|
|
|
|
|
FunExport::FunExport()
|
|
{
|
|
fun.url = L"export";
|
|
}
|
|
|
|
|
|
void FunExport::SetExportInfo(ExportInfo * pexport_info)
|
|
{
|
|
export_info = pexport_info;
|
|
}
|
|
|
|
|
|
bool FunExport::HasAccess()
|
|
{
|
|
// temporarily only a logged user can use this function
|
|
// !! IMPROVEME we have to change to only some users can use this function in a specified directory
|
|
return cur->session->puser;
|
|
}
|
|
|
|
|
|
void FunExport::ExportFile(const Item & item)
|
|
{
|
|
log << log4 << "Export: exporting file: url: " << item.url << ", id: " << item.id << logend;
|
|
|
|
if( item.file_type == WINIX_ITEM_FILETYPE_NONE )
|
|
{
|
|
export_info->SendFile(item, false, true);
|
|
}
|
|
else
|
|
{
|
|
export_info->SendFile(item, false, false);
|
|
export_info->SendFile(item, true, true);
|
|
}
|
|
}
|
|
|
|
|
|
void FunExport::ExportDir(const Item & dir, bool static_files_too)
|
|
{
|
|
export_info->SendDir(dir);
|
|
|
|
log << log4 << "Export: exporting directory: url: " << dir.url << ", id: " << dir.id << logend;
|
|
|
|
iq_dir.SetAll(false, false);
|
|
iq_dir.sel_parent_id = true;
|
|
iq_dir.sel_url = true;
|
|
iq_dir.sel_file = true;
|
|
iq_dir.WhereParentId(dir.id);
|
|
iq_dir.WhereType(Item::file);
|
|
|
|
if( !static_files_too )
|
|
iq_dir.WhereFileType(WINIX_ITEM_FILETYPE_NONE);
|
|
|
|
db->GetItems(dir_items, iq_dir);
|
|
|
|
for(size_t i=0 ; i<dir_items.size() ; ++i)
|
|
{
|
|
ExportFile(dir_items[i]);
|
|
}
|
|
|
|
|
|
|
|
DirContainer::ParentIterator i = system->dirs.FindFirstChild(dir.id);
|
|
|
|
for( ; i != system->dirs.ParentEnd() ; i = system->dirs.NextChild(i) )
|
|
{
|
|
ExportDir(*i->second, static_files_too);
|
|
}
|
|
}
|
|
|
|
|
|
void FunExport::Export()
|
|
{
|
|
export_info->ResetRecurrenceCheck();
|
|
bool static_files_too = cur->request->IsPostVar(L"staticfilestoo");
|
|
|
|
if( cur->request->is_item )
|
|
ExportFile(cur->request->item);
|
|
else
|
|
ExportDir(*cur->request->dir_tab.back(), static_files_too);
|
|
}
|
|
|
|
|
|
|
|
void FunExport::MakePost()
|
|
{
|
|
Export();
|
|
}
|
|
|
|
|
|
void FunExport::MakeGet()
|
|
{
|
|
// if( cur->request->IsParam(L"noconfirm") )
|
|
// Export();
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|