Search in sources :

Example 1 with GlossarySecurityCallback

use of org.olat.core.commons.modules.glossary.GlossarySecurityCallback in project OpenOLAT by OpenOLAT.

the class CourseGlossaryFactory method createCourseGlossaryMainRunController.

/**
 * The glossarymaincontroller allows browsing in the glossary. A flag enables
 * the edit mode.
 *
 * @param windowControl
 * @param ureq
 * @param courseConfig use the glossary configuration from the given course
 *          configuration
 * @param hasGlossaryEditRights
 * @return
 */
public static GlossaryMainController createCourseGlossaryMainRunController(WindowControl lwControl, UserRequest lureq, CourseConfig cc, boolean hasGlossaryRights) {
    if (cc.hasGlossary()) {
        RepositoryEntry repoEntry = RepositoryManager.getInstance().lookupRepositoryEntryBySoftkey(cc.getGlossarySoftKey(), false);
        if (repoEntry == null) {
            // seems to be removed
            return null;
        }
        RepositoryService repositoryService = CoreSpringFactory.getImpl(RepositoryService.class);
        boolean owner = repositoryService.hasRole(lureq.getIdentity(), repoEntry, GroupRoles.owner.name());
        VFSContainer glossaryFolder = GlossaryManager.getInstance().getGlossaryRootFolder(repoEntry.getOlatResource());
        Properties glossProps = GlossaryItemManager.getInstance().getGlossaryConfig(glossaryFolder);
        boolean editUsersEnabled = "true".equals(glossProps.getProperty(GlossaryItemManager.EDIT_USERS));
        GlossarySecurityCallback secCallback;
        if (lureq.getUserSession().getRoles().isGuestOnly()) {
            secCallback = new GlossarySecurityCallbackImpl();
        } else {
            secCallback = new GlossarySecurityCallbackImpl(hasGlossaryRights, owner, editUsersEnabled, lureq.getIdentity().getKey());
        }
        return new GlossaryMainController(lwControl, lureq, glossaryFolder, repoEntry.getOlatResource(), secCallback, true);
    }
    return null;
}
Also used : GlossarySecurityCallback(org.olat.core.commons.modules.glossary.GlossarySecurityCallback) GlossaryMainController(org.olat.core.commons.modules.glossary.GlossaryMainController) GlossarySecurityCallbackImpl(org.olat.core.commons.modules.glossary.GlossarySecurityCallbackImpl) VFSContainer(org.olat.core.util.vfs.VFSContainer) RepositoryEntry(org.olat.repository.RepositoryEntry) Properties(java.util.Properties) RepositoryService(org.olat.repository.RepositoryService)

Example 2 with GlossarySecurityCallback

use of org.olat.core.commons.modules.glossary.GlossarySecurityCallback in project openolat by klemens.

the class CourseGlossaryFactory method createCourseGlossaryMainRunController.

/**
 * The glossarymaincontroller allows browsing in the glossary. A flag enables
 * the edit mode.
 *
 * @param windowControl
 * @param ureq
 * @param courseConfig use the glossary configuration from the given course
 *          configuration
 * @param hasGlossaryEditRights
 * @return
 */
public static GlossaryMainController createCourseGlossaryMainRunController(WindowControl lwControl, UserRequest lureq, CourseConfig cc, boolean hasGlossaryRights) {
    if (cc.hasGlossary()) {
        RepositoryEntry repoEntry = RepositoryManager.getInstance().lookupRepositoryEntryBySoftkey(cc.getGlossarySoftKey(), false);
        if (repoEntry == null) {
            // seems to be removed
            return null;
        }
        RepositoryService repositoryService = CoreSpringFactory.getImpl(RepositoryService.class);
        boolean owner = repositoryService.hasRole(lureq.getIdentity(), repoEntry, GroupRoles.owner.name());
        VFSContainer glossaryFolder = GlossaryManager.getInstance().getGlossaryRootFolder(repoEntry.getOlatResource());
        Properties glossProps = GlossaryItemManager.getInstance().getGlossaryConfig(glossaryFolder);
        boolean editUsersEnabled = "true".equals(glossProps.getProperty(GlossaryItemManager.EDIT_USERS));
        GlossarySecurityCallback secCallback;
        if (lureq.getUserSession().getRoles().isGuestOnly()) {
            secCallback = new GlossarySecurityCallbackImpl();
        } else {
            secCallback = new GlossarySecurityCallbackImpl(hasGlossaryRights, owner, editUsersEnabled, lureq.getIdentity().getKey());
        }
        return new GlossaryMainController(lwControl, lureq, glossaryFolder, repoEntry.getOlatResource(), secCallback, true);
    }
    return null;
}
Also used : GlossarySecurityCallback(org.olat.core.commons.modules.glossary.GlossarySecurityCallback) GlossaryMainController(org.olat.core.commons.modules.glossary.GlossaryMainController) GlossarySecurityCallbackImpl(org.olat.core.commons.modules.glossary.GlossarySecurityCallbackImpl) VFSContainer(org.olat.core.util.vfs.VFSContainer) RepositoryEntry(org.olat.repository.RepositoryEntry) Properties(java.util.Properties) RepositoryService(org.olat.repository.RepositoryService)

