Search in sources :

Example 66 with ContextEntry

use of org.olat.core.id.context.ContextEntry in project openolat by klemens.

the class WikiHandler method createLaunchController.

@Override
public MainLayoutController createLaunchController(RepositoryEntry re, RepositoryEntrySecurity reSecurity, UserRequest ureq, WindowControl wControl) {
    // first handle special case: disabled wiki for security (XSS Attacks) reasons
    BaseSecurityModule securityModule = CoreSpringFactory.getImpl(BaseSecurityModule.class);
    if (!securityModule.isWikiEnabled()) {
        return RepositoyUIFactory.createRepoEntryDisabledDueToSecurityMessageController(ureq, wControl);
    }
    // check role
    boolean isOLatAdmin = ureq.getUserSession().getRoles().isOLATAdmin();
    boolean isGuestOnly = ureq.getUserSession().getRoles().isGuestOnly();
    boolean isResourceOwner = false;
    if (isOLatAdmin) {
        isResourceOwner = true;
    } else {
        isResourceOwner = reSecurity.isOwner();
    }
    OLATResource res = re.getOlatResource();
    BusinessControl bc = wControl.getBusinessControl();
    final ContextEntry ce = bc.popLauncherContextEntry();
    SubscriptionContext subsContext = new SubscriptionContext(res, WikiManager.WIKI_RESOURCE_FOLDER_NAME);
    final WikiSecurityCallback callback = new WikiSecurityCallbackImpl(null, isOLatAdmin, isGuestOnly, false, isResourceOwner, subsContext);
    RepositoryEntryRuntimeController runtime = new RepositoryEntryRuntimeController(ureq, wControl, re, reSecurity, new RuntimeControllerCreator() {

        @Override
        public Controller create(UserRequest uureq, WindowControl wwControl, TooledStackedPanel toolbarPanel, RepositoryEntry entry, RepositoryEntrySecurity security, AssessmentMode assessmentMode) {
            CoreSpringFactory.getImpl(UserCourseInformationsManager.class).updateUserCourseInformations(entry.getOlatResource(), uureq.getIdentity());
            Controller controller;
            if (ce != null) {
                // jump to a certain context
                OLATResourceable ores = ce.getOLATResourceable();
                String typeName = ores.getResourceableTypeName();
                String page = typeName.substring("page=".length());
                controller = new WikiMainController(uureq, wwControl, entry.getOlatResource(), callback, page);
            } else {
                controller = new WikiMainController(uureq, wwControl, entry.getOlatResource(), callback, null);
            }
            return new OLATResourceableListeningWrapperController(uureq, wwControl, entry.getOlatResource(), controller, null, uureq.getIdentity());
        }
    });
    return runtime;
}
Also used : TooledStackedPanel(org.olat.core.gui.components.stack.TooledStackedPanel) AssessmentMode(org.olat.course.assessment.AssessmentMode) OLATResourceable(org.olat.core.id.OLATResourceable) WikiMainController(org.olat.modules.wiki.WikiMainController) BusinessControl(org.olat.core.id.context.BusinessControl) BaseSecurityModule(org.olat.basesecurity.BaseSecurityModule) OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry) WindowControl(org.olat.core.gui.control.WindowControl) OLATResourceableListeningWrapperController(org.olat.core.util.controller.OLATResourceableListeningWrapperController) StepsMainRunController(org.olat.core.gui.control.generic.wizard.StepsMainRunController) MainLayoutController(org.olat.core.gui.control.generic.layout.MainLayoutController) RepositoryEntryRuntimeController(org.olat.repository.ui.RepositoryEntryRuntimeController) Controller(org.olat.core.gui.control.Controller) WikiMainController(org.olat.modules.wiki.WikiMainController) ContextEntry(org.olat.core.id.context.ContextEntry) RepositoryEntryRuntimeController(org.olat.repository.ui.RepositoryEntryRuntimeController) RuntimeControllerCreator(org.olat.repository.ui.RepositoryEntryRuntimeController.RuntimeControllerCreator) WikiSecurityCallbackImpl(org.olat.modules.wiki.WikiSecurityCallbackImpl) RepositoryEntrySecurity(org.olat.repository.model.RepositoryEntrySecurity) OLATResourceableListeningWrapperController(org.olat.core.util.controller.OLATResourceableListeningWrapperController) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) WikiSecurityCallback(org.olat.modules.wiki.WikiSecurityCallback) UserRequest(org.olat.core.gui.UserRequest)

