mirror of
https://github.com/pierre42100/ComunicAndroid
synced 2024-11-27 15:59:29 +00:00
Created a function to know if a user can delete a post or not.
This commit is contained in:
parent
54bb812e5c
commit
a4e8ada1c7
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user