added: to Item struct: ameta (PT::Space)

admin meta information
added: option "a" to meta winix function
       editing admin meta information
changed: now if you don't have write access to an item
         you can't see the meta information
         previous if you had read access you could have seen them
added: in plugin ticket and thread
       support for 'closing' (ticket, thread)
       (this is only logic, we need some html yet)
added: some ezc function for getting meta/admin meta information
       (for the current item and the last directory)




git-svn-id: svn://ttmath.org/publicrep/winix/trunk@907 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2012-11-04 21:01:02 +00:00
parent 4809016b78
commit 0045c6c72c
24 changed files with 389 additions and 88 deletions

View File

@@ -54,7 +54,7 @@ return (conf_parser.ParseString(env_str) == PT::SpaceParser::ok);
}
bool Env::EditAdminEnv(long user_id, const std::wstring & env_str)
bool Env::EditAdminEnv(long user_id, const std::wstring & env_str, bool use_ses_log)
{
if( Parse(env_str) )
{
@@ -69,21 +69,23 @@ bool Env::EditAdminEnv(long user_id, const std::wstring & env_str)
}
else
{
log << log1 << "Evn: a problem with changing environment variables for user: "
log << log1 << "Evn: a database problem with changing environment variables for user: "
<< cur->session->puser->name << ", id: " << cur->session->puser->id << logend;
}
}
else
{
log << log2 << "Env: Syntax error in line: " << conf_parser.line << logend;
slog << logerror << "Syntax error in line: " << conf_parser.line << logend;
if( use_ses_log )
slog << logerror << T("syntax_error_in_line") << ' ' << conf_parser.line << logend;
}
return false;
}
bool Env::EditEnv(long user_id, const std::wstring & env_str)
bool Env::EditEnv(long user_id, const std::wstring & env_str, bool use_ses_log)
{
if( Parse(env_str) )
{
@@ -98,20 +100,23 @@ bool Env::EditEnv(long user_id, const std::wstring & env_str)
}
else
{
log << log1 << "Evn: a problem with changing admin environment variables for user: "
log << log1 << "Evn: a database problem with changing admin environment variables for user: "
<< cur->session->puser->name << ", id: " << cur->session->puser->id << logend;
}
}
else
{
log << log2 << "Env: Syntax error in line: " << conf_parser.line << logend;
slog << logerror << "Syntax error in line: " << conf_parser.line << logend;
if( use_ses_log )
slog << logerror << T("syntax_error_in_line") << ' ' << conf_parser.line << logend;
}
return false;
}
void Env::SaveEnv()
{
if( GetUser() )
@@ -123,11 +128,11 @@ void Env::SaveEnv()
if( cur->request->IsParam(L"a") )
{
if( cur->session->puser->super_user )
status = EditAdminEnv(user_id, env_str);
status = EditAdminEnv(user_id, env_str, true);
}
else
{
status = EditEnv(user_id, env_str);
status = EditEnv(user_id, env_str, true);
}
if( status )

View File

@@ -24,8 +24,8 @@ public:
Env();
bool EditAdminEnv(long user_id, const std::wstring & env_str);
bool EditEnv(long user_id, const std::wstring & env_str);
bool EditAdminEnv(long user_id, const std::wstring & env_str, bool use_ses_log = false);
bool EditEnv(long user_id, const std::wstring & env_str, bool use_ses_log = false);
bool HasAccess();
void MakePost();

View File

@@ -17,30 +17,53 @@ namespace Fun
Meta::Meta()
{
fun.url = L"meta";
// !! CHECKME what about follow symlinks?
}
bool Meta::HasAccess()
{
return system->HasReadAccess(*cur->request->last_item);
if( cur->request->IsParam(L"a") )
return cur->session->puser && cur->session->puser->super_user;
else
return system->HasWriteAccess(*cur->request->last_item);
}
bool Meta::AddMetaInfo(Item & item, const std::wstring & meta_str)
bool Meta::Parse(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 )
return (conf_parser.ParseString(meta_str) == PT::SpaceParser::ok);
}
bool Meta::EditAdminMeta(long item_id, const std::wstring & meta_str, bool use_ses_log)
{
if( Parse(meta_str) )
{
if( db->EditMetaById(space, item.id) == WINIX_ERR_OK )
if( db->EditAdminMetaById(space, item_id) == WINIX_ERR_OK )
{
item.meta = space;
return true;
}
else
{
log << log1 << "Meta: a database problem with changing admin meta information for item id: "
<< item_id << logend;
}
}
else
{
log << log2 << "Meta: Syntax error in line: " << conf_parser.line << logend;
if( use_ses_log )
slog << logerror << T("syntax_error_in_line") << ' ' << conf_parser.line << logend;
}
return false;
@@ -48,21 +71,64 @@ return false;
void Meta::MakePost()
bool Meta::EditMeta(long item_id, const std::wstring & meta_str, bool use_ses_log)
{
if( Parse(meta_str) )
{
if( db->EditMetaById(space, item_id) == WINIX_ERR_OK )
{
return true;
}
else
{
log << log1 << "Meta: a database problem with changing meta information for item id: "
<< item_id << logend;
}
}
else
{
log << log2 << "Meta: Syntax error in line: " << conf_parser.line << logend;
if( use_ses_log )
slog << logerror << T("syntax_error_in_line") << ' ' << conf_parser.line << logend;
}
return false;
}
void Meta::ChangeAdminMeta()
{
if( cur->session->puser && cur->session->puser->super_user )
{
const std::wstring & meta_str = cur->request->PostVar(L"itemmeta");
if( EditAdminMeta(cur->request->last_item->id, meta_str, true) )
system->RedirectToLastItem();
}
}
void Meta::ChangeMeta()
{
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) )
if( EditMeta(cur->request->last_item->id, meta_str, true) )
system->RedirectToLastItem();
else
slog << logerror << "Syntax error in line: " << conf_parser.line << logend;
}
}
void Meta::MakePost()
{
if( cur->request->IsParam(L"a") )
ChangeAdminMeta();
else
{
cur->request->status = WINIX_ERR_PERMISSION_DENIED;
}
ChangeMeta();
}

View File

@@ -26,12 +26,19 @@ public:
bool HasAccess();
void MakePost();
bool AddMetaInfo(Item & item, const std::wstring & meta_str);
bool EditAdminMeta(long item_id, const std::wstring & meta_str, bool use_ses_log = false);
bool EditMeta(long item_id, const std::wstring & meta_str, bool use_ses_log = false);
private:
PT::SpaceParser conf_parser;
PT::Space space;
bool Parse(const std::wstring & meta_str);
void ChangeAdminMeta();
void ChangeMeta();
};