removed from Item: update() and save() methods which take the 'url_was_changed' argument
and added ItemModelData (based on morm::ModelData) class which has 'prepare_unique_url' field, an object of this class is passed to update(), insert() and save() methods fixed: Dirs::CheckRootDir(): update should update childs too (privileges) WIP: #4
This commit is contained in:
@@ -152,12 +152,13 @@ bool ok = true;
|
||||
if( CopyStaticFile(old_path, new_path) )
|
||||
{
|
||||
//cur->request->status = db->EditFileById(item, item.id);
|
||||
if( !item.update(false, true) )
|
||||
item.propagate_connector();
|
||||
|
||||
if( !item.item_content.update() )
|
||||
{
|
||||
cur->request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
}
|
||||
|
||||
|
||||
if( item.item_content.file_has_thumb )
|
||||
CopyStaticFile(old_path_thumb, new_path_thumb);
|
||||
}
|
||||
|
||||
@@ -58,6 +58,7 @@ bool Default::HasAccess()
|
||||
void Default::MakePost()
|
||||
{
|
||||
Item & dir = *cur->request->dir_tab.back();
|
||||
dir.propagate_connector();
|
||||
|
||||
dir.item_content.link_to = cur->request->PostVar(L"linkto");
|
||||
dir.item_content.link_redirect = cur->request->IsPostVar(L"makeredirect") ? 1 : 0;
|
||||
@@ -66,7 +67,7 @@ void Default::MakePost()
|
||||
// !! IMPROVEME dodac sprawdzenie czy link_to jest pusty teraz
|
||||
|
||||
//cur->request->status = db->EditLinkItem(dir.id, dir.link_to, dir.link_redirect);
|
||||
if( dir.update(false, true) )
|
||||
if( dir.item_content.update() )
|
||||
{
|
||||
log << log2 << "Default: changed link_to: " << dir.item_content.link_to << ", for dir_id: " << dir.id << logend;
|
||||
system->RedirectToLastDir();
|
||||
|
||||
@@ -75,10 +75,11 @@ bool Meta::EditAdminMeta(Item & item, const std::wstring & meta_str, bool use_se
|
||||
{
|
||||
if( Parse(meta_str) )
|
||||
{
|
||||
item.propagate_connector();
|
||||
item.item_content.meta_admin = space;
|
||||
|
||||
//if( db->EditAdminMetaById(space, item_id) == WINIX_ERR_OK )
|
||||
if( item.update(false, true) )
|
||||
if( item.item_content.update() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -105,10 +106,11 @@ bool Meta::EditMeta(Item & item, const std::wstring & meta_str, bool use_ses_log
|
||||
{
|
||||
if( Parse(meta_str) )
|
||||
{
|
||||
item.propagate_connector();
|
||||
item.item_content.meta = space;
|
||||
|
||||
//if( db->EditMetaById(space, item_id) == WINIX_ERR_OK )
|
||||
if( item.update(false, true) )
|
||||
if( item.item_content.update() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -90,6 +90,7 @@ return true;
|
||||
|
||||
void Mkdir::PostFunMkdir(bool add_to_dir_tab, int privileges)
|
||||
{
|
||||
cur->request->item.set_connector(model_connector);
|
||||
functions->ReadItem(cur->request->item, Item::dir);
|
||||
functions->SetUser(cur->request->item);
|
||||
cur->request->item.item_content.privileges = privileges;
|
||||
|
||||
@@ -283,8 +283,10 @@ bool ok = true;
|
||||
|
||||
if( MoveStaticFile(old_static_path, new_static_path) )
|
||||
{
|
||||
item.propagate_connector();
|
||||
|
||||
//if( db->EditFileById(item, item.id) != WINIX_ERR_OK )
|
||||
if( !item.update(false, true) )
|
||||
if( !item.item_content.update() )
|
||||
{
|
||||
log << log1 << "Mv: cannot move static file (database problem)" << logend;
|
||||
slog << logerror << T("internal_error") << logend;
|
||||
@@ -401,7 +403,7 @@ bool Mv::MoveDir(Item & src_dir, std::vector<Item*> & dst_dir_tab, const std::ws
|
||||
}
|
||||
|
||||
//Error status = db->EditParentUrlById(src_dir, src_dir.id);
|
||||
if( src_dir.update(true, false) )
|
||||
if( src_dir.update(false) )
|
||||
{
|
||||
log << log3 << "Mv: directory: " << old_url << " was moved to: ";
|
||||
system->dirs.LogDir(dst_dir_tab);
|
||||
@@ -530,7 +532,7 @@ bool Mv::MoveFileOrSymlink(Item & src_file, std::vector<Item*> & dst_dir_tab, co
|
||||
src_file.parent_id = dst_dir_tab.back()->id;
|
||||
|
||||
//Error status = db->EditParentUrlById(src_file, src_file.id);
|
||||
if( src_file.update(true, false) )
|
||||
if( src_file.update(false) )
|
||||
{
|
||||
if( src_file.type == Item::file )
|
||||
log << log3 << "Mv: file: ";
|
||||
|
||||
@@ -133,8 +133,10 @@ void PrivChanger::ChangePriv(Item & item, long user_id, long group_id, int privi
|
||||
return;
|
||||
}
|
||||
|
||||
item.propagate_connector();
|
||||
|
||||
//cur->request->status = db->EditPrivById(item, item.id);
|
||||
if( !item.update(false, true) )
|
||||
if( !item.item_content.update() )
|
||||
{
|
||||
// IMPROVEME put some log here, and slog too
|
||||
}
|
||||
|
||||
@@ -136,8 +136,11 @@ void Sort::UpdateSortIndex(Item & item, int sort_index)
|
||||
{
|
||||
item.sort_index = sort_index;
|
||||
|
||||
ItemModelData item_model_data;
|
||||
item_model_data.prepare_unique_url = false;
|
||||
|
||||
//if( db->EditSortIndexItemById(item.id, sort_index) == WINIX_ERR_OK )
|
||||
if( item.update(false, false) )
|
||||
if( item.update(item_model_data, false) )
|
||||
{
|
||||
log << log2
|
||||
<< "Sort: updated sort index, item_id=" << item.id
|
||||
|
||||
@@ -76,8 +76,12 @@ void Subject::EditDirSubject()
|
||||
Item & dir = *cur->request->dir_tab.back();
|
||||
|
||||
cur->request->PostVar(L"subject", dir.subject);
|
||||
dir.update(false, false);
|
||||
|
||||
ItemModelData item_model_data;
|
||||
item_model_data.prepare_unique_url = false;
|
||||
|
||||
//db->EditSubjectById(dir, dir.id);
|
||||
dir.update(item_model_data, false);
|
||||
|
||||
// !! IMPROVE ME
|
||||
// we need something like WINIX_DIR_CHANGED message
|
||||
@@ -91,7 +95,11 @@ void Subject::EditDirSubject()
|
||||
void Subject::EditFileSubject()
|
||||
{
|
||||
cur->request->PostVar(L"subject", cur->request->item.subject);
|
||||
cur->request->item.update(false, false);
|
||||
|
||||
ItemModelData item_model_data;
|
||||
item_model_data.prepare_unique_url = false;
|
||||
|
||||
cur->request->item.update(item_model_data, false);
|
||||
//db->EditSubjectById(cur->request->item, cur->request->item.id);
|
||||
|
||||
plugin->Call(WINIX_FILE_CHANGED, &cur->request->item);
|
||||
|
||||
@@ -124,8 +124,11 @@ void Template::ChangeTemplate(Item & item)
|
||||
{
|
||||
item.html_template = html_template;
|
||||
|
||||
ItemModelData item_model_data;
|
||||
item_model_data.prepare_unique_url = false;
|
||||
|
||||
//cur->request->status = db->EditTemplateItemById(item.id, html_template);
|
||||
if( item.update(false, false) )
|
||||
if( item.update(item_model_data, false) )
|
||||
{
|
||||
PutLog(item);
|
||||
}
|
||||
|
||||
@@ -154,8 +154,11 @@ void Upload::UploadFile(Item & item, const std::wstring & tmp_filename)
|
||||
{
|
||||
if( UploadSaveStaticFile(item, tmp_filename) )
|
||||
{
|
||||
ItemModelData item_model_data;
|
||||
item_model_data.prepare_unique_url = false;
|
||||
|
||||
//cur->request->status = db->EditFileById(item, item.id);
|
||||
if( item.update(false, true) )
|
||||
if( item.update(item_model_data) )
|
||||
{
|
||||
plugin->Call(WINIX_FILE_ADDED, &item);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user