Item class has been moved to a new directory 'models', a new class has been added: ItemContent
and same fields from Item were moved to ItemContent Item - id - parent_id - type (file, dir, symlink) - url - subject - template (html template) - sort_index - content_id ItemContent - id - ref -> references (renamed) - user_id - modification_user_id - group_id - privileges - date_creation - date_modification - guest_name - link_to - link_redirect - file_path - file_fs - file_type - file_size - has_thumb -> file_has_thumb (renamed) - hash -> file_hash (renamed) - hash_type -> file_hash_type (renamed) - content -> content_raw (renamed) - content_type -> content_raw_type (renamed) - content_parsed - content_parsed_type - meta - ameta -> meta_admin (renamed) - modify_index (removed) WIP: #4
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2018, Tomasz Sowa
|
||||
* Copyright (c) 2008-2021, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -135,15 +135,15 @@ bool Cp::CopyStaticFile(const std::wstring & from, const std::wstring & to)
|
||||
|
||||
void Cp::CopyStaticFile(Item & item)
|
||||
{
|
||||
bool res1, res2, res3, res4, res5;
|
||||
bool ok = true;
|
||||
|
||||
res1 = system->MakeFilePath(item, old_path, false);
|
||||
res2 = !item.has_thumb || system->MakeFilePath(item, old_path_thumb, true);
|
||||
res3 = system->CreateNewFile(item);
|
||||
res4 = system->MakeFilePath(item, new_path, false, true, config->upload_dirs_chmod);
|
||||
res5 = !item.has_thumb || system->MakeFilePath(item, new_path_thumb, true, true, config->upload_dirs_chmod);
|
||||
ok = ok && system->MakeFilePath(item, old_path, false);
|
||||
ok = ok && (!item.item_content.file_has_thumb || system->MakeFilePath(item, old_path_thumb, true));
|
||||
ok = ok && system->CreateNewFile(item);
|
||||
ok = ok && system->MakeFilePath(item, new_path, false, true, config->upload_dirs_chmod);
|
||||
ok = ok && (!item.item_content.file_has_thumb || system->MakeFilePath(item, new_path_thumb, true, true, config->upload_dirs_chmod));
|
||||
|
||||
if( !res1 || !res2 || !res3 || !res4 || !res5 )
|
||||
if( !ok )
|
||||
{
|
||||
cur->request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
return;
|
||||
@@ -151,9 +151,14 @@ bool res1, res2, res3, res4, res5;
|
||||
|
||||
if( CopyStaticFile(old_path, new_path) )
|
||||
{
|
||||
cur->request->status = db->EditFileById(item, item.id);
|
||||
//cur->request->status = db->EditFileById(item, item.id);
|
||||
if( !item.update(false, true) )
|
||||
{
|
||||
cur->request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
}
|
||||
|
||||
if( item.has_thumb )
|
||||
|
||||
if( item.item_content.file_has_thumb )
|
||||
CopyStaticFile(old_path_thumb, new_path_thumb);
|
||||
}
|
||||
}
|
||||
@@ -162,9 +167,9 @@ bool res1, res2, res3, res4, res5;
|
||||
|
||||
void Cp::SetNewAttributes(Item & item)
|
||||
{
|
||||
item.user_id = new_user;
|
||||
item.group_id = new_group;
|
||||
item.SetDateModifyToNow();
|
||||
item.item_content.user_id = new_user;
|
||||
item.item_content.group_id = new_group;
|
||||
item.item_content.SetDateModifyToNow();
|
||||
}
|
||||
|
||||
|
||||
@@ -174,11 +179,12 @@ void Cp::CopyFile(Item & item, long dst_dir_id)
|
||||
SetNewAttributes(item);
|
||||
|
||||
item.parent_id = dst_dir_id;
|
||||
cur->request->status = db->AddItem(item);
|
||||
|
||||
if( cur->request->status == WINIX_ERR_OK )
|
||||
// cur->request->status = db->AddItem(item);
|
||||
// if( cur->request->status == WINIX_ERR_OK )
|
||||
if( item.insert() )
|
||||
{
|
||||
if( item.file_type != WINIX_ITEM_FILETYPE_NONE )
|
||||
if( item.item_content.file_type != WINIX_ITEM_FILETYPE_NONE )
|
||||
CopyStaticFile(item);
|
||||
|
||||
plugin->Call(WINIX_FILE_COPIED, &item);
|
||||
@@ -195,7 +201,7 @@ void Cp::CopyFileOrSymlink(Item & item, long dst_dir_id)
|
||||
{
|
||||
if( system->dirs.CreateDirTab(item.parent_id, symlink_dir_tab) )
|
||||
{
|
||||
int res = system->FollowAllLinks(symlink_dir_tab, item.link_to, symlink_dir_tab, item);
|
||||
int res = system->FollowAllLinks(symlink_dir_tab, item.item_content.link_to, symlink_dir_tab, item);
|
||||
|
||||
if( res == 0 )
|
||||
CopyDirTree(*symlink_dir_tab.back(), dst_dir_id);
|
||||
@@ -215,11 +221,11 @@ void Cp::CopyFileOrSymlink(Item & item, long dst_dir_id)
|
||||
|
||||
void Cp::Prepare()
|
||||
{
|
||||
iq.SetAll(true, false);
|
||||
iq.WhereType(Item::dir, false);
|
||||
// iq.SetAll(true, false);
|
||||
// iq.WhereType(Item::dir, false);
|
||||
|
||||
new_user = -1;
|
||||
new_group = dir_tab.back()->group_id;
|
||||
new_group = dir_tab.back()->item_content.group_id;
|
||||
|
||||
if( cur->session->puser )
|
||||
new_user = cur->session->puser->id;
|
||||
@@ -232,8 +238,17 @@ void Cp::Prepare()
|
||||
|
||||
void Cp::CopyFilesInDir(const Item & dir, long dst_dir_id)
|
||||
{
|
||||
iq.WhereParentId(dir.id);
|
||||
db->GetItems(item_tab, iq);
|
||||
morm::Finder<Item> finder(model_connector);
|
||||
|
||||
item_tab = finder.
|
||||
select().
|
||||
where().
|
||||
neq(L"type", static_cast<int>(Item::dir)).
|
||||
eq(L"parent_id", dir.id).
|
||||
get_vector();
|
||||
|
||||
//iq.WhereParentId(dir.id);
|
||||
//db->GetItems(item_tab, iq);
|
||||
|
||||
for(size_t i=0 ; i<item_tab.size() ; ++i)
|
||||
CopyFileOrSymlink(item_tab[i], dst_dir_id);
|
||||
@@ -291,8 +306,8 @@ long Cp::CopyDirTree(const Item & dir, long dst_dir_id)
|
||||
|
||||
if( remove_defaults )
|
||||
{
|
||||
temp.link_to.clear();
|
||||
temp.link_redirect = 0;
|
||||
temp.item_content.link_to.clear();
|
||||
temp.item_content.link_redirect = 0;
|
||||
}
|
||||
|
||||
cur->request->status = system->dirs.AddDirectory(temp);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010-2014, Tomasz Sowa
|
||||
* Copyright (c) 2010-2021, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -57,7 +57,6 @@ public:
|
||||
private:
|
||||
|
||||
Item temp;
|
||||
DbItemQuery iq;
|
||||
bool remove_defaults;
|
||||
bool preserve_attr;
|
||||
bool follow_symlinks;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* Copyright (c) 2008-2021, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -59,17 +59,16 @@ void Default::MakePost()
|
||||
{
|
||||
Item & dir = *cur->request->dir_tab.back();
|
||||
|
||||
dir.link_to = cur->request->PostVar(L"linkto");
|
||||
dir.link_redirect = cur->request->IsPostVar(L"makeredirect") ? 1 : 0;
|
||||
TrimWhite(dir.link_to);
|
||||
dir.item_content.link_to = cur->request->PostVar(L"linkto");
|
||||
dir.item_content.link_redirect = cur->request->IsPostVar(L"makeredirect") ? 1 : 0;
|
||||
TrimWhite(dir.item_content.link_to);
|
||||
|
||||
// !! dodac sprawdzenie czy link_to jest pusty teraz
|
||||
// !! IMPROVEME dodac sprawdzenie czy link_to jest pusty teraz
|
||||
|
||||
cur->request->status = db->EditLinkItem(dir.id, dir.link_to, dir.link_redirect);
|
||||
|
||||
if( cur->request->status == WINIX_ERR_OK )
|
||||
//cur->request->status = db->EditLinkItem(dir.id, dir.link_to, dir.link_redirect);
|
||||
if( dir.update(false, true) )
|
||||
{
|
||||
log << log2 << "Default: changed link_to: " << dir.link_to << ", for dir_id: " << dir.id << logend;
|
||||
log << log2 << "Default: changed link_to: " << dir.item_content.link_to << ", for dir_id: " << dir.id << logend;
|
||||
system->RedirectToLastDir();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2018, Tomasz Sowa
|
||||
* Copyright (c) 2008-2021, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -63,8 +63,8 @@ void Download::MakeGet()
|
||||
|
||||
|
||||
if( !system->HasReadAccess(cur->request->item) ||
|
||||
cur->request->item.file_type == WINIX_ITEM_FILETYPE_NONE ||
|
||||
cur->request->item.file_path.empty() )
|
||||
cur->request->item.item_content.file_type == WINIX_ITEM_FILETYPE_NONE ||
|
||||
cur->request->item.item_content.file_path.empty() )
|
||||
{
|
||||
cur->request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
return;
|
||||
@@ -72,7 +72,7 @@ void Download::MakeGet()
|
||||
|
||||
cur->request->send_as_attachment = cur->request->IsParam(L"attachment");
|
||||
|
||||
if( cur->request->item.has_thumb && cur->request->IsParam(L"thumb") )
|
||||
if( cur->request->item.item_content.file_has_thumb && cur->request->IsParam(L"thumb") )
|
||||
system->MakeFilePath(cur->request->item, cur->request->x_sendfile, true);
|
||||
else
|
||||
system->MakeFilePath(cur->request->item, cur->request->x_sendfile);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2018, Tomasz Sowa
|
||||
* Copyright (c) 2008-2021, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -149,7 +149,7 @@ void Emacs::MakePost()
|
||||
{
|
||||
cur->request->is_item = true; // !! moze lepiej nie ustawiac is_item? (bo jak wystapi blad np dodania do bazy danych
|
||||
// to formularz edycji zmieni sie z 'dodaj' na 'edytuj'
|
||||
cur->request->item.privileges = system->NewFilePrivileges();
|
||||
cur->request->item.item_content.privileges = system->NewFilePrivileges();
|
||||
cur->request->status = system->AddFile(cur->request->item, NotifyCodeAdd());
|
||||
}
|
||||
else
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010-2018, Tomasz Sowa
|
||||
* Copyright (c) 2010-2021, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -47,9 +47,9 @@ FunctionBase::FunctionBase()
|
||||
need_ssl = false;
|
||||
need_session = true;
|
||||
|
||||
fun.user_id = -1;
|
||||
fun.group_id = -1;
|
||||
fun.privileges = 07555;
|
||||
fun.item_content.user_id = -1;
|
||||
fun.item_content.group_id = -1;
|
||||
fun.item_content.privileges = 07555;
|
||||
fun.parent_id = -1;
|
||||
fun.id = -1;
|
||||
fun.type = Item::file;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010-2018, Tomasz Sowa
|
||||
* Copyright (c) 2010-2021, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -37,7 +37,6 @@
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "core/item.h"
|
||||
#include "db/db.h"
|
||||
#include "core/request.h"
|
||||
#include "core/config.h"
|
||||
@@ -45,6 +44,7 @@
|
||||
#include "core/synchro.h"
|
||||
#include "notify/notify.h"
|
||||
#include "core/winixrequest.h"
|
||||
#include "models/item.h"
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2018, Tomasz Sowa
|
||||
* Copyright (c) 2008-2021, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -34,10 +34,10 @@
|
||||
|
||||
#include "functionparser.h"
|
||||
#include "core/log.h"
|
||||
#include "core/item.h"
|
||||
#include "core/error.h"
|
||||
#include "functions.h"
|
||||
#include "utf8/utf8.h"
|
||||
#include "models/item.h"
|
||||
|
||||
|
||||
|
||||
@@ -141,17 +141,26 @@ bool FunctionParser::CheckAddItem()
|
||||
{
|
||||
// cur->request->dir_tab has at least one element
|
||||
long parent_id = cur->request->dir_tab.back()->id;
|
||||
Error status = db->GetItem(parent_id, name, cur->request->item);
|
||||
|
||||
if( status == WINIX_ERR_OK )
|
||||
morm::Finder<Item> finder(model_connector);
|
||||
|
||||
finder.
|
||||
select().
|
||||
where().
|
||||
eq(L"parent_id", parent_id).
|
||||
eq(L"url", name).
|
||||
get(cur->request->item);
|
||||
|
||||
//Error status = db->GetItem(parent_id, name, cur->request->item);
|
||||
//if( status == WINIX_ERR_OK )
|
||||
if( cur->request->item.found() )
|
||||
{
|
||||
log << log3 << "FP: Item: id: " << cur->request->item.id << ", url: " << cur->request->item.url << logend;
|
||||
cur->request->last_item = &cur->request->item;
|
||||
cur->request->is_item = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
if( status == WINIX_ERR_NO_ITEM )
|
||||
else
|
||||
{
|
||||
log << log3 << "FP: No Item: url: " << name << logend;
|
||||
cur->request->status = WINIX_ERR_NO_ITEM;
|
||||
|
||||
@@ -169,7 +169,7 @@ Error Functions::CheckSpecialFile(const Item & item)
|
||||
log << log3 << "Functions: reloading mount points" << logend;
|
||||
|
||||
cur->mount = system->mounts.GetEmptyMount();
|
||||
system->mounts.ReadMounts(item.content);
|
||||
system->mounts.ReadMounts(item.item_content.content_raw);
|
||||
cur->mount = system->mounts.pmount;
|
||||
templates->ReadNewIndexTemplates();
|
||||
templates->ReadNewChangeTemplates();
|
||||
@@ -302,7 +302,7 @@ void Functions::Parse()
|
||||
|
||||
void Functions::SetDefaultFunctionForFile()
|
||||
{
|
||||
if( cur->request->item.file_type != WINIX_ITEM_FILETYPE_NONE )
|
||||
if( cur->request->item.item_content.file_type != WINIX_ITEM_FILETYPE_NONE )
|
||||
cur->request->function = &fun_download;
|
||||
else
|
||||
if( system->HasReadExecAccess(cur->request->item) )
|
||||
@@ -359,13 +359,13 @@ void Functions::CheckFunctionFollowDir(bool was_default_function)
|
||||
|
||||
if( was_default_function )
|
||||
{
|
||||
if( cur->request->dir_tab.back()->link_redirect == 1 )
|
||||
if( cur->request->dir_tab.back()->item_content.link_redirect == 1 )
|
||||
{
|
||||
system->RedirectTo(cur->request->dir_tab.back()->link_to);
|
||||
system->RedirectTo(cur->request->dir_tab.back()->item_content.link_to);
|
||||
}
|
||||
else
|
||||
{
|
||||
if( system->FollowAllLinks(cur->request->dir_tab.back()->link_to, true, true) )
|
||||
if( system->FollowAllLinks(cur->request->dir_tab.back()->item_content.link_to, true, true) )
|
||||
SetDefaultFunction();
|
||||
}
|
||||
}
|
||||
@@ -375,15 +375,15 @@ void Functions::CheckFunctionFollowDir(bool was_default_function)
|
||||
|
||||
void Functions::CheckFunctionFollowSymlink(bool was_default_function)
|
||||
{
|
||||
if( cur->request->item.link_redirect == 1 )
|
||||
if( cur->request->item.item_content.link_redirect == 1 )
|
||||
{
|
||||
if( was_default_function )
|
||||
system->RedirectTo(cur->request->item.link_to);
|
||||
system->RedirectTo(cur->request->item.item_content.link_to);
|
||||
else
|
||||
system->RedirectWithFunctionAndParamsTo(cur->request->item.link_to);
|
||||
system->RedirectWithFunctionAndParamsTo(cur->request->item.item_content.link_to);
|
||||
}
|
||||
else
|
||||
if( system->FollowAllLinks(cur->request->item.link_to, true, true) )
|
||||
if( system->FollowAllLinks(cur->request->item.item_content.link_to, true, true) )
|
||||
{
|
||||
if( was_default_function )
|
||||
SetDefaultFunction();
|
||||
@@ -415,7 +415,7 @@ bool was_default_function = false;
|
||||
if( cur->request->status != WINIX_ERR_OK || !cur->request->redirect_to.empty() )
|
||||
return;
|
||||
|
||||
if( !cur->request->is_item && !cur->request->dir_tab.back()->link_to.empty() )
|
||||
if( !cur->request->is_item && !cur->request->dir_tab.back()->item_content.link_to.empty() )
|
||||
CheckFunctionFollowDir(was_default_function);
|
||||
else
|
||||
if( cur->request->is_item && cur->request->item.type == Item::symlink && cur->request->function && cur->request->function->follow_symlinks )
|
||||
@@ -603,7 +603,7 @@ void Functions::ReadItemFilterHtml(Item & item)
|
||||
html_filter.ClearOrphans();
|
||||
// SetNoFilterTag doesn't have to be called (default empty tag)
|
||||
|
||||
html_filter.Filter(cur->request->PostVar(L"itemcontent"), item.content);
|
||||
html_filter.Filter(cur->request->PostVar(L"itemcontent"), item.item_content.content_raw);
|
||||
}
|
||||
|
||||
|
||||
@@ -618,13 +618,13 @@ void Functions::ReadItemContent(Item & item, const std::wstring & content_type)
|
||||
if( filter_html )
|
||||
ReadItemFilterHtml(item);
|
||||
else
|
||||
cur->request->PostVar(L"itemcontent", item.content);
|
||||
cur->request->PostVar(L"itemcontent", item.item_content.content_raw);
|
||||
}
|
||||
|
||||
|
||||
void Functions::ReadItemContentWithType(Item & item)
|
||||
{
|
||||
item.content_type = Item::ct_formatted_text; // default is formatted text
|
||||
item.item_content.content_raw_type = ItemContent::ct_formatted_text; // default is formatted text
|
||||
cur->request->PostVar(L"contenttype", temp);
|
||||
|
||||
ReadItemContent(item, temp);
|
||||
@@ -633,10 +633,10 @@ void Functions::ReadItemContentWithType(Item & item)
|
||||
// ct_text and ct_formatted_text can use everyone
|
||||
|
||||
if( temp == L"0" )
|
||||
item.content_type = Item::ct_text;
|
||||
item.item_content.content_raw_type = ItemContent::ct_text;
|
||||
else
|
||||
if( temp == L"1" )
|
||||
item.content_type = Item::ct_formatted_text;
|
||||
item.item_content.content_raw_type = ItemContent::ct_formatted_text;
|
||||
|
||||
|
||||
// those below need special privileges
|
||||
@@ -649,19 +649,19 @@ void Functions::ReadItemContentWithType(Item & item)
|
||||
if( temp == L"2" )
|
||||
{
|
||||
if( system->CanUseHtml(user_id) )
|
||||
item.content_type = Item::ct_html;
|
||||
item.item_content.content_raw_type = ItemContent::ct_html;
|
||||
}
|
||||
else
|
||||
if( temp == L"3" )
|
||||
{
|
||||
if( system->CanUseBBCode(user_id) )
|
||||
item.content_type = Item::ct_bbcode;
|
||||
item.item_content.content_raw_type = ItemContent::ct_bbcode;
|
||||
}
|
||||
else
|
||||
if( temp == L"4" )
|
||||
{
|
||||
if( system->CanUseOther(user_id) )
|
||||
item.content_type = Item::ct_other;
|
||||
item.item_content.content_raw_type = ItemContent::ct_other;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -691,16 +691,16 @@ void Functions::SetUser(Item & item)
|
||||
{
|
||||
if( cur->session && cur->session->puser )
|
||||
{
|
||||
item.user_id = cur->session->puser->id;
|
||||
item.guest_name.clear();
|
||||
item.item_content.user_id = cur->session->puser->id;
|
||||
item.item_content.guest_name.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
item.user_id = -1;
|
||||
cur->request->PostVar(L"guestname", item.guest_name);
|
||||
item.item_content.user_id = -1;
|
||||
cur->request->PostVar(L"guestname", item.item_content.guest_name);
|
||||
}
|
||||
|
||||
item.group_id = cur->request->dir_tab.back()->group_id;
|
||||
item.item_content.group_id = cur->request->dir_tab.back()->item_content.group_id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2013-2014, Tomasz Sowa
|
||||
* Copyright (c) 2013-2021, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -63,13 +63,23 @@ bool ImgCrop::HasAccess()
|
||||
|
||||
void ImgCrop::GetDirContent()
|
||||
{
|
||||
iq.sel_type = Item::file;
|
||||
iq.sel_content = false;
|
||||
// iq.sel_type = Item::file;
|
||||
// iq.sel_content = false;
|
||||
//
|
||||
// iq.WhereParentId(cur->request->dir_tab.back()->id);
|
||||
// iq.WhereFileType(WINIX_ITEM_FILETYPE_IMAGE);
|
||||
|
||||
iq.WhereParentId(cur->request->dir_tab.back()->id);
|
||||
iq.WhereFileType(WINIX_ITEM_FILETYPE_IMAGE);
|
||||
morm::Finder<Item> finder(model_connector);
|
||||
|
||||
db->GetItems(cur->request->item_tab, iq);
|
||||
cur->request->item_tab = finder.
|
||||
select().
|
||||
where().
|
||||
eq(L"type", static_cast<int>(Item::file)).
|
||||
eq(L"parent_id", cur->request->dir_tab.back()->id).
|
||||
eq(L"content.file_type", WINIX_ITEM_FILETYPE_IMAGE).
|
||||
get_vector();
|
||||
|
||||
//db->GetItems(cur->request->item_tab, iq);
|
||||
system->CheckWriteAccessToItems(cur->request->item_tab);
|
||||
}
|
||||
|
||||
@@ -89,7 +99,7 @@ void ImgCrop::MakePost()
|
||||
|
||||
Item & item = cur->request->item;
|
||||
|
||||
if( cur->request->is_item && item.type == Item::file && item.file_type == WINIX_ITEM_FILETYPE_IMAGE )
|
||||
if( cur->request->is_item && item.type == Item::file && item.item_content.file_type == WINIX_ITEM_FILETYPE_IMAGE )
|
||||
{
|
||||
if( system->HasWriteAccess(item) )
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2013-2014, Tomasz Sowa
|
||||
* Copyright (c) 2013-2021, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
DbItemQuery iq;
|
||||
//DbItemQuery iq;
|
||||
|
||||
void GetDirContent();
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010-2014, Tomasz Sowa
|
||||
* Copyright (c) 2010-2021, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -62,17 +62,19 @@ bool Ln::HasAccess()
|
||||
|
||||
bool Ln::CreateSymbolicLink(long parent_id, const wchar_t * link_to, const wchar_t * url, bool link_redirect)
|
||||
{
|
||||
item.set_connector(model_connector);
|
||||
item.Clear(); // setting the date to now
|
||||
item.type = Item::symlink;
|
||||
item.parent_id = parent_id;
|
||||
item.url = url;
|
||||
item.link_to = link_to;
|
||||
item.link_redirect = static_cast<int>(link_redirect);
|
||||
item.privileges = system->NewFilePrivileges();
|
||||
item.item_content.link_to = link_to;
|
||||
item.item_content.link_redirect = static_cast<int>(link_redirect);
|
||||
item.item_content.privileges = system->NewFilePrivileges();
|
||||
functions->SetUser(item);
|
||||
functions->PrepareUrl(item);
|
||||
|
||||
return db->AddItem(item) == WINIX_ERR_OK;
|
||||
return item.insert();
|
||||
//return db->AddItem(item) == WINIX_ERR_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -124,7 +126,11 @@ bool Ln::CreateHardLink(const std::vector<Item*> & dirs, const std::wstring & li
|
||||
item.url = url;
|
||||
functions->PrepareUrl(item);
|
||||
|
||||
return db->AddHardLink(item) == WINIX_ERR_OK;
|
||||
/*
|
||||
* IMPROVEME
|
||||
*
|
||||
*/
|
||||
//return db->AddHardLink(item) == WINIX_ERR_OK;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -61,22 +61,33 @@ void Ls::MakeGet()
|
||||
|
||||
if( !cur->request->is_item )
|
||||
{
|
||||
DbItemQuery iq;
|
||||
// DbItemQuery iq;
|
||||
//
|
||||
// iq.sel_content = false;
|
||||
//
|
||||
// iq.WhereParentId(cur->request->dir_tab.back()->id);
|
||||
// iq.WhereType(Item::dir, false);
|
||||
|
||||
iq.sel_content = false;
|
||||
morm::Finder<Item> finder(model_connector);
|
||||
|
||||
iq.WhereParentId(cur->request->dir_tab.back()->id);
|
||||
iq.WhereType(Item::dir, false);
|
||||
finder.
|
||||
select().
|
||||
where().
|
||||
eq(L"parent_id", cur->request->dir_tab.back()->id).
|
||||
neq(L"type", static_cast<int>(Item::dir));
|
||||
|
||||
if( cur->request->IsParam(L"ckeditor_browse") )
|
||||
{
|
||||
iq.WhereFileType(WINIX_ITEM_FILETYPE_IMAGE);
|
||||
db->GetItems(cur->request->item_tab, iq);
|
||||
}
|
||||
else
|
||||
{
|
||||
db->GetItems(cur->request->item_tab, iq);
|
||||
//iq.WhereFileType(WINIX_ITEM_FILETYPE_IMAGE);
|
||||
//db->GetItems(cur->request->item_tab, iq);
|
||||
finder.eq(L"content.file_type", WINIX_ITEM_FILETYPE_IMAGE);
|
||||
}
|
||||
// else
|
||||
// {
|
||||
// //db->GetItems(cur->request->item_tab, iq);
|
||||
// }
|
||||
|
||||
finder.get_vector(cur->request->item_tab);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -71,18 +71,21 @@ return (conf_parser.ParseString(meta_str) == PT::SpaceParser::ok);
|
||||
|
||||
|
||||
|
||||
bool Meta::EditAdminMeta(long item_id, const std::wstring & meta_str, bool use_ses_log)
|
||||
bool Meta::EditAdminMeta(Item & item, const std::wstring & meta_str, bool use_ses_log)
|
||||
{
|
||||
if( Parse(meta_str) )
|
||||
{
|
||||
if( db->EditAdminMetaById(space, item_id) == WINIX_ERR_OK )
|
||||
item.item_content.meta_admin = space;
|
||||
|
||||
//if( db->EditAdminMetaById(space, item_id) == WINIX_ERR_OK )
|
||||
if( item.update(false, true) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Meta: a database problem with changing admin meta information for item id: "
|
||||
<< item_id << logend;
|
||||
<< item.id << logend;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -98,18 +101,21 @@ return false;
|
||||
|
||||
|
||||
|
||||
bool Meta::EditMeta(long item_id, const std::wstring & meta_str, bool use_ses_log)
|
||||
bool Meta::EditMeta(Item & item, const std::wstring & meta_str, bool use_ses_log)
|
||||
{
|
||||
if( Parse(meta_str) )
|
||||
{
|
||||
if( db->EditMetaById(space, item_id) == WINIX_ERR_OK )
|
||||
item.item_content.meta = space;
|
||||
|
||||
//if( db->EditMetaById(space, item_id) == WINIX_ERR_OK )
|
||||
if( item.update(false, true) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Meta: a database problem with changing meta information for item id: "
|
||||
<< item_id << logend;
|
||||
<< item.id << logend;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -133,11 +139,8 @@ void Meta::ChangeAdminMeta()
|
||||
{
|
||||
const std::wstring & meta_str = cur->request->PostVar(L"itemmeta");
|
||||
|
||||
if( EditAdminMeta(cur->request->last_item->id, meta_str, true) )
|
||||
if( EditAdminMeta(*cur->request->last_item, meta_str, true) )
|
||||
{
|
||||
if( cur->request->last_item->type == Item::dir )
|
||||
cur->request->last_item->ameta = space;
|
||||
|
||||
system->RedirectToLastItem();
|
||||
}
|
||||
}
|
||||
@@ -150,11 +153,8 @@ void Meta::ChangeMeta()
|
||||
{
|
||||
const std::wstring & meta_str = cur->request->PostVar(L"itemmeta");
|
||||
|
||||
if( EditMeta(cur->request->last_item->id, meta_str, true) )
|
||||
if( EditMeta(*cur->request->last_item, meta_str, true) )
|
||||
{
|
||||
if( cur->request->last_item->type == Item::dir )
|
||||
cur->request->last_item->meta = space;
|
||||
|
||||
system->RedirectToLastItem();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2011-2014, Tomasz Sowa
|
||||
* Copyright (c) 2011-2021, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -55,8 +55,8 @@ public:
|
||||
bool HasAccess();
|
||||
void MakePost();
|
||||
|
||||
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);
|
||||
bool EditAdminMeta(Item & item, const std::wstring & meta_str, bool use_ses_log = false);
|
||||
bool EditMeta(Item & item, const std::wstring & meta_str, bool use_ses_log = false);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2018, Tomasz Sowa
|
||||
* Copyright (c) 2008-2021, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -92,7 +92,7 @@ void Mkdir::PostFunMkdir(bool add_to_dir_tab, int privileges)
|
||||
{
|
||||
functions->ReadItem(cur->request->item, Item::dir);
|
||||
functions->SetUser(cur->request->item);
|
||||
cur->request->item.privileges = privileges;
|
||||
cur->request->item.item_content.privileges = privileges;
|
||||
Item * pdir;
|
||||
|
||||
cur->request->status = system->dirs.AddDirectory(cur->request->item, add_to_dir_tab, &pdir);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2018, Tomasz Sowa
|
||||
* Copyright (c) 2008-2021, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -62,7 +62,7 @@ bool Mv::HasAccess()
|
||||
{
|
||||
if( cur->request->is_item )
|
||||
{
|
||||
if( !system->CanRemoveRenameChild(*cur->request->dir_tab.back(), cur->request->item.user_id) )
|
||||
if( !system->CanRemoveRenameChild(*cur->request->dir_tab.back(), cur->request->item.item_content.user_id) )
|
||||
return false;
|
||||
}
|
||||
else
|
||||
@@ -102,7 +102,7 @@ bool Mv::CheckAccessFromToDir(const Item & dir, bool only_content)
|
||||
// ops, there is no a parent dir
|
||||
return false;
|
||||
|
||||
if( !system->CanRemoveRenameChild(*last_but_one_dir, dir.user_id) )
|
||||
if( !system->CanRemoveRenameChild(*last_but_one_dir, dir.item_content.user_id) )
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -115,26 +115,26 @@ return true;
|
||||
// !! IMPROVE ME: may a better name?
|
||||
void Mv::Prepare()
|
||||
{
|
||||
content_dir_iq.SetAll(false, false);
|
||||
content_dir_iq.sel_parent_id = true;
|
||||
content_dir_iq.sel_type = true;
|
||||
content_dir_iq.sel_url = true;
|
||||
content_dir_iq.sel_file = true;
|
||||
content_dir_iq.sel_user_id = true;
|
||||
content_dir_iq.sel_group_id = true;
|
||||
content_dir_iq.sel_privileges = true;
|
||||
content_dir_iq.sel_meta = true;
|
||||
|
||||
files_iq.SetAll(false, false);
|
||||
files_iq.sel_parent_id = true;
|
||||
files_iq.sel_type = true;
|
||||
files_iq.sel_url = true;
|
||||
files_iq.sel_file = true;
|
||||
files_iq.sel_user_id = true;
|
||||
files_iq.sel_group_id = true;
|
||||
files_iq.sel_privileges = true;
|
||||
files_iq.sel_meta = true;
|
||||
files_iq.WhereType(Item::dir, false);
|
||||
// content_dir_iq.SetAll(false, false);
|
||||
// content_dir_iq.sel_parent_id = true;
|
||||
// content_dir_iq.sel_type = true;
|
||||
// content_dir_iq.sel_url = true;
|
||||
// content_dir_iq.sel_file = true;
|
||||
// content_dir_iq.sel_user_id = true;
|
||||
// content_dir_iq.sel_group_id = true;
|
||||
// content_dir_iq.sel_privileges = true;
|
||||
// content_dir_iq.sel_meta = true;
|
||||
//
|
||||
// files_iq.SetAll(false, false);
|
||||
// files_iq.sel_parent_id = true;
|
||||
// files_iq.sel_type = true;
|
||||
// files_iq.sel_url = true;
|
||||
// files_iq.sel_file = true;
|
||||
// files_iq.sel_user_id = true;
|
||||
// files_iq.sel_group_id = true;
|
||||
// files_iq.sel_privileges = true;
|
||||
// files_iq.sel_meta = true;
|
||||
// files_iq.WhereType(Item::dir, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -169,7 +169,17 @@ bool Mv::ParseDirCheckLastName()
|
||||
}
|
||||
else
|
||||
{
|
||||
if( db->GetItem(out_dir_tab.back()->id, out_filename, out_item) == WINIX_ERR_OK )
|
||||
morm::Finder<Item> finder(model_connector);
|
||||
|
||||
out_item = finder.
|
||||
select().
|
||||
where().
|
||||
eq(L"parent_id", out_dir_tab.back()->id).
|
||||
eq(L"url", out_filename).
|
||||
get();
|
||||
|
||||
//if( db->GetItem(out_dir_tab.back()->id, out_filename, out_item) == WINIX_ERR_OK )
|
||||
if( out_item.found() )
|
||||
{
|
||||
out_has_file = true;
|
||||
out_filename.clear();
|
||||
@@ -219,7 +229,7 @@ bool Mv::CanRemoveRenameChild(const Item & child)
|
||||
{
|
||||
Item * parent_dir = system->dirs.GetDir(child.parent_id);
|
||||
|
||||
if( !parent_dir || !system->CanRemoveRenameChild(*parent_dir, child.user_id) )
|
||||
if( !parent_dir || !system->CanRemoveRenameChild(*parent_dir, child.item_content.user_id) )
|
||||
{
|
||||
log << log1 << "Mv: permission denied to: " << child.url << logend;
|
||||
slog << logerror << T("mv_permission_denied_to") << ": " << child.url << logend;
|
||||
@@ -255,15 +265,16 @@ bool Mv::MoveStaticFile(const std::wstring & from, const std::wstring & to)
|
||||
|
||||
void Mv::MoveStaticFile(Item & item)
|
||||
{
|
||||
bool res1, res2, res3, res4, res5;
|
||||
bool ok = true;
|
||||
//bool res1, res2, res3, res4, res5;
|
||||
|
||||
res1 = system->MakeFilePath(item, old_static_path, false);
|
||||
res2 = !item.has_thumb || system->MakeFilePath(item, old_static_thumb_path, true);
|
||||
res3 = system->CreateNewFile(item);
|
||||
res4 = system->MakeFilePath(item, new_static_path, false, true, config->upload_dirs_chmod);
|
||||
res5 = !item.has_thumb || system->MakeFilePath(item, new_static_thumb_path, true, true, config->upload_dirs_chmod);
|
||||
ok = ok && system->MakeFilePath(item, old_static_path, false);
|
||||
ok = ok && (!item.item_content.file_has_thumb || system->MakeFilePath(item, old_static_thumb_path, true));
|
||||
ok = ok && system->CreateNewFile(item);
|
||||
ok = ok && system->MakeFilePath(item, new_static_path, false, true, config->upload_dirs_chmod);
|
||||
ok = ok && (!item.item_content.file_has_thumb || system->MakeFilePath(item, new_static_thumb_path, true, true, config->upload_dirs_chmod));
|
||||
|
||||
if( !res1 || !res2 || !res3 || !res4 || !res5 )
|
||||
if( !ok )
|
||||
{
|
||||
log << log1 << "Mv: cannot create a static path" << logend;
|
||||
slog << logerror << T("internal_error") << logend;
|
||||
@@ -272,14 +283,15 @@ bool res1, res2, res3, res4, res5;
|
||||
|
||||
if( MoveStaticFile(old_static_path, new_static_path) )
|
||||
{
|
||||
if( db->EditFileById(item, item.id) != WINIX_ERR_OK )
|
||||
//if( db->EditFileById(item, item.id) != WINIX_ERR_OK )
|
||||
if( !item.update(false, true) )
|
||||
{
|
||||
log << log1 << "Mv: cannot move static file (database problem)" << logend;
|
||||
slog << logerror << T("internal_error") << logend;
|
||||
return;
|
||||
}
|
||||
|
||||
if( item.has_thumb )
|
||||
if( item.item_content.file_has_thumb )
|
||||
MoveStaticFile(old_static_thumb_path, new_static_thumb_path);
|
||||
}
|
||||
}
|
||||
@@ -294,8 +306,17 @@ void Mv::MoveFilesPrepareTreeGo(const Item & src_dir)
|
||||
for( ; i != system->dirs.ParentEnd() ; i = system->dirs.NextChild(i) )
|
||||
MoveFilesPrepareTreeGo(*(i->second));
|
||||
|
||||
files_iq.WhereParentId(src_dir.id);
|
||||
db->GetItems(files_item_tab, files_iq);
|
||||
//files_iq.WhereParentId(src_dir.id);
|
||||
//db->GetItems(files_item_tab, files_iq);
|
||||
|
||||
morm::Finder<Item> finder(model_connector);
|
||||
|
||||
finder.
|
||||
select().
|
||||
where().
|
||||
eq(L"parent_id", src_dir.id).
|
||||
neq(L"type", static_cast<int>(Item::dir)).
|
||||
get_vector(files_item_tab);
|
||||
|
||||
for(size_t i=0 ; i<files_item_tab.size() ; ++i)
|
||||
plugin->Call(WINIX_FILE_PREPARE_TO_MOVE, &files_item_tab[i]);
|
||||
@@ -324,12 +345,21 @@ void Mv::MoveFilesTree(const Item & dir)
|
||||
for( ; i != system->dirs.ParentEnd() ; i = system->dirs.NextChild(i) )
|
||||
MoveFilesTree(*(i->second));
|
||||
|
||||
files_iq.WhereParentId(dir.id);
|
||||
db->GetItems(files_item_tab, files_iq);
|
||||
morm::Finder<Item> finder(model_connector);
|
||||
|
||||
finder.
|
||||
select().
|
||||
where().
|
||||
eq(L"parent_id", dir.id).
|
||||
neq(L"type", static_cast<int>(Item::dir)).
|
||||
get_vector(files_item_tab);
|
||||
|
||||
//files_iq.WhereParentId(dir.id);
|
||||
//db->GetItems(files_item_tab, files_iq);
|
||||
|
||||
for(size_t i=0 ; i<files_item_tab.size() ; ++i)
|
||||
{
|
||||
if( files_item_tab[i].file_type != WINIX_ITEM_FILETYPE_NONE )
|
||||
if( files_item_tab[i].item_content.file_type != WINIX_ITEM_FILETYPE_NONE )
|
||||
{
|
||||
plugin->Call(WINIX_FILE_PREPARE_TO_MOVE, &files_item_tab[i]);
|
||||
MoveStaticFile(files_item_tab[i]);
|
||||
@@ -370,9 +400,8 @@ bool Mv::MoveDir(Item & src_dir, std::vector<Item*> & dst_dir_tab, const std::ws
|
||||
functions->PrepareUrl(src_dir);
|
||||
}
|
||||
|
||||
Error status = db->EditParentUrlById(src_dir, src_dir.id);
|
||||
|
||||
if( status == WINIX_ERR_OK )
|
||||
//Error status = db->EditParentUrlById(src_dir, src_dir.id);
|
||||
if( src_dir.update(true, false) )
|
||||
{
|
||||
log << log3 << "Mv: directory: " << old_url << " was moved to: ";
|
||||
system->dirs.LogDir(dst_dir_tab);
|
||||
@@ -499,9 +528,9 @@ 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( status == WINIX_ERR_OK )
|
||||
//Error status = db->EditParentUrlById(src_file, src_file.id);
|
||||
if( src_file.update(true, false) )
|
||||
{
|
||||
if( src_file.type == Item::file )
|
||||
log << log3 << "Mv: file: ";
|
||||
@@ -512,7 +541,7 @@ bool Mv::MoveFileOrSymlink(Item & src_file, std::vector<Item*> & dst_dir_tab, co
|
||||
system->dirs.LogDir(dst_dir_tab);
|
||||
log << src_file.url << logend;
|
||||
|
||||
if( src_file.file_type != WINIX_ITEM_FILETYPE_NONE )
|
||||
if( src_file.item_content.file_type != WINIX_ITEM_FILETYPE_NONE )
|
||||
MoveStaticFile(src_file);
|
||||
|
||||
plugin->Call(WINIX_FILE_MOVED, &src_file);
|
||||
@@ -604,13 +633,22 @@ bool Mv::MoveFileOrSymlink2(Item & src_file, const std::wstring & dst_path, bool
|
||||
// private
|
||||
void Mv::MoveAllFilesFromDir(Item & src_dir, std::vector<Item*> & dst_dir_tab, bool check_access)
|
||||
{
|
||||
content_dir_iq.WhereParentId(src_dir.id);
|
||||
db->GetItems(item_tab, content_dir_iq);
|
||||
// content_dir_iq.WhereParentId(src_dir.id);
|
||||
// db->GetItems(item_tab, content_dir_iq);
|
||||
|
||||
morm::Finder<Item> finder(model_connector);
|
||||
|
||||
finder.
|
||||
select().
|
||||
where().
|
||||
eq(L"parent_id", src_dir.id).
|
||||
get_vector(item_tab);
|
||||
|
||||
out_filename.clear();
|
||||
|
||||
for(size_t i=0 ; i<item_tab.size() ; ++i)
|
||||
{
|
||||
if( check_access && !system->CanRemoveRenameChild(src_dir, item_tab[i].user_id) )
|
||||
if( check_access && !system->CanRemoveRenameChild(src_dir, item_tab[i].item_content.user_id) )
|
||||
{
|
||||
log << log1 << "Mv: permission denied to: " << src_dir.url << logend;
|
||||
slog << logerror << T("mv_permission_denied_to") << ": " << src_dir.url << logend;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010-2014, Tomasz Sowa
|
||||
* Copyright (c) 2010-2021, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -95,10 +95,10 @@ private:
|
||||
|
||||
// for files/symlinks in a directory
|
||||
std::vector<Item> files_item_tab;
|
||||
DbItemQuery files_iq;
|
||||
//DbItemQuery files_iq;
|
||||
|
||||
// for moving content of a directory (all dirs/files/symlinks)
|
||||
DbItemQuery content_dir_iq;
|
||||
//DbItemQuery content_dir_iq;
|
||||
std::vector<Item> item_tab;
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010-2018, Tomasz Sowa
|
||||
* Copyright (c) 2010-2021, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -78,7 +78,7 @@ return true;
|
||||
|
||||
bool PrivChanger::ChangeOwner(Item & item, long user_id, long group_id)
|
||||
{
|
||||
if( user_id!=item.user_id || group_id!=item.group_id )
|
||||
if( user_id!=item.item_content.user_id || group_id!=item.item_content.group_id )
|
||||
{
|
||||
if( !system->CanChangeUser(item, user_id) )
|
||||
{
|
||||
@@ -93,8 +93,8 @@ bool PrivChanger::ChangeOwner(Item & item, long user_id, long group_id)
|
||||
}
|
||||
}
|
||||
|
||||
item.user_id = user_id;
|
||||
item.group_id = group_id;
|
||||
item.item_content.user_id = user_id;
|
||||
item.item_content.group_id = group_id;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -103,7 +103,7 @@ return true;
|
||||
|
||||
bool PrivChanger::ChangePrivileges(Item & item, int privileges)
|
||||
{
|
||||
if( privileges != item.privileges )
|
||||
if( privileges != item.item_content.privileges )
|
||||
{
|
||||
if( !system->CanChangePrivileges(item, privileges) )
|
||||
{
|
||||
@@ -112,7 +112,7 @@ bool PrivChanger::ChangePrivileges(Item & item, int privileges)
|
||||
}
|
||||
}
|
||||
|
||||
item.privileges = privileges;
|
||||
item.item_content.privileges = privileges;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -133,7 +133,11 @@ void PrivChanger::ChangePriv(Item & item, long user_id, long group_id, int privi
|
||||
return;
|
||||
}
|
||||
|
||||
cur->request->status = db->EditPrivById(item, item.id);
|
||||
//cur->request->status = db->EditPrivById(item, item.id);
|
||||
if( !item.update(false, true) )
|
||||
{
|
||||
// IMPROVEME put some log here, and slog too
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -197,16 +201,24 @@ Item * root = 0;
|
||||
|
||||
void PrivChanger::PrivFilesInDir(long parent_id)
|
||||
{
|
||||
DbItemQuery iq;
|
||||
// DbItemQuery iq;
|
||||
//
|
||||
// iq.SetAll(false, false);
|
||||
// iq.sel_user_id = iq.sel_group_id = iq.sel_guest_name = iq.sel_privileges = iq.sel_url = true;
|
||||
//
|
||||
// iq.WhereParentId(parent_id);
|
||||
// iq.WhereType(Item::dir, false);
|
||||
|
||||
iq.SetAll(false, false);
|
||||
iq.sel_user_id = iq.sel_group_id = iq.sel_guest_name = iq.sel_privileges = iq.sel_url = true;
|
||||
morm::Finder<Item> finder(model_connector);
|
||||
|
||||
iq.WhereParentId(parent_id);
|
||||
iq.WhereType(Item::dir, false);
|
||||
|
||||
db->GetItems(cur->request->item_tab, iq);
|
||||
finder.
|
||||
select().
|
||||
where().
|
||||
eq(L"parent_id", parent_id).
|
||||
neq(L"type", static_cast<int>(Item::dir)).
|
||||
get_vector(cur->request->item_tab);
|
||||
|
||||
//db->GetItems(cur->request->item_tab, iq);
|
||||
|
||||
std::vector<Item>::iterator i = cur->request->item_tab.begin();
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2012-2014, Tomasz Sowa
|
||||
* Copyright (c) 2012-2021, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -48,7 +48,7 @@ namespace Fun
|
||||
Pw::Pw()
|
||||
{
|
||||
fun.url = L"pw";
|
||||
fun.privileges = 07000;
|
||||
fun.item_content.privileges = 07000;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* Copyright (c) 2008-2021, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -47,7 +47,7 @@ namespace Fun
|
||||
Reload::Reload()
|
||||
{
|
||||
fun.url = L"reload";
|
||||
fun.privileges = 07000;
|
||||
fun.item_content.privileges = 07000;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2018, Tomasz Sowa
|
||||
* Copyright (c) 2008-2021, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -80,7 +80,7 @@ bool Rm::HasAccessToDir(const Item & dir, bool only_content)
|
||||
// ops, there is no a parent dir
|
||||
return false;
|
||||
|
||||
if( !system->CanRemoveRenameChild(*last_but_one_dir, dir.user_id) )
|
||||
if( !system->CanRemoveRenameChild(*last_but_one_dir, dir.item_content.user_id) )
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ bool res = false;
|
||||
|
||||
if( cur->request->is_item )
|
||||
{
|
||||
res = system->CanRemoveRenameChild(*cur->request->dir_tab.back(), cur->request->item.user_id);
|
||||
res = system->CanRemoveRenameChild(*cur->request->dir_tab.back(), cur->request->item.item_content.user_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -131,16 +131,16 @@ return res;
|
||||
void Rm::Prepare()
|
||||
{
|
||||
// selecting files and symlinks (without directories)
|
||||
content_dir_iq.SetAll(false, false);
|
||||
content_dir_iq.sel_parent_id = true;
|
||||
content_dir_iq.sel_type = true;
|
||||
content_dir_iq.sel_url = true;
|
||||
content_dir_iq.sel_file = true;
|
||||
content_dir_iq.sel_user_id = true;
|
||||
content_dir_iq.sel_group_id = true;
|
||||
content_dir_iq.sel_privileges = true;
|
||||
content_dir_iq.sel_meta = true;
|
||||
content_dir_iq.WhereType(Item::dir, false);
|
||||
// content_dir_iq.SetAll(false, false);
|
||||
// content_dir_iq.sel_parent_id = true;
|
||||
// content_dir_iq.sel_type = true;
|
||||
// content_dir_iq.sel_url = true;
|
||||
// content_dir_iq.sel_file = true;
|
||||
// content_dir_iq.sel_user_id = true;
|
||||
// content_dir_iq.sel_group_id = true;
|
||||
// content_dir_iq.sel_privileges = true;
|
||||
// content_dir_iq.sel_meta = true;
|
||||
// content_dir_iq.WhereType(Item::dir, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -166,7 +166,7 @@ void Rm::RemoveStaticFile(const Item & item)
|
||||
{
|
||||
RemoveStaticFile(path);
|
||||
|
||||
if( item.has_thumb && system->MakeFilePath(item, path, true) )
|
||||
if( item.item_content.file_has_thumb && system->MakeFilePath(item, path, true) )
|
||||
RemoveStaticFile(path);
|
||||
}
|
||||
else
|
||||
@@ -190,7 +190,8 @@ bool Rm::RemoveFile(Item & item)
|
||||
{
|
||||
plugin->Call(WINIX_FILE_PREPARE_TO_REMOVE, &item);
|
||||
|
||||
if( db->DelItem(item) == WINIX_ERR_OK )
|
||||
//if( db->DelItem(item) == WINIX_ERR_OK )
|
||||
if( item.remove() )
|
||||
{
|
||||
if( item.type == Item::file )
|
||||
log << log2 << "Rm: deleted file: ";
|
||||
@@ -201,7 +202,7 @@ bool Rm::RemoveFile(Item & item)
|
||||
|
||||
TemplatesFunctions::pattern_cacher.DeletePattern(item);
|
||||
|
||||
if( item.file_type != WINIX_ITEM_FILETYPE_NONE )
|
||||
if( item.item_content.file_type != WINIX_ITEM_FILETYPE_NONE )
|
||||
RemoveStaticFile(item);
|
||||
|
||||
plugin->Call(WINIX_FILE_REMOVED, &item);
|
||||
@@ -230,7 +231,7 @@ bool Rm::RemoveFileOrSymlink(Item & item, bool check_access)
|
||||
// if there is not 'dir' directory then we can simply remove 'item'
|
||||
if( dir )
|
||||
{
|
||||
if( !system->CanRemoveRenameChild(*dir, item.user_id) )
|
||||
if( !system->CanRemoveRenameChild(*dir, item.item_content.user_id) )
|
||||
{
|
||||
log << log1 << "Rm: permission denied to remove: " << item.url << ", id: " << item.id << logend;
|
||||
slog << logerror << T("rm_permission_denied_to") << ": " << item.url << logend;
|
||||
@@ -248,18 +249,27 @@ bool Rm::RemoveFileOrSymlink(long item_id, bool check_access)
|
||||
bool result = false;
|
||||
|
||||
// selecting files, symlinks and directories
|
||||
rm_by_id_iq.SetAll(false, false);
|
||||
rm_by_id_iq.sel_parent_id = true;
|
||||
rm_by_id_iq.sel_type = true;
|
||||
rm_by_id_iq.sel_url = true;
|
||||
rm_by_id_iq.sel_file = true;
|
||||
rm_by_id_iq.sel_user_id = true;
|
||||
rm_by_id_iq.sel_group_id = true;
|
||||
rm_by_id_iq.sel_privileges = true;
|
||||
rm_by_id_iq.sel_meta = true;
|
||||
rm_by_id_iq.WhereId(item_id);
|
||||
// rm_by_id_iq.SetAll(false, false);
|
||||
// rm_by_id_iq.sel_parent_id = true;
|
||||
// rm_by_id_iq.sel_type = true;
|
||||
// rm_by_id_iq.sel_url = true;
|
||||
// rm_by_id_iq.sel_file = true;
|
||||
// rm_by_id_iq.sel_user_id = true;
|
||||
// rm_by_id_iq.sel_group_id = true;
|
||||
// rm_by_id_iq.sel_privileges = true;
|
||||
// rm_by_id_iq.sel_meta = true;
|
||||
// rm_by_id_iq.WhereId(item_id);
|
||||
|
||||
if( db->GetItem(rm_by_id_item, rm_by_id_iq) == WINIX_ERR_OK )
|
||||
morm::Finder<Item> finder(model_connector);
|
||||
|
||||
rm_by_id_item = finder.
|
||||
select().
|
||||
where().
|
||||
eq(L"id", item_id).
|
||||
get();
|
||||
|
||||
//if( db->GetItem(rm_by_id_item, rm_by_id_iq) == WINIX_ERR_OK )
|
||||
if( rm_by_id_item.found() )
|
||||
{
|
||||
if( rm_by_id_item.type == Item::file || rm_by_id_item.type == Item::symlink )
|
||||
{
|
||||
@@ -282,18 +292,27 @@ bool Rm::RemoveItemById(long item_id, bool check_access)
|
||||
bool result = false;
|
||||
|
||||
// selecting files, symlinks and directories
|
||||
rm_by_id_iq.SetAll(false, false);
|
||||
rm_by_id_iq.sel_parent_id = true;
|
||||
rm_by_id_iq.sel_type = true;
|
||||
rm_by_id_iq.sel_url = true;
|
||||
rm_by_id_iq.sel_file = true;
|
||||
rm_by_id_iq.sel_user_id = true;
|
||||
rm_by_id_iq.sel_group_id = true;
|
||||
rm_by_id_iq.sel_privileges = true;
|
||||
rm_by_id_iq.sel_meta = true;
|
||||
rm_by_id_iq.WhereId(item_id);
|
||||
// rm_by_id_iq.SetAll(false, false);
|
||||
// rm_by_id_iq.sel_parent_id = true;
|
||||
// rm_by_id_iq.sel_type = true;
|
||||
// rm_by_id_iq.sel_url = true;
|
||||
// rm_by_id_iq.sel_file = true;
|
||||
// rm_by_id_iq.sel_user_id = true;
|
||||
// rm_by_id_iq.sel_group_id = true;
|
||||
// rm_by_id_iq.sel_privileges = true;
|
||||
// rm_by_id_iq.sel_meta = true;
|
||||
// rm_by_id_iq.WhereId(item_id);
|
||||
|
||||
if( db->GetItem(rm_by_id_item, rm_by_id_iq) == WINIX_ERR_OK )
|
||||
morm::Finder<Item> finder(model_connector);
|
||||
|
||||
rm_by_id_item = finder.
|
||||
select().
|
||||
where().
|
||||
eq(L"id", item_id).
|
||||
get();
|
||||
|
||||
//if( db->GetItem(rm_by_id_item, rm_by_id_iq) == WINIX_ERR_OK )
|
||||
if( rm_by_id_item.found() )
|
||||
{
|
||||
if( rm_by_id_item.type == Item::dir )
|
||||
{
|
||||
@@ -341,8 +360,16 @@ return result;
|
||||
|
||||
bool Rm::RemoveDirFiles(long dir_id, bool check_access)
|
||||
{
|
||||
content_dir_iq.WhereParentId(dir_id);
|
||||
db->GetItems(content_item_tab, content_dir_iq);
|
||||
// content_dir_iq.WhereParentId(dir_id);
|
||||
// db->GetItems(content_item_tab, content_dir_iq);
|
||||
|
||||
morm::Finder<Item> finder(model_connector);
|
||||
|
||||
finder.
|
||||
select().
|
||||
where().
|
||||
eq(L"parent_id", dir_id).
|
||||
get_vector(content_item_tab);
|
||||
|
||||
size_t removed = 0;
|
||||
|
||||
@@ -362,7 +389,7 @@ void Rm::RemoveCurrentDir(Item * parent_dir, Item * current_dir, bool check_acce
|
||||
{
|
||||
if( check_access )
|
||||
{
|
||||
if( !parent_dir || !system->CanRemoveRenameChild(*parent_dir, current_dir->user_id) )
|
||||
if( !parent_dir || !system->CanRemoveRenameChild(*parent_dir, current_dir->item_content.user_id) )
|
||||
{
|
||||
log << log1 << "Rm: permission denied to directory: " << current_dir->url << logend;
|
||||
slog << logerror << T("rm_permission_denied_to") << ": " << current_dir->url << logend;
|
||||
@@ -372,7 +399,8 @@ void Rm::RemoveCurrentDir(Item * parent_dir, Item * current_dir, bool check_acce
|
||||
|
||||
plugin->Call(WINIX_DIR_PREPARE_TO_REMOVE, current_dir);
|
||||
|
||||
if( db->DelDirById(current_dir->id) == WINIX_ERR_OK )
|
||||
//if( db->DelDirById(current_dir->id) == WINIX_ERR_OK )
|
||||
if( current_dir->remove() )
|
||||
{
|
||||
long dir_id = current_dir->id;
|
||||
old_url = current_dir->url;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010-2014, Tomasz Sowa
|
||||
* Copyright (c) 2010-2021, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -74,7 +74,7 @@ public:
|
||||
private:
|
||||
|
||||
// for deleting content in a directory (files and symlinks)
|
||||
DbItemQuery content_dir_iq;
|
||||
//DbItemQuery content_dir_iq;
|
||||
std::vector<Item> content_item_tab;
|
||||
std::wstring path;
|
||||
|
||||
@@ -82,7 +82,7 @@ private:
|
||||
std::wstring old_url;
|
||||
|
||||
// for removing an item by id
|
||||
DbItemQuery rm_by_id_iq;
|
||||
//DbItemQuery rm_by_id_iq;
|
||||
Item rm_by_id_item;
|
||||
|
||||
std::vector<Item*> rm_path_dir_tab;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2011-2018, Tomasz Sowa
|
||||
* Copyright (c) 2011-2021, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -65,9 +65,18 @@ bool Sort::HasAccess()
|
||||
|
||||
void Sort::GetDirContent()
|
||||
{
|
||||
iq.sel_content = false;
|
||||
iq.WhereParentId(cur->request->dir_tab.back()->id);
|
||||
db->GetItems(cur->request->item_tab, iq);
|
||||
// iq.sel_content = false;
|
||||
// iq.WhereParentId(cur->request->dir_tab.back()->id);
|
||||
// db->GetItems(cur->request->item_tab, iq);
|
||||
|
||||
morm::Finder<Item> finder(model_connector);
|
||||
|
||||
finder.
|
||||
select().
|
||||
where().
|
||||
eq(L"parent_id", cur->request->dir_tab.back()->id).
|
||||
get_vector(cur->request->item_tab);
|
||||
|
||||
system->CheckWriteAccessToItems(cur->request->item_tab);
|
||||
}
|
||||
|
||||
@@ -127,7 +136,8 @@ void Sort::UpdateSortIndex(Item & item, int sort_index)
|
||||
{
|
||||
item.sort_index = sort_index;
|
||||
|
||||
if( db->EditSortIndexItemById(item.id, sort_index) == WINIX_ERR_OK )
|
||||
//if( db->EditSortIndexItemById(item.id, sort_index) == WINIX_ERR_OK )
|
||||
if( item.update(false, false) )
|
||||
{
|
||||
log << log2
|
||||
<< "Sort: updated sort index, item_id=" << item.id
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2011-2018, Tomasz Sowa
|
||||
* Copyright (c) 2011-2021, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
DbItemQuery iq;
|
||||
//DbItemQuery iq;
|
||||
std::vector<size_t> item_tab; // indexes to cur->request->item_tab
|
||||
|
||||
struct SortPair
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* Copyright (c) 2008-2021, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -76,7 +76,8 @@ void Subject::EditDirSubject()
|
||||
Item & dir = *cur->request->dir_tab.back();
|
||||
|
||||
cur->request->PostVar(L"subject", dir.subject);
|
||||
db->EditSubjectById(dir, dir.id);
|
||||
dir.update(false, false);
|
||||
//db->EditSubjectById(dir, dir.id);
|
||||
|
||||
// !! IMPROVE ME
|
||||
// we need something like WINIX_DIR_CHANGED message
|
||||
@@ -90,7 +91,8 @@ void Subject::EditDirSubject()
|
||||
void Subject::EditFileSubject()
|
||||
{
|
||||
cur->request->PostVar(L"subject", cur->request->item.subject);
|
||||
db->EditSubjectById(cur->request->item, cur->request->item.id);
|
||||
cur->request->item.update(false, false);
|
||||
//db->EditSubjectById(cur->request->item, cur->request->item.id);
|
||||
|
||||
plugin->Call(WINIX_FILE_CHANGED, &cur->request->item);
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010-2016, Tomasz Sowa
|
||||
* Copyright (c) 2010-2021, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -122,11 +122,11 @@ void Template::ChangeTemplate(Item & item)
|
||||
{
|
||||
if( html_template != item.html_template )
|
||||
{
|
||||
cur->request->status = db->EditTemplateItemById(item.id, html_template);
|
||||
item.html_template = html_template;
|
||||
|
||||
if( cur->request->status == WINIX_ERR_OK )
|
||||
//cur->request->status = db->EditTemplateItemById(item.id, html_template);
|
||||
if( item.update(false, false) )
|
||||
{
|
||||
item.html_template = html_template;
|
||||
PutLog(item);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2018, Tomasz Sowa
|
||||
* Copyright (c) 2008-2021, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -154,25 +154,32 @@ void Upload::UploadFile(Item & item, const std::wstring & tmp_filename)
|
||||
{
|
||||
if( UploadSaveStaticFile(item, tmp_filename) )
|
||||
{
|
||||
cur->request->status = db->EditFileById(item, item.id);
|
||||
|
||||
plugin->Call(WINIX_FILE_ADDED, &item);
|
||||
|
||||
if( item.file_type == WINIX_ITEM_FILETYPE_IMAGE )
|
||||
//cur->request->status = db->EditFileById(item, item.id);
|
||||
if( item.update(false, true) )
|
||||
{
|
||||
if( config->image_resize )
|
||||
ResizeImage(item);
|
||||
plugin->Call(WINIX_FILE_ADDED, &item);
|
||||
|
||||
if( config->create_thumb )
|
||||
CreateThumb(item);
|
||||
if( item.item_content.file_type == WINIX_ITEM_FILETYPE_IMAGE )
|
||||
{
|
||||
if( config->image_resize )
|
||||
ResizeImage(item);
|
||||
|
||||
if( config->create_thumb )
|
||||
CreateThumb(item);
|
||||
}
|
||||
|
||||
if( is_jquery_upload )
|
||||
cur->request->item_tab.push_back(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
cur->request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
}
|
||||
|
||||
if( is_jquery_upload )
|
||||
cur->request->item_tab.push_back(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
db->DelItem(item);
|
||||
item.remove();
|
||||
//db->DelItem(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -208,7 +215,7 @@ void Upload::UploadMulti()
|
||||
cur->request->item.Clear(); // clearing and setting date
|
||||
cur->request->item.parent_id = cur->request->dir_tab.back()->id;
|
||||
cur->request->item.type = Item::file;
|
||||
cur->request->item.privileges = system->NewFilePrivileges();
|
||||
cur->request->item.item_content.privileges = system->NewFilePrivileges();
|
||||
functions->SetUser(cur->request->item);
|
||||
|
||||
PostFileTab::iterator i = cur->request->post_file_tab.begin();
|
||||
@@ -219,8 +226,8 @@ void Upload::UploadMulti()
|
||||
|
||||
cur->request->item.subject = file_name;
|
||||
cur->request->item.url = file_name;
|
||||
cur->request->item.file_type = SelectFileType(file_name);
|
||||
cur->request->item.file_size = i->second.file_size;
|
||||
cur->request->item.item_content.file_type = SelectFileType(file_name);
|
||||
cur->request->item.item_content.file_size = i->second.file_size;
|
||||
|
||||
functions->PrepareUrl(cur->request->item);
|
||||
UploadFile(cur->request->item, i->second.tmp_filename);
|
||||
@@ -243,13 +250,13 @@ void Upload::UploadSingle()
|
||||
|
||||
functions->ReadItem(cur->request->item, Item::file); // ReadItem() changes the url if it is empty
|
||||
functions->SetUser(cur->request->item);
|
||||
cur->request->item.privileges = system->NewFilePrivileges();
|
||||
cur->request->item.item_content.privileges = system->NewFilePrivileges();
|
||||
|
||||
PostFile & post_file = cur->request->post_file_tab.begin()->second;
|
||||
|
||||
const wchar_t * file_name = post_file.filename.c_str();
|
||||
cur->request->item.file_type = SelectFileType(file_name);
|
||||
cur->request->item.file_size = post_file.file_size;
|
||||
cur->request->item.item_content.file_type = SelectFileType(file_name);
|
||||
cur->request->item.item_content.file_size = post_file.file_size;
|
||||
|
||||
if( !has_subject )
|
||||
cur->request->item.subject = file_name;
|
||||
@@ -305,7 +312,7 @@ void Upload::CreateAnswer()
|
||||
PT::Space & file = files.AddSpace(L"");
|
||||
|
||||
file.Add(L"name", req.item_tab[i].url);
|
||||
file.Add(L"size", req.item_tab[i].file_size);
|
||||
file.Add(L"size", req.item_tab[i].item_content.file_size);
|
||||
|
||||
std::wstring & link = file.Add(L"url", L"");
|
||||
system->CreateItemLink(req.item_tab[i], link);
|
||||
@@ -315,11 +322,11 @@ void Upload::CreateAnswer()
|
||||
|
||||
file.Add(L"deleteType", L"POST");
|
||||
|
||||
if( req.item_tab[i].file_type == WINIX_ITEM_FILETYPE_IMAGE )
|
||||
if( req.item_tab[i].item_content.file_type == WINIX_ITEM_FILETYPE_IMAGE )
|
||||
{
|
||||
std::wstring & thumb = file.Add(L"thumbnailUrl", link);
|
||||
|
||||
if( req.item_tab[i].has_thumb )
|
||||
if( req.item_tab[i].item_content.file_has_thumb )
|
||||
thumb += L"/-/thumb";
|
||||
}
|
||||
|
||||
@@ -342,12 +349,22 @@ void Upload::MakeGet()
|
||||
{
|
||||
if( cur->request->IsParam(L"jquery_upload") )
|
||||
{
|
||||
query.Clear();
|
||||
query.WhereParentId(cur->request->dir_tab.back()->id);
|
||||
query.WhereType(Item::file);
|
||||
query.WhereFileType(WINIX_ITEM_FILETYPE_NONE, false);
|
||||
// query.Clear();
|
||||
// query.WhereParentId(cur->request->dir_tab.back()->id);
|
||||
// query.WhereType(Item::file);
|
||||
// query.WhereFileType(WINIX_ITEM_FILETYPE_NONE, false);
|
||||
|
||||
db->GetItems(cur->request->item_tab, query);
|
||||
morm::Finder<Item> finder(model_connector);
|
||||
|
||||
finder.
|
||||
select().
|
||||
where().
|
||||
eq(L"parent_id", cur->request->dir_tab.back()->id).
|
||||
eq(L"type", static_cast<int>(Item::file)).
|
||||
neq(L"content.file_type", WINIX_ITEM_FILETYPE_NONE).
|
||||
get_vector(cur->request->item_tab);
|
||||
|
||||
//db->GetItems(cur->request->item_tab, query);
|
||||
|
||||
CreateAnswer();
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010-2014, Tomasz Sowa
|
||||
* Copyright (c) 2010-2021, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
private:
|
||||
|
||||
std::wstring path;
|
||||
DbItemQuery query;
|
||||
//DbItemQuery query;
|
||||
bool is_jquery_upload;
|
||||
|
||||
// this object is used in App at the end of a request
|
||||
|
||||
Reference in New Issue
Block a user