use of org.olat.modules.portfolio.model.AccessRights in project openolat by klemens.
the class ConfirmClosePageController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
if (formLayout instanceof FormLayoutContainer) {
FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
List<String> names = new ArrayList<>(rights.size());
for (AccessRights right : rights) {
String fullName = null;
if (right.getInvitation() != null) {
Invitation invitation = right.getInvitation();
fullName = userManager.getUserDisplayName(invitation.getFirstName(), invitation.getLastName());
} else if (getIdentity().equals(right.getIdentity()) || owners.contains(right.getIdentity())) {
continue;
} else if (right.getIdentity() != null) {
fullName = userManager.getUserDisplayName(right.getIdentity());
}
if (fullName != null) {
names.add(StringHelper.escapeHtml(fullName));
}
}
layoutCont.contextPut("names", names);
}
uifactory.addFormCancelButton("cancel", formLayout, ureq, getWindowControl());
uifactory.addFormSubmitButton("close.page", formLayout);
}
use of org.olat.modules.portfolio.model.AccessRights in project openolat by klemens.
the class PortfolioServiceTest method binderAndSectionAndPageAccessRights.
@Test
public void binderAndSectionAndPageAccessRights() {
Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-3");
Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-4");
Identity reviewer = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-5");
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, coach, PortfolioRoles.coach);
dbInstance.commit();
List<Page> pages = portfolioService.getPages(section);
Page page = pages.get(0);
portfolioService.addAccessRights(page, reviewer, PortfolioRoles.reviewer);
// load right
List<AccessRights> rights = portfolioService.getAccessRights(binder);
Assert.assertNotNull(rights);
Assert.assertEquals(4, rights.size());
boolean foundOwner = false;
boolean foundCoach = false;
boolean foundReviewer = false;
for (AccessRights right : rights) {
if (PortfolioRoles.owner.equals(right.getRole()) && owner.equals(right.getIdentity())) {
foundOwner = true;
} else if (PortfolioRoles.coach.equals(right.getRole()) && coach.equals(right.getIdentity())) {
foundCoach = true;
} else if (PortfolioRoles.reviewer.equals(right.getRole()) && reviewer.equals(right.getIdentity())) {
foundReviewer = true;
}
}
Assert.assertTrue(foundOwner);
Assert.assertTrue(foundCoach);
Assert.assertTrue(foundReviewer);
}
use of org.olat.modules.portfolio.model.AccessRights in project openolat by klemens.
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 klemens.
the class EvaluationFormHandler method getController.
private Controller getController(UserRequest ureq, WindowControl wControl, PageBody body, EvaluationFormPart eva) {
PortfolioService portfolioService = CoreSpringFactory.getImpl(PortfolioService.class);
Controller ctrl = null;
Page page = portfolioService.getPageByBody(body);
List<AccessRights> accessRights = portfolioService.getAccessRights(page);
if (hasRole(PortfolioRoles.owner, ureq.getIdentity(), accessRights)) {
ctrl = new EvaluationFormController(ureq, wControl, ureq.getIdentity(), body, eva.getContent(), false);
} else if (hasRole(PortfolioRoles.coach, ureq.getIdentity(), accessRights)) {
Identity owner = getOwner(accessRights);
ctrl = new EvaluationFormController(ureq, wControl, owner, body, eva.getContent(), true);
} else if (hasRole(PortfolioRoles.reviewer, ureq.getIdentity(), accessRights) || hasRole(PortfolioRoles.invitee, ureq.getIdentity(), accessRights)) {
Identity owner = getOwner(accessRights);
ctrl = new EvaluationFormController(ureq, wControl, owner, body, eva.getContent(), true);
}
return ctrl;
}
use of org.olat.modules.portfolio.model.AccessRights in project openolat by klemens.
the class BinderInvitationContextEntryControllerCreator method createController.
@Override
public Controller createController(List<ContextEntry> ces, UserRequest ureq, WindowControl wControl) {
if (!ureq.getUserSession().getRoles().isInvitee()) {
return null;
}
Binder binder = getBinderFromContext(ces.get(0));
BinderConfiguration config = BinderConfiguration.createInvitationConfig();
List<AccessRights> rights = CoreSpringFactory.getImpl(PortfolioService.class).getAccessRights(binder, ureq.getIdentity());
BinderSecurityCallback secCallback = BinderSecurityCallbackFactory.getCallbackForInvitation(rights);
Controller binderCtrl = new PortfolioInvitationController(ureq, wControl, secCallback, binder, config);
LayoutMain3ColsController layoutCtr = new LayoutMain3ColsController(ureq, wControl, binderCtrl);
layoutCtr.addDisposableChildController(binderCtrl);
return layoutCtr;
}
Aggregations