Skip to content

Instantly share code, notes, and snippets.

@peterdietz
Created March 29, 2011 18:13
Show Gist options
  • Save peterdietz/892895 to your computer and use it in GitHub Desktop.
Save peterdietz/892895 to your computer and use it in GitHub Desktop.
quick and dirty look at restricting hits based on items user has authorization to actually view
// now instantiate the results and put them in their buckets
for (int i = 0; i < qResults.getHitTypes().size(); i++)
{
Integer myType = qResults.getHitTypes().get(i);
// add the handle to the appropriate lists
switch (myType.intValue())
{
case Constants.ITEM:
Item item = Item.find(context, qResults.getHitIds().get(i));
if (AuthorizeManager.authorizeActionBoolean(context, item, Constants.READ))
{
itemCount++;
}
break;
case Constants.COLLECTION:
collCount++;
break;
case Constants.COMMUNITY:
commCount++;
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment