diff --git a/src/main/java/com/erudika/scoold/controllers/ProfileController.java b/src/main/java/com/erudika/scoold/controllers/ProfileController.java index 2e6cadcb..6ff54859 100755 --- a/src/main/java/com/erudika/scoold/controllers/ProfileController.java +++ b/src/main/java/com/erudika/scoold/controllers/ProfileController.java @@ -476,7 +476,7 @@ private Object getUserDescription(Profile showUser, Long questions, Long answers public List getQuestions(Profile authUser, Profile showUser, boolean isMyProfile, Pager itemcount) { itemcount.setSortby("votes"); String spaceFilter = getSpaceFilter(authUser, isMyProfile); - if (CONF.postsNeedApproval() && (isMyProfile || utils.isMod(authUser))) { + if (isMyProfile || utils.isMod(authUser)) { return pc.findQuery("", getTypeQuery(Utils.type(Question.class), Utils.type(Sticky.class), Utils.type(UnapprovedQuestion.class)) + " AND " + getAuthorQuery(showUser) + spaceFilter, itemcount); } else { @@ -488,7 +488,7 @@ public List getQuestions(Profile authUser, Profile showUser, boo public List getAnswers(Profile authUser, Profile showUser, boolean isMyProfile, Pager itemcount) { itemcount.setSortby("votes"); String spaceFilter = getSpaceFilter(authUser, isMyProfile); - if (CONF.postsNeedApproval() && (isMyProfile || utils.isMod(authUser))) { + if (isMyProfile || utils.isMod(authUser)) { return pc.findQuery("", getTypeQuery(Utils.type(Reply.class), Utils.type(UnapprovedReply.class)) + " AND " + getAuthorQuery(showUser) + spaceFilter, itemcount); } else { diff --git a/src/main/java/com/erudika/scoold/controllers/ReportsController.java b/src/main/java/com/erudika/scoold/controllers/ReportsController.java index 1695e799..dd78edd3 100755 --- a/src/main/java/com/erudika/scoold/controllers/ReportsController.java +++ b/src/main/java/com/erudika/scoold/controllers/ReportsController.java @@ -38,6 +38,7 @@ import com.erudika.scoold.utils.ScooldUtils; import java.io.IOException; import java.util.Collections; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -95,6 +96,9 @@ public String get(@RequestParam(required = false, defaultValue = Config._TIMESTA model.addAttribute("reportsSelected", "navbtn-hover"); model.addAttribute("itemcount", itemcount); model.addAttribute("reportslist", reportslist); + Pager count = new Pager(1); + pc.findQuery("", "type:(" + Utils.type(UnapprovedQuestion.class) + " OR " + Utils.type(UnapprovedReply.class) + ")", count); + model.addAttribute("unapprovedCount", count.getCount()); return "base"; } @@ -255,13 +259,15 @@ public String cleanupUnapproved(HttpServletRequest req, HttpServletResponse res) if (utils.isAuthenticated(req)) { Profile authUser = utils.getAuthUser(req); if (utils.isAdmin(authUser)) { + List toDelete = new LinkedList<>(); pc.readEverything(pager -> { pager.setSelect(Collections.singletonList(Config._ID)); List objects = pc.findQuery("", Config._TYPE + ":" + Utils.type(UnapprovedQuestion.class) + " OR " + Config._TYPE + ":" + Utils.type(UnapprovedReply.class), pager); - pc.deleteAll(objects.stream().map(r -> r.getId()).collect(Collectors.toList())); + toDelete.addAll(objects.stream().map(r -> r.getId()).collect(Collectors.toList())); return objects; }); + pc.deleteAll(toDelete); } } return "redirect:" + REPORTSLINK; diff --git a/src/main/resources/templates/reports.vm b/src/main/resources/templates/reports.vm index d48a4e7f..38477fc5 100755 --- a/src/main/resources/templates/reports.vm +++ b/src/main/resources/templates/reports.vm @@ -59,7 +59,7 @@ #if ($isAdmin) - $!lang.get("delete") +  $!lang.get("delete") #end @@ -110,7 +110,7 @@

$!lang.get("reports.title") #showcount($itemcount.count)

- #if ($isAdmin && $scooldUtils.config.postsNeedApproval()) + #if ($isAdmin && $unapprovedCount > 0) $!lang.get('reports.cleanup')