72 lines
1.1 KiB
C++
Executable File
72 lines
1.1 KiB
C++
Executable File
/*
|
|
* This file is a part of Winix
|
|
* and is not publicly distributed
|
|
*
|
|
* Copyright (c) 2011-2012, Tomasz Sowa
|
|
* All rights reserved.
|
|
*
|
|
*/
|
|
|
|
#include "meta.h"
|
|
#include "core/log.h"
|
|
|
|
|
|
namespace Fun
|
|
{
|
|
|
|
Meta::Meta()
|
|
{
|
|
fun.url = L"meta";
|
|
}
|
|
|
|
|
|
bool Meta::HasAccess()
|
|
{
|
|
return system->HasReadAccess(*cur->request->last_item);
|
|
}
|
|
|
|
|
|
|
|
bool Meta::AddMetaInfo(Item & item, const std::wstring & meta_str)
|
|
{
|
|
space.Clear();
|
|
conf_parser.SetSpace(space);
|
|
conf_parser.UTF8(config->utf8);
|
|
conf_parser.SplitSingle(true);
|
|
|
|
if( conf_parser.ParseString(meta_str) == PT::SpaceParser::ok )
|
|
{
|
|
if( db->EditMetaById(space, item.id) == WINIX_ERR_OK )
|
|
{
|
|
item.meta = space;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
|
|
|
|
void Meta::MakePost()
|
|
{
|
|
if( system->HasWriteAccess(*cur->request->last_item) )
|
|
{
|
|
const std::wstring & meta_str = cur->request->PostVar(L"itemmeta");
|
|
|
|
if( AddMetaInfo(*cur->request->last_item, meta_str) )
|
|
system->RedirectToLastItem();
|
|
else
|
|
slog << logerror << "Syntax error in line: " << conf_parser.line << logend;
|
|
}
|
|
else
|
|
{
|
|
cur->request->status = WINIX_ERR_PERMISSION_DENIED;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
|
|