Author: agilliland
Date: Wed Apr 12 13:40:22 2006
New Revision: 393600

URL: http://svn.apache.org/viewcvs?rev=393600&view=rev
Log:
changing entry attributes to use cascade="all-delete-orphan".
added new method hasWritePermissions(user) which works in a similar style to 
website.hasPermissions().


Modified:
    
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/WeblogEntryData.java

Modified: 
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/WeblogEntryData.java
URL: 
http://svn.apache.org/viewcvs/incubator/roller/branches/roller-newbackend/src/org/roller/pojos/WeblogEntryData.java?rev=393600&r1=393599&r2=393600&view=diff
==============================================================================
--- 
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/WeblogEntryData.java
 (original)
+++ 
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/WeblogEntryData.java
 Wed Apr 12 13:40:22 2006
@@ -268,7 +268,7 @@
      *
      * @roller.wrapPojoMethod type="pojo-collection" 
class="org.roller.pojos.EntryAttributeData"
      * @ejb:persistent-field
-     * @hibernate.set lazy="true" order-by="name" inverse="true" cascade="all" 
+     * @hibernate.set lazy="true" order-by="name" inverse="true" 
cascade="all-delete-orphan" 
      * @hibernate.collection-key column="entryid" type="String"
      * @hibernate.collection-one-to-many 
class="org.roller.pojos.EntryAttributeData"
      */
@@ -337,7 +337,6 @@
         {
             attMap.remove(att);
             attSet.remove(att);
-            att.remove();
         }
     }
     //-------------------------------------------------------------------------
@@ -1108,6 +1107,29 @@
     /** no-op: needed only to satisfy XDoclet, use setStatus() instead */
     public void setPublished(boolean value)
     {
+    }
+    
+    
+    /**
+     * Determine if the specified user has permissions to edit this entry.
+     */
+    public boolean hasWritePermissions(UserData user) throws RollerException {
+        
+        // global admins can hack whatever they want
+        if(user.hasRole("admin")) {
+            return true;
+        }
+        
+        boolean author = getWebsite().hasUserPermissions(
+                user, (short)(PermissionsData.AUTHOR));
+        boolean limited = getWebsite().hasUserPermissions(
+                user, (short)(PermissionsData.LIMITED));
+        
+        if (author || (limited && isDraft()) || (limited && isPending())) {
+            return true;
+        }
+        
+        return false;
     }
     
 }


Reply via email to