Search in sources :

Example 26 with AccessRights

use of org.olat.modules.portfolio.model.AccessRights in project OpenOLAT by OpenOLAT.

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 27 with AccessRights

use of org.olat.modules.portfolio.model.AccessRights in project OpenOLAT by OpenOLAT.

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 28 with AccessRights

use of org.olat.modules.portfolio.model.AccessRights in project OpenOLAT by OpenOLAT.

the class BinderDAO method getSectionAccesRights.

public List<AccessRights> getSectionAccesRights(BinderRef binder, IdentityRef identity) {
    if (binder == null) {
        return Collections.emptyList();
    }
    StringBuilder sb = new StringBuilder();
    sb.append("select section.key, membership.role, ident, invitation from pfbinder as binder").append(" inner join binder.sections as section").append(" inner join section.baseGroup as baseGroup").append(" inner join baseGroup.members as membership");
    if (identity != null) {
        sb.append(" on (membership.identity.key =:identityKey)");
    }
    sb.append(" inner join membership.identity as ident").append(" inner join fetch ident.user as identUser").append(" left join binvitation as invitation on (invitation.baseGroup.key=binder.baseGroup.key and identUser.email=invitation.mail)").append(" where binder.key=:binderKey");
    TypedQuery<Object[]> query = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class).setParameter("binderKey", binder.getKey());
    if (identity != null) {
        query.setParameter("identityKey", identity.getKey());
    }
    List<Object[]> objects = query.getResultList();
    List<AccessRights> rightList = new ArrayList<>(objects.size());
    for (Object[] object : objects) {
        Long sectionKey = (Long) object[0];
        String role = (String) object[1];
        Identity member = (Identity) object[2];
        Invitation invitation = (Invitation) object[3];
        AccessRights rights = new AccessRights();
        rights.setRole(PortfolioRoles.valueOf(role));
        rights.setBinderKey(binder.getKey());
        rights.setSectionKey(sectionKey);
        rights.setIdentity(member);
        rights.setInvitation(invitation);
        rightList.add(rights);
    }
    return rightList;
}
Also used : AccessRights(org.olat.modules.portfolio.model.AccessRights) ArrayList(java.util.ArrayList) Invitation(org.olat.basesecurity.Invitation) Identity(org.olat.core.id.Identity)

Example 29 with AccessRights

use of org.olat.modules.portfolio.model.AccessRights in project OpenOLAT by OpenOLAT.

the class BinderDAO method getPageAccesRights.

public List<AccessRights> getPageAccesRights(BinderRef binder, IdentityRef identity) {
    if (binder == null) {
        return Collections.emptyList();
    }
    StringBuilder sb = new StringBuilder();
    sb.append("select section.key, page.key, membership.role, ident, invitation from pfbinder as binder").append(" inner join binder.sections as section").append(" inner join section.pages as page").append(" inner join page.baseGroup as baseGroup").append(" inner join baseGroup.members as membership");
    if (identity != null) {
        sb.append(" on (membership.identity.key=:identityKey)");
    }
    sb.append(" inner join membership.identity as ident").append(" inner join fetch ident.user as identUser").append(" left join binvitation as invitation on (invitation.baseGroup.key=binder.baseGroup.key and identUser.email=invitation.mail)").append(" where binder.key=:binderKey");
    TypedQuery<Object[]> query = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class).setParameter("binderKey", binder.getKey());
    if (identity != null) {
        query.setParameter("identityKey", identity.getKey());
    }
    List<Object[]> objects = query.getResultList();
    List<AccessRights> rightList = new ArrayList<>(objects.size());
    for (Object[] object : objects) {
        Long sectionKey = (Long) object[0];
        Long pageKey = (Long) object[1];
        String role = (String) object[2];
        Identity member = (Identity) object[3];
        Invitation invitation = (Invitation) object[4];
        AccessRights rights = new AccessRights();
        rights.setRole(PortfolioRoles.valueOf(role));
        rights.setBinderKey(binder.getKey());
        rights.setSectionKey(sectionKey);
        rights.setPageKey(pageKey);
        rights.setIdentity(member);
        rights.setInvitation(invitation);
        rightList.add(rights);
    }
    return rightList;
}
Also used : AccessRights(org.olat.modules.portfolio.model.AccessRights) ArrayList(java.util.ArrayList) Invitation(org.olat.basesecurity.Invitation) Identity(org.olat.core.id.Identity)

Example 30 with AccessRights

use of org.olat.modules.portfolio.model.AccessRights in project OpenOLAT by OpenOLAT.

the class BinderDAO method getBinderAccesRights.

public List<AccessRights> getBinderAccesRights(Page page) {
    if (page == null) {
        return Collections.emptyList();
    }
    StringBuilder sb = new StringBuilder();
    sb.append("select binder.key, section.key, page.key, membership.role, ident, invitation from pfpage as page").append(" inner join page.section as section").append(" inner join section.binder as binder").append(" inner join binder.baseGroup as baseGroup").append(" inner join baseGroup.members as membership").append(" inner join membership.identity as ident").append(" inner join fetch ident.user as identUser").append(" left join binvitation as invitation on (invitation.baseGroup.key=binder.baseGroup.key and identUser.email=invitation.mail)").append(" where page.key=:pageKey");
    TypedQuery<Object[]> query = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class).setParameter("pageKey", page.getKey());
    List<Object[]> objects = query.getResultList();
    List<AccessRights> rightList = new ArrayList<>(objects.size());
    for (Object[] object : objects) {
        Long binderKey = (Long) object[0];
        Long sectionKey = (Long) object[1];
        Long pageKey = (Long) object[2];
        String role = (String) object[3];
        Identity member = (Identity) object[4];
        Invitation invitation = (Invitation) object[5];
        AccessRights rights = new AccessRights();
        rights.setRole(PortfolioRoles.valueOf(role));
        rights.setBinderKey(binderKey);
        rights.setSectionKey(sectionKey);
        rights.setPageKey(pageKey);
        rights.setIdentity(member);
        rights.setInvitation(invitation);
        rightList.add(rights);
    }
    return rightList;
}
Also used : AccessRights(org.olat.modules.portfolio.model.AccessRights) ArrayList(java.util.ArrayList) Invitation(org.olat.basesecurity.Invitation) Identity(org.olat.core.id.Identity)

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