Search in sources :

Example 11 with TaxonomyCompetenceTypes

use of org.olat.modules.taxonomy.TaxonomyCompetenceTypes in project OpenOLAT by OpenOLAT.

the class TaxonomyCompetenceTypeRenderer method render.

@Override
public void render(Renderer renderer, StringOutput target, Object cellValue, int row, FlexiTableComponent source, URLBuilder ubu, Translator trans) {
    if (cellValue instanceof TaxonomyCompetenceTypes) {
        TaxonomyCompetenceTypes type = (TaxonomyCompetenceTypes) cellValue;
        target.append(translator.translate(type.name()));
    }
}
Also used : TaxonomyCompetenceTypes(org.olat.modules.taxonomy.TaxonomyCompetenceTypes)

Example 12 with TaxonomyCompetenceTypes

use of org.olat.modules.taxonomy.TaxonomyCompetenceTypes in project OpenOLAT by OpenOLAT.

the class IdentityCompetenceRow method isManaged.

public boolean isManaged() {
    TaxonomyLevel level = competence.getTaxonomyLevel();
    TaxonomyCompetenceTypes competenceType = competence.getCompetenceType();
    TaxonomyLevelManagedFlag marker = TaxonomyLevelManagedFlag.getCorrespondingFlag(competenceType);
    return TaxonomyLevelManagedFlag.isManaged(level, marker);
}
Also used : TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) TaxonomyCompetenceTypes(org.olat.modules.taxonomy.TaxonomyCompetenceTypes) TaxonomyLevelManagedFlag(org.olat.modules.taxonomy.TaxonomyLevelManagedFlag)

Example 13 with TaxonomyCompetenceTypes

use of org.olat.modules.taxonomy.TaxonomyCompetenceTypes in project OpenOLAT by OpenOLAT.

the class TaxonomyTreeBuilder method computePermissionsRecursive.

private void computePermissionsRecursive(TaxonomyTreeNode node, Map<TaxonomyLevel, List<TaxonomyCompetenceTypes>> levelToCompetences) {
    boolean hasRead = node.isCanRead();
    boolean hasWrite = node.isCanWrite();
    if (node.getType() == TaxonomyTreeNodeType.lostAndFound) {
        hasRead = isTaxonomyAdmin;
        hasWrite = isTaxonomyAdmin;
        node.setCanRead(hasRead);
        node.setCanWrite(hasWrite);
    } else if (node.getTaxonomyLevel() != null) {
        TaxonomyLevel level = node.getTaxonomyLevel();
        TaxonomyLevelType type = level.getType();
        if (type != null) {
            List<TaxonomyCompetenceTypes> competences = levelToCompetences.get(level);
            if (competences != null && competences.size() > 0) {
                for (TaxonomyCompetenceTypes competence : competences) {
                    hasRead |= hasReadAccess(type, competence);
                    hasWrite |= hasWriteAccess(type, competence);
                    if (competence == TaxonomyCompetenceTypes.teach && type.getDocumentsLibraryTeachCompetenceReadParentLevels() > 0) {
                        int parentLevels = type.getDocumentsLibraryTeachCompetenceReadParentLevels();
                        TaxonomyTreeNode parent = (TaxonomyTreeNode) node.getParent();
                        for (int i = parentLevels; i-- > 0 && parent != null; ) {
                            parent.setCanRead(true);
                            parent = (TaxonomyTreeNode) parent.getParent();
                        }
                    }
                }
            } else if (isTaxonomyAdmin) {
                hasRead |= hasReadAccess(type, null);
                hasWrite |= hasWriteAccess(type, null);
            }
        }
        node.setCanRead(hasRead);
        node.setCanWrite(hasWrite);
    } else if (node.getType() == TaxonomyTreeNodeType.templates) {
        hasRead = true;
        hasWrite = isTaxonomyAdmin;
        node.setCanRead(hasRead);
        node.setCanWrite(hasWrite);
    }
    for (int i = node.getChildCount(); i-- > 0; ) {
        TaxonomyTreeNode child = (TaxonomyTreeNode) node.getChildAt(i);
        child.setCanRead(hasRead);
        child.setCanWrite(hasWrite);
        computePermissionsRecursive(child, levelToCompetences);
    }
}
Also used : TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) TaxonomyLevelType(org.olat.modules.taxonomy.TaxonomyLevelType) TaxonomyTreeNode(org.olat.modules.taxonomy.model.TaxonomyTreeNode) ArrayList(java.util.ArrayList) List(java.util.List) TaxonomyCompetenceTypes(org.olat.modules.taxonomy.TaxonomyCompetenceTypes)

Example 14 with TaxonomyCompetenceTypes

use of org.olat.modules.taxonomy.TaxonomyCompetenceTypes in project OpenOLAT by OpenOLAT.

the class PoolTaxonomySecurityCallback method isAllowedToLaunchSite.

