Search in sources :

Example 51 with ChiefController

use of org.olat.core.gui.control.ChiefController in project openolat by klemens.

the class LayoutMain3ColsController method setAsFullscreen.

public void setAsFullscreen(UserRequest ureq) {
    ChiefController cc = getWindowControl().getWindowBackOffice().getChiefController();
    if (cc != null) {
        thebaseChief = cc;
        thebaseChief.getScreenMode().setMode(Mode.full);
    } else {
        Windows.getWindows(ureq).setFullScreen(Boolean.TRUE);
    }
    fullScreen = true;
}
Also used : ChiefController(org.olat.core.gui.control.ChiefController)

Example 52 with ChiefController

use of org.olat.core.gui.control.ChiefController in project openolat by klemens.

the class IsAssessmentModeFunction method call.

/**
 * @see com.neemsoft.jmep.FunctionCB#call(java.lang.Object[])
 */
@Override
public Object call(Object[] inStack) {
    /*
		 * expression check only if cev != null
		 */
    CourseEditorEnv cev = getUserCourseEnv().getCourseEditorEnv();
    if (cev != null) {
        // return a valid value to continue with condition evaluation test
        return defaultValue();
    }
    WindowControl wControl = getUserCourseEnv().getWindowControl();
    if (wControl == null) {
        return ConditionInterpreter.INT_FALSE;
    }
    ChiefController chiefController = wControl.getWindowBackOffice().getChiefController();
    if (chiefController == null) {
        return ConditionInterpreter.INT_FALSE;
    }
    OLATResourceable lockedResource = chiefController.getLockResource();
    if (lockedResource == null) {
        return ConditionInterpreter.INT_FALSE;
    }
    Long resourceableId = getUserCourseEnv().getCourseEnvironment().getCourseResourceableId();
    if (lockedResource.getResourceableId().equals(resourceableId)) {
        RepositoryEntry entry = getUserCourseEnv().getCourseEnvironment().getCourseGroupManager().getCourseEntry();
        AssessmentModeManager assessmentModeMgr = CoreSpringFactory.getImpl(AssessmentModeManager.class);
        boolean inAssessment = assessmentModeMgr.isInAssessmentMode(entry, new Date());
        return inAssessment ? ConditionInterpreter.INT_TRUE : ConditionInterpreter.INT_FALSE;
    } else {
        return ConditionInterpreter.INT_FALSE;
    }
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) CourseEditorEnv(org.olat.course.editor.CourseEditorEnv) ChiefController(org.olat.core.gui.control.ChiefController) RepositoryEntry(org.olat.repository.RepositoryEntry) WindowControl(org.olat.core.gui.control.WindowControl) AssessmentModeManager(org.olat.course.assessment.AssessmentModeManager) Date(java.util.Date)

Example 53 with ChiefController

use of org.olat.core.gui.control.ChiefController in project openolat by klemens.

the class QTI21AssessmentMainLayoutController method setAsFullscreen.

public void setAsFullscreen(UserRequest ureq) {
    ChiefController cc = getWindowControl().getWindowBackOffice().getChiefController();
    if (cc != null) {
        thebaseChief = cc;
        thebaseChief.getScreenMode().setMode(Mode.full);
    } else {
        Windows.getWindows(ureq).setFullScreen(Boolean.TRUE);
    }
    fullScreen = true;
}
Also used : ChiefController(org.olat.core.gui.control.ChiefController)

Example 54 with ChiefController

use of org.olat.core.gui.control.ChiefController in project openolat by klemens.

the class ValidatingVisitor method doDispatchToComponent.

/**
 * @param ureq
 * @return true if the event was indeed dispatched to the component, false
 *         otherwise (reasons: no component found with given id, or component
 *         disabled)
 */
