115 lines
1.8 KiB
C++
115 lines
1.8 KiB
C++
|
/*
|
||
|
* This file is a part of Winix
|
||
|
* and is not publicly distributed
|
||
|
*
|
||
|
* Copyright (c) 2012, 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 the root can use this function
|
||
|
return cur->session->puser && cur->session->puser->super_user;
|
||
|
}
|
||
|
|
||
|
|
||
|
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)
|
||
|
{
|
||
|
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);
|
||
|
//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);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
void FunExport::Export()
|
||
|
{
|
||
|
export_info->ResetRecurrenceCheck();
|
||
|
|
||
|
if( cur->request->is_item )
|
||
|
ExportFile(cur->request->item);
|
||
|
else
|
||
|
ExportDir(*cur->request->dir_tab.back());
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
void FunExport::MakePost()
|
||
|
{
|
||
|
Export();
|
||
|
}
|
||
|
|
||
|
|
||
|
void FunExport::MakeGet()
|
||
|
{
|
||
|
// if( cur->request->IsParam(L"noconfirm") )
|
||
|
// Export();
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
} // namespace
|
||
|
|
||
|
|