Skip to content

Commit

Permalink
Fix oqtane#4976: exclude deleted pages.
Browse files Browse the repository at this point in the history
  • Loading branch information
zyhfish committed Jan 13, 2025
1 parent 7f3d6ef commit aa37a50
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Oqtane.Client/Modules/Admin/RecycleBin/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ else

private async Task Load()
{
_pages = await PageService.GetPagesAsync(PageState.Site.SiteId);
_pages = await PageService.GetPagesAsync(PageState.Site.SiteId, true);
_modules = await ModuleService.GetModulesAsync(PageState.Site.SiteId);
}

Expand Down
8 changes: 8 additions & 0 deletions Oqtane.Client/Services/Interfaces/IPageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ public interface IPageService
/// <returns></returns>
Task<List<Page>> GetPagesAsync(int siteId);

/// <summary>
/// Returns a list of pages
/// </summary>
/// <param name="siteId"></param>
/// <param name="includeDeleted"></param>
/// <returns></returns>
Task<List<Page>> GetPagesAsync(int siteId, bool includeDeleted);

/// <summary>
/// Returns a specific page
/// </summary>
Expand Down
7 changes: 6 additions & 1 deletion Oqtane.Client/Services/PageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ public PageService(HttpClient http, SiteState siteState) : base(http, siteState)

public async Task<List<Page>> GetPagesAsync(int siteId)
{
return await GetJsonAsync<List<Page>>($"{Apiurl}?siteid={siteId}");
return await GetPagesAsync(siteId, false);
}

public async Task<List<Page>> GetPagesAsync(int siteId, bool includeDeleted)
{
return await GetJsonAsync<List<Page>>($"{Apiurl}?siteid={siteId}&includeDeleted={includeDeleted}");
}

public async Task<Page> GetPageAsync(int pageId)
Expand Down
5 changes: 3 additions & 2 deletions Oqtane.Server/Controllers/PageController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,19 @@ public PageController(IPageRepository pages, IModuleRepository modules, IPageMod

// GET: api/<controller>?siteid=x
[HttpGet]
public IEnumerable<Page> Get(string siteid)
public IEnumerable<Page> Get(string siteid, string includedeleted)
{
List<Page> pages = new List<Page>();

int SiteId;
if (int.TryParse(siteid, out SiteId) && SiteId == _alias.SiteId)
{
var includeDeleted = bool.Parse(includedeleted);
List<Setting> settings = _settings.GetSettings(EntityNames.Page).ToList();

foreach (Page page in _pages.GetPages(SiteId))
{
if (_userPermissions.IsAuthorized(User, PermissionNames.View, page.PermissionList))
if ((includeDeleted || !page.IsDeleted) && _userPermissions.IsAuthorized(User, PermissionNames.View, page.PermissionList))
{
page.Settings = settings.Where(item => item.EntityId == page.PageId)
.Where(item => !item.IsPrivate || _userPermissions.IsAuthorized(User, PermissionNames.Edit, page.PermissionList))
Expand Down
2 changes: 1 addition & 1 deletion Oqtane.Server/Pages/Sitemap.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public IActionResult OnGet()
var pageModules = _pageModules.GetPageModules(_alias.SiteId);
foreach (var page in _pages.GetPages(_alias.SiteId))
{
if (_userPermissions.IsAuthorized(null, PermissionNames.View, page.PermissionList) && !Constants.InternalPagePaths.Contains(page.Path))
if (!page.IsDeleted && _userPermissions.IsAuthorized(null, PermissionNames.View, page.PermissionList) && !Constants.InternalPagePaths.Contains(page.Path))
{
var pageurl = rooturl;
if (string.IsNullOrEmpty(page.Url))
Expand Down

0 comments on commit aa37a50

Please sign in to comment.