private DispatchResult doDispatchToComponent(UserRequest ureq, StringBuilder debugMsg) {
    String s_compID = ureq.getComponentID();
    if (s_compID == null) {
        return NO_DISPATCHRESULT;
    }
    List<Component> foundPath = new ArrayList<Component>(10);
    // OLAT-1973
    Component target = ComponentHelper.findDescendantOrSelfByID(getContentPane(), s_compID, foundPath);
    if (target == null) {
        // there was a component id given, but no matching target could be found
        fireEvent(ureq, COMPONENTNOTFOUND);
        return NO_DISPATCHRESULT;
    // do not dispatch; which means just rerender later; good if
    // the
    // gui tree was changed by another thread in the meantime.
    // do not throw an exception here, because this can happen if the gui
    // tree was changed by another thread in the meantime
    }
    if (!target.isVisible()) {
        throw new OLATRuntimeException(Window.class, "target with name: '" + target.getComponentName() + "', was invisible, but called to dispatch", null);
    }
    boolean toDispatch = true;
    boolean incTimestamp = false;
    for (Iterator<Component> iter = foundPath.iterator(); iter.hasNext(); ) {
        Component curComp = iter.next();
        if (!curComp.isEnabled()) {
            toDispatch = false;
            break;
        }
    }
    if (toDispatch) {
        latestDispatchComponentInfo = target.getComponentName() + " :" + target.getExtendedDebugInfo();
        latestDispatchedComp = target;
        // dispatch
        wbackofficeImpl.fireCycleEvent(Window.ABOUT_TO_DISPATCH);
        target.dispatchRequest(ureq);
        List<Component> ancestors = ComponentHelper.findAncestorsOrSelfByID(getContentPane(), target);
        for (Component ancestor : ancestors) {
            incTimestamp |= ancestor.isSilentlyDynamicalCmp();
        }
        // after dispatching, commit (docu)
        DBFactory.getInstance().commit();
        // add the new URL to the browser history, but not if the klick resulted in a new browser window (a href .. target=...) or in a download (excel or such)
        wbackofficeImpl.fireCycleEvent(END_OF_DISPATCH_CYCLE);
        // if loglevel is set accordingly, collect anonymous controller usage statistics.
        if (debugMsg != null) {
            appendDispatchDebugInfos(target, debugMsg);
        } else {
            // no debug level, consume the left over event (for minor memory reasons)
            target.getAndClearLatestFiredEvent();
        }
        // we do not want to keep a reference which could be old.
        // in case we do not reach the next line because of an exception in dispatch(), we clear the value in the exceptionwindowcontroller's error handling
        latestDispatchedComp = null;
    }
    ChiefController chief = wbackofficeImpl.getChiefController();
    boolean reload = chief == null ? false : chief.wishReload(ureq, true);
    return new DispatchResult(toDispatch, incTimestamp, reload);
}
Also used : OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) ArrayList(java.util.ArrayList) ChiefController(org.olat.core.gui.control.ChiefController)

Example 55 with ChiefController

use of org.olat.core.gui.control.ChiefController in project openolat by klemens.

the class RemoteLoginformDispatcher method execute.

/**
 * Tries to login the user with the parameters from the POST request and
 * redirects to the home screen in case of success. In case of failure,
 * redirects to the login screen.
 *
 * @param request
 * @param response
 * @param uriPrefix
 */
