added: 'export' winix function (export plugin)
exporting an item or the whole directory git-svn-id: svn://ttmath.org/publicrep/winix/trunk@867 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
114
plugins/export/funexport.cpp
Executable file
114
plugins/export/funexport.cpp
Executable file
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
|
Reference in New Issue
Block a user