Search in sources :

Example 6 with BusinessControl

use of org.olat.core.id.context.BusinessControl in project OpenOLAT by OpenOLAT.

the class OpenMeetingsAdminRoomsController method openResource.

protected void openResource(UserRequest ureq, OpenMeetingsRoom room) {
    OpenMeetingsRoomReference prop = room.getReference();
    if (prop != null) {
        String url;
        if (prop.getGroup() != null) {
            url = "[BusinessGroup:" + prop.getGroup().getKey() + "]";
        } else {
            OLATResourceable ores = OresHelper.createOLATResourceableInstance(prop.getResourceTypeName(), prop.getResourceTypeId());
            RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntry(ores, false);
            if (re != null) {
                url = "[RepositoryEntry:" + re.getKey() + "]";
                if (StringHelper.containsNonWhitespace(prop.getSubIdentifier()) && "CourseModule".equals(ores.getResourceableTypeName())) {
                    url += "[CourseNode:" + prop.getSubIdentifier() + "]";
                }
            } else {
                showWarning("resource.dont.exist");
                return;
            }
        }
        BusinessControl bc = BusinessControlFactory.getInstance().createFromString(url);
        WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(bc, getWindowControl());
        NewControllerFactory.getInstance().launch(ureq, bwControl);
    }
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) OpenMeetingsRoomReference(org.olat.modules.openmeetings.model.OpenMeetingsRoomReference) BusinessControl(org.olat.core.id.context.BusinessControl) RepositoryEntry(org.olat.repository.RepositoryEntry) WindowControl(org.olat.core.gui.control.WindowControl)

Example 7 with BusinessControl

use of org.olat.core.id.context.BusinessControl in project OpenOLAT by OpenOLAT.

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 8 with BusinessControl

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

the class NewControllerFactory method launch.

/**
 * Launch a controller in a tab or site in the given window from a user
 * request url
 *
 * @param ureq
 * @param wControl
 */
public boolean launch(UserRequest ureq, WindowControl wControl) {
    BusinessControl bc = wControl.getBusinessControl();
    ContextEntry mainCe = bc.popLauncherContextEntry();
    if (mainCe == null) {
        // nothing to launch
        return false;
    }
    OLATResourceable ores = mainCe.getOLATResourceable();
    // Check for RepositoryEntry resource
    RepositoryEntry re = null;
    if (ores.getResourceableTypeName().equals(OresHelper.calculateTypeName(RepositoryEntry.class))) {
        if (ores instanceof RepositoryEntry) {
            re = (RepositoryEntry) ores;
            ores = re.getOlatResource();
        } else {
            // It is a repository-entry => get OLATResourceable from RepositoryEntry
            RepositoryManager repom = RepositoryManager.getInstance();
            re = repom.lookupRepositoryEntry(ores.getResourceableId());
            if (re != null) {
                ores = re.getOlatResource();
                mainCe.upgradeOLATResourceable(re);
            }
        }
    }
    // was brasato:: DTabs dts = wControl.getDTabs();
    UserSession usess = ureq.getUserSession();
    Window window = Windows.getWindows(usess).getWindow(ureq);
    if (window == null) {
        log.debug("Found no window for jumpin => take WindowBackOffice", null);
        window = wControl.getWindowBackOffice().getWindow();
    }
    DTabs dts = window.getDTabs();
    String firstType = mainCe.getOLATResourceable().getResourceableTypeName();
    // String firstTypeId = ClassToId.getInstance().lookup() BusinessGroup
    ContextEntryControllerCreator typeHandler = getContextEntryControllerCreator(firstType);
    if (typeHandler == null) {
        log.warn("Cannot found an handler for context entry: " + mainCe, null);
        // simply return and don't throw a red screen
        return false;
    }
    if (!typeHandler.validateContextEntryAndShowError(mainCe, ureq, wControl)) {
        // simply return and don't throw a red screen
        return false;
    }
    List<ContextEntry> entries = new ArrayList<ContextEntry>(5);
    while (bc.hasContextEntry()) {
        entries.add(bc.popLauncherContextEntry());
    }
    List<ContextEntry> ces = new ArrayList<ContextEntry>(entries.size() + 1);
    ces.add(mainCe);
    if (entries.size() > 0) {
        ces.addAll(entries);
    }
    TabContext context = typeHandler.getTabContext(ureq, ores, mainCe, entries);
    String siteClassName = typeHandler.getSiteClassName(ces, ureq);
    // open in existing site
    boolean launched = false;
    boolean assessmentMode = usess.isInAssessmentModeProcess();
    if (siteClassName != null) {
        if (!assessmentMode) {
            dts.activateStatic(ureq, siteClassName, context.getContext());
            launched = true;
        }
    } else if (!assessmentMode || usess.matchLockResource(ores)) {
        // get current tab or create new tab
        DTab dt = dts.getDTab(ores);
        if (dt == null) {
            WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(bc, dts.getWindowControl());
            usess.addToHistory(ureq, bc);
            Controller launchC = typeHandler.createController(ces, ureq, bwControl);
            if (launchC != null) {
                dt = dts.createDTab(context.getTabResource(), re, launchC, context.getName());
                if (dt == null) {
                    launched = false;
                } else if (dts.addDTab(ureq, dt)) {
                    dts.activate(ureq, dt, context.getContext());
                    launched = true;
                }
            }
        } else {
            dts.activate(ureq, dt, context.getContext());
            launched = true;
        }
    }
    return launched;
}
Also used : Window(org.olat.core.gui.components.Window) OLATResourceable(org.olat.core.id.OLATResourceable) ContextEntryControllerCreator(org.olat.core.id.context.ContextEntryControllerCreator) BusinessControl(org.olat.core.id.context.BusinessControl) DTabs(org.olat.core.gui.control.generic.dtabs.DTabs) ArrayList(java.util.ArrayList) RepositoryEntry(org.olat.repository.RepositoryEntry) WindowControl(org.olat.core.gui.control.WindowControl) BaseChiefController(org.olat.core.commons.chiefcontrollers.BaseChiefController) Controller(org.olat.core.gui.control.Controller) ContextEntry(org.olat.core.id.context.ContextEntry) TabContext(org.olat.core.id.context.TabContext) DTab(org.olat.core.gui.control.generic.dtabs.DTab) UserSession(org.olat.core.util.UserSession) RepositoryManager(org.olat.repository.RepositoryManager)

