Search in sources :

Example 16 with AccessRights

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);
}
Also used : AccessRights(org.olat.modules.portfolio.model.AccessRights) ArrayList(java.util.ArrayList) Invitation(org.olat.basesecurity.Invitation) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Example 17 with AccessRights

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);
}
Also used : AccessRights(org.olat.modules.portfolio.model.AccessRights) SynchedBinder(org.olat.modules.portfolio.model.SynchedBinder) Binder(org.olat.modules.portfolio.Binder) Page(org.olat.modules.portfolio.Page) Identity(org.olat.core.id.Identity) Section(org.olat.modules.portfolio.Section) Test(org.junit.Test)

Example 18 with AccessRights

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());
}
Also used : AccessRights(org.olat.modules.portfolio.model.AccessRights) SynchedBinder(org.olat.modules.portfolio.model.SynchedBinder) Binder(org.olat.modules.portfolio.Binder) Page(org.olat.modules.portfolio.Page) Identity(org.olat.core.id.Identity) Section(org.olat.modules.portfolio.Section) Test(org.junit.Test)

Example 19 with AccessRights

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;
}
Also used : AccessRights(org.olat.modules.portfolio.model.AccessRights) MultiEvaluationFormController(org.olat.modules.portfolio.ui.MultiEvaluationFormController) EvaluationFormController(org.olat.modules.forms.ui.EvaluationFormController) PortfolioService(org.olat.modules.portfolio.PortfolioService) Page(org.olat.modules.portfolio.Page) MultiEvaluationFormController(org.olat.modules.portfolio.ui.MultiEvaluationFormController) Controller(org.olat.core.gui.control.Controller) EvaluationFormController(org.olat.modules.forms.ui.EvaluationFormController) PortfolioHomeController(org.olat.modules.portfolio.ui.PortfolioHomeController) Identity(org.olat.core.id.Identity)

Example 20 with AccessRights

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;
}
Also used : AccessRights(org.olat.modules.portfolio.model.AccessRights) PortfolioInvitationController(org.olat.modules.portfolio.ui.PortfolioInvitationController) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) PortfolioInvitationController(org.olat.modules.portfolio.ui.PortfolioInvitationController) Controller(org.olat.core.gui.control.Controller) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController)

Aggregations

AccessRights (org.olat.modules.portfolio.model.AccessRights)38 Identity (org.olat.core.id.Identity)24 ArrayList (java.util.ArrayList)16 Invitation (org.olat.basesecurity.Invitation)14 Binder (org.olat.modules.portfolio.Binder)12 Page (org.olat.modules.portfolio.Page)12 BinderSecurityCallback (org.olat.modules.portfolio.BinderSecurityCallback)10 Test (org.junit.Test)6 Controller (org.olat.core.gui.control.Controller)6 BinderConfiguration (org.olat.modules.portfolio.BinderConfiguration)6 Section (org.olat.modules.portfolio.Section)6 SynchedBinder (org.olat.modules.portfolio.model.SynchedBinder)6 WindowControl (org.olat.core.gui.control.WindowControl)4 OLATResourceable (org.olat.core.id.OLATResourceable)4 EvaluationFormController (org.olat.modules.forms.ui.EvaluationFormController)4 PortfolioService (org.olat.modules.portfolio.PortfolioService)4 BinderController (org.olat.modules.portfolio.ui.BinderController)4 MultiEvaluationFormController (org.olat.modules.portfolio.ui.MultiEvaluationFormController)4 PortfolioHomeController (org.olat.modules.portfolio.ui.PortfolioHomeController)4 Date (java.util.Date)2