Author: thomas.heute(a)jboss.com
Date: 2007-03-14 10:07:51 -0400 (Wed, 14 Mar 2007)
New Revision: 6665
Modified:
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java
Log:
Don't display unauthorized sub-menu links [JBPORTAL-1319]
Modified:
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java 2007-03-14
13:41:46 UTC (rev 6664)
+++
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java 2007-03-14
14:07:51 UTC (rev 6665)
@@ -55,6 +55,7 @@
import org.jboss.portal.theme.page.WindowResult;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
@@ -352,8 +353,10 @@
}
html.append("
onmouseover=\"this.className='hoverOn'\"
onmouseout=\"this.className='hoverOff'\"><a
href='").append(childURL).append("'>").append(name);
+ List childPages = getAuthorizedChildrenPages(navElement);
+
// ie 6 hack
- if (hasChildPages(navElement))
+ if (childPages.size() != 0)
{
html.append("<!--[if IE
7]><!--></a><!--<![endif]-->");
html.append("<!--[if lte IE
6]><table><tr><td><![endif]-->");
@@ -364,10 +367,10 @@
}
// Submenu logic
- if (hasChildPages(navElement))
+ if (childPages.size() != 0)
{
html.append("<ul>");
- for (Iterator j = navElement.getChildren().iterator(); j.hasNext();)
+ for (Iterator j = childPages.iterator(); j.hasNext();)
{
PortalObject child = (PortalObject)j.next();
if (child.getType() == PortalObject.TYPE_PAGE)
@@ -394,18 +397,24 @@
return null;
}
}
-
- private boolean hasChildPages(PortalObject portalObject)
+
+ private List getAuthorizedChildrenPages(PortalObject portalObject)
{
- for (Iterator i = portalObject.getChildren().iterator(); i.hasNext();)
+ List result = new ArrayList();
+ Collection children = portalObject.getChildren(PortalObject.PAGE_MASK);
+
+ for (Iterator i = children.iterator(); i.hasNext();)
{
PortalObject child = (PortalObject)i.next();
- if (child.getType() == PortalObject.TYPE_PAGE)
+ PortalObjectId id = child.getId();
+
+ PortalObjectPermission perm = new PortalObjectPermission(id,
PortalObjectPermission.VIEW_MASK);
+ if (portalAuthorizationManagerFactory.getManager().checkPermission(perm))
{
- return true;
+ result.add(child);
}
}
- return false;
+ return result;
}
protected void sortTabs(List navElements)
Show replies by date