@Override
public void execute(HttpServletRequest request, HttpServletResponse response) {
    UserRequest ureq = null;
    try {
        String uriPrefix = DispatcherModule.getLegacyUriPrefix(request);
        ureq = new UserRequestImpl(uriPrefix, request, response);
        if (!request.getMethod().equals(METHOD_POST)) {
            log.warn("Wrong HTTP method, only POST allowed, but current method::" + request.getMethod());
            DispatcherModule.redirectToDefaultDispatcher(response);
            return;
        }
        String userName = ureq.getParameter(PARAM_USERNAME);
        if (!StringHelper.containsNonWhitespace(userName)) {
            log.warn("Missing username parameter, use '" + PARAM_USERNAME + "' to submit the login name");
            DispatcherModule.redirectToDefaultDispatcher(response);
            return;
        }
        String pwd = ureq.getParameter(PARAM_PASSWORD);
        if (!StringHelper.containsNonWhitespace(pwd)) {
            log.warn("Missing password parameter, use '" + PARAM_PASSWORD + "' to submit the password");
            DispatcherModule.redirectToDefaultDispatcher(response);
            return;
        }
        // Authenticate user
        OLATAuthManager olatAuthenticationSpi = CoreSpringFactory.getImpl(OLATAuthManager.class);
        Identity identity = olatAuthenticationSpi.authenticate(null, userName, pwd);
        if (identity == null) {
            log.info("Could not authenticate user '" + userName + "', wrong password or user name");
            // redirect to OLAT loginscreen, add error parameter so that the loginform can mark itself as errorfull
            String loginUrl = WebappHelper.getServletContextPath() + DispatcherModule.getPathDefault() + "?" + OLATAuthenticationController.PARAM_LOGINERROR + "=true";
            DispatcherModule.redirectTo(response, loginUrl);
            return;
        }
        UserSession usess = ureq.getUserSession();
        // re-init the activity logger to pass the user session and identity
        ThreadLocalUserActivityLoggerInstaller.initUserActivityLogger(request);
        // sync over the UserSession Instance to prevent double logins
        synchronized (usess) {
            // Login user, set up everything
            int loginStatus = AuthHelper.doLogin(identity, BaseSecurityModule.getDefaultAuthProviderIdentifier(), ureq);
            if (loginStatus == AuthHelper.LOGIN_OK) {
                // redirect to authenticated environment
                UserDeletionManager.getInstance().setIdentityAsActiv(identity);
                final String origUri = request.getRequestURI();
                String restPart = origUri.substring(uriPrefix.length());
                if (request.getParameter("redirect") != null) {
                    // redirect parameter like: /olat/url/RepositoryEntry/917504/CourseNode/81254724902921
                    String redirect = request.getParameter("redirect");
                    DispatcherModule.redirectTo(response, redirect);
                } else if (StringHelper.containsNonWhitespace(restPart)) {
                    // redirect like: http://www.frentix.com/olat/remotelogin/RepositoryEntry/917504/CourseNode/81254724902921
                    try {
                        restPart = URLDecoder.decode(restPart, "UTF8");
                    } catch (UnsupportedEncodingException e) {
                        log.error("Unsupported encoding", e);
                    }
                    String[] split = restPart.split("/");
                    assert (split.length % 2 == 0);
                    String businessPath = "";
                    for (int i = 0; i < split.length; i = i + 2) {
                        String key = split[i];
                        if (key != null && key.startsWith("path=")) {
                            key = key.replace("~~", "/");
                        }
                        String value = split[i + 1];
                        businessPath += "[" + key + ":" + value + "]";
                    }
                    // UserSession usess = UserSession.getUserSession(request);
                    usess.putEntryInNonClearedStore(AuthenticatedDispatcher.AUTHDISPATCHER_BUSINESSPATH, businessPath);
                    String url = getRedirectToURL(usess);
                    DispatcherModule.redirectTo(response, url);
                } else {
                    // redirect
                    ServletUtil.serveResource(request, response, ureq.getDispatchResult().getResultingMediaResource());
                }
            } else if (loginStatus == AuthHelper.LOGIN_NOTAVAILABLE) {
                DispatcherModule.redirectToServiceNotAvailable(response);
            } else {
                // error, redirect to login screen
                DispatcherModule.redirectToDefaultDispatcher(response);
            }
        }
    } catch (Throwable th) {
        try {
            ChiefController msgcc = MsgFactory.createMessageChiefController(ureq, th);
            // the controller's window must be failsafe also
            msgcc.getWindow().dispatchRequest(ureq, true);
        // do not dispatch (render only), since this is a new Window created as
        // a result of another window's click.
        } catch (Throwable t) {
            log.error("Sorry, can't handle this remote login request....", t);
        }
    }
}
Also used : UserSession(org.olat.core.util.UserSession) OLATAuthManager(org.olat.login.auth.OLATAuthManager) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ChiefController(org.olat.core.gui.control.ChiefController) Identity(org.olat.core.id.Identity) UserRequest(org.olat.core.gui.UserRequest) UserRequestImpl(org.olat.core.gui.UserRequestImpl)

Aggregations

ChiefController (org.olat.core.gui.control.ChiefController)58 UserRequest (org.olat.core.gui.UserRequest)10 UserRequestImpl (org.olat.core.gui.UserRequestImpl)10 IOException (java.io.IOException)8 Window (org.olat.core.gui.components.Window)8 InvalidRequestParameterException (org.olat.core.gui.components.form.flexible.impl.InvalidRequestParameterException)8 WindowControl (org.olat.core.gui.control.WindowControl)8 OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)8 ArrayList (java.util.ArrayList)6 BaseFullWebappController (org.olat.core.commons.fullWebApp.BaseFullWebappController)6 StringOutput (org.olat.core.gui.render.StringOutput)6 URLBuilder (org.olat.core.gui.render.URLBuilder)6 AssertException (org.olat.core.logging.AssertException)6 UserSession (org.olat.core.util.UserSession)6 HttpSession (javax.servlet.http.HttpSession)4 BaseFullWebappControllerParts (org.olat.core.commons.fullWebApp.BaseFullWebappControllerParts)4 Windows (org.olat.core.gui.Windows)4 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)4 RedirectMediaResource (org.olat.core.gui.media.RedirectMediaResource)4 ContextEntry (org.olat.core.id.context.ContextEntry)4