diff options
author | Paul Martin <paul@paulsputer.com> | 2016-04-04 23:05:39 +0100 |
---|---|---|
committer | Paul Martin <paul@paulsputer.com> | 2016-04-04 23:11:53 +0100 |
commit | 6e29341815153799468cbf4876564d665202edd2 (patch) | |
tree | 40d3fef2229b2296eaa86f69aa51013443ce976d /src | |
parent | 2c545280196ded9c042c0a8fa564048338bc19de (diff) | |
download | gitblit-6e29341815153799468cbf4876564d665202edd2.tar.gz gitblit-6e29341815153799468cbf4876564d665202edd2.zip |
Fix for #1037 myTickets now honours permissions
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/com/gitblit/wicket/pages/MyTicketsPage.java | 18 |
1 files 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<QueryResult> results = + final List<QueryResult> 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<QueryResult> 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( |