From 6e29341815153799468cbf4876564d665202edd2 Mon Sep 17 00:00:00 2001 From: Paul Martin Date: Mon, 4 Apr 2016 23:05:39 +0100 Subject: [PATCH] Fix for #1037 myTickets now honours permissions --- .../gitblit/wicket/pages/MyTicketsPage.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gitblit/wicket/pages/MyTicketsPage.java b/src/main/java/com/gitblit/wicket/pages/MyTicketsPage.java index 591c7fef..bfcedf6e 100644 --- a/src/main/java/com/gitblit/wicket/pages/MyTicketsPage.java +++ b/src/main/java/com/gitblit/wicket/pages/MyTicketsPage.java @@ -19,7 +19,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; -import java.util.Comparator; import java.util.HashMap; import java.util.List; @@ -343,14 +342,23 @@ public class MyTicketsPage extends RootPage { int page = (params != null) ? Math.max(1, WicketUtils.getPage(params)) : 1; int pageSize = app().settings().getInteger(Keys.tickets.perPage, 25); - final List results = + final List allResults = StringUtils.isEmpty(searchParam) ? query(qb, page, pageSize, sortBy, desc) : search(searchParam, page, pageSize); - int totalResults = results.size() == 0 ? 0 : results.get(0).totalResults; - buildPager(queryParam, milestoneParam, statiiParam, assignedToParam, sortBy, desc, repositoryId, page, pageSize, results.size(), totalResults); + List viewableResults = new ArrayList<>(allResults.size()); + for (QueryResult queryResult : allResults) { + RepositoryModel model = app().repositories().getRepositoryModel(currentUser, queryResult.repository); + + if ((model != null) && (currentUser.canView(model))) { + viewableResults.add(queryResult); + } + } + + int totalResults = viewableResults.size() == 0 ? 0 : viewableResults.get(0).totalResults; + buildPager(queryParam, milestoneParam, statiiParam, assignedToParam, sortBy, desc, repositoryId, page, pageSize, viewableResults.size(), totalResults); final boolean showSwatch = app().settings().getBoolean(Keys.web.repositoryListSwatches, true); - add(new TicketListPanel("ticketList", results, showSwatch, true)); + add(new TicketListPanel("ticketList", viewableResults, showSwatch, true)); } protected PageParameters queryParameters( -- 2.39.5