Author: ludovic
Date: 2008-01-12 01:10:14 +0100 (Sat, 12 Jan 2008)
New Revision: 6793

Modified:
   
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/impl/SpaceManagerImpl.java
Log:
CURRIKI-1345 Rights in groups implementation

Modified: 
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/impl/SpaceManagerImpl.java
===================================================================
--- 
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/impl/SpaceManagerImpl.java
    2008-01-12 00:03:39 UTC (rev 6792)
+++ 
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/impl/SpaceManagerImpl.java
    2008-01-12 00:10:14 UTC (rev 6793)
@@ -255,8 +255,8 @@
      * @param level Access level
      * @param allow True if the right is allow, deny if not
      */
-    protected boolean giveRightToGroup( String spaceName, String groupName, 
String level, boolean allow, XWikiContext context) throws XWikiException {
-       final String rightsClass = "XWiki.XWikiRights";
+    protected boolean giveRightToGroup( String spaceName, String groupName, 
String level, boolean allow, boolean global, XWikiContext context) throws 
XWikiException {
+       final String rightsClass = global ? "XWiki.XWikiRights" : 
"XWiki.XWikiRights";
        final String prefDocName = spaceName+".WebPreferences";
        final String groupsField = "groups";
        final String levelsField = "levels";
@@ -334,7 +334,14 @@
                }
        }
     }
-    
+
+    protected void setGroupRights(Space newspace, XWikiContext context) throws 
XWikiException {
+        // Set admin edit rights on group prefs
+        giveRightToGroup( newspace.getSpaceName(), getAdminGroupName( 
newspace.getSpaceName() ), "edit", true, false, context );
+        // Set admin admin rights on group prefs
+        giveRightToGroup( newspace.getSpaceName(), getAdminGroupName( 
newspace.getSpaceName() ), "admin", true, true, context );
+    }
+
     /**
      * Creates a new space from scratch
      * @param spaceTitle The name(display title) of the new space
@@ -353,8 +360,7 @@
             // we need to add the creator as a member and as an admin
             addAdmin(newspace.getSpaceName(), context.getUser(), context);
             addMember(newspace.getSpaceName(), context.getUser(), context);
-
-            giveRightToGroup( newspace.getSpaceName(), getAdminGroupName( 
newspace.getSpaceName() ), "edit", true, context );
+            setGroupRights(newspace, context);
         } catch (XWikiException e) {
             throw new SpaceManagerException(e);
         }
@@ -396,8 +402,7 @@
             // we need to add the creator as a member and as an admin
             addAdmin(newspace.getSpaceName(), context.getUser(), context);
             addMember(newspace.getSpaceName(), context.getUser(), context);
-
-            giveRightToGroup( newspace.getSpaceName(), getAdminGroupName( 
newspace.getSpaceName() ), "edit", true, context );
+            setGroupRights(newspace, context);
         } catch (XWikiException e) {
             throw new SpaceManagerException(e);
         }
@@ -456,7 +461,7 @@
             // we need to add the creator as a member and as an admin
             addAdmin(newspace.getSpaceName(), context.getUser(), context);
             addMember(newspace.getSpaceName(), context.getUser(), context);
-            giveRightToGroup( newspace.getSpaceName(), getAdminGroupName( 
newspace.getSpaceName() ), "edit", true, context );
+            setGroupRights(newspace, context);
         } catch (XWikiException e) {
             throw new SpaceManagerException(e);
         }

_______________________________________________
notifications mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/notifications

Reply via email to