Example 3 with GlossarySecurityCallback

use of org.olat.core.commons.modules.glossary.GlossarySecurityCallback in project OpenOLAT by OpenOLAT.

the class GlossaryHandler method createEditorController.

@Override
public Controller createEditorController(RepositoryEntry re, UserRequest ureq, WindowControl wControl, TooledStackedPanel toolbar) {
    VFSContainer glossaryFolder = GlossaryManager.getInstance().getGlossaryRootFolder(re.getOlatResource());
    Properties glossProps = GlossaryItemManager.getInstance().getGlossaryConfig(glossaryFolder);
    boolean editableByUser = "true".equals(glossProps.getProperty(GlossaryItemManager.EDIT_USERS));
    GlossarySecurityCallback secCallback;
    if (ureq.getUserSession().getRoles().isGuestOnly()) {
        secCallback = new GlossarySecurityCallbackImpl();
    } else {
        secCallback = new GlossarySecurityCallbackImpl(true, true, editableByUser, ureq.getIdentity().getKey());
    }
    GlossaryMainController gctr = new GlossaryMainController(wControl, ureq, glossaryFolder, re.getOlatResource(), secCallback, false);
    // use on column layout
    LayoutMain3ColsController layoutCtr = new LayoutMain3ColsController(ureq, wControl, gctr);
    // dispose content on layout dispose
    layoutCtr.addDisposableChildController(gctr);
    return layoutCtr;
}
Also used : GlossarySecurityCallback(org.olat.core.commons.modules.glossary.GlossarySecurityCallback) GlossaryMainController(org.olat.core.commons.modules.glossary.GlossaryMainController) GlossarySecurityCallbackImpl(org.olat.core.commons.modules.glossary.GlossarySecurityCallbackImpl) VFSContainer(org.olat.core.util.vfs.VFSContainer) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) Properties(java.util.Properties)

Example 4 with GlossarySecurityCallback

use of org.olat.core.commons.modules.glossary.GlossarySecurityCallback in project openolat by klemens.

the class GlossaryHandler method createEditorController.

@Override
public Controller createEditorController(RepositoryEntry re, UserRequest ureq, WindowControl wControl, TooledStackedPanel toolbar) {
    VFSContainer glossaryFolder = GlossaryManager.getInstance().getGlossaryRootFolder(re.getOlatResource());
    Properties glossProps = GlossaryItemManager.getInstance().getGlossaryConfig(glossaryFolder);
    boolean editableByUser = "true".equals(glossProps.getProperty(GlossaryItemManager.EDIT_USERS));
    GlossarySecurityCallback secCallback;
    if (ureq.getUserSession().getRoles().isGuestOnly()) {
        secCallback = new GlossarySecurityCallbackImpl();
    } else {
        secCallback = new GlossarySecurityCallbackImpl(true, true, editableByUser, ureq.getIdentity().getKey());
    }
    GlossaryMainController gctr = new GlossaryMainController(wControl, ureq, glossaryFolder, re.getOlatResource(), secCallback, false);
    // use on column layout
    LayoutMain3ColsController layoutCtr = new LayoutMain3ColsController(ureq, wControl, gctr);
    // dispose content on layout dispose
    layoutCtr.addDisposableChildController(gctr);
    return layoutCtr;
}
Also used : GlossarySecurityCallback(org.olat.core.commons.modules.glossary.GlossarySecurityCallback) GlossaryMainController(org.olat.core.commons.modules.glossary.GlossaryMainController) GlossarySecurityCallbackImpl(org.olat.core.commons.modules.glossary.GlossarySecurityCallbackImpl) VFSContainer(org.olat.core.util.vfs.VFSContainer) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) Properties(java.util.Properties)

Aggregations

Properties (java.util.Properties)4 GlossaryMainController (org.olat.core.commons.modules.glossary.GlossaryMainController)4 GlossarySecurityCallback (org.olat.core.commons.modules.glossary.GlossarySecurityCallback)4 GlossarySecurityCallbackImpl (org.olat.core.commons.modules.glossary.GlossarySecurityCallbackImpl)4 VFSContainer (org.olat.core.util.vfs.VFSContainer)4 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)2 RepositoryEntry (org.olat.repository.RepositoryEntry)2 RepositoryService (org.olat.repository.RepositoryService)2