use of org.olat.modules.portfolio.model.AccessRights in project openolat by klemens.
the class PublishController method reloadData.
public void reloadData() {
binderRow.getChildren().clear();
binderRow.getAccessRights().clear();
List<AccessRights> rights = portfolioService.getAccessRights(binder);
boolean canEditBinderAccessRights = secCallback.canEditAccessRights(binder);
for (AccessRights right : rights) {
if (right.getSectionKey() == null && right.getPageKey() == null) {
if (PortfolioRoles.invitee.equals(right.getRole())) {
// only access
continue;
}
Link editLink = null;
if (canEditBinderAccessRights && !PortfolioRoles.owner.equals(right.getRole())) {
String id = "edit_" + (counter++);
editLink = LinkFactory.createLink(id, id, "edit_access", "edit", getTranslator(), mainVC, this, Link.LINK);
}
binderRow.getAccessRights().add(new AccessRightsRow(binder, right, editLink));
}
}
List<AssessmentSection> assessmentSections = portfolioService.getAssessmentSections(binder, getIdentity());
Map<Section, AssessmentSection> sectionToAssessmentSectionMap = new HashMap<>();
for (AssessmentSection assessmentSection : assessmentSections) {
sectionToAssessmentSectionMap.put(assessmentSection.getSection(), assessmentSection);
}
// sections
List<Section> sections = portfolioService.getSections(binder);
Map<Long, PortfolioElementRow> sectionMap = new HashMap<>();
for (Section section : sections) {
boolean canEditSectionAccessRights = secCallback.canEditAccessRights(section);
boolean canViewSectionAccessRights = secCallback.canViewAccessRights(section);
if (canEditSectionAccessRights || canViewSectionAccessRights) {
PortfolioElementRow sectionRow = new PortfolioElementRow(section, sectionToAssessmentSectionMap.get(section));
binderRow.getChildren().add(sectionRow);
sectionMap.put(section.getKey(), sectionRow);
for (AccessRights right : rights) {
if (section.getKey().equals(right.getSectionKey()) && right.getPageKey() == null) {
Link editLink = null;
if (canEditSectionAccessRights && !PortfolioRoles.owner.equals(right.getRole())) {
String id = "edit_" + (counter++);
editLink = LinkFactory.createLink(id, id, "edit_access", "edit", getTranslator(), mainVC, this, Link.LINK);
sectionRow.getAccessRights().add(new AccessRightsRow(section, right, editLink));
}
}
}
}
}
// pages
List<Page> pages = portfolioService.getPages(binder, null);
for (Page page : pages) {
boolean canEditPageAccessRights = secCallback.canEditAccessRights(page);
boolean canViewPageAccessRights = secCallback.canViewAccessRights(page);
if (canEditPageAccessRights || canViewPageAccessRights) {
Section section = page.getSection();
PortfolioElementRow sectionRow = sectionMap.get(section.getKey());
if (sectionRow == null) {
logError("Section not found: " + section.getKey() + " of page: " + page.getKey(), null);
continue;
}
PortfolioElementRow pageRow = new PortfolioElementRow(page, null);
sectionRow.getChildren().add(pageRow);
for (AccessRights right : rights) {
if (page.getKey().equals(right.getPageKey())) {
Link editLink = null;
if (canEditPageAccessRights && !PortfolioRoles.owner.equals(right.getRole())) {
String id = "edit_" + (counter++);
editLink = LinkFactory.createLink(id, id, "edit_access", "edit", getTranslator(), mainVC, this, Link.LINK);
pageRow.getAccessRights().add(new AccessRightsRow(page, right, editLink));
}
}
}
}
}
mainVC.setDirty(true);
}
use of org.olat.modules.portfolio.model.AccessRights in project openolat by klemens.
the class PortfolioAssessmentDetailsController method loadModel.
private void loadModel(UserRequest ureq, Binder loadedBinder) {
if (loadedBinder == null) {
mainVC.contextPut("noMap", Boolean.TRUE);
} else {
Formatter formatter = Formatter.getInstance(getLocale());
String templateTitle = loadedBinder.getTemplate().getTitle();
mainVC.contextPut("templateTitle", templateTitle);
String copyDate = "";
if (loadedBinder.getCopyDate() != null) {
copyDate = formatter.formatDateAndTime(loadedBinder.getCopyDate());
}
mainVC.contextPut("copyDate", copyDate);
String returnDate = "";
if (loadedBinder.getReturnDate() != null) {
returnDate = formatter.formatDateAndTime(loadedBinder.getReturnDate());
}
mainVC.contextPut("returnDate", returnDate);
List<AccessRights> rights = portfolioService.getAccessRights(loadedBinder, getIdentity());
BinderSecurityCallback secCallback = BinderSecurityCallbackFactory.getCallbackForCourseCoach(loadedBinder, rights);
BinderConfiguration config = BinderConfiguration.createConfig(loadedBinder);
assessmentCtrl = new BinderAssessmentController(ureq, getWindowControl(), secCallback, loadedBinder, config);
listenTo(assessmentCtrl);
mainVC.put("assessment", assessmentCtrl.getInitialComponent());
}
}
use of org.olat.modules.portfolio.model.AccessRights in project openolat by klemens.
the class SharedPagesController method doSelectedPage.
private Activateable2 doSelectedPage(UserRequest ureq, SharedPageRow row) {
removeAsListenerAndDispose(pageCtrl);
Page reloadedPage = portfolioService.getPageByKey(row.getPageKey());
Binder binder = reloadedPage.getSection().getBinder();
OLATResourceable pageOres = OresHelper.createOLATResourceableInstance("Entry", reloadedPage.getKey());
WindowControl swControl = addToHistory(ureq, pageOres, null);
List<AccessRights> rights = portfolioService.getAccessRights(binder, getIdentity());
BinderSecurityCallback secCallback = BinderSecurityCallbackFactory.getCallbackForCoach(binder, rights);
pageCtrl = new PageRunController(ureq, swControl, stackPanel, secCallback, reloadedPage, false);
listenTo(pageCtrl);
stackPanel.pushController(reloadedPage.getTitle(), pageCtrl);
return pageCtrl;
}
use of org.olat.modules.portfolio.model.AccessRights in project OpenOLAT by OpenOLAT.
the class PortfolioServiceTest method binderAndSectionAndPageAccessRights_byIdentity.
@Test
public void binderAndSectionAndPageAccessRights_byIdentity() {
Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-5");
Identity identity = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-6");
String title = "My published binder";
String summary = "My live";
Binder binder = portfolioService.createNewBinder(title, summary, null, owner);
dbInstance.commit();
portfolioService.appendNewSection("Section", "Coached section", null, null, binder);
dbInstance.commit();
List<Section> sections = portfolioService.getSections(binder);
Section section = sections.get(0);
portfolioService.appendNewPage(owner, "Reviewed page", "", null, null, section);
portfolioService.addAccessRights(section, identity, PortfolioRoles.coach);
dbInstance.commit();
List<Page> pages = portfolioService.getPages(section);
Page page = pages.get(0);
portfolioService.addAccessRights(page, identity, PortfolioRoles.reviewer);
// load right
List<AccessRights> rights = portfolioService.getAccessRights(binder, identity);
Assert.assertNotNull(rights);
Assert.assertEquals(2, rights.size());
}
use of org.olat.modules.portfolio.model.AccessRights in project OpenOLAT by OpenOLAT.
the class PortfolioServiceTest method binderAccessRights.
@Test
public void binderAccessRights() {
Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-2");
String title = "My private binder";
String summary = "My live";
Binder binder = portfolioService.createNewBinder(title, summary, null, owner);
dbInstance.commitAndCloseSession();
// load right
List<AccessRights> rights = portfolioService.getAccessRights(binder);
Assert.assertNotNull(rights);
Assert.assertEquals(1, rights.size());
AccessRights ownerRight = rights.get(0);
Assert.assertEquals(binder.getKey(), ownerRight.getBinderKey());
Assert.assertEquals(owner, ownerRight.getIdentity());
Assert.assertEquals(PortfolioRoles.owner, ownerRight.getRole());
}
Aggregations