diff --git a/app/src/main/java/org/communiquons/android/comunic/client/data/posts/Post.java b/app/src/main/java/org/communiquons/android/comunic/client/data/posts/Post.java index 4776110..f3dc06e 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/data/posts/Post.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/data/posts/Post.java @@ -108,6 +108,16 @@ public class Post { return user_access_level; } + /** + * Check whether the user can delete the post or not + * + * @return TRUE if the post can be deleted by the user / FALSE else + */ + public boolean canDelete(){ + return getUser_access_level() == PostUserAccess.INTERMEDIATE_ACCESS || + getUser_access_level() == PostUserAccess.FULL_ACCESS; + } + //Set and get file path url void setFile_path_url(String file_path_url) { this.file_path_url = file_path_url; diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/PostsListFragment.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/PostsListFragment.java index c710c3b..7070eab 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/PostsListFragment.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/PostsListFragment.java @@ -278,8 +278,7 @@ public class PostsListFragment extends Fragment mNumCurrPostInContextMenu = pos; //Disable some options if the user is not the post owner - if(post.getUser_access_level() != PostUserAccess.INTERMEDIATE_ACCESS && - post.getUser_access_level() != PostUserAccess.FULL_ACCESS){ + if(!post.canDelete()){ //Disable delete action menu.findItem(R.id.action_delete).setEnabled(false);