Skip to content

Instantly share code, notes, and snippets.

@FWidm
Created January 19, 2017 10:56
Show Gist options
  • Save FWidm/16a9c0ce72baf49f3614732d80496fee to your computer and use it in GitHub Desktop.
Save FWidm/16a9c0ce72baf49f3614732d80496fee to your computer and use it in GitHub Desktop.
public boolean checkRights(UserRights neededRight, Object manipulated){
final int RATING_CREATE_CATEGORY=1000;
final int RATING_DELETE_CARD=100;
switch(neededRight){
case CREATE_CATEGORY:{
if(rating>RATING_CREATE_CATEGORY){
return true;
}
return false;
}
case DELETE_CARD:{
if(manipulated!=null && manipulated.getClass()==FlashCard.class){
FlashCard card=(FlashCard)manipulated;
//can delete own cards OR any cards when this user's rating is over a specific value
if(card.getAuthor()==this || rating>RATING_DELETE_CARD){
return true;
}
}
return false;
}
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment