commit
1fb7ab557e
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -12,3 +12,4 @@ Oqtane.Server/appsettings.json
|
||||||
Oqtane.Server/Data/*.mdf
|
Oqtane.Server/Data/*.mdf
|
||||||
Oqtane.Server/Data/*.ldf
|
Oqtane.Server/Data/*.ldf
|
||||||
|
|
||||||
|
/Oqtane.Server/Properties/PublishProfiles/FolderProfile.pubxml
|
||||||
|
|
|
@ -8,9 +8,15 @@
|
||||||
|
|
||||||
@((MarkupString)content)
|
@((MarkupString)content)
|
||||||
|
|
||||||
<br />
|
@if (PageState.EditMode)
|
||||||
|
{
|
||||||
|
<br />
|
||||||
|
}
|
||||||
<ActionLink Action="Edit" />
|
<ActionLink Action="Edit" />
|
||||||
<br /><br />
|
@if (PageState.EditMode)
|
||||||
|
{
|
||||||
|
<br /><br />
|
||||||
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private string content = "";
|
private string content = "";
|
||||||
|
|
|
@ -27,8 +27,8 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="3.2.0-preview4.20210.8" />
|
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="3.2.0-preview5.20216.8" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Build" Version="3.2.0-preview4.20210.8" PrivateAssets="all" />
|
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Build" Version="3.2.0-preview5.20216.8" PrivateAssets="all" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="3.1.2" />
|
<PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="3.1.2" />
|
||||||
<PackageReference Include="System.Net.Http.Json" Version="3.2.0-preview5.20210.3" />
|
<PackageReference Include="System.Net.Http.Json" Version="3.2.0-preview5.20210.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
@ -42,9 +42,9 @@ namespace Oqtane.Services
|
||||||
|
|
||||||
public async Task<List<File>> GetFilesAsync(int siteId, string folderPath)
|
public async Task<List<File>> GetFilesAsync(int siteId, string folderPath)
|
||||||
{
|
{
|
||||||
if (!folderPath.EndsWith("\\"))
|
if (!(folderPath.EndsWith(System.IO.Path.DirectorySeparatorChar) || folderPath.EndsWith(System.IO.Path.AltDirectorySeparatorChar)))
|
||||||
{
|
{
|
||||||
folderPath += "\\";
|
folderPath = Utilities.PathCombine(folderPath,"\\");
|
||||||
}
|
}
|
||||||
|
|
||||||
var path = WebUtility.UrlEncode(folderPath);
|
var path = WebUtility.UrlEncode(folderPath);
|
||||||
|
|
|
@ -38,9 +38,9 @@ namespace Oqtane.Services
|
||||||
|
|
||||||
public async Task<Folder> GetFolderAsync(int siteId, [NotNull] string folderPath)
|
public async Task<Folder> GetFolderAsync(int siteId, [NotNull] string folderPath)
|
||||||
{
|
{
|
||||||
if (!folderPath.EndsWith("\\"))
|
if (!(folderPath.EndsWith(System.IO.Path.DirectorySeparatorChar) || folderPath.EndsWith(System.IO.Path.AltDirectorySeparatorChar)))
|
||||||
{
|
{
|
||||||
folderPath += "\\";
|
folderPath = Utilities.PathCombine(folderPath, "\\");
|
||||||
}
|
}
|
||||||
|
|
||||||
var path = WebUtility.UrlEncode(folderPath);
|
var path = WebUtility.UrlEncode(folderPath);
|
||||||
|
|
|
@ -161,7 +161,7 @@ namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
_files.DeleteFile(id);
|
_files.DeleteFile(id);
|
||||||
|
|
||||||
string filepath = Path.Combine(GetFolderPath(file.Folder) + file.Name);
|
string filepath = Path.Combine(GetFolderPath(file.Folder), file.Name);
|
||||||
if (System.IO.File.Exists(filepath))
|
if (System.IO.File.Exists(filepath))
|
||||||
{
|
{
|
||||||
System.IO.File.Delete(filepath);
|
System.IO.File.Delete(filepath);
|
||||||
|
@ -199,14 +199,15 @@ namespace Oqtane.Controllers
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var client = new WebClient();
|
var client = new WebClient();
|
||||||
|
string targetPath = Path.Combine(folderPath, filename);
|
||||||
// remove file if it already exists
|
// remove file if it already exists
|
||||||
if (System.IO.File.Exists(folderPath + filename))
|
if (System.IO.File.Exists(targetPath))
|
||||||
{
|
{
|
||||||
System.IO.File.Delete(folderPath + filename);
|
System.IO.File.Delete(targetPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
client.DownloadFile(url, folderPath + filename);
|
client.DownloadFile(url, targetPath);
|
||||||
_files.AddFile(CreateFile(filename, folder.FolderId, folderPath + filename));
|
_files.AddFile(CreateFile(filename, folder.FolderId, targetPath));
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
@ -262,7 +263,7 @@ namespace Oqtane.Controllers
|
||||||
string upload = await MergeFile(folderPath, file.FileName);
|
string upload = await MergeFile(folderPath, file.FileName);
|
||||||
if (upload != "" && folderId != -1)
|
if (upload != "" && folderId != -1)
|
||||||
{
|
{
|
||||||
_files.AddFile(CreateFile(upload, folderId, folderPath + upload));
|
_files.AddFile(CreateFile(upload, folderId, Path.Combine(folderPath, upload)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -400,7 +401,7 @@ namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
if (_userPermissions.IsAuthorized(User, PermissionNames.View, file.Folder.Permissions))
|
if (_userPermissions.IsAuthorized(User, PermissionNames.View, file.Folder.Permissions))
|
||||||
{
|
{
|
||||||
string filepath = GetFolderPath(file.Folder) + file.Name;
|
string filepath = Path.Combine(GetFolderPath(file.Folder) , file.Name);
|
||||||
if (System.IO.File.Exists(filepath))
|
if (System.IO.File.Exists(filepath))
|
||||||
{
|
{
|
||||||
byte[] filebytes = System.IO.File.ReadAllBytes(filepath);
|
byte[] filebytes = System.IO.File.ReadAllBytes(filepath);
|
||||||
|
@ -430,12 +431,12 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
private string GetFolderPath(Folder folder)
|
private string GetFolderPath(Folder folder)
|
||||||
{
|
{
|
||||||
return _environment.ContentRootPath + "\\Content\\Tenants\\" + _tenants.GetTenant().TenantId.ToString() + "\\Sites\\" + folder.SiteId.ToString() + "\\" + folder.Path;
|
return Utilities.PathCombine(_environment.ContentRootPath, "Content", "Tenants", _tenants.GetTenant().TenantId.ToString(), "Sites", folder.SiteId.ToString(), folder.Path);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetFolderPath(string folder)
|
private string GetFolderPath(string folder)
|
||||||
{
|
{
|
||||||
return Path.Combine(_environment.WebRootPath, folder);
|
return Utilities.PathCombine(_environment.WebRootPath, folder);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CreateDirectory(string folderpath)
|
private void CreateDirectory(string folderpath)
|
||||||
|
@ -443,10 +444,11 @@ namespace Oqtane.Controllers
|
||||||
if (!Directory.Exists(folderpath))
|
if (!Directory.Exists(folderpath))
|
||||||
{
|
{
|
||||||
string path = "";
|
string path = "";
|
||||||
string[] folders = folderpath.Split(new[] {'\\'}, StringSplitOptions.RemoveEmptyEntries);
|
var separators = new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar };
|
||||||
|
string[] folders = folderpath.Split(separators, StringSplitOptions.RemoveEmptyEntries);
|
||||||
foreach (string folder in folders)
|
foreach (string folder in folders)
|
||||||
{
|
{
|
||||||
path += folder + "\\";
|
path = Utilities.PathCombine(path, folder,"\\");
|
||||||
if (!Directory.Exists(path))
|
if (!Directory.Exists(path))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(path);
|
Directory.CreateDirectory(path);
|
||||||
|
|
|
@ -6,9 +6,11 @@ using Oqtane.Shared;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using Oqtane.Enums;
|
using Oqtane.Enums;
|
||||||
|
using Oqtane.Extensions;
|
||||||
using Oqtane.Infrastructure;
|
using Oqtane.Infrastructure;
|
||||||
using Oqtane.Repository;
|
using Oqtane.Repository;
|
||||||
using Oqtane.Security;
|
using Oqtane.Security;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace Oqtane.Controllers
|
namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
|
@ -17,14 +19,12 @@ namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
private readonly IFolderRepository _folders;
|
private readonly IFolderRepository _folders;
|
||||||
private readonly IUserPermissions _userPermissions;
|
private readonly IUserPermissions _userPermissions;
|
||||||
private readonly IPermissionRepository _permissionRepository;
|
|
||||||
private readonly ILogManager _logger;
|
private readonly ILogManager _logger;
|
||||||
|
|
||||||
public FolderController(IFolderRepository folders, IUserPermissions userPermissions, IPermissionRepository permissionRepository, ILogManager logger)
|
public FolderController(IFolderRepository folders, IUserPermissions userPermissions, ILogManager logger)
|
||||||
{
|
{
|
||||||
_folders = folders;
|
_folders = folders;
|
||||||
_userPermissions = userPermissions;
|
_userPermissions = userPermissions;
|
||||||
_permissionRepository = permissionRepository;
|
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,16 +100,16 @@ namespace Oqtane.Controllers
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
permissions = _permissionRepository.EncodePermissions(new List<Permission> {
|
permissions = new List<Permission> {
|
||||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
new Permission(PermissionNames.Edit, Constants.AdminRole, true),
|
||||||
});
|
}.EncodePermissions();
|
||||||
}
|
}
|
||||||
if (_userPermissions.IsAuthorized(User,PermissionNames.Edit, permissions))
|
if (_userPermissions.IsAuthorized(User,PermissionNames.Edit, permissions))
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(folder.Path) && folder.ParentId != null)
|
if (string.IsNullOrEmpty(folder.Path) && folder.ParentId != null)
|
||||||
{
|
{
|
||||||
Folder parent = _folders.GetFolder(folder.ParentId.Value);
|
Folder parent = _folders.GetFolder(folder.ParentId.Value);
|
||||||
folder.Path = parent.Path + folder.Name + "\\";
|
folder.Path = Utilities.PathCombine(parent.Path, folder.Name,"\\");
|
||||||
}
|
}
|
||||||
folder = _folders.AddFolder(folder);
|
folder = _folders.AddFolder(folder);
|
||||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Folder Added {Folder}", folder);
|
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Folder Added {Folder}", folder);
|
||||||
|
@ -134,7 +134,7 @@ namespace Oqtane.Controllers
|
||||||
if (string.IsNullOrEmpty(folder.Path) && folder.ParentId != null)
|
if (string.IsNullOrEmpty(folder.Path) && folder.ParentId != null)
|
||||||
{
|
{
|
||||||
Folder parent = _folders.GetFolder(folder.ParentId.Value);
|
Folder parent = _folders.GetFolder(folder.ParentId.Value);
|
||||||
folder.Path = parent.Path + folder.Name + "\\";
|
folder.Path = Utilities.PathCombine(parent.Path, folder.Name,"\\");
|
||||||
}
|
}
|
||||||
folder = _folders.UpdateFolder(folder);
|
folder = _folders.UpdateFolder(folder);
|
||||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Folder Updated {Folder}", folder);
|
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Folder Updated {Folder}", folder);
|
||||||
|
|
|
@ -116,7 +116,7 @@ namespace Oqtane.Controllers
|
||||||
assemblyname = assemblyname.Replace(".Client", "");
|
assemblyname = assemblyname.Replace(".Client", "");
|
||||||
|
|
||||||
// clean up module static resource folder
|
// clean up module static resource folder
|
||||||
string folder = Path.Combine(_environment.WebRootPath, "Modules\\" + assemblyname);
|
string folder = Path.Combine(_environment.WebRootPath, Path.Combine("Modules",assemblyname));
|
||||||
if (Directory.Exists(folder))
|
if (Directory.Exists(folder))
|
||||||
{
|
{
|
||||||
Directory.Delete(folder, true);
|
Directory.Delete(folder, true);
|
||||||
|
@ -130,6 +130,10 @@ namespace Oqtane.Controllers
|
||||||
System.IO.File.Delete(file);
|
System.IO.File.Delete(file);
|
||||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Module Assembly Removed {Filename}", file);
|
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Module Assembly Removed {Filename}", file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// clean up module schema versions
|
||||||
|
_sql.ExecuteNonQuery(tenant, "DELETE FROM [dbo].[SchemaVersions] WHERE ScriptName LIKE '" + assemblyname + "%'");
|
||||||
|
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Module Schema Versions Removed For {AssemblyName}", assemblyname);
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove module definition
|
// remove module definition
|
||||||
|
@ -168,17 +172,17 @@ namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
string rootPath;
|
string rootPath;
|
||||||
DirectoryInfo rootFolder = Directory.GetParent(_environment.ContentRootPath);
|
DirectoryInfo rootFolder = Directory.GetParent(_environment.ContentRootPath);
|
||||||
string templatePath = Path.Combine(rootFolder.FullName, "Oqtane.Client\\Modules\\Admin\\ModuleCreator\\Templates\\" + moduleDefinition.Template + "\\");
|
string templatePath = Utilities.PathCombine(rootFolder.FullName, "Oqtane.Client", "Modules", "Admin", "ModuleCreator", "Templates",moduleDefinition.Template,"\\");
|
||||||
|
|
||||||
if (moduleDefinition.Template == "internal")
|
if (moduleDefinition.Template == "internal")
|
||||||
{
|
{
|
||||||
rootPath = rootFolder.FullName + "\\";
|
rootPath = Utilities.PathCombine(rootFolder.FullName,"\\");
|
||||||
moduleDefinition.ModuleDefinitionName = moduleDefinition.Owner + "." + moduleDefinition.Name + "s.Modules, Oqtane.Client";
|
moduleDefinition.ModuleDefinitionName = moduleDefinition.Owner + "." + moduleDefinition.Name + "s.Modules, Oqtane.Client";
|
||||||
moduleDefinition.ServerManagerType = moduleDefinition.Owner + "." + moduleDefinition.Name + "s.Manager." + moduleDefinition.Name + "Manager, Oqtane.Server";
|
moduleDefinition.ServerManagerType = moduleDefinition.Owner + "." + moduleDefinition.Name + "s.Manager." + moduleDefinition.Name + "Manager, Oqtane.Server";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rootPath = rootFolder.Parent.FullName + "\\" + moduleDefinition.Owner + "." + moduleDefinition.Name + "s.Module\\";
|
rootPath = Utilities.PathCombine(rootFolder.Parent.FullName , moduleDefinition.Owner + "." + moduleDefinition.Name + "s.Module","\\");
|
||||||
moduleDefinition.ModuleDefinitionName = moduleDefinition.Owner + "." + moduleDefinition.Name + "s.Modules, " + moduleDefinition.Owner + "." + moduleDefinition.Name + "s.Module.Client";
|
moduleDefinition.ModuleDefinitionName = moduleDefinition.Owner + "." + moduleDefinition.Name + "s.Modules, " + moduleDefinition.Owner + "." + moduleDefinition.Name + "s.Module.Client";
|
||||||
moduleDefinition.ServerManagerType = moduleDefinition.Owner + "." + moduleDefinition.Name + "s.Manager." + moduleDefinition.Name + "Manager, " + moduleDefinition.Owner + "." + moduleDefinition.Name + "s.Module.Server";
|
moduleDefinition.ServerManagerType = moduleDefinition.Owner + "." + moduleDefinition.Name + "s.Manager." + moduleDefinition.Name + "Manager, " + moduleDefinition.Owner + "." + moduleDefinition.Name + "s.Module.Server";
|
||||||
}
|
}
|
||||||
|
@ -197,7 +201,7 @@ namespace Oqtane.Controllers
|
||||||
private void ProcessTemplatesRecursively(DirectoryInfo current, string rootPath, string rootFolder, string templatePath, ModuleDefinition moduleDefinition)
|
private void ProcessTemplatesRecursively(DirectoryInfo current, string rootPath, string rootFolder, string templatePath, ModuleDefinition moduleDefinition)
|
||||||
{
|
{
|
||||||
// process folder
|
// process folder
|
||||||
string folderPath = rootPath + current.FullName.Replace(templatePath, "");
|
string folderPath = Utilities.PathCombine(rootPath, current.FullName.Replace(templatePath, ""));
|
||||||
folderPath = folderPath.Replace("[Owner]", moduleDefinition.Owner);
|
folderPath = folderPath.Replace("[Owner]", moduleDefinition.Owner);
|
||||||
folderPath = folderPath.Replace("[Module]", moduleDefinition.Name);
|
folderPath = folderPath.Replace("[Module]", moduleDefinition.Name);
|
||||||
if (!Directory.Exists(folderPath))
|
if (!Directory.Exists(folderPath))
|
||||||
|
|
|
@ -7,6 +7,7 @@ using System.Linq;
|
||||||
using Oqtane.Security;
|
using Oqtane.Security;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using Oqtane.Enums;
|
using Oqtane.Enums;
|
||||||
|
using Oqtane.Extensions;
|
||||||
using Oqtane.Infrastructure;
|
using Oqtane.Infrastructure;
|
||||||
using Oqtane.Repository;
|
using Oqtane.Repository;
|
||||||
|
|
||||||
|
@ -19,17 +20,15 @@ namespace Oqtane.Controllers
|
||||||
private readonly IModuleRepository _modules;
|
private readonly IModuleRepository _modules;
|
||||||
private readonly IPageModuleRepository _pageModules;
|
private readonly IPageModuleRepository _pageModules;
|
||||||
private readonly IUserPermissions _userPermissions;
|
private readonly IUserPermissions _userPermissions;
|
||||||
private readonly IPermissionRepository _permissionRepository;
|
|
||||||
private readonly ISyncManager _syncManager;
|
private readonly ISyncManager _syncManager;
|
||||||
private readonly ILogManager _logger;
|
private readonly ILogManager _logger;
|
||||||
|
|
||||||
public PageController(IPageRepository pages, IModuleRepository modules, IPageModuleRepository pageModules, IUserPermissions userPermissions, IPermissionRepository permissionRepository, ISyncManager syncManager, ILogManager logger)
|
public PageController(IPageRepository pages, IModuleRepository modules, IPageModuleRepository pageModules, IUserPermissions userPermissions, ISyncManager syncManager, ILogManager logger)
|
||||||
{
|
{
|
||||||
_pages = pages;
|
_pages = pages;
|
||||||
_modules = modules;
|
_modules = modules;
|
||||||
_pageModules = pageModules;
|
_pageModules = pageModules;
|
||||||
_userPermissions = userPermissions;
|
_userPermissions = userPermissions;
|
||||||
_permissionRepository = permissionRepository;
|
|
||||||
_syncManager = syncManager;
|
_syncManager = syncManager;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
@ -113,9 +112,9 @@ namespace Oqtane.Controllers
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
permissions = _permissionRepository.EncodePermissions(new List<Permission> {
|
permissions = new List<Permission> {
|
||||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
||||||
});
|
}.EncodePermissions();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_userPermissions.IsAuthorized(User,PermissionNames.Edit, permissions))
|
if (_userPermissions.IsAuthorized(User,PermissionNames.Edit, permissions))
|
||||||
|
@ -156,10 +155,10 @@ namespace Oqtane.Controllers
|
||||||
page.ThemeType = parent.ThemeType;
|
page.ThemeType = parent.ThemeType;
|
||||||
page.LayoutType = parent.LayoutType;
|
page.LayoutType = parent.LayoutType;
|
||||||
page.Icon = parent.Icon;
|
page.Icon = parent.Icon;
|
||||||
page.Permissions = _permissionRepository.EncodePermissions(new List<Permission> {
|
page.Permissions = new List<Permission> {
|
||||||
new Permission(PermissionNames.View, userid, true),
|
new Permission(PermissionNames.View, userid, true),
|
||||||
new Permission(PermissionNames.Edit, userid, true)
|
new Permission(PermissionNames.Edit, userid, true)
|
||||||
});
|
}.EncodePermissions();
|
||||||
page.IsPersonalizable = false;
|
page.IsPersonalizable = false;
|
||||||
page.UserId = int.Parse(userid);
|
page.UserId = int.Parse(userid);
|
||||||
page = _pages.AddPage(page);
|
page = _pages.AddPage(page);
|
||||||
|
@ -173,10 +172,10 @@ namespace Oqtane.Controllers
|
||||||
module.SiteId = page.SiteId;
|
module.SiteId = page.SiteId;
|
||||||
module.PageId = page.PageId;
|
module.PageId = page.PageId;
|
||||||
module.ModuleDefinitionName = pm.Module.ModuleDefinitionName;
|
module.ModuleDefinitionName = pm.Module.ModuleDefinitionName;
|
||||||
module.Permissions = _permissionRepository.EncodePermissions(new List<Permission> {
|
module.Permissions = new List<Permission> {
|
||||||
new Permission(PermissionNames.View, userid, true),
|
new Permission(PermissionNames.View, userid, true),
|
||||||
new Permission(PermissionNames.Edit, userid, true)
|
new Permission(PermissionNames.Edit, userid, true)
|
||||||
});
|
}.EncodePermissions();
|
||||||
module = _modules.AddModule(module);
|
module = _modules.AddModule(module);
|
||||||
|
|
||||||
string content = _modules.ExportModule(pm.ModuleId);
|
string content = _modules.ExportModule(pm.ModuleId);
|
||||||
|
|
|
@ -58,7 +58,7 @@ namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
themename = theme.ThemeName.Substring(0, theme.ThemeName.IndexOf(","));
|
themename = theme.ThemeName.Substring(0, theme.ThemeName.IndexOf(","));
|
||||||
|
|
||||||
string folder = Path.Combine(_environment.WebRootPath, "Themes\\" + themename);
|
string folder = Path.Combine(_environment.WebRootPath, "Themes" , themename);
|
||||||
if (Directory.Exists(folder))
|
if (Directory.Exists(folder))
|
||||||
{
|
{
|
||||||
Directory.Delete(folder, true);
|
Directory.Delete(folder, true);
|
||||||
|
|
|
@ -150,7 +150,7 @@ namespace Oqtane.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
// add folder for user
|
// add folder for user
|
||||||
Folder folder = _folders.GetFolder(user.SiteId, "Users\\");
|
Folder folder = _folders.GetFolder(user.SiteId, Utilities.PathCombine("Users","\\"));
|
||||||
if (folder != null)
|
if (folder != null)
|
||||||
{
|
{
|
||||||
_folders.AddFolder(new Folder
|
_folders.AddFolder(new Folder
|
||||||
|
@ -158,7 +158,7 @@ namespace Oqtane.Controllers
|
||||||
SiteId = folder.SiteId,
|
SiteId = folder.SiteId,
|
||||||
ParentId = folder.FolderId,
|
ParentId = folder.FolderId,
|
||||||
Name = "My Folder",
|
Name = "My Folder",
|
||||||
Path = folder.Path + newUser.UserId.ToString() + "\\",
|
Path = Utilities.PathCombine(folder.Path, newUser.UserId.ToString(),"\\"),
|
||||||
Order = 1,
|
Order = 1,
|
||||||
IsSystem = true,
|
IsSystem = true,
|
||||||
Permissions = "[{\"PermissionName\":\"Browse\",\"Permissions\":\"[" + newUser.UserId.ToString() + "]\"},{\"PermissionName\":\"View\",\"Permissions\":\"All Users\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"[" +
|
Permissions = "[{\"PermissionName\":\"Browse\",\"Permissions\":\"[" + newUser.UserId.ToString() + "]\"},{\"PermissionName\":\"View\",\"Permissions\":\"All Users\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"[" +
|
||||||
|
|
|
@ -38,6 +38,10 @@ namespace Oqtane.Infrastructure
|
||||||
{
|
{
|
||||||
var defaultConnectionString = _config.GetConnectionString(SettingKeys.ConnectionStringKey);
|
var defaultConnectionString = _config.GetConnectionString(SettingKeys.ConnectionStringKey);
|
||||||
var defaultAlias = GetInstallationConfig(SettingKeys.DefaultAliasKey, string.Empty);
|
var defaultAlias = GetInstallationConfig(SettingKeys.DefaultAliasKey, string.Empty);
|
||||||
|
var dataDirectory = AppDomain.CurrentDomain.GetData("DataDirectory")?.ToString();
|
||||||
|
|
||||||
|
//create data directory if does not exists
|
||||||
|
if (!Directory.Exists(dataDirectory)) Directory.CreateDirectory(dataDirectory);
|
||||||
|
|
||||||
// if no values specified, fallback to IDE installer
|
// if no values specified, fallback to IDE installer
|
||||||
if (string.IsNullOrEmpty(defaultConnectionString))
|
if (string.IsNullOrEmpty(defaultConnectionString))
|
||||||
|
@ -61,7 +65,6 @@ namespace Oqtane.Infrastructure
|
||||||
|
|
||||||
if (result.Success)
|
if (result.Success)
|
||||||
{
|
{
|
||||||
var dataDirectory = AppDomain.CurrentDomain.GetData("DataDirectory")?.ToString();
|
|
||||||
WriteVersionInfo(defaultConnectionString);
|
WriteVersionInfo(defaultConnectionString);
|
||||||
TenantMigration(defaultConnectionString, dataDirectory);
|
TenantMigration(defaultConnectionString, dataDirectory);
|
||||||
}
|
}
|
||||||
|
@ -69,7 +72,6 @@ namespace Oqtane.Infrastructure
|
||||||
if (_isInstalled && !IsDefaultSiteInstalled(defaultConnectionString))
|
if (_isInstalled && !IsDefaultSiteInstalled(defaultConnectionString))
|
||||||
{
|
{
|
||||||
BuildDefaultSite(password,email);
|
BuildDefaultSite(password,email);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,7 +212,6 @@ namespace Oqtane.Infrastructure
|
||||||
|
|
||||||
private static void ModuleMigration(Assembly assembly, string connectionString)
|
private static void ModuleMigration(Assembly assembly, string connectionString)
|
||||||
{
|
{
|
||||||
|
|
||||||
Console.WriteLine($"Migrating assembly {assembly.FullName}");
|
Console.WriteLine($"Migrating assembly {assembly.FullName}");
|
||||||
var dbUpgradeConfig = DeployChanges.To.SqlDatabase(connectionString)
|
var dbUpgradeConfig = DeployChanges.To.SqlDatabase(connectionString)
|
||||||
.WithScriptsEmbeddedInAssembly(assembly, s => !s.ToLower().Contains("uninstall.sql")); // scripts must be included as Embedded Resources
|
.WithScriptsEmbeddedInAssembly(assembly, s => !s.ToLower().Contains("uninstall.sql")); // scripts must be included as Embedded Resources
|
||||||
|
@ -387,14 +388,14 @@ namespace Oqtane.Infrastructure
|
||||||
}
|
}
|
||||||
|
|
||||||
// add folder for user
|
// add folder for user
|
||||||
var folder = folderRepository.GetFolder(user.SiteId, "Users\\");
|
var folder = folderRepository.GetFolder(user.SiteId, Utilities.PathCombine("Users","\\"));
|
||||||
if (folder != null)
|
if (folder != null)
|
||||||
folderRepository.AddFolder(new Folder
|
folderRepository.AddFolder(new Folder
|
||||||
{
|
{
|
||||||
SiteId = folder.SiteId,
|
SiteId = folder.SiteId,
|
||||||
ParentId = folder.FolderId,
|
ParentId = folder.FolderId,
|
||||||
Name = "My Folder",
|
Name = "My Folder",
|
||||||
Path = folder.Path + newUser.UserId + "\\",
|
Path = Utilities.PathCombine(folder.Path, newUser.UserId.ToString(),"\\"),
|
||||||
Order = 1,
|
Order = 1,
|
||||||
IsSystem = true,
|
IsSystem = true,
|
||||||
Permissions = new List<Permission>
|
Permissions = new List<Permission>
|
||||||
|
|
|
@ -103,7 +103,8 @@ namespace Oqtane.Infrastructure
|
||||||
case ".svg":
|
case ".svg":
|
||||||
case ".js":
|
case ".js":
|
||||||
case ".css":
|
case ".css":
|
||||||
filename = sourceFolder + "\\" + entry.FullName.Replace("wwwroot", name).Replace("/", "\\");
|
string entryPath = Utilities.PathCombine(entry.FullName.Replace("wwwroot", name).Split('/'));
|
||||||
|
filename = Path.Combine(sourceFolder, entryPath);
|
||||||
if (!Directory.Exists(Path.GetDirectoryName(filename)))
|
if (!Directory.Exists(Path.GetDirectoryName(filename)))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(filename));
|
Directory.CreateDirectory(Path.GetDirectoryName(filename));
|
||||||
|
|
|
@ -3,21 +3,22 @@ using Oqtane.Infrastructure;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Oqtane.Repository;
|
using Oqtane.Repository;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Oqtane.Extensions;
|
||||||
using Oqtane.Shared;
|
using Oqtane.Shared;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace Oqtane.SiteTemplates
|
namespace Oqtane.SiteTemplates
|
||||||
{
|
{
|
||||||
public class DefaultSiteTemplate : ISiteTemplate
|
public class DefaultSiteTemplate : ISiteTemplate
|
||||||
{
|
{
|
||||||
private readonly IPermissionRepository _permissionRepository;
|
|
||||||
private readonly IWebHostEnvironment _environment;
|
private readonly IWebHostEnvironment _environment;
|
||||||
private readonly ISiteRepository _siteRepository;
|
private readonly ISiteRepository _siteRepository;
|
||||||
private readonly IFolderRepository _folderRepository;
|
private readonly IFolderRepository _folderRepository;
|
||||||
private readonly IFileRepository _fileRepository;
|
private readonly IFileRepository _fileRepository;
|
||||||
|
|
||||||
public DefaultSiteTemplate(IPermissionRepository permissionRepository, IWebHostEnvironment environment, ISiteRepository siteRepository, IFolderRepository folderRepository, IFileRepository fileRepository)
|
public DefaultSiteTemplate(IWebHostEnvironment environment, ISiteRepository siteRepository, IFolderRepository folderRepository, IFileRepository fileRepository)
|
||||||
{
|
{
|
||||||
_permissionRepository = permissionRepository;
|
|
||||||
_environment = environment;
|
_environment = environment;
|
||||||
_siteRepository = siteRepository;
|
_siteRepository = siteRepository;
|
||||||
_folderRepository = folderRepository;
|
_folderRepository = folderRepository;
|
||||||
|
@ -42,40 +43,40 @@ namespace Oqtane.SiteTemplates
|
||||||
IsNavigation = true,
|
IsNavigation = true,
|
||||||
IsPersonalizable = false,
|
IsPersonalizable = false,
|
||||||
EditMode = false,
|
EditMode = false,
|
||||||
PagePermissions = _permissionRepository.EncodePermissions( new List<Permission> {
|
PagePermissions = new List<Permission> {
|
||||||
new Permission(PermissionNames.View, Constants.AllUsersRole, true),
|
new Permission(PermissionNames.View, Constants.AllUsersRole, true),
|
||||||
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
||||||
}) ,
|
}.EncodePermissions() ,
|
||||||
PageTemplateModules = new List<PageTemplateModule> {
|
PageTemplateModules = new List<PageTemplateModule> {
|
||||||
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.HtmlText, Oqtane.Client", Title = "Welcome To Oqtane...", Pane = "Content",
|
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.HtmlText, Oqtane.Client", Title = "Welcome To Oqtane...", Pane = "Content",
|
||||||
ModulePermissions = _permissionRepository.EncodePermissions( new List<Permission> {
|
ModulePermissions = new List<Permission> {
|
||||||
new Permission(PermissionNames.View, Constants.AllUsersRole, true),
|
new Permission(PermissionNames.View, Constants.AllUsersRole, true),
|
||||||
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
||||||
}),
|
}.EncodePermissions(),
|
||||||
Content = "<p><a href=\"https://www.oqtane.org\" target=\"_new\">Oqtane</a> is an open source <b>modular application framework</b> built from the ground up using modern .NET Core technology. It leverages the revolutionary new Blazor component model to create a <b>fully dynamic</b> web development experience which can be executed on a client or server. Whether you are looking for a platform to <b>accelerate your web development</b> efforts, or simply interested in exploring the anatomy of a large-scale Blazor application, Oqtane provides a solid foundation based on proven enterprise architectural principles.</p>" +
|
Content = "<p><a href=\"https://www.oqtane.org\" target=\"_new\">Oqtane</a> is an open source <b>modular application framework</b> built from the ground up using modern .NET Core technology. It leverages the revolutionary new Blazor component model to create a <b>fully dynamic</b> web development experience which can be executed on a client or server. Whether you are looking for a platform to <b>accelerate your web development</b> efforts, or simply interested in exploring the anatomy of a large-scale Blazor application, Oqtane provides a solid foundation based on proven enterprise architectural principles.</p>" +
|
||||||
"<p align=\"center\"><a href=\"https://www.oqtane.org\" target=\"_new\"><img class=\"img-fluid\" src=\"oqtane.png\"></a></p><p align=\"center\"><a class=\"btn btn-primary\" href=\"https://www.oqtane.org/Community\" target=\"_new\">Join Our Community</a> <a class=\"btn btn-primary\" href=\"https://github.com/oqtane/oqtane.framework\" target=\"_new\">Clone Our Repo</a></p>" +
|
"<p align=\"center\"><a href=\"https://www.oqtane.org\" target=\"_new\"><img class=\"img-fluid\" src=\"oqtane.png\"></a></p><p align=\"center\"><a class=\"btn btn-primary\" href=\"https://www.oqtane.org/Community\" target=\"_new\">Join Our Community</a> <a class=\"btn btn-primary\" href=\"https://github.com/oqtane/oqtane.framework\" target=\"_new\">Clone Our Repo</a></p>" +
|
||||||
"<p><a href=\"https://dotnet.microsoft.com/apps/aspnet/web-apps/blazor\" target=\"_new\">Blazor</a> is a single-page app framework that lets you build interactive web applications using C# instead of JavaScript. Client-side Blazor relies on WebAssembly, an open web standard that does not require plugins or code transpilation in order to run natively in a web browser. Server-side Blazor uses SignalR to host your application on a web server and provide a responsive and robust debugging experience. Blazor applications works in all modern web browsers, including mobile browsers.</p>" +
|
"<p><a href=\"https://dotnet.microsoft.com/apps/aspnet/web-apps/blazor\" target=\"_new\">Blazor</a> is a single-page app framework that lets you build interactive web applications using C# instead of JavaScript. Client-side Blazor relies on WebAssembly, an open web standard that does not require plugins or code transpilation in order to run natively in a web browser. Server-side Blazor uses SignalR to host your application on a web server and provide a responsive and robust debugging experience. Blazor applications works in all modern web browsers, including mobile browsers.</p>" +
|
||||||
"<p>Blazor is a feature of <a href=\"https://dotnet.microsoft.com/apps/aspnet\" target=\"_new\">ASP.NET Core 3</a>, the popular cross platform web development framework from Microsoft that extends the <a href=\"https://dotnet.microsoft.com/learn/dotnet/what-is-dotnet\" target=\"_new\" >.NET developer platform</a> with tools and libraries for building web apps.</p>"
|
"<p>Blazor is a feature of <a href=\"https://dotnet.microsoft.com/apps/aspnet\" target=\"_new\">ASP.NET Core 3</a>, the popular cross platform web development framework from Microsoft that extends the <a href=\"https://dotnet.microsoft.com/learn/dotnet/what-is-dotnet\" target=\"_new\" >.NET developer platform</a> with tools and libraries for building web apps.</p>"
|
||||||
},
|
},
|
||||||
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.HtmlText, Oqtane.Client", Title = "MIT License", Pane = "Content",
|
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.HtmlText, Oqtane.Client", Title = "MIT License", Pane = "Content",
|
||||||
ModulePermissions = _permissionRepository.EncodePermissions( new List<Permission> {
|
ModulePermissions = new List<Permission> {
|
||||||
new Permission(PermissionNames.View, Constants.AllUsersRole, true),
|
new Permission(PermissionNames.View, Constants.AllUsersRole, true),
|
||||||
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
||||||
}),
|
}.EncodePermissions(),
|
||||||
Content = "<p>Copyright (c) 2019-2020 .NET Foundation</p>" +
|
Content = "<p>Copyright (c) 2019-2020 .NET Foundation</p>" +
|
||||||
"<p>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:</p>" +
|
"<p>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:</p>" +
|
||||||
"<p>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</p>" +
|
"<p>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</p>" +
|
||||||
"<p>THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p>"
|
"<p>THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p>"
|
||||||
},
|
},
|
||||||
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.HtmlText, Oqtane.Client", Title = "Secure Content", Pane = "Content",
|
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.HtmlText, Oqtane.Client", Title = "Secure Content", Pane = "Content",
|
||||||
ModulePermissions = _permissionRepository.EncodePermissions( new List<Permission> {
|
ModulePermissions = new List<Permission> {
|
||||||
new Permission(PermissionNames.View, Constants.RegisteredRole, true),
|
new Permission(PermissionNames.View, Constants.RegisteredRole, true),
|
||||||
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
||||||
}),
|
}.EncodePermissions(),
|
||||||
Content = "<p>Oqtane allows you to control access to your content using security roles. This module is only visible to Registered Users of the site.</p>"
|
Content = "<p>Oqtane allows you to control access to your content using security roles. This module is only visible to Registered Users of the site.</p>"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,18 +90,18 @@ namespace Oqtane.SiteTemplates
|
||||||
IsNavigation = true,
|
IsNavigation = true,
|
||||||
IsPersonalizable = false,
|
IsPersonalizable = false,
|
||||||
EditMode = false,
|
EditMode = false,
|
||||||
PagePermissions = _permissionRepository.EncodePermissions(new List<Permission> {
|
PagePermissions = new List<Permission> {
|
||||||
new Permission(PermissionNames.View, Constants.RegisteredRole, true),
|
new Permission(PermissionNames.View, Constants.RegisteredRole, true),
|
||||||
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
||||||
}),
|
}.EncodePermissions(),
|
||||||
PageTemplateModules = new List<PageTemplateModule> {
|
PageTemplateModules = new List<PageTemplateModule> {
|
||||||
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.HtmlText, Oqtane.Client", Title = "Secure Content", Pane = "Content",
|
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.HtmlText, Oqtane.Client", Title = "Secure Content", Pane = "Content",
|
||||||
ModulePermissions = _permissionRepository.EncodePermissions( new List<Permission> {
|
ModulePermissions = new List<Permission> {
|
||||||
new Permission(PermissionNames.View, Constants.RegisteredRole, true),
|
new Permission(PermissionNames.View, Constants.RegisteredRole, true),
|
||||||
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
||||||
}),
|
}.EncodePermissions(),
|
||||||
Content = "<p>Oqtane allows you to control access to your content using security roles. This page is only visible to Registered Users of the site.</p>"
|
Content = "<p>Oqtane allows you to control access to your content using security roles. This page is only visible to Registered Users of the site.</p>"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,33 +115,33 @@ namespace Oqtane.SiteTemplates
|
||||||
IsNavigation = true,
|
IsNavigation = true,
|
||||||
IsPersonalizable = true,
|
IsPersonalizable = true,
|
||||||
EditMode = false,
|
EditMode = false,
|
||||||
PagePermissions = _permissionRepository.EncodePermissions(new List<Permission> {
|
PagePermissions = new List<Permission> {
|
||||||
new Permission(PermissionNames.View, Constants.AllUsersRole, true),
|
new Permission(PermissionNames.View, Constants.AllUsersRole, true),
|
||||||
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
||||||
}),
|
}.EncodePermissions(),
|
||||||
PageTemplateModules = new List<PageTemplateModule> {
|
PageTemplateModules = new List<PageTemplateModule> {
|
||||||
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.HtmlText, Oqtane.Client", Title = "My Page", Pane = "Content",
|
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.HtmlText, Oqtane.Client", Title = "My Page", Pane = "Content",
|
||||||
ModulePermissions = _permissionRepository.EncodePermissions( new List<Permission> {
|
ModulePermissions = new List<Permission> {
|
||||||
new Permission(PermissionNames.View, Constants.AllUsersRole, true),
|
new Permission(PermissionNames.View, Constants.AllUsersRole, true),
|
||||||
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
||||||
}),
|
}.EncodePermissions(),
|
||||||
Content = "<p>Oqtane offers native support for user personalized pages. If a page is identified as personalizable by the site administrator in the page settings, when an authenticated user visits the page they will see an edit button at the top right corner of the page next to their username. When they click this button the sytem will create a new version of the page and allow them to edit the page content.</p>"
|
Content = "<p>Oqtane offers native support for user personalized pages. If a page is identified as personalizable by the site administrator in the page settings, when an authenticated user visits the page they will see an edit button at the top right corner of the page next to their username. When they click this button the sytem will create a new version of the page and allow them to edit the page content.</p>"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (System.IO.File.Exists(_environment.WebRootPath + "\\images\\logo.png"))
|
if (System.IO.File.Exists(Path.Combine(_environment.WebRootPath, "images", "logo.png")))
|
||||||
{
|
{
|
||||||
string folderpath = _environment.ContentRootPath + "\\Content\\Tenants\\" + site.TenantId.ToString() + "\\Sites\\" + site.SiteId.ToString() + "\\";
|
string folderpath = Utilities.PathCombine(_environment.ContentRootPath, "Content", "Tenants", site.TenantId.ToString(), "Sites", site.SiteId.ToString(),"\\");
|
||||||
System.IO.Directory.CreateDirectory(folderpath);
|
System.IO.Directory.CreateDirectory(folderpath);
|
||||||
if (!System.IO.File.Exists(folderpath + "logo.png"))
|
if (!System.IO.File.Exists(Path.Combine(folderpath, "logo.png")))
|
||||||
{
|
{
|
||||||
System.IO.File.Copy(_environment.WebRootPath + "\\images\\logo.png", folderpath + "logo.png");
|
System.IO.File.Copy(Path.Combine(_environment.WebRootPath, "images", "logo.png"), Path.Combine(folderpath, "logo.png"));
|
||||||
}
|
}
|
||||||
Folder folder = _folderRepository.GetFolder(site.SiteId, "");
|
Folder folder = _folderRepository.GetFolder(site.SiteId, "");
|
||||||
File file = _fileRepository.AddFile(new File { FolderId = folder.FolderId, Name = "logo.png", Extension = "png", Size = 8192, ImageHeight = 80, ImageWidth = 250 });
|
Oqtane.Models.File file = _fileRepository.AddFile(new Oqtane.Models.File { FolderId = folder.FolderId, Name = "logo.png", Extension = "png", Size = 8192, ImageHeight = 80, ImageWidth = 250 });
|
||||||
site.LogoFileId = file.FileId;
|
site.LogoFileId = file.FileId;
|
||||||
_siteRepository.UpdateSite(site);
|
_siteRepository.UpdateSite(site);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using Oqtane.Models;
|
using Oqtane.Models;
|
||||||
using Oqtane.Infrastructure;
|
using Oqtane.Infrastructure;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Oqtane.Extensions;
|
||||||
using Oqtane.Repository;
|
using Oqtane.Repository;
|
||||||
using Oqtane.Shared;
|
using Oqtane.Shared;
|
||||||
|
|
||||||
|
@ -8,11 +9,8 @@ namespace Oqtane.SiteTemplates
|
||||||
{
|
{
|
||||||
public class EmptySiteTemplate : ISiteTemplate
|
public class EmptySiteTemplate : ISiteTemplate
|
||||||
{
|
{
|
||||||
private readonly IPermissionRepository _permissionRepository;
|
public EmptySiteTemplate()
|
||||||
|
|
||||||
public EmptySiteTemplate(IPermissionRepository permissionRepository)
|
|
||||||
{
|
{
|
||||||
_permissionRepository = permissionRepository;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Name
|
public string Name
|
||||||
|
@ -33,11 +31,11 @@ namespace Oqtane.SiteTemplates
|
||||||
IsNavigation = true,
|
IsNavigation = true,
|
||||||
IsPersonalizable = false,
|
IsPersonalizable = false,
|
||||||
EditMode = false,
|
EditMode = false,
|
||||||
PagePermissions = _permissionRepository.EncodePermissions( new List<Permission> {
|
PagePermissions = new List<Permission> {
|
||||||
new Permission(PermissionNames.View, Constants.AllUsersRole, true),
|
new Permission(PermissionNames.View, Constants.AllUsersRole, true),
|
||||||
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
||||||
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
||||||
}),
|
}.EncodePermissions(),
|
||||||
PageTemplateModules = new List<PageTemplateModule>()
|
PageTemplateModules = new List<PageTemplateModule>()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="dbup" Version="4.3.0" />
|
<PackageReference Include="dbup" Version="4.3.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="3.2.0-preview4.20210.8" />
|
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="3.2.0-preview5.20216.8" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.2" />
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.2" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.2" />
|
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.2" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.2" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.2" />
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Oqtane.Extensions;
|
||||||
using Oqtane.Models;
|
using Oqtane.Models;
|
||||||
using Oqtane.Shared;
|
using Oqtane.Shared;
|
||||||
|
|
||||||
|
@ -23,7 +24,7 @@ namespace Oqtane.Repository
|
||||||
IEnumerable<File> files = _db.File.Where(item => item.FolderId == folderId).Include(item => item.Folder);
|
IEnumerable<File> files = _db.File.Where(item => item.FolderId == folderId).Include(item => item.Folder);
|
||||||
foreach (File file in files)
|
foreach (File file in files)
|
||||||
{
|
{
|
||||||
file.Folder.Permissions = _permissions.EncodePermissions(permissions);
|
file.Folder.Permissions = permissions.EncodePermissions();
|
||||||
}
|
}
|
||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
|
@ -48,7 +49,7 @@ namespace Oqtane.Repository
|
||||||
if (file != null)
|
if (file != null)
|
||||||
{
|
{
|
||||||
IEnumerable<Permission> permissions = _permissions.GetPermissions(EntityNames.Folder, file.FolderId).ToList();
|
IEnumerable<Permission> permissions = _permissions.GetPermissions(EntityNames.Folder, file.FolderId).ToList();
|
||||||
file.Folder.Permissions = _permissions.EncodePermissions(permissions);
|
file.Folder.Permissions = permissions.EncodePermissions();
|
||||||
}
|
}
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Oqtane.Extensions;
|
||||||
using Oqtane.Models;
|
using Oqtane.Models;
|
||||||
using Oqtane.Shared;
|
using Oqtane.Shared;
|
||||||
|
|
||||||
|
@ -23,7 +24,7 @@ namespace Oqtane.Repository
|
||||||
IEnumerable<Folder> folders = _db.Folder.Where(item => item.SiteId == siteId);
|
IEnumerable<Folder> folders = _db.Folder.Where(item => item.SiteId == siteId);
|
||||||
foreach(Folder folder in folders)
|
foreach(Folder folder in folders)
|
||||||
{
|
{
|
||||||
folder.Permissions = _permissions.EncodePermissions(permissions.Where(item => item.EntityId == folder.FolderId));
|
folder.Permissions = permissions.Where(item => item.EntityId == folder.FolderId).EncodePermissions();
|
||||||
}
|
}
|
||||||
return folders;
|
return folders;
|
||||||
}
|
}
|
||||||
|
@ -49,8 +50,7 @@ namespace Oqtane.Repository
|
||||||
Folder folder = _db.Folder.Find(folderId);
|
Folder folder = _db.Folder.Find(folderId);
|
||||||
if (folder != null)
|
if (folder != null)
|
||||||
{
|
{
|
||||||
IEnumerable<Permission> permissions = _permissions.GetPermissions(EntityNames.Folder, folder.FolderId).ToList();
|
folder.Permissions = _permissions.GetPermissionString(EntityNames.Folder, folder.FolderId);
|
||||||
folder.Permissions = _permissions.EncodePermissions(permissions);
|
|
||||||
}
|
}
|
||||||
return folder;
|
return folder;
|
||||||
}
|
}
|
||||||
|
@ -60,8 +60,7 @@ namespace Oqtane.Repository
|
||||||
Folder folder = _db.Folder.Where(item => item.SiteId == siteId && item.Path == path).FirstOrDefault();
|
Folder folder = _db.Folder.Where(item => item.SiteId == siteId && item.Path == path).FirstOrDefault();
|
||||||
if (folder != null)
|
if (folder != null)
|
||||||
{
|
{
|
||||||
IEnumerable<Permission> permissions = _permissions.GetPermissions(EntityNames.Folder, folder.FolderId).ToList();
|
folder.Permissions = _permissions.GetPermissionString(EntityNames.Folder, folder.FolderId);
|
||||||
folder.Permissions = _permissions.EncodePermissions(permissions);
|
|
||||||
}
|
}
|
||||||
return folder;
|
return folder;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Oqtane.Models;
|
using Oqtane.Models;
|
||||||
|
|
||||||
|
// ReSharper disable once CheckNamespace
|
||||||
namespace Oqtane.Repository
|
namespace Oqtane.Repository
|
||||||
{
|
{
|
||||||
public interface IPermissionRepository
|
public interface IPermissionRepository
|
||||||
|
@ -8,13 +9,17 @@ namespace Oqtane.Repository
|
||||||
IEnumerable<Permission> GetPermissions(int siteId, string entityName);
|
IEnumerable<Permission> GetPermissions(int siteId, string entityName);
|
||||||
IEnumerable<Permission> GetPermissions(string entityName, int entityId);
|
IEnumerable<Permission> GetPermissions(string entityName, int entityId);
|
||||||
IEnumerable<Permission> GetPermissions(string entityName, int entityId, string permissionName);
|
IEnumerable<Permission> GetPermissions(string entityName, int entityId, string permissionName);
|
||||||
|
|
||||||
|
string GetPermissionString(int siteId, string entityName);
|
||||||
|
string GetPermissionString(string entityName, int entityId);
|
||||||
|
string GetPermissionString(string entityName, int entityId, string permissionName);
|
||||||
|
|
||||||
Permission AddPermission(Permission permission);
|
Permission AddPermission(Permission permission);
|
||||||
Permission UpdatePermission(Permission permission);
|
Permission UpdatePermission(Permission permission);
|
||||||
void UpdatePermissions(int siteId, string entityName, int entityId, string permissionStrings);
|
void UpdatePermissions(int siteId, string entityName, int entityId, string permissionStrings);
|
||||||
Permission GetPermission(int permissionId);
|
Permission GetPermission(int permissionId);
|
||||||
void DeletePermission(int permissionId);
|
void DeletePermission(int permissionId);
|
||||||
void DeletePermissions(int siteId, string entityName, int entityId);
|
void DeletePermissions(int siteId, string entityName, int entityId);
|
||||||
string EncodePermissions(IEnumerable<Permission> permissionList);
|
|
||||||
IEnumerable<Permission> DecodePermissions(string permissions, int siteId, string entityName, int entityId);
|
IEnumerable<Permission> DecodePermissions(string permissions, int siteId, string entityName, int entityId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,7 +115,7 @@ namespace Oqtane.Repository
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
moduledefinition.Permissions = _permissions.EncodePermissions(permissions.Where(item => item.EntityId == moduledef.ModuleDefinitionId));
|
moduledefinition.Permissions = permissions.Where(item => item.EntityId == moduledef.ModuleDefinitionId).EncodePermissions();
|
||||||
}
|
}
|
||||||
// remove module definition from list as it is already synced
|
// remove module definition from list as it is already synced
|
||||||
moduledefs.Remove(moduledef);
|
moduledefs.Remove(moduledef);
|
||||||
|
@ -160,7 +160,7 @@ namespace Oqtane.Repository
|
||||||
{
|
{
|
||||||
if (modulecontroltype.Name != "ModuleBase" && !modulecontroltype.Namespace.EndsWith(".Controls"))
|
if (modulecontroltype.Name != "ModuleBase" && !modulecontroltype.Namespace.EndsWith(".Controls"))
|
||||||
{
|
{
|
||||||
string[] typename = modulecontroltype.AssemblyQualifiedName.Split(',').Select(item => item.Trim()).ToList().ToArray();
|
string[] typename = modulecontroltype.AssemblyQualifiedName?.Split(',').Select(item => item.Trim()).ToArray();
|
||||||
string[] segments = typename[0].Split('.');
|
string[] segments = typename[0].Split('.');
|
||||||
Array.Resize(ref segments, segments.Length - 1);
|
Array.Resize(ref segments, segments.Length - 1);
|
||||||
string moduleType = string.Join(".", segments);
|
string moduleType = string.Join(".", segments);
|
||||||
|
@ -195,7 +195,7 @@ namespace Oqtane.Repository
|
||||||
moduledefinition.ModuleDefinitionName = qualifiedModuleType;
|
moduledefinition.ModuleDefinitionName = qualifiedModuleType;
|
||||||
moduledefinition.Version = ""; // will be populated from database
|
moduledefinition.Version = ""; // will be populated from database
|
||||||
moduledefinition.ControlTypeTemplate = moduleType + "." + Constants.ActionToken + ", " + typename[1];
|
moduledefinition.ControlTypeTemplate = moduleType + "." + Constants.ActionToken + ", " + typename[1];
|
||||||
moduledefinition.AssemblyName = assembly.FullName.Split(",")[0];
|
moduledefinition.AssemblyName = assembly.GetName().Name;
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(moduledefinition.Categories))
|
if (string.IsNullOrEmpty(moduledefinition.Categories))
|
||||||
{
|
{
|
||||||
|
@ -222,8 +222,8 @@ namespace Oqtane.Repository
|
||||||
moduledefinition = moduledefinitions[index];
|
moduledefinition = moduledefinitions[index];
|
||||||
// actions
|
// actions
|
||||||
var modulecontrolobject = Activator.CreateInstance(modulecontroltype);
|
var modulecontrolobject = Activator.CreateInstance(modulecontroltype);
|
||||||
string actions = (string)modulecontroltype.GetProperty("Actions").GetValue(modulecontrolobject);
|
string actions = (string)modulecontroltype.GetProperty("Actions")?.GetValue(modulecontrolobject);
|
||||||
if (actions != "")
|
if (!string.IsNullOrEmpty(actions))
|
||||||
{
|
{
|
||||||
foreach (string action in actions.Split(','))
|
foreach (string action in actions.Split(','))
|
||||||
{
|
{
|
||||||
|
|
|
@ -51,9 +51,9 @@ namespace Oqtane.Repository
|
||||||
Module module = _db.Module.Find(moduleId);
|
Module module = _db.Module.Find(moduleId);
|
||||||
if (module != null)
|
if (module != null)
|
||||||
{
|
{
|
||||||
List<Permission> permissions = _permissions.GetPermissions("Module", module.ModuleId).ToList();
|
module.Permissions = _permissions.GetPermissionString("Module", module.ModuleId);
|
||||||
module.Permissions = _permissions.EncodePermissions(permissions);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return module;
|
return module;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ namespace Oqtane.Repository
|
||||||
if (module != null)
|
if (module != null)
|
||||||
{
|
{
|
||||||
List<ModuleDefinition> moduledefinitions = _moduleDefinitions.GetModuleDefinitions(module.SiteId).ToList();
|
List<ModuleDefinition> moduledefinitions = _moduleDefinitions.GetModuleDefinitions(module.SiteId).ToList();
|
||||||
ModuleDefinition moduledefinition = moduledefinitions.Where(item => item.ModuleDefinitionName == module.ModuleDefinitionName).FirstOrDefault();
|
ModuleDefinition moduledefinition = moduledefinitions.FirstOrDefault(item => item.ModuleDefinitionName == module.ModuleDefinitionName);
|
||||||
if (moduledefinition != null)
|
if (moduledefinition != null)
|
||||||
{
|
{
|
||||||
ModuleContent modulecontent = new ModuleContent();
|
ModuleContent modulecontent = new ModuleContent();
|
||||||
|
@ -88,9 +88,10 @@ namespace Oqtane.Repository
|
||||||
if (moduletype != null && moduletype.GetInterface("IPortable") != null)
|
if (moduletype != null && moduletype.GetInterface("IPortable") != null)
|
||||||
{
|
{
|
||||||
var moduleobject = ActivatorUtilities.CreateInstance(_serviceProvider, moduletype);
|
var moduleobject = ActivatorUtilities.CreateInstance(_serviceProvider, moduletype);
|
||||||
modulecontent.Content = ((IPortable)moduleobject).ExportModule(module);
|
modulecontent.Content = ((IPortable) moduleobject).ExportModule(module);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
content = JsonSerializer.Serialize(modulecontent);
|
content = JsonSerializer.Serialize(modulecontent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,6 +100,7 @@ namespace Oqtane.Repository
|
||||||
{
|
{
|
||||||
// error occurred during export
|
// error occurred during export
|
||||||
}
|
}
|
||||||
|
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,7 +125,7 @@ namespace Oqtane.Repository
|
||||||
if (moduletype != null && moduletype.GetInterface("IPortable") != null)
|
if (moduletype != null && moduletype.GetInterface("IPortable") != null)
|
||||||
{
|
{
|
||||||
var moduleobject = ActivatorUtilities.CreateInstance(_serviceProvider, moduletype);
|
var moduleobject = ActivatorUtilities.CreateInstance(_serviceProvider, moduletype);
|
||||||
((IPortable)moduleobject).ImportModule(module, modulecontent.Content, modulecontent.Version);
|
((IPortable) moduleobject).ImportModule(module, modulecontent.Content, modulecontent.Version);
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -135,8 +137,8 @@ namespace Oqtane.Repository
|
||||||
{
|
{
|
||||||
// error occurred during import
|
// error occurred during import
|
||||||
}
|
}
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Oqtane.Extensions;
|
||||||
using Oqtane.Models;
|
using Oqtane.Models;
|
||||||
|
|
||||||
namespace Oqtane.Repository
|
namespace Oqtane.Repository
|
||||||
|
@ -21,12 +22,12 @@ namespace Oqtane.Repository
|
||||||
IEnumerable<PageModule> pagemodules = _db.PageModule
|
IEnumerable<PageModule> pagemodules = _db.PageModule
|
||||||
.Include(item => item.Module) // eager load modules
|
.Include(item => item.Module) // eager load modules
|
||||||
.Where(item => item.Module.SiteId == siteId);
|
.Where(item => item.Module.SiteId == siteId);
|
||||||
if (pagemodules != null && pagemodules.Any())
|
if (pagemodules.Any())
|
||||||
{
|
{
|
||||||
IEnumerable<Permission> permissions = _permissions.GetPermissions(pagemodules.FirstOrDefault().Module.SiteId, "Module").ToList();
|
IEnumerable<Permission> permissions = _permissions.GetPermissions(pagemodules.FirstOrDefault().Module.SiteId, "Module").ToList();
|
||||||
foreach (PageModule pagemodule in pagemodules)
|
foreach (PageModule pagemodule in pagemodules)
|
||||||
{
|
{
|
||||||
pagemodule.Module.Permissions = _permissions.EncodePermissions(permissions.Where(item => item.EntityId == pagemodule.ModuleId));
|
pagemodule.Module.Permissions = permissions.Where(item => item.EntityId == pagemodule.ModuleId).EncodePermissions();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return pagemodules;
|
return pagemodules;
|
||||||
|
@ -37,16 +38,16 @@ namespace Oqtane.Repository
|
||||||
IEnumerable<PageModule> pagemodules = _db.PageModule
|
IEnumerable<PageModule> pagemodules = _db.PageModule
|
||||||
.Include(item => item.Module) // eager load modules
|
.Include(item => item.Module) // eager load modules
|
||||||
.Where(item => item.PageId == pageId);
|
.Where(item => item.PageId == pageId);
|
||||||
if (pane != "" && pagemodules != null && pagemodules.Any())
|
if (pane != "" && pagemodules.Any())
|
||||||
{
|
{
|
||||||
pagemodules = pagemodules.Where(item => item.Pane == pane);
|
pagemodules = pagemodules.Where(item => item.Pane == pane);
|
||||||
}
|
}
|
||||||
if (pagemodules != null && pagemodules.Any())
|
if (pagemodules.Any())
|
||||||
{
|
{
|
||||||
IEnumerable<Permission> permissions = _permissions.GetPermissions(pagemodules.FirstOrDefault().Module.SiteId, "Module").ToList();
|
IEnumerable<Permission> permissions = _permissions.GetPermissions(pagemodules.FirstOrDefault().Module.SiteId, "Module").ToList();
|
||||||
foreach (PageModule pagemodule in pagemodules)
|
foreach (PageModule pagemodule in pagemodules)
|
||||||
{
|
{
|
||||||
pagemodule.Module.Permissions = _permissions.EncodePermissions(permissions.Where(item => item.EntityId == pagemodule.ModuleId));
|
pagemodule.Module.Permissions = permissions.Where(item => item.EntityId == pagemodule.ModuleId).EncodePermissions();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return pagemodules;
|
return pagemodules;
|
||||||
|
@ -72,8 +73,7 @@ namespace Oqtane.Repository
|
||||||
.SingleOrDefault(item => item.PageModuleId == pageModuleId);
|
.SingleOrDefault(item => item.PageModuleId == pageModuleId);
|
||||||
if (pagemodule != null)
|
if (pagemodule != null)
|
||||||
{
|
{
|
||||||
IEnumerable<Permission> permissions = _permissions.GetPermissions("Module", pagemodule.ModuleId).ToList();
|
pagemodule.Module.Permissions = _permissions.GetPermissionString("Module", pagemodule.ModuleId);
|
||||||
pagemodule.Module.Permissions = _permissions.EncodePermissions(permissions);
|
|
||||||
}
|
}
|
||||||
return pagemodule;
|
return pagemodule;
|
||||||
}
|
}
|
||||||
|
@ -84,8 +84,7 @@ namespace Oqtane.Repository
|
||||||
.SingleOrDefault(item => item.PageId == pageId && item.ModuleId == moduleId);
|
.SingleOrDefault(item => item.PageId == pageId && item.ModuleId == moduleId);
|
||||||
if (pagemodule != null)
|
if (pagemodule != null)
|
||||||
{
|
{
|
||||||
IEnumerable<Permission> permissions = _permissions.GetPermissions("Module", pagemodule.ModuleId).ToList();
|
pagemodule.Module.Permissions = _permissions.GetPermissionString("Module", pagemodule.ModuleId);
|
||||||
pagemodule.Module.Permissions = _permissions.EncodePermissions(permissions);
|
|
||||||
}
|
}
|
||||||
return pagemodule;
|
return pagemodule;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Oqtane.Extensions;
|
||||||
using Oqtane.Models;
|
using Oqtane.Models;
|
||||||
using Oqtane.Shared;
|
using Oqtane.Shared;
|
||||||
|
|
||||||
|
@ -25,7 +26,7 @@ namespace Oqtane.Repository
|
||||||
IEnumerable<Page> pages = _db.Page.Where(item => item.SiteId == siteId && item.UserId == null);
|
IEnumerable<Page> pages = _db.Page.Where(item => item.SiteId == siteId && item.UserId == null);
|
||||||
foreach(Page page in pages)
|
foreach(Page page in pages)
|
||||||
{
|
{
|
||||||
page.Permissions = _permissions.EncodePermissions(permissions.Where(item => item.EntityId == page.PageId));
|
page.Permissions = permissions.Where(item => item.EntityId == page.PageId).EncodePermissions();
|
||||||
}
|
}
|
||||||
return pages;
|
return pages;
|
||||||
}
|
}
|
||||||
|
@ -51,8 +52,7 @@ namespace Oqtane.Repository
|
||||||
Page page = _db.Page.Find(pageId);
|
Page page = _db.Page.Find(pageId);
|
||||||
if (page != null)
|
if (page != null)
|
||||||
{
|
{
|
||||||
IEnumerable<Permission> permissions = _permissions.GetPermissions(EntityNames.Page, page.PageId).ToList();
|
page.Permissions = _permissions.GetPermissionString(EntityNames.Page, page.PageId);
|
||||||
page.Permissions = _permissions.EncodePermissions(permissions);
|
|
||||||
}
|
}
|
||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
|
@ -62,27 +62,22 @@ namespace Oqtane.Repository
|
||||||
Page page = _db.Page.Find(pageId);
|
Page page = _db.Page.Find(pageId);
|
||||||
if (page != null)
|
if (page != null)
|
||||||
{
|
{
|
||||||
Page personalized = _db.Page.Where(item => item.SiteId == page.SiteId && item.Path == page.Path && item.UserId == userId).FirstOrDefault();
|
Page personalized = _db.Page.FirstOrDefault(item => item.SiteId == page.SiteId && item.Path == page.Path && item.UserId == userId);
|
||||||
if (personalized != null)
|
if (personalized != null)
|
||||||
{
|
{
|
||||||
page = personalized;
|
page = personalized;
|
||||||
}
|
}
|
||||||
if (page != null)
|
page.Permissions = _permissions.GetPermissionString(EntityNames.Page, page.PageId);
|
||||||
{
|
|
||||||
IEnumerable<Permission> permissions = _permissions.GetPermissions(EntityNames.Page, page.PageId).ToList();
|
|
||||||
page.Permissions = _permissions.EncodePermissions(permissions);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Page GetPage(string path, int siteId)
|
public Page GetPage(string path, int siteId)
|
||||||
{
|
{
|
||||||
Page page = _db.Page.Where(item => item.Path == path && item.SiteId == siteId).FirstOrDefault();
|
Page page = _db.Page.FirstOrDefault(item => item.Path == path && item.SiteId == siteId);
|
||||||
if (page != null)
|
if (page != null)
|
||||||
{
|
{
|
||||||
IEnumerable<Permission> permissions = _permissions.GetPermissions(EntityNames.Page, page.PageId).ToList();
|
page.Permissions = _permissions.GetPermissionString(EntityNames.Page, page.PageId);
|
||||||
page.Permissions = _permissions.EncodePermissions(permissions);
|
|
||||||
}
|
}
|
||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Oqtane.Extensions;
|
||||||
using Oqtane.Models;
|
using Oqtane.Models;
|
||||||
|
|
||||||
namespace Oqtane.Repository
|
namespace Oqtane.Repository
|
||||||
|
@ -41,6 +42,22 @@ namespace Oqtane.Repository
|
||||||
.Include(item => item.Role); // eager load roles
|
.Include(item => item.Role); // eager load roles
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string GetPermissionString(int siteId, string entityName)
|
||||||
|
{
|
||||||
|
return GetPermissions(siteId, entityName)?.EncodePermissions();
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetPermissionString(string entityName, int entityId)
|
||||||
|
{
|
||||||
|
return GetPermissions(entityName, entityId)?.EncodePermissions();
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetPermissionString(string entityName, int entityId, string permissionName)
|
||||||
|
{
|
||||||
|
return GetPermissions(entityName, entityId, permissionName)?.EncodePermissions();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public Permission AddPermission(Permission permission)
|
public Permission AddPermission(Permission permission)
|
||||||
{
|
{
|
||||||
_db.Permission.Add(permission);
|
_db.Permission.Add(permission);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
|
@ -691,7 +692,7 @@ namespace Oqtane.Repository
|
||||||
});
|
});
|
||||||
_folderRepository.AddFolder(new Folder
|
_folderRepository.AddFolder(new Folder
|
||||||
{
|
{
|
||||||
SiteId = site.SiteId, ParentId = folder.FolderId, Name = "Users", Path = "Users\\", Order = 1, IsSystem = true,
|
SiteId = site.SiteId, ParentId = folder.FolderId, Name = "Users", Path = Utilities.PathCombine("Users","\\"), Order = 1, IsSystem = true,
|
||||||
Permissions = "[{\"PermissionName\":\"Browse\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]"
|
Permissions = "[{\"PermissionName\":\"Browse\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace Oqtane.Security
|
||||||
|
|
||||||
public bool IsAuthorized(ClaimsPrincipal user, string entityName, int entityId, string permissionName)
|
public bool IsAuthorized(ClaimsPrincipal user, string entityName, int entityId, string permissionName)
|
||||||
{
|
{
|
||||||
return IsAuthorized(user, permissionName, _permissions.EncodePermissions(_permissions.GetPermissions(entityName, entityId, permissionName).ToList()));
|
return IsAuthorized(user, permissionName, _permissions.GetPermissionString(entityName, entityId, permissionName));
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsAuthorized(ClaimsPrincipal user, string permissionName, string permissions)
|
public bool IsAuthorized(ClaimsPrincipal user, string permissionName, string permissions)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
@ -236,5 +237,21 @@ namespace Oqtane.Shared
|
||||||
@"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-0-9a-z]*[0-9a-z]*\.)+[a-z0-9][\-a-z0-9]{0,22}[a-z0-9]))$",
|
@"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-0-9a-z]*[0-9a-z]*\.)+[a-z0-9][\-a-z0-9]{0,22}[a-z0-9]))$",
|
||||||
RegexOptions.IgnoreCase, TimeSpan.FromMilliseconds(250));
|
RegexOptions.IgnoreCase, TimeSpan.FromMilliseconds(250));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string PathCombine(params string[] segments)
|
||||||
|
{
|
||||||
|
var separators = new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar };
|
||||||
|
|
||||||
|
for (int i =1;i < segments.Length; i++){
|
||||||
|
if(Path.IsPathRooted(segments[i])){
|
||||||
|
segments[i] = segments[i].TrimStart(separators);
|
||||||
|
if(String.IsNullOrEmpty(segments[i])){
|
||||||
|
segments[i]=" ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Path.Combine(segments).TrimEnd();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,11 +13,11 @@ namespace Oqtane.Upgrade
|
||||||
string binfolder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
|
string binfolder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
|
||||||
|
|
||||||
// assumes that the application executable must be deployed to the /bin of the Oqtane.Server project
|
// assumes that the application executable must be deployed to the /bin of the Oqtane.Server project
|
||||||
if (binfolder.Contains("Oqtane.Server\\bin"))
|
if (binfolder.Contains(Path.Combine("Oqtane.Server", "bin")))
|
||||||
{
|
{
|
||||||
// ie. binfolder = Oqtane.Server\bin\Debug\netcoreapp3.0\
|
// ie. binfolder = Oqtane.Server\bin\Debug\netcoreapp3.0\
|
||||||
string rootfolder = Directory.GetParent(binfolder).Parent.Parent.FullName;
|
string rootfolder = Directory.GetParent(binfolder).Parent.Parent.FullName;
|
||||||
string deployfolder = Path.Combine(rootfolder, "wwwroot\\Framework");
|
string deployfolder = Path.Combine(rootfolder, Path.Combine("wwwroot","Framework"));
|
||||||
|
|
||||||
if (Directory.Exists(deployfolder))
|
if (Directory.Exists(deployfolder))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user