From b2d55334817917c2f8df5bb1e3e865a04b33bcbe Mon Sep 17 00:00:00 2001 From: Berk Arslan Date: Wed, 14 Aug 2019 22:57:11 +0000 Subject: [PATCH] DNN-31366 - Deleted page can still be selected as parent page (#2925) * DNN-31366 - TabController HasChildren returns false if all children are deleted * Simplify HasChildren condition --- .../Library/Entities/Tabs/TabController.cs | 51 +++++++++++++++++-- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/DNN Platform/Library/Entities/Tabs/TabController.cs b/DNN Platform/Library/Entities/Tabs/TabController.cs index 3d013baf22a..20933161bfb 100644 --- a/DNN Platform/Library/Entities/Tabs/TabController.cs +++ b/DNN Platform/Library/Entities/Tabs/TabController.cs @@ -2473,7 +2473,8 @@ public static List GetPortalTabs(int portalId, int excludeTabId, bool i false, false, false, - false); + false, + true); } /// @@ -2497,7 +2498,8 @@ public static List GetPortalTabs(int portalId, int excludeTabId, bool i includeDeleted, includeURL, false, - false); + false, + true); } /// @@ -2525,7 +2527,8 @@ public static List GetPortalTabs(int portalId, int excludeTabId, bool i includeDeleted, includeURL, checkViewPermisison, - checkEditPermission); + checkEditPermission, + true); } /// @@ -2544,6 +2547,45 @@ public static List GetPortalTabs(int portalId, int excludeTabId, bool i public static List GetPortalTabs(List tabs, int excludeTabId, bool includeNoneSpecified, string noneSpecifiedText, bool includeHidden, bool includeDeleted, bool includeURL, bool checkViewPermisison, bool checkEditPermission) + { + return GetPortalTabs( + tabs, + excludeTabId, + includeNoneSpecified, + noneSpecifiedText, + includeHidden, + includeDeleted, + includeURL, + checkViewPermisison, + checkEditPermission, + true); + } + + /// + /// Gets the portal tabs. + /// + /// The tabs. + /// The exclude tab id. + /// if set to true [include none specified]. + /// The none specified text. + /// if set to true [include hidden]. + /// if set to true [include deleted]. + /// if set to true [include URL]. + /// if set to true [check view permisison]. + /// if set to true [check edit permission]. + /// The value of this parameter affects property. + /// + public static List GetPortalTabs( + List tabs, + int excludeTabId, + bool includeNoneSpecified, + string noneSpecifiedText, + bool includeHidden, + bool includeDeleted, + bool includeURL, + bool checkViewPermisison, + bool checkEditPermission, + bool includeDeletedChildren) { var listTabs = new List(); if (includeNoneSpecified) @@ -2580,6 +2622,9 @@ public static List GetPortalTabs(List tabs, int excludeTabId, listTabs.Add(tab); } } + + // HasChildren should be true in case there is at least one not deleted child + tab.HasChildren = tab.HasChildren && (includeDeletedChildren || GetTabsByParent(tab.TabID, tab.PortalID).Any(a => !a.IsDeleted)); } } return listTabs;