Search in sources :

Example 1 with GlossaryMainController

use of org.olat.core.commons.modules.glossary.GlossaryMainController 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 GlossaryMainController

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

the class CourseRuntimeController method launchGlossary.

private void launchGlossary(UserRequest ureq) {
    // start glossary in window
    ICourse course = CourseFactory.loadCourse(getRepositoryEntry());
    // do not cache cc, not save
    final CourseConfig cc = course.getCourseConfig();
    final boolean allowGlossaryEditing = reSecurity.isEntryAdmin() || hasCourseRight(CourseRights.RIGHT_GLOSSARY);
    // if glossary had been opened from LR as Tab before, warn user:
    DTabs dts = Windows.getWindows(ureq).getWindow(ureq).getDTabs();
    RepositoryEntry repoEntry = RepositoryManager.getInstance().lookupRepositoryEntryBySoftkey(cc.getGlossarySoftKey(), false);
    DTab dt = dts.getDTab(repoEntry.getOlatResource());
    if (dt != null) {
        List<ContextEntry> entries = BusinessControlFactory.getInstance().createCEListFromResourceType(allowGlossaryEditing ? "true" : "false");
        dts.activate(ureq, dt, entries);
    } else {
        ControllerCreator ctrlCreator = new ControllerCreator() {

            public Controller createController(UserRequest lureq, WindowControl lwControl) {
                GlossaryMainController glossaryController = CourseGlossaryFactory.createCourseGlossaryMainRunController(lwControl, lureq, cc, allowGlossaryEditing);
                listenTo(glossaryController);
                if (glossaryController == null) {
                    // happens in the unlikely event of a user who is in a course and
                    // now
                    // tries to access the glossary
                    String text = translate("error.noglossary");
                    return MessageUIFactory.createInfoMessage(lureq, lwControl, null, text);
                } else {
                    // use a one-column main layout
                    LayoutMain3ColsController layoutCtr = new LayoutMain3ColsController(lureq, lwControl, glossaryController);
                    // dispose glossary on layout dispose
                    layoutCtr.addDisposableChildController(glossaryController);
                    return layoutCtr;
                }
            }
        };
        ControllerCreator layoutCtrlr = BaseFullWebappPopupLayoutFactory.createAuthMinimalPopupLayout(ureq, ctrlCreator);
        // open in new browser window
        openInNewBrowserWindow(ureq, layoutCtrlr);
        // immediate return after opening new browser window!
        return;
    }
}
Also used : GlossaryMainController(org.olat.core.commons.modules.glossary.GlossaryMainController) DTabs(org.olat.core.gui.control.generic.dtabs.DTabs) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) WindowControl(org.olat.core.gui.control.WindowControl) ContextEntry(org.olat.core.id.context.ContextEntry) ControllerCreator(org.olat.core.gui.control.creator.ControllerCreator) CourseConfig(org.olat.course.config.CourseConfig) DTab(org.olat.core.gui.control.generic.dtabs.DTab) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) UserRequest(org.olat.core.gui.UserRequest)

Example 3 with GlossaryMainController

use of org.olat.core.commons.modules.glossary.GlossaryMainController 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 4 with GlossaryMainController

use of org.olat.core.commons.modules.glossary.GlossaryMainController 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 5 with GlossaryMainController

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

the class CourseRuntimeController method launchGlossary.

private void launchGlossary(UserRequest ureq) {
    // start glossary in window
    ICourse course = CourseFactory.loadCourse(getRepositoryEntry());
    // do not cache cc, not save
    final CourseConfig cc = course.getCourseConfig();
    final boolean allowGlossaryEditing = reSecurity.isEntryAdmin() || hasCourseRight(CourseRights.RIGHT_GLOSSARY);
    // if glossary had been opened from LR as Tab before, warn user:
    DTabs dts = Windows.getWindows(ureq).getWindow(ureq).getDTabs();
    RepositoryEntry repoEntry = RepositoryManager.getInstance().lookupRepositoryEntryBySoftkey(cc.getGlossarySoftKey(), false);
    DTab dt = dts.getDTab(repoEntry.getOlatResource());
    if (dt != null) {
        List<ContextEntry> entries = BusinessControlFactory.getInstance().createCEListFromResourceType(allowGlossaryEditing ? "true" : "false");
        dts.activate(ureq, dt, entries);
    } else {
        ControllerCreator ctrlCreator = new ControllerCreator() {

            public Controller createController(UserRequest lureq, WindowControl lwControl) {
                GlossaryMainController glossaryController = CourseGlossaryFactory.createCourseGlossaryMainRunController(lwControl, lureq, cc, allowGlossaryEditing);
                listenTo(glossaryController);
                if (glossaryController == null) {
                    // happens in the unlikely event of a user who is in a course and
                    // now
                    // tries to access the glossary
                    String text = translate("error.noglossary");
                    return MessageUIFactory.createInfoMessage(lureq, lwControl, null, text);
                } else {
                    // use a one-column main layout
                    LayoutMain3ColsController layoutCtr = new LayoutMain3ColsController(lureq, lwControl, glossaryController);
                    // dispose glossary on layout dispose
                    layoutCtr.addDisposableChildController(glossaryController);
                    return layoutCtr;
                }
            }
        };
        ControllerCreator layoutCtrlr = BaseFullWebappPopupLayoutFactory.createAuthMinimalPopupLayout(ureq, ctrlCreator);
        // open in new browser window
        openInNewBrowserWindow(ureq, layoutCtrlr);
        // immediate return after opening new browser window!
        return;
    }
}
Also used : GlossaryMainController(org.olat.core.commons.modules.glossary.GlossaryMainController) DTabs(org.olat.core.gui.control.generic.dtabs.DTabs) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) WindowControl(org.olat.core.gui.control.WindowControl) ContextEntry(org.olat.core.id.context.ContextEntry) ControllerCreator(org.olat.core.gui.control.creator.ControllerCreator) CourseConfig(org.olat.course.config.CourseConfig) DTab(org.olat.core.gui.control.generic.dtabs.DTab) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) UserRequest(org.olat.core.gui.UserRequest)

Aggregations

GlossaryMainController (org.olat.core.commons.modules.glossary.GlossaryMainController)6 Properties (java.util.Properties)4 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)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 RepositoryEntry (org.olat.repository.RepositoryEntry)4 UserRequest (org.olat.core.gui.UserRequest)2 WindowControl (org.olat.core.gui.control.WindowControl)2 ControllerCreator (org.olat.core.gui.control.creator.ControllerCreator)2 DTab (org.olat.core.gui.control.generic.dtabs.DTab)2 DTabs (org.olat.core.gui.control.generic.dtabs.DTabs)2 ContextEntry (org.olat.core.id.context.ContextEntry)2 ICourse (org.olat.course.ICourse)2 CourseConfig (org.olat.course.config.CourseConfig)2 RepositoryService (org.olat.repository.RepositoryService)2