From a8181b4441d953f49192e2f183107f4074d6dc6b Mon Sep 17 00:00:00 2001
From: srosse <stephane.rosse@frentix.com>
Date: Thu, 24 Oct 2019 20:53:42 +0200
Subject: [PATCH] OO-4321: show only valid offer in the groups list

---
 src/main/java/org/olat/group/manager/BusinessGroupDAO.java | 7 ++++---
 .../group/ui/main/BusinessGroupListFlexiTableModel.java    | 2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/olat/group/manager/BusinessGroupDAO.java b/src/main/java/org/olat/group/manager/BusinessGroupDAO.java
index b63c8d32d7c..a42f913fa43 100644
--- a/src/main/java/org/olat/group/manager/BusinessGroupDAO.java
+++ b/src/main/java/org/olat/group/manager/BusinessGroupDAO.java
@@ -1266,11 +1266,12 @@ public class BusinessGroupDAO {
 		StringBuilder so = new StringBuilder();
 		so.append("select access.method, resource.key, offer.price from acofferaccess access ")
 			.append(" inner join access.offer offer")
-			.append(" inner join offer.resource resource");
+			.append(" inner join offer.resource resource")
+			.append(" where offer.valid=true");
 		if(resourceKeyToGroup.size() < OFFERS_IN_LIMIT) {
-			so.append(" where resource.key in (:resourceKeys)");
+			so.append(" and resource.key in (:resourceKeys)");
 		} else {
-			so.append(" where exists (select bgi.key from businessgroup bgi where bgi.resource=resource)");
+			so.append(" and exists (select bgi.key from businessgroup bgi where bgi.resource=resource)");
 		}
 			
 		TypedQuery<Object[]> offersQuery = dbInstance.getCurrentEntityManager()
diff --git a/src/main/java/org/olat/group/ui/main/BusinessGroupListFlexiTableModel.java b/src/main/java/org/olat/group/ui/main/BusinessGroupListFlexiTableModel.java
index 5c5747adcb1..5a825ee3bcf 100644
--- a/src/main/java/org/olat/group/ui/main/BusinessGroupListFlexiTableModel.java
+++ b/src/main/java/org/olat/group/ui/main/BusinessGroupListFlexiTableModel.java
@@ -95,7 +95,7 @@ public class BusinessGroupListFlexiTableModel extends DefaultFlexiTableDataModel
 			case resources:
 				return wrapped;
 			case accessControl:
-				return new Boolean(wrapped.isAccessControl());
+				return Boolean.valueOf(wrapped.isAccessControl());
 			case accessControlLaunch:
 				return wrapped.getAccessLink();
 			case accessTypes:
-- 
GitLab