mirror of
				https://github.com/pierre42100/ComunicAndroid
				synced 2025-11-04 11:34:06 +00:00 
			
		
		
		
	Created a function to know if a user can delete a post or not.
This commit is contained in:
		@@ -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;
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user