Author: jkoster
Date: 2009-06-02 13:42:32 +0200 (Tue, 02 Jun 2009)
New Revision: 35564

Modified:
   
CMSContainer/branches/b1_5/CMSContainer/cmsc/contentrepository/src/java/com/finalist/cmsc/repository/RepositoryUtil.java
   
CMSContainer/branches/b1_5/CMSContainer/cmsc/sitemanagement/src/java/com/finalist/cmsc/navigation/NavigationUtil.java
Log:
CMSC-1415 - Site tree collapses pages too often: only collapse when getting 
higher rights.

Modified: 
CMSContainer/branches/b1_5/CMSContainer/cmsc/contentrepository/src/java/com/finalist/cmsc/repository/RepositoryUtil.java
===================================================================
--- 
CMSContainer/branches/b1_5/CMSContainer/cmsc/contentrepository/src/java/com/finalist/cmsc/repository/RepositoryUtil.java
    2009-06-02 11:41:54 UTC (rev 35563)
+++ 
CMSContainer/branches/b1_5/CMSContainer/cmsc/contentrepository/src/java/com/finalist/cmsc/repository/RepositoryUtil.java
    2009-06-02 11:42:32 UTC (rev 35564)
@@ -946,30 +946,40 @@
         if (info == null) {
             info = new RepositoryInfo();
             cloud.setProperty(RepositoryInfo.class.getName(), info);
-            TreeMap<String,UserRole> channelsWithRole = 
SecurityUtil.getLoggedInRoleMap(cloud, treeManagers, CHILDREL);
-
-            for(Map.Entry<String,UserRole> entry : 
channelsWithRole.entrySet()) {
-                UserRole role = entry.getValue();
-                if (!Role.NONE.equals(role.getRole())) {
-                    String path = entry.getKey();
-                    Node channel = getChannelFromPath(cloud, path);
-                    if(channel != null) {
-                        if (isRoot(channel)) {
-                            info.expand(channel.getNumber());
-                        }
-                        else {
-                            List<Node> pathNodes = getPathToRoot(channel);
-                            for (Node pathNode : pathNodes) {
-                                info.expand(pathNode.getNumber());
-                            }
-                        }
-                    }
-                }
-            }
+            addChannelsWithRoleToInfo(cloud, info);
         }
         return info;
     }
 
+   private static void addChannelsWithRoleToInfo(Cloud cloud, RepositoryInfo 
info) {
+      TreeMap<String,UserRole> channelsWithRole = 
SecurityUtil.getLoggedInRoleMap(cloud, treeManagers, CHILDREL);
+
+      for(Map.Entry<String,UserRole> entry : channelsWithRole.entrySet()) {
+          UserRole role = entry.getValue();
+          if (!Role.NONE.equals(role.getRole())) {
+              String path = entry.getKey();
+              Node channel = getChannelFromPath(cloud, path);
+              if(channel != null) {
+                  if (isRoot(channel)) {
+                      info.expand(channel.getNumber());
+                  }
+                  else {
+                      List<Node> pathNodes = getPathToRoot(channel);
+                      for (Node pathNode : pathNodes) {
+                          info.expand(pathNode.getNumber());
+                          
+                          String pathToRoot = getPathToRootString(pathNode);
+                          UserRole pathRole = channelsWithRole.get(pathToRoot);
+                          if (pathRole != null && 
!Role.NONE.equals(pathRole.getRole())) {
+                             break;
+                          }
+                      }
+                  }
+              }
+          }
+      }
+   }
+
     public static RolesInfo getRolesInfo(Cloud cloud, Node group) {
         RolesInfo info = new RolesInfo();
         TreeMap<String,UserRole> channelsWithRole = 
SecurityUtil.getRoleMap(treeManagers, CHILDREL, group);

Modified: 
CMSContainer/branches/b1_5/CMSContainer/cmsc/sitemanagement/src/java/com/finalist/cmsc/navigation/NavigationUtil.java
===================================================================
--- 
CMSContainer/branches/b1_5/CMSContainer/cmsc/sitemanagement/src/java/com/finalist/cmsc/navigation/NavigationUtil.java
       2009-06-02 11:41:54 UTC (rev 35563)
+++ 
CMSContainer/branches/b1_5/CMSContainer/cmsc/sitemanagement/src/java/com/finalist/cmsc/navigation/NavigationUtil.java
       2009-06-02 11:42:32 UTC (rev 35564)
@@ -458,7 +458,12 @@
                     if (!SiteUtil.isSite(page)) {
                         List<Node> pathNodes = getPathToRoot(page);
                         for (Node pathNode : pathNodes) {
-                            info.expand(pathNode.getNumber());
+                           info.expand(pathNode.getNumber());
+                           String pathToRoot = getPathToRootString(pathNode);
+                           UserRole pathRole = pagesWithRole.get(pathToRoot);
+                           if (pathRole != null && 
!Role.NONE.equals(pathRole.getRole())) {
+                              break;
+                           }
                         }
                     }
                 }

_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to