Author: ludovic
Date: 2008-02-26 16:33:36 +0100 (Tue, 26 Feb 2008)
New Revision: 7961

Modified:
   
xwiki-platform/core/branches/xwiki-core-1.2/xwiki-core/src/main/java/com/xpn/xwiki/user/impl/xwiki/XWikiRightServiceImpl.java
Log:
XWIKI-1649 'delete' right is totally messed up

Modified: 
xwiki-platform/core/branches/xwiki-core-1.2/xwiki-core/src/main/java/com/xpn/xwiki/user/impl/xwiki/XWikiRightServiceImpl.java
===================================================================
--- 
xwiki-platform/core/branches/xwiki-core-1.2/xwiki-core/src/main/java/com/xpn/xwiki/user/impl/xwiki/XWikiRightServiceImpl.java
       2008-02-26 14:37:26 UTC (rev 7960)
+++ 
xwiki-platform/core/branches/xwiki-core-1.2/xwiki-core/src/main/java/com/xpn/xwiki/user/impl/xwiki/XWikiRightServiceImpl.java
       2008-02-26 15:33:36 UTC (rev 7961)
@@ -131,7 +131,6 @@
                     return true;
                 }
             }
-            right = "admin";
         }
 
         // We do not need to authenticate twice
@@ -455,6 +454,18 @@
             if (needsAuth(accessLevel, context))
                 return false;
         }
+        
+        //fast return for delete right: allow the creator to delete the 
document 
+        if (accessLevel.equals("delete") && user) {
+            currentdoc = (currentdoc==null) ? 
context.getWiki().getDocument(resourceKey, context) : currentdoc;            
+            String creator = currentdoc.getCreator();
+            if ((name != null) && (creator != null)) {
+                if (name.equals(creator)) {
+                    logAllow(name, resourceKey, accessLevel, "delete right 
from document ownership");
+                    return true;
+                } 
+            }
+        }        
 
         allow = isSuperAdminOrProgramming(name, resourceKey, accessLevel, 
user, context);
         if ((allow==true)||(accessLevel.equals("programming"))) {
@@ -607,8 +618,9 @@
 // and that all users that were not denied
 // should be allowed.
             if (!allow_found) {
-                if (accessLevel.equals("register")) {
-                    logDeny(name, resourceKey, accessLevel, "global level 
(register right must be explicit)");
+                if (accessLevel.equals("register") || 
accessLevel.equals("delete")) {
+                    logDeny(name, resourceKey, accessLevel, "global level (" 
+                            + accessLevel + " right must be explicit)");
                     return false;
                 } else {
                     logAllow(name, resourceKey, accessLevel, "global level (no 
restricting right)");

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

Reply via email to