Author: dward
Date: 2008-01-14 22:30:25 +0100 (Mon, 14 Jan 2008)
New Revision: 6825

Modified:
   
xwiki-products/curriki/trunk/gwt/src/main/java/org/curriki/gwt/client/Constants.java
   
xwiki-products/curriki/trunk/gwt/src/main/java/org/curriki/gwt/server/CurrikiServiceImpl.java
Log:
- CURRIKI-1413
 - Collections for Groups do not default to public, but to a setting specific 
to the group

Modified: 
xwiki-products/curriki/trunk/gwt/src/main/java/org/curriki/gwt/client/Constants.java
===================================================================
--- 
xwiki-products/curriki/trunk/gwt/src/main/java/org/curriki/gwt/client/Constants.java
        2008-01-14 18:29:18 UTC (rev 6824)
+++ 
xwiki-products/curriki/trunk/gwt/src/main/java/org/curriki/gwt/client/Constants.java
        2008-01-14 21:30:25 UTC (rev 6825)
@@ -135,6 +135,13 @@
     public static final String RIGHT_PROTECTED = "members";
     public static final String RIGHT_PRIVATE = "private";
 
+    public static final String GROUP_RIGHTS_PAGE = "WebPreferences";
+    public static final String GROUP_RIGHTS_CLASS = "CurrikiSpaceClass";
+    public static final String GROUP_RIGHTS_PROPERTY = "accessprivileges";
+    public static final String GROUP_RIGHT_PUBLIC = "open";
+    public static final String GROUP_RIGHT_PROTECTED = "protected";
+    public static final String GROUP_RIGHT_PRIVATE = "private";
+
     public static final String ASSET_LICENCE_TYPE_DEFAULT = 
"Licences.CurrikiLicense";
     public static final String ASSET_FW_ITEMS_DEFAULT = 
"FW_masterFramework.WebHome";
 

Modified: 
xwiki-products/curriki/trunk/gwt/src/main/java/org/curriki/gwt/server/CurrikiServiceImpl.java
===================================================================
--- 
xwiki-products/curriki/trunk/gwt/src/main/java/org/curriki/gwt/server/CurrikiServiceImpl.java
       2008-01-14 18:29:18 UTC (rev 6824)
+++ 
xwiki-products/curriki/trunk/gwt/src/main/java/org/curriki/gwt/server/CurrikiServiceImpl.java
       2008-01-14 21:30:25 UTC (rev 6825)
@@ -197,7 +197,33 @@
         XWikiDocument doc = context.getWiki().getDocument(fullName, context);
 
         BaseObject obj = doc.getObject(Constants.ASSET_CLASS);
-        obj.set(Constants.ASSET_RIGHTS_PROPERTY, Constants.RIGHT_PUBLIC, 
context);
+
+        // Fix for CURRIKI-1413 - Collections for groups need to inherit 
rights from the group
+        if (doc.getSpace().startsWith("Coll_Group_")){
+            String rights = Constants.RIGHT_PUBLIC;
+
+            // TODO: This should probably be using the SpaceManager extension
+            XWikiDocument spaceDoc = 
context.getWiki().getDocument(doc.getSpace()+"."+Constants.GROUP_RIGHTS_PAGE, 
context);
+            if (spaceDoc != null){
+                // Note that the values for the group access defaults
+                //  DO NOT MATCH the values that need to be applied to the 
collection
+                BaseObject rObj = doc.getObject(Constants.GROUP_RIGHTS_CLASS);
+                if (rObj != null){
+                    String groupDefaultPrivs = 
rObj.getStringValue(Constants.GROUP_RIGHTS_PROPERTY);
+                    if 
(groupDefaultPrivs.equals(Constants.GROUP_RIGHT_PRIVATE)){
+                        rights = Constants.RIGHT_PRIVATE;
+                    } else if 
(groupDefaultPrivs.equals(Constants.GROUP_RIGHT_PROTECTED)){
+                        rights = Constants.RIGHT_PROTECTED;
+                    } else if 
(groupDefaultPrivs.equals(Constants.GROUP_RIGHT_PUBLIC)){
+                        rights = Constants.RIGHT_PUBLIC;
+                    }
+                }
+            }
+
+            obj.set(Constants.ASSET_RIGHTS_PROPERTY, rights, context);
+        } else {
+            obj.set(Constants.ASSET_RIGHTS_PROPERTY, Constants.RIGHT_PUBLIC, 
context);
+        }
         obj.set(Constants.ASSET_CATEGORY_PROPERTY, 
Constants.CATEGORY_COLLECTION, context);
         obj.set(Constants.ASSET_TITLE_PROPERTY, pageTitle, context);
         if (doc.getName().equals(Constants.DEFAULT_COLLECTION_PAGE)){

_______________________________________________
notifications mailing list
notifications@xwiki.org
http://lists.xwiki.org/mailman/listinfo/notifications

Reply via email to