Get all items that the provided user has favorited
@param user to lookup favorites for
@return favorite items
170837
public static Iterable<Item> getFavorites(@Nonnull User user) {
        FavoriteUserProperty fup = user.getProperty(FavoriteUserProperty.class);
        if (fup == null) {
            return ImmutableList.of();
        }
        Set<String> favorites = fup.getAllFavorites();
        if (favorites.isEmpty()) {
            return ImmutableList.of();
        }
        final Iterator<String> iterator = favorites.iterator();
        final Jenkins jenkins = Jenkins.getInstance();
        if (jenkins == null) {
            throw new IllegalStateException("Jenkins not started");
        }
        return new Iterable<Item>() {
            @Override
            public Iterator<Item> iterator() {
                return Iterators.filter(new Iterator<Item>() {
                    @Override
                    public boolean hasNext() {
                        return iterator.hasNext();
                    }

                    @Override
                    public Item next() {
                        return jenkins.getItemByFullName(iterator.next());
                    }
                    
                    /* Fix build. */
                    @Override
                    public void remove() {
                        throw new UnsupportedOperationException();
                    }
                }, Predicates.<Item>notNull());
            }
        };
    }
856839
private UserRole getDelfoiRole(User user) {
    Delfoi delfoi = getDelfoi();
    if (delfoi != null) {
      DelfoiUserDAO delfoiUserDAO = new DelfoiUserDAO();
      DelfoiUser delfoiUser = delfoiUserDAO.findByDelfoiAndUser(delfoi, user);
      return delfoiUser == null ? getEveryoneRole() : delfoiUser.getRole();
    }
    
    return getEveryoneRole();
  }
247478
public User getActiveUser() {
        SharedPreferences prefs = getStorage();
        if (prefs.contains("uuid") && prefs.contains("name")) {
            return new User(
                    prefs.getString("app_name", ""),
                    prefs.getString("name", ""),
                    prefs.getString("uuid", ""),
                    null);
        } else {
            return null;
        }
    }
1186507
def favorites(self):
        
        return bind_api(
            api=self,
            path='/favorites/list.json',
            payload_type='status', payload_list=True,
            allowed_param=['screen_name', 'user_id', 'max_id', 'count', 'since_id', 'max_id']
        )
1068085
public Result<List<PermDAO.Data>> getPermsByUser(AuthzTrans trans, String user, boolean lookup) {
		return PermLookup.get(trans, this, user).getPerms(lookup);
	}
534864
public function getFavorites(): UserFavoritesData
    {
        $json = $this->client->performApiCallWithJsonResponse('get', '/user/favorites');
        return ResponseHandler::create($json, ResponseHandler::METHOD_USER_FAVORITES)->handle();
    }
1237623
public AccessLevel getAccessForPrincipal(String user) {
        AccessLevel result = AccessLevel.NOTHING;
        for (Access item : getAccessList()) {
            if (item.isNegativeRule()) {
                if (!item.getPrincipal().contains(user)) {
                    result = item.getLevel();
                }
            } else {
                if (item.getPrincipal().contains(user)) {
                    result = item.getLevel();
                }
            }
        }
        return result;
    }
1362440
def load_favorites(self):
    
    character = self.session.session.get(u'http://myanimelist.net/character/' + str(self.id) + u'/' + utilities.urlencode(self.name) + u'/favorites').text
    self.set(self.parse_favorites(utilities.get_clean_dom(character)))
    return self
1183306
public FavoriteResources favoriteResources() {
        if (favorites.get() == null) {
            favorites.compareAndSet(null, new FavoriteResourcesImpl(this));
        }
        return favorites.get();
    }
38231
protected Collection<? extends ItemHolder> items()
    {
        for (CompositePollItem item : all) {
            item.handler(globalHandler);
        }
        return all;
    }
715791
def users_favorites(*args)
      options = args.extract_options!.merge(:client_id => api_key)
      args[1].nil? ? (response = conn.get("/users/#{args[0]}/favorites.json") { |req| req.params = options }) : (response = conn.get("/users/#{args[0]}/favorites/#{args[1]}.json") { |req| req.params = options })
      args.nil? ? response.body.send(sym) : response.body
    end
592640
public Set<Item> getSelectedItems() {
        if (mOriginalItems != null) {
            Set<Item> selections = new HashSet<>();
            for (int i = 0, size = mOriginalItems.size(); i < size; i++) {
                Item item = mOriginalItems.get(i);
                if (item.isSelected()) {
                    selections.add(item);
                }
            }
            return selections;
        } else {
            return mItemAdapter.getFastAdapter().getSelectedItems();
        }
    }
1124236
public function getUserRegistrations(User $user, array $collections)
    {
        $qb = $this->createQueryBuilder('d');
        $qb->where($qb->expr()->eq('d.user', ':user'));
        $qb->setParameter(':user', $user->getId());

        if (count($collections) > 0) {
            $qb->andWhere('d.baseId IN (:bases)');
            $qb->setParameter(':bases', array_map(function (\collection $collection) {
                return $collection->get_base_id();
            }, $collections));
        }

        $qb->orderBy('d.created', 'DESC');

        return $qb->getQuery()->getResult();
    }
234983
def _get_collection_for_user(self, collection_id, user):
        """"""
        collection_query = Collection.objects.filter(pk=collection_id)
        if not collection_query.exists():
            raise exceptions.ValidationError('Collection id does not exist')

        collection = collection_query.first()
        if not user.has_perm('add_collection', obj=collection):
            if user.is_authenticated:
                raise exceptions.PermissionDenied()
            else:
                raise exceptions.NotFound()

        return collection
54428
public function all(User $user = null)
    {
        $query = Tag::query();

        return $this->scopeVisibleTo($query, $user)->get();
    }
1236062
@Override
    public Set<IPortletEntity> getPortletEntitiesForUser(int userId) {
        final Set<IPortletEntity> portletEntities =
                this.delegatePortletEntityDao.getPortletEntitiesForUser(userId);
        return this.wrapEntities(portletEntities);
    }
1146987
@Programmatic
    public List<ApplicationPermission> findByUserCached(final ApplicationUser user) {
        return queryResultsCache.execute(new Callable<List<ApplicationPermission>>() {
            @Override public List<ApplicationPermission> call() throws Exception {
                return findByUser(user);
            }
        }, ApplicationPermissionRepository.class, "findByUserCached", user);
    }