Search in sources :

Example 21 with AccessRights

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);
}
Also used : HashMap(java.util.HashMap) Page(org.olat.modules.portfolio.Page) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Section(org.olat.modules.portfolio.Section) AccessRights(org.olat.modules.portfolio.model.AccessRights) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Link(org.olat.core.gui.components.link.Link)

Example 22 with AccessRights

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());
    }
}
Also used : AccessRights(org.olat.modules.portfolio.model.AccessRights) Formatter(org.olat.core.util.Formatter) BinderSecurityCallback(org.olat.modules.portfolio.BinderSecurityCallback) BinderConfiguration(org.olat.modules.portfolio.BinderConfiguration)

Example 23 with AccessRights

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;
}
Also used : AccessRights(org.olat.modules.portfolio.model.AccessRights) Binder(org.olat.modules.portfolio.Binder) OLATResourceable(org.olat.core.id.OLATResourceable) PageRunController(org.olat.modules.portfolio.ui.PageRunController) AssessedPage(org.olat.modules.portfolio.model.AssessedPage) Page(org.olat.modules.portfolio.Page) BinderSecurityCallback(org.olat.modules.portfolio.BinderSecurityCallback) WindowControl(org.olat.core.gui.control.WindowControl)

Example 24 with AccessRights

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());
}
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 25 with AccessRights

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

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