Example 67 with ContextEntry

use of org.olat.core.id.context.ContextEntry in project openolat by klemens.

the class OverviewRepositoryListController method activate.

@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
    if (entries == null || entries.isEmpty()) {
        if (currentCtrl == null) {
            if (isGuestOnly) {
                doOpenMyCourses(ureq);
                segmentView.select(myCourseLink);
            } else {
                boolean markEmpty = doOpenMark(ureq).isEmpty();
                if (markEmpty) {
                    doOpenMyCourses(ureq);
                    segmentView.select(myCourseLink);
                } else {
                    segmentView.select(favoriteLink);
                }
            }
        }
        if (favoritDirty && markedCtrl != null) {
            markedCtrl.reloadRows();
        }
        if (myDirty && myCoursesCtrl != null) {
            myCoursesCtrl.reloadRows();
        }
        addToHistory(ureq, this);
    } else {
        ContextEntry entry = entries.get(0);
        String segment = entry.getOLATResourceable().getResourceableTypeName();
        List<ContextEntry> subEntries = entries.subList(1, entries.size());
        if ("Favorits".equalsIgnoreCase(segment)) {
            if (isGuestOnly) {
                doOpenMyCourses(ureq).activate(ureq, subEntries, entry.getTransientState());
                segmentView.select(myCourseLink);
            } else {
                doOpenMark(ureq).activate(ureq, subEntries, entry.getTransientState());
                segmentView.select(favoriteLink);
            }
        } else if ("My".equalsIgnoreCase(segment)) {
            doOpenMyCourses(ureq).activate(ureq, subEntries, entry.getTransientState());
            segmentView.select(myCourseLink);
        } else if (("Catalog".equalsIgnoreCase(segment) || "CatalogEntry".equalsIgnoreCase(segment)) && catalogLink != null) {
            CatalogNodeController ctrl = doOpenCatalog(ureq);
            if (ctrl != null) {
                ctrl.activate(ureq, entries, entry.getTransientState());
                segmentView.select(catalogLink);
            }
        } else if ("Search".equalsIgnoreCase(segment) && searchCourseLink != null) {
            doOpenSearchCourses(ureq).activate(ureq, subEntries, entry.getTransientState());
            segmentView.select(searchCourseLink);
        } else if ("Closed".equalsIgnoreCase(segment) && closedCourseLink != null) {
            doOpenClosedCourses(ureq).activate(ureq, subEntries, entry.getTransientState());
            segmentView.select(closedCourseLink);
        } else {
            // default if the others fail
            doOpenMyCourses(ureq).activate(ureq, subEntries, entry.getTransientState());
            segmentView.select(myCourseLink);
        }
    }
}
Also used : ContextEntry(org.olat.core.id.context.ContextEntry) CatalogNodeController(org.olat.repository.ui.catalog.CatalogNodeController)

Example 68 with ContextEntry

use of org.olat.core.id.context.ContextEntry in project openolat by klemens.

the class CatalogManagerController method activate.

@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
    if (entries == null || entries.isEmpty())
        return;
    ContextEntry entry = entries.get(0);
    String type = entry.getOLATResourceable().getResourceableTypeName();
    if ("CatalogEntry".equalsIgnoreCase(type)) {
        Long entryKey = entry.getOLATResourceable().getResourceableId();
        if (entryKey != null && entryKey.longValue() > 0) {
            List<ContextEntry> parentLine = new ArrayList<>();
            for (CatalogEntry node = catalogManager.getCatalogEntryByKey(entryKey); node != null && node.getParent() != null; node = node.getParent()) {
                OLATResourceable nodeRes = OresHelper.createOLATResourceableInstance("Node", node.getKey());
                ContextEntry ctxEntry = BusinessControlFactory.getInstance().createContextEntry(nodeRes);
                ctxEntry.setTransientState(new CatalogStateEntry(node));
                parentLine.add(ctxEntry);
            }
            Collections.reverse(parentLine);
            toolbarPanel.popUpToRootController(ureq);
            catalogCtrl.activate(ureq, parentLine, null);
        }
    }
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) ArrayList(java.util.ArrayList) CatalogEntry(org.olat.repository.CatalogEntry) ContextEntry(org.olat.core.id.context.ContextEntry)

