From 0476cf68aa60ac0f8b77f5f75de8339d46a98688 Mon Sep 17 00:00:00 2001 From: James Moger Date: Mon, 8 Sep 2014 15:25:47 -0400 Subject: [PATCH] Include all users with RW access in New Ticket responsible choices --- .../gitblit/wicket/pages/NewTicketPage.java | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/gitblit/wicket/pages/NewTicketPage.java b/src/main/java/com/gitblit/wicket/pages/NewTicketPage.java index 7a68febb..21a2af10 100644 --- a/src/main/java/com/gitblit/wicket/pages/NewTicketPage.java +++ b/src/main/java/com/gitblit/wicket/pages/NewTicketPage.java @@ -19,6 +19,8 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Set; +import java.util.TreeSet; import org.apache.wicket.PageParameters; import org.apache.wicket.ajax.AjaxRequestTarget; @@ -35,6 +37,7 @@ import org.eclipse.jgit.lib.Repository; import com.gitblit.Constants; import com.gitblit.Constants.AccessPermission; +import com.gitblit.Constants.AuthorizationControl; import com.gitblit.models.RegistrantAccessPermission; import com.gitblit.models.TicketModel; import com.gitblit.models.TicketModel.Change; @@ -117,25 +120,29 @@ public class NewTicketPage extends RepositoryPage { if (currentUser.canAdmin(null, getRepositoryModel())) { // responsible - List responsibles = new ArrayList(); - if (UserModel.ANONYMOUS.canPush(getRepositoryModel())) { - // anonymous push allowed - for (UserModel user : app().users().getAllUsers()) { - if (!user.disabled) { - responsibles.add(new TicketResponsible(user)); - } - } + Set userlist = new TreeSet(); + + if (UserModel.ANONYMOUS.canPush(getRepositoryModel()) + || AuthorizationControl.AUTHENTICATED == getRepositoryModel().authorizationControl) { + // authorization is ANONYMOUS or AUTHENTICATED (i.e. all users can be set responsible) + userlist.addAll(app().users().getAllUsernames()); } else { - // authenticated push + // authorization is by NAMED users (users with PUSH permission can be set responsible) for (RegistrantAccessPermission rp : app().repositories().getUserAccessPermissions(getRepositoryModel())) { - if (rp.permission.atLeast(AccessPermission.PUSH) && !rp.isTeam()) { - UserModel user = app().users().getUserModel(rp.registrant); - if (user != null && !user.disabled) { - responsibles.add(new TicketResponsible(user)); - } + if (rp.permission.atLeast(AccessPermission.PUSH)) { + userlist.add(rp.registrant); } } } + + List responsibles = new ArrayList(); + for (String username : userlist) { + UserModel user = app().users().getUserModel(username); + if (user != null && !user.disabled) { + TicketResponsible responsible = new TicketResponsible(user); + responsibles.add(responsible); + } + } Collections.sort(responsibles); Fragment responsible = new Fragment("responsible", "responsibleFragment", this); responsible.add(new DropDownChoice("responsible", responsibleModel, responsibles)); -- 2.39.5