Example 9 with BusinessControl

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

the class NewControllerFactory method launch.

/**
 * Launch a controller in a tab or a site with the business path
 * @param businessPath
 * @param ureq
 * @param origControl
 */
public boolean launch(String businessPath, UserRequest ureq, WindowControl origControl) {
    BusinessControl bc = BusinessControlFactory.getInstance().createFromString(businessPath);
    WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(bc, origControl);
    return launch(ureq, bwControl);
}
Also used : BusinessControl(org.olat.core.id.context.BusinessControl) WindowControl(org.olat.core.gui.control.WindowControl)

Example 10 with BusinessControl

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

the class MembersAvatarDisplayRunController method doOpenHomePage.

private void doOpenHomePage(Member member, UserRequest ureq) {
    String url = "[HomePage:" + member.getKey() + "]";
    BusinessControl bc = BusinessControlFactory.getInstance().createFromString(url);
    WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(bc, getWindowControl());
    NewControllerFactory.getInstance().launch(ureq, bwControl);
}
Also used : BusinessControl(org.olat.core.id.context.BusinessControl) WindowControl(org.olat.core.gui.control.WindowControl)

Aggregations

BusinessControl (org.olat.core.id.context.BusinessControl)80 WindowControl (org.olat.core.gui.control.WindowControl)56 OLATResourceable (org.olat.core.id.OLATResourceable)24 ContextEntry (org.olat.core.id.context.ContextEntry)22 RepositoryEntry (org.olat.repository.RepositoryEntry)16 ArrayList (java.util.ArrayList)14 Controller (org.olat.core.gui.control.Controller)8 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)6 Window (org.olat.core.gui.components.Window)6 HistoryPoint (org.olat.core.id.context.HistoryPoint)6 CourseNode (org.olat.course.nodes.CourseNode)6 Date (java.util.Date)4 UserRequest (org.olat.core.gui.UserRequest)4 DTab (org.olat.core.gui.control.generic.dtabs.DTab)4 DTabs (org.olat.core.gui.control.generic.dtabs.DTabs)4 Identity (org.olat.core.id.Identity)4 Roles (org.olat.core.id.Roles)4 BusinessControlFactory (org.olat.core.id.context.BusinessControlFactory)4 NodeRunConstructionResult (org.olat.course.run.navigation.NodeRunConstructionResult)4 IOException (java.io.IOException)3