@Override
public boolean isAllowedToLaunchSite(UserRequest ureq) {
    if (!questionPoolModule.isEnabled() || !StringHelper.isLong(questionPoolModule.getTaxonomyQPoolKey()) || ureq == null || ureq.getIdentity() == null) {
        return false;
    }
    UserSession usess = ureq.getUserSession();
    if (usess == null) {
        return false;
    }
    Roles roles = usess.getRoles();
    if (roles == null || roles.isInvitee() || roles.isGuestOnly()) {
        return false;
    }
    if (roles.isOLATAdmin() || roles.isPoolAdmin()) {
        return true;
    }
    TaxonomyCompetenceTypes[] types = new TaxonomyCompetenceTypes[] { TaxonomyCompetenceTypes.manage, TaxonomyCompetenceTypes.teach };
    TaxonomyRef taxonomy = new TaxonomyRefImpl(Long.valueOf(questionPoolModule.getTaxonomyQPoolKey()));
    return taxonomyService.hasTaxonomyCompetences(taxonomy, ureq.getIdentity(), new Date(), types);
}
Also used : TaxonomyRefImpl(org.olat.modules.taxonomy.model.TaxonomyRefImpl) TaxonomyRef(org.olat.modules.taxonomy.TaxonomyRef) UserSession(org.olat.core.util.UserSession) Roles(org.olat.core.id.Roles) TaxonomyCompetenceTypes(org.olat.modules.taxonomy.TaxonomyCompetenceTypes) Date(java.util.Date)

Example 15 with TaxonomyCompetenceTypes

use of org.olat.modules.taxonomy.TaxonomyCompetenceTypes in project openolat by klemens.

the class PoolTaxonomySecurityCallback method isAllowedToLaunchSite.

@Override
public boolean isAllowedToLaunchSite(UserRequest ureq) {
    if (!questionPoolModule.isEnabled() || !StringHelper.isLong(questionPoolModule.getTaxonomyQPoolKey()) || ureq == null || ureq.getIdentity() == null) {
        return false;
    }
    UserSession usess = ureq.getUserSession();
    if (usess == null) {
        return false;
    }
    Roles roles = usess.getRoles();
    if (roles == null || roles.isInvitee() || roles.isGuestOnly()) {
        return false;
    }
    if (roles.isOLATAdmin() || roles.isPoolAdmin()) {
        return true;
    }
    TaxonomyCompetenceTypes[] types = new TaxonomyCompetenceTypes[] { TaxonomyCompetenceTypes.manage, TaxonomyCompetenceTypes.teach };
    TaxonomyRef taxonomy = new TaxonomyRefImpl(Long.valueOf(questionPoolModule.getTaxonomyQPoolKey()));
    return taxonomyService.hasTaxonomyCompetences(taxonomy, ureq.getIdentity(), new Date(), types);
}
Also used : TaxonomyRefImpl(org.olat.modules.taxonomy.model.TaxonomyRefImpl) TaxonomyRef(org.olat.modules.taxonomy.TaxonomyRef) UserSession(org.olat.core.util.UserSession) Roles(org.olat.core.id.Roles) TaxonomyCompetenceTypes(org.olat.modules.taxonomy.TaxonomyCompetenceTypes) Date(java.util.Date)

Aggregations

TaxonomyCompetenceTypes (org.olat.modules.taxonomy.TaxonomyCompetenceTypes)18 ArrayList (java.util.ArrayList)8 TaxonomyLevel (org.olat.modules.taxonomy.TaxonomyLevel)8 List (java.util.List)6 Date (java.util.Date)4 Identity (org.olat.core.id.Identity)4 TaxonomyCompetence (org.olat.modules.taxonomy.TaxonomyCompetence)4 TaxonomyLevelManagedFlag (org.olat.modules.taxonomy.TaxonomyLevelManagedFlag)4 HashMap (java.util.HashMap)2 MultiIdentityChosenEvent (org.olat.basesecurity.events.MultiIdentityChosenEvent)2 SingleIdentityChosenEvent (org.olat.basesecurity.events.SingleIdentityChosenEvent)2 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)2 Roles (org.olat.core.id.Roles)2 UserSession (org.olat.core.util.UserSession)2 TaxonomyLevelType (org.olat.modules.taxonomy.TaxonomyLevelType)2 TaxonomyRef (org.olat.modules.taxonomy.TaxonomyRef)2 TaxonomyLevelRefImpl (org.olat.modules.taxonomy.model.TaxonomyLevelRefImpl)2 TaxonomyRefImpl (org.olat.modules.taxonomy.model.TaxonomyRefImpl)2 TaxonomyTreeNode (org.olat.modules.taxonomy.model.TaxonomyTreeNode)2 RestSecurityHelper.getIdentity (org.olat.restapi.security.RestSecurityHelper.getIdentity)2