Created
January 19, 2017 10:56
-
-
Save FWidm/16a9c0ce72baf49f3614732d80496fee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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