Example 69 with ContextEntry

use of org.olat.core.id.context.ContextEntry in project openolat by klemens.

the class CatalogNodeController method activate.

@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
    if (entries == null || entries.isEmpty()) {
        return;
    }
    ContextEntry entry = entries.get(0);
    String type = entry.getOLATResourceable().getResourceableTypeName();
    if ("CatalogEntry".equalsIgnoreCase(type)) {
        Long entryKey = entry.getOLATResourceable().getResourceableId();
        if (entryKey != null && entryKey.longValue() > 0) {
            activateRoot(ureq, entryKey);
        }
    } else if ("Node".equalsIgnoreCase(type)) {
        // the "Node" is only for internal usage
        StateEntry stateEntry = entry.getTransientState();
        if (stateEntry instanceof CatalogStateEntry) {
            CatalogEntry catalogEntry = ((CatalogStateEntry) stateEntry).getEntry();
            CatalogNodeController nextCtrl = selectCatalogEntry(ureq, catalogEntry);
            if (nextCtrl != null && entries.size() > 1) {
                nextCtrl.activate(ureq, entries.subList(1, entries.size()), null);
            }
        }
    }
}
Also used : StateEntry(org.olat.core.id.context.StateEntry) CatalogEntry(org.olat.repository.CatalogEntry) ContextEntry(org.olat.core.id.context.ContextEntry)

Example 70 with ContextEntry

use of org.olat.core.id.context.ContextEntry in project openolat by klemens.

the class CatalogNodeManagerController method activateRoot.

/**
 * Build an internal business path made of "Node" with the category
 * as state entry to prevent loading several times the same entries.
 *
 * @param ureq
 * @param entryKey
 */
private void activateRoot(UserRequest ureq, Long entryKey) {
    List<ContextEntry> parentLine = new ArrayList<>();
    for (CatalogEntry node = catalogManager.getCatalogEntryByKey(entryKey); node.getParent() != null; node = node.getParent()) {
        OLATResourceable nodeRes = OresHelper.createOLATResourceableInstance("Node", node.getKey());
        ContextEntry ctxEntry = BusinessControlFactory.getInstance().createContextEntry(nodeRes);
        ctxEntry.setTransientState(new CatalogStateEntry(node));
        parentLine.add(ctxEntry);
    }
    Collections.reverse(parentLine);
    activate(ureq, parentLine, null);
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) ArrayList(java.util.ArrayList) CatalogEntry(org.olat.repository.CatalogEntry) ContextEntry(org.olat.core.id.context.ContextEntry)

Aggregations

ContextEntry (org.olat.core.id.context.ContextEntry)270 OLATResourceable (org.olat.core.id.OLATResourceable)78 WindowControl (org.olat.core.gui.control.WindowControl)58 Activateable2 (org.olat.core.gui.control.generic.dtabs.Activateable2)44 ArrayList (java.util.ArrayList)42 TreeNode (org.olat.core.gui.components.tree.TreeNode)30 Controller (org.olat.core.gui.control.Controller)26 RepositoryEntry (org.olat.repository.RepositoryEntry)24 List (java.util.List)22 Identity (org.olat.core.id.Identity)22 BusinessControl (org.olat.core.id.context.BusinessControl)22 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)20 BusinessControlFactory (org.olat.core.id.context.BusinessControlFactory)18 HistoryPoint (org.olat.core.id.context.HistoryPoint)18 CollaborationTools (org.olat.collaboration.CollaborationTools)16 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)14 UserSession (org.olat.core.util.UserSession)14 CourseNode (org.olat.course.nodes.CourseNode)14 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)12 Translator (org.olat.core.gui.translator.Translator)12