fix #4984 - path mapping for personalized pages
This commit is contained in:
parent
74bfb46f73
commit
334054bcd4
|
@ -116,7 +116,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="row mb-1 align-items-center">
|
||||
<Label Class="col-sm-3" For="path" HelpText="Optionally enter a url path for this page (ie. home ). If you do not provide a url path, the page name will be used. If the page is intended to be the root path specify '/'." ResourceKey="UrlPath">Url Path: </Label>
|
||||
<Label Class="col-sm-3" For="path" HelpText="Optionally enter a url path for this page (ie. home ). If you do not provide a url path, the page name will be used. Please note that spaces and punctuation will be replaced by a dash. If the page is intended to be the root path specify '/'." ResourceKey="UrlPath">Url Path: </Label>
|
||||
<div class="col-sm-9">
|
||||
<input id="path" class="form-control" @bind="@_path" maxlength="256" />
|
||||
</div>
|
||||
|
@ -263,6 +263,12 @@
|
|||
<input id="title" class="form-control" @bind="@_title" maxlength="200" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-1 align-items-center">
|
||||
<Label Class="col-sm-3" For="path" HelpText="Provide a url path for your personalized page. Please note that spaces and punctuation will be replaced by a dash." ResourceKey="PersonalizedUrlPath">Url Path: </Label>
|
||||
<div class="col-sm-9">
|
||||
<input id="path" class="form-control" @bind="@_path" maxlength="256" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-1 align-items-center">
|
||||
<Label Class="col-sm-3" For="theme" HelpText="Select the theme for this page" ResourceKey="Theme">Theme: </Label>
|
||||
<div class="col-sm-9">
|
||||
|
|
|
@ -169,7 +169,7 @@
|
|||
<value>Select whether the page is part of the site navigation or hidden</value>
|
||||
</data>
|
||||
<data name="UrlPath.HelpText" xml:space="preserve">
|
||||
<value>Optionally enter a url path for this page (ie. home ). If you do not provide a url path, the page name will be used. If the page is intended to be the root path specify '/'.</value>
|
||||
<value>Optionally enter a url path for this page (ie. home ). If you do not provide a url path, the page name will be used. Please note that spaces and punctuation will be replaced by a dash. If the page is intended to be the root path specify '/'.</value>
|
||||
</data>
|
||||
<data name="Redirect.HelpText" xml:space="preserve">
|
||||
<value>Optionally enter a url which this page should redirect to when a user navigates to it</value>
|
||||
|
@ -297,4 +297,10 @@
|
|||
<data name="ExpiryDate.Text" xml:space="preserve">
|
||||
<value>Expiry Date: </value>
|
||||
</data>
|
||||
</root>
|
||||
<data name="PersonalizedUrlPath.Text" xml:space="preserve">
|
||||
<value>Url Path:</value>
|
||||
</data>
|
||||
<data name="PersonalizedUrlPath.HelpText" xml:space="preserve">
|
||||
<value>Provide a url path for your personalized page. Please note that spaces and punctuation will be replaced by a dash.</value>
|
||||
</data>
|
||||
</root>
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
@if (!string.IsNullOrEmpty(_error))
|
||||
{
|
||||
<ModuleMessage Message="@_error" Type="@MessageType.Warning" />
|
||||
<ModuleMessage Message="@_error" Type="@MessageType.Warning" />
|
||||
}
|
||||
|
||||
@DynamicComponent
|
||||
|
@ -244,7 +244,9 @@
|
|||
// look for personalized page
|
||||
if (user != null && page.IsPersonalizable && !UserSecurity.IsAuthorized(user, PermissionNames.Edit, page.PermissionList))
|
||||
{
|
||||
var personalized = await PageService.GetPageAsync(route.PagePath + "/" + Utilities.GetFriendlyUrl(user.Username), site.SiteId);
|
||||
var settingName = $"PersonalizedPagePath:{page.SiteId}:{page.PageId}";
|
||||
var path = (user.Settings.ContainsKey(settingName)) ? user.Settings[settingName] : Utilities.GetFriendlyUrl(user.Username);
|
||||
var personalized = await PageService.GetPageAsync(route.PagePath + "/" + path, site.SiteId);
|
||||
if (personalized != null)
|
||||
{
|
||||
// redirect to the personalized page
|
||||
|
|
|
@ -9,7 +9,6 @@ using System.Net;
|
|||
using Oqtane.Enums;
|
||||
using Oqtane.Infrastructure;
|
||||
using Oqtane.Repository;
|
||||
using System;
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
{
|
||||
|
@ -189,16 +188,16 @@ namespace Oqtane.Controllers
|
|||
User user = _userPermissions.GetUser(User);
|
||||
if (parent != null && parent.SiteId == _alias.SiteId && parent.IsPersonalizable && user.UserId == int.Parse(userid))
|
||||
{
|
||||
var path = parent.Path + "/" + Utilities.GetFriendlyUrl(user.Username);
|
||||
page = _pages.GetPage(path, parent.SiteId);
|
||||
var path = Utilities.GetFriendlyUrl(user.Username);
|
||||
page = _pages.GetPage(parent.Path + "/" + path, parent.SiteId);
|
||||
if (page == null)
|
||||
{
|
||||
page = new Page();
|
||||
page.SiteId = parent.SiteId;
|
||||
page.ParentId = parent.PageId;
|
||||
page.Name = (!string.IsNullOrEmpty(user.DisplayName)) ? user.DisplayName : user.Username;
|
||||
page.Path = path;
|
||||
page.Title = page.Name + " - " + parent.Name;
|
||||
page.Name = user.Username;
|
||||
page.Path = parent.Path + "/" + path;
|
||||
page.Title = ((!string.IsNullOrEmpty(user.DisplayName)) ? user.DisplayName : user.Username) + " - " + parent.Name;
|
||||
page.Order = 0;
|
||||
page.IsNavigation = false;
|
||||
page.Url = "";
|
||||
|
@ -251,6 +250,11 @@ namespace Oqtane.Controllers
|
|||
|
||||
_syncManager.AddSyncEvent(_alias, EntityNames.Page, page.PageId, SyncEventActions.Create);
|
||||
_syncManager.AddSyncEvent(_alias, EntityNames.Site, page.SiteId, SyncEventActions.Refresh);
|
||||
|
||||
// set user personalized page path
|
||||
var setting = new Setting { EntityName = EntityNames.User, EntityId = page.UserId.Value, SettingName = $"PersonalizedPagePath:{page.SiteId}:{parent.PageId}", SettingValue = path, IsPrivate = false };
|
||||
_settings.AddSetting(setting);
|
||||
_syncManager.AddSyncEvent(_alias, EntityNames.User, user.UserId, SyncEventActions.Update);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -341,6 +345,28 @@ namespace Oqtane.Controllers
|
|||
|
||||
_syncManager.AddSyncEvent(_alias, EntityNames.Page, page.PageId, SyncEventActions.Update);
|
||||
_syncManager.AddSyncEvent(_alias, EntityNames.Site, page.SiteId, SyncEventActions.Refresh);
|
||||
|
||||
// personalized page
|
||||
if (page.UserId != null && currentPage.Path != page.Path)
|
||||
{
|
||||
// set user personalized page path
|
||||
var settingName = $"PersonalizedPagePath:{page.SiteId}:{page.ParentId}";
|
||||
var path = page.Path.Substring(page.Path.LastIndexOf("/") + 1);
|
||||
var settings = _settings.GetSettings(EntityNames.User, page.UserId.Value).ToList();
|
||||
var setting = settings.FirstOrDefault(item => item.SettingName == settingName);
|
||||
if (setting == null)
|
||||
{
|
||||
setting = new Setting { EntityName = EntityNames.User, EntityId = page.UserId.Value, SettingName = settingName, SettingValue = path, IsPrivate = false };
|
||||
_settings.AddSetting(setting);
|
||||
}
|
||||
else
|
||||
{
|
||||
setting.SettingValue = path;
|
||||
_settings.UpdateSetting(setting);
|
||||
}
|
||||
_syncManager.AddSyncEvent(_alias, EntityNames.User, page.UserId.Value, SyncEventActions.Update);
|
||||
}
|
||||
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Page Updated {Page}", page);
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue
Block a user