Skip to content

Commit

Permalink
SAK-32386: force 'overview' tool to the top of the tool menu via saka…
Browse files Browse the repository at this point in the history
…i.property (sakaiproject#4163)
  • Loading branch information
bjones86 authored and jonespm committed Apr 6, 2017
1 parent a060b25 commit 752d78e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,11 @@
# DEFAULT: 0
# portal.cdn.expire=0

# Allows forcing the 'Overview' tool to the top of tool list LHS menu system wide.
# See SAK-32386.
# DEFAULT: false
# portal.forceOverviewToTop=true

# ########################################################################
# SECURITY
# ########################################################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ public class PortalSiteHelperImpl implements PortalSiteHelper

protected final static String CURRENT_PLACEMENT = "sakai:ToolComponent:current.placement";

private static final String OVERVIEW_TOOL_TITLE = "overview";
private static final String SAK_PROP_FORCE_OVERVIEW_TO_TOP = "portal.forceOverviewToTop";
private static final boolean SAK_PROP_FORCE_OVERVIEW_TO_TOP_DEFAULT = false;

private Portal portal;

private AliasService aliasService;
Expand Down Expand Up @@ -1176,18 +1180,16 @@ public Site getSiteVisit(String siteId) throws PermissionException, IdUnusedExce
public List getPermittedPagesInOrder(Site site)
{
// Get all of the pages
List pages = site.getOrderedPages();
boolean siteUpdate = SecurityService.unlock("site.upd", site.getReference());
List<SitePage> pages = site.getOrderedPages();
boolean siteUpdate = SecurityService.unlock("site.upd", site.getReference());

List newPages = new ArrayList();
List<SitePage> newPages = new ArrayList<>();

for (Iterator i = pages.iterator(); i.hasNext();)
for (SitePage p : pages)
{
// check if current user has permission to see page
SitePage p = (SitePage) i.next();
List pTools = p.getTools();
Iterator iPt = pTools.iterator();

boolean allowPage = false;
while (iPt.hasNext())
{
Expand All @@ -1206,6 +1208,29 @@ public List getPermittedPagesInOrder(Site site)
{
newPages = pageFilter.filter(newPages, site);
}

// Force "Overview" to the top at all times if enabled
if (ServerConfigurationService.getBoolean(SAK_PROP_FORCE_OVERVIEW_TO_TOP, SAK_PROP_FORCE_OVERVIEW_TO_TOP_DEFAULT))
{
List<SitePage> newPagesCopy = new ArrayList<>(newPages);
for (SitePage page : newPages)
{
if (OVERVIEW_TOOL_TITLE.equalsIgnoreCase(page.getTitle()))
{
int index = newPages.indexOf(page);
if (index >= 0)
{
newPagesCopy = new ArrayList<>(newPages.size());
newPagesCopy.addAll(newPages.subList(0, index));
newPagesCopy.add(0, (SitePage) newPages.get(index));
newPagesCopy.addAll(newPages.subList(index + 1, newPages.size()));
}
}
}

return newPagesCopy;
}

return newPages;
}

Expand Down

0 comments on commit 752d78e

Please sign in to comment.