diff --git a/src/main/java/org/olat/core/gui/render/velocity/VelocityRenderDecorator.java b/src/main/java/org/olat/core/gui/render/velocity/VelocityRenderDecorator.java index e53ecd6548b0ae11eb37958f4fb41ce98724b9ca..ddb70d8a33b1faa681d7200d91f7c9f6b9292c2e 100644 --- a/src/main/java/org/olat/core/gui/render/velocity/VelocityRenderDecorator.java +++ b/src/main/java/org/olat/core/gui/render/velocity/VelocityRenderDecorator.java @@ -835,6 +835,15 @@ public class VelocityRenderDecorator implements Closeable { return (source != null && source.isVisible() && source.isEnabled()); } + public boolean enabled(Component component) { + return component != null && component.isVisible() && component.isEnabled(); + } + + public boolean enabled(FormItem item) { + if(item == null) return false; + return enabled(item.getComponent()); + } + /** * Return the component * @param componentName diff --git a/src/main/java/org/olat/modules/portfolio/BinderSecurityCallback.java b/src/main/java/org/olat/modules/portfolio/BinderSecurityCallback.java index f0d4fdca23237e4fc50eeb1fdf37ba573dca2eec..4ad46daca880590aaa052c8f92827ac40a1e760a 100644 --- a/src/main/java/org/olat/modules/portfolio/BinderSecurityCallback.java +++ b/src/main/java/org/olat/modules/portfolio/BinderSecurityCallback.java @@ -96,6 +96,14 @@ public interface BinderSecurityCallback { public boolean canViewElement(PortfolioElement element); + + /** + * View only the title of the element but not its content + * @param element + * @return + */ + public boolean canViewTitleOfElement(PortfolioElement element); + public boolean canViewPendingAssignments(Section section); public boolean canViewEmptySection(Section section); diff --git a/src/main/java/org/olat/modules/portfolio/BinderSecurityCallbackFactory.java b/src/main/java/org/olat/modules/portfolio/BinderSecurityCallbackFactory.java index 7e57c3d33493fa5ca072486a2dd8a31589556d90..62c9a07f850ee4de555742f8d61d36f8abe69f1c 100644 --- a/src/main/java/org/olat/modules/portfolio/BinderSecurityCallbackFactory.java +++ b/src/main/java/org/olat/modules/portfolio/BinderSecurityCallbackFactory.java @@ -188,6 +188,13 @@ public class BinderSecurityCallbackFactory { if(element instanceof Page) { Page page = (Page)element; if(page.getPageStatus() == null || page.getPageStatus() == PageStatus.draft) { + if(rights != null) { + for(AccessRights right:rights) { + if(right.getRole() == PortfolioRoles.readInvitee && right.matchElementAndAncestors(element)) { + return true; + } + } + } return false; } } @@ -557,6 +564,40 @@ public class BinderSecurityCallbackFactory { return false; } + @Override + public boolean canViewTitleOfElement(PortfolioElement element) { + if(owner) { + return true; + } + + if(element instanceof Page) { + Page page = (Page)element; + if(page.getPageStatus() == null || page.getPageStatus() == PageStatus.draft) { + //need to be recursive, if page -> section too -> binder too??? + if(rights != null) { + for(AccessRights right:rights) { + if((PortfolioRoles.reviewer.equals(right.getRole()) || PortfolioRoles.coach.equals(right.getRole())) + && right.matchElementAndAncestors(element)) { + return true; + } + } + } + return owner; + } + } + + //need to be recursive, if page -> section too -> binder too??? + if(rights != null) { + for(AccessRights right:rights) { + if((PortfolioRoles.reviewer.equals(right.getRole()) || PortfolioRoles.coach.equals(right.getRole())) + && right.matchElementAndAncestors(element)) { + return true; + } + } + } + return false; + } + @Override public boolean canViewPendingAssignments(Section section) { if(owner) return true; @@ -763,6 +804,11 @@ public class BinderSecurityCallbackFactory { return false; } + @Override + public boolean canViewTitleOfElement(PortfolioElement element) { + return canViewElement(element); + } + @Override public boolean canViewPendingAssignments(Section section) { return false; diff --git a/src/main/java/org/olat/modules/portfolio/ui/AbstractPageListController.java b/src/main/java/org/olat/modules/portfolio/ui/AbstractPageListController.java index be04487e0ea67cb2db88c46ae634963a9a374a27..1242be9bdef2cfade65b6d91c50dd6292c6f2355 100644 --- a/src/main/java/org/olat/modules/portfolio/ui/AbstractPageListController.java +++ b/src/main/java/org/olat/modules/portfolio/ui/AbstractPageListController.java @@ -370,13 +370,14 @@ implements Activateable2, TooledController, FlexiTableComponentDelegate { } protected PortfolioElementRow forgePageRow(UserRequest ureq, Page page, AssessmentSection assessmentSection, List<Assignment> assignments, - Map<OLATResourceable,List<Category>> categorizedElementMap, Map<Long,Long> numberOfCommentsMap) { + Map<OLATResourceable,List<Category>> categorizedElementMap, Map<Long,Long> numberOfCommentsMap, boolean selectElement) { Section section = page.getSection(); PortfolioElementRow row = new PortfolioElementRow(page, assessmentSection, config.isAssessable()); String openLinkId = "open_" + (++counter); FormLink openLink = uifactory.addFormLink(openLinkId, "open.full", "open.full.page", null, flc, Link.BUTTON_SMALL); openLink.setIconRightCSS("o_icon o_icon_start"); + openLink.setEnabled(selectElement); openLink.setPrimary(true); row.setOpenFormLink(openLink); openLink.setUserObject(row); diff --git a/src/main/java/org/olat/modules/portfolio/ui/BinderPageListController.java b/src/main/java/org/olat/modules/portfolio/ui/BinderPageListController.java index 34158338bba98084b2ff4efa68f392cbf052daa5..2f9bb7ab2dfc838c6c0fa62a0dfbd6d96091ec9c 100644 --- a/src/main/java/org/olat/modules/portfolio/ui/BinderPageListController.java +++ b/src/main/java/org/olat/modules/portfolio/ui/BinderPageListController.java @@ -243,14 +243,16 @@ public class BinderPageListController extends AbstractPageListController { List<Page> pages = portfolioService.getPages(binder, searchString); for (Page page : pages) { - if(!secCallback.canViewElement(page)) { + boolean viewElement = secCallback.canViewElement(page); + boolean viewTitleElement = viewElement || secCallback.canViewTitleOfElement(page); + if(!viewTitleElement) { continue; } Section section = page.getSection(); PortfolioElementRow pageRow = forgePageRow(ureq, page, sectionToAssessmentSectionMap.get(section), - sectionToAssignmentMap.get(section), categorizedElementMap, numberOfCommentsMap); + sectionToAssignmentMap.get(section), categorizedElementMap, numberOfCommentsMap, viewElement); rows.add(pageRow); if(secCallback.canAddPage(section)) { FormLink newEntryButton = uifactory.addFormLink("new.entry." + (++counter), "new.entry", "create.new.page", null, flc, Link.BUTTON); diff --git a/src/main/java/org/olat/modules/portfolio/ui/DeletedPageListController.java b/src/main/java/org/olat/modules/portfolio/ui/DeletedPageListController.java index c90c787a1d239c2a720d4dac8f6b7373eb4315b7..e04ddf53b8a43f35ab0db742a2fdbba7a54fd2be 100644 --- a/src/main/java/org/olat/modules/portfolio/ui/DeletedPageListController.java +++ b/src/main/java/org/olat/modules/portfolio/ui/DeletedPageListController.java @@ -101,7 +101,7 @@ public class DeletedPageListController extends AbstractPageListController { List<Page> pages = portfolioService.searchDeletedPages(getIdentity(), searchString); List<PortfolioElementRow> rows = new ArrayList<>(pages.size()); for (Page page : pages) { - rows.add(forgePageRow(ureq, page, null, null, categorizedElementMap, numberOfCommentsMap)); + rows.add(forgePageRow(ureq, page, null, null, categorizedElementMap, numberOfCommentsMap, true)); } disposeRows();//clean up the posters diff --git a/src/main/java/org/olat/modules/portfolio/ui/MyPageListController.java b/src/main/java/org/olat/modules/portfolio/ui/MyPageListController.java index 628ac0b8aaf29ff9cf76362fbc44bb631a426270..fe38162ea57b2c1ea7ae5d04c79dcb7b991ffcad 100644 --- a/src/main/java/org/olat/modules/portfolio/ui/MyPageListController.java +++ b/src/main/java/org/olat/modules/portfolio/ui/MyPageListController.java @@ -123,7 +123,7 @@ public class MyPageListController extends AbstractPageListController { } List<Assignment> assignmentList = pageToAssignments.get(page); - PortfolioElementRow row = forgePageRow(ureq, page, null, assignmentList, categorizedElementMap, numberOfCommentsMap); + PortfolioElementRow row = forgePageRow(ureq, page, null, assignmentList, categorizedElementMap, numberOfCommentsMap, true); rows.add(row); if(page.getSection() != null) { Section section = page.getSection(); diff --git a/src/main/java/org/olat/modules/portfolio/ui/TableOfContentController.java b/src/main/java/org/olat/modules/portfolio/ui/TableOfContentController.java index 78e5deb2b64169150963e489d7bbe12ae2d9199b..585027e6b1d5a6e7f39e358d1c4db52c22d3b670 100644 --- a/src/main/java/org/olat/modules/portfolio/ui/TableOfContentController.java +++ b/src/main/java/org/olat/modules/portfolio/ui/TableOfContentController.java @@ -245,10 +245,14 @@ public class TableOfContentController extends BasicController implements TooledC List<Page> pages = portfolioService.getPages(binder, null); for(Page page:pages) { Section section = page.getSection(); - if(secCallback.canViewElement(page) && section != null && sectionMap.containsKey(section.getKey())) { - SectionRow sectionRow = sectionMap.get(section.getKey()); - PageRow pageRow = forgePageRow(page, numberOfCommentsMap); - sectionRow.getPages().add(pageRow); + if(section != null && sectionMap.containsKey(section.getKey())) { + boolean viewElement = secCallback.canViewElement(page); + boolean viewTitleElement = secCallback.canViewTitleOfElement(page); + if(viewElement || viewTitleElement) { + SectionRow sectionRow = sectionMap.get(section.getKey()); + PageRow pageRow = forgePageRow(page, numberOfCommentsMap, viewElement); + sectionRow.getPages().add(pageRow); + } } } mainVC.contextPut("sections", sectionRows); @@ -350,7 +354,7 @@ public class TableOfContentController extends BasicController implements TooledC return sectionRow; } - private PageRow forgePageRow(Page page, Map<Long,Long> numberOfCommentsMap) { + private PageRow forgePageRow(Page page, Map<Long,Long> numberOfCommentsMap, boolean selectElement) { PageRow pageRow = new PageRow(page); String pageId = "page" + (++counter); @@ -358,6 +362,7 @@ public class TableOfContentController extends BasicController implements TooledC Link openLink = LinkFactory.createCustomLink(pageId, "open_page", title, Link.LINK | Link.NONTRANSLATED, mainVC, this); openLink.setElementCssClass("o_pf_open_entry"); openLink.setUserObject(pageRow); + openLink.setEnabled(selectElement); pageRow.setOpenLink(openLink); Long numOfComments = numberOfCommentsMap.get(page.getKey()); diff --git a/src/main/java/org/olat/modules/portfolio/ui/_content/portfolio_element_row.html b/src/main/java/org/olat/modules/portfolio/ui/_content/portfolio_element_row.html index 74c604bada41082fd29c7c5f07ab565daa0bbad5..351229b44094b5e404c4048178c73ca314cf7c8c 100644 --- a/src/main/java/org/olat/modules/portfolio/ui/_content/portfolio_element_row.html +++ b/src/main/java/org/olat/modules/portfolio/ui/_content/portfolio_element_row.html @@ -161,12 +161,14 @@ </div> </div> </div> + #if($r.enabled($row.openFormItem)) <div class="o_portfolio_page_links o_noprint"> $r.render($row.openFormItem) #if($r.isNotNull($row.commentFormLink)) <span class="btn btn-sm o_portfolio_comment">$r.render($row.commentFormLink)</span> #end </div> + #end </div> #end #if($row.newEntry && $r.isNotNull($row.newEntryLink))