Search in sources :

Example 36 with Preferences

use of org.olat.core.util.prefs.Preferences in project openolat by klemens.

the class MSCourseNodeRunController method saveOpenPanel.

private void saveOpenPanel(UserRequest ureq, String panelId, boolean newValue) {
    Preferences guiPrefs = ureq.getUserSession().getGuiPreferences();
    if (guiPrefs != null) {
        guiPrefs.putAndSave(MSCourseNodeRunController.class, getOpenPanelId(panelId), new Boolean(newValue));
    }
    myContent.contextPut("in-" + panelId, new Boolean(newValue));
}
Also used : Preferences(org.olat.core.util.prefs.Preferences)

Example 37 with Preferences

use of org.olat.core.util.prefs.Preferences in project openolat by klemens.

the class OlatTopNavController method loadPersonalTools.

private void loadPersonalTools(UserRequest ureq) {
    List<Tool> toolSetLinksName = new ArrayList<Tool>();
    Preferences prefs = ureq.getUserSession().getGuiPreferences();
    String selectedTools = userToolsModule.getUserTools(prefs);
    if (!StringHelper.containsNonWhitespace(selectedTools)) {
        selectedTools = userToolsModule.getDefaultPresetOfUserTools();
    }
    Set<String> selectedToolSet = new HashSet<>();
    if (StringHelper.containsNonWhitespace(selectedTools)) {
        String[] selectedToolArr = selectedTools.split(",");
        for (String selectedTool : selectedToolArr) {
            selectedToolSet.add(UserToolsModule.stripToolKey(selectedTool));
        }
    }
    List<UserToolExtension> toolExtensions = userToolsModule.getUserToolExtensions(ureq);
    for (UserToolExtension toolExtension : toolExtensions) {
        // check for sites
        if (toolExtension.isShortCutOnly() || selectedToolSet.contains(toolExtension.getUniqueExtensionID())) {
            UserTool tool = toolExtension.createUserTool(ureq, getWindowControl(), getLocale());
            if (tool != null) {
                Component cmp = tool.getMenuComponent(ureq, topNavVC);
                String cssId = toolExtension.getShortCutCssId();
                String cssClass = toolExtension.getShortCutCssClass();
                toolSetLinksName.add(new Tool(cssId, cssClass, cmp.getComponentName()));
                disposableTools.add(tool);
            }
        }
    }
    topNavVC.contextPut("toolSet", toolSetLinksName);
}
Also used : UserToolExtension(org.olat.admin.user.tools.UserToolExtension) ArrayList(java.util.ArrayList) UserTool(org.olat.admin.user.tools.UserTool) Preferences(org.olat.core.util.prefs.Preferences) Component(org.olat.core.gui.components.Component) UserTool(org.olat.admin.user.tools.UserTool) HashSet(java.util.HashSet)

Example 38 with Preferences

use of org.olat.core.util.prefs.Preferences in project openolat by klemens.

the class UserToolsMenuController method loadPersonalTools.

private void loadPersonalTools(UserRequest ureq) {
    List<String> linksName = new ArrayList<>();
    List<String> configLinksName = new ArrayList<>();
    List<String> searchLinksName = new ArrayList<>();
    List<String> systemLinksName = new ArrayList<>();
    Preferences prefs = ureq.getUserSession().getGuiPreferences();
    String selectedTools = userToolsModule.getUserTools(prefs);
    if (!StringHelper.containsNonWhitespace(selectedTools)) {
        selectedTools = userToolsModule.getDefaultPresetOfUserTools();
    }
    Set<String> selectedToolSet = new HashSet<>();
    if (StringHelper.containsNonWhitespace(selectedTools)) {
        String[] selectedToolArr = selectedTools.split(",");
        for (String selectedTool : selectedToolArr) {
            selectedToolSet.add(UserToolsModule.stripToolKey(selectedTool));
        }
    }
    List<UserToolExtension> toolExtensions = userToolsModule.getUserToolExtensions(ureq);
    for (UserToolExtension toolExtension : toolExtensions) {
        // check for sites
        UserTool tool = toolExtension.createUserTool(ureq, getWindowControl(), getLocale());
        if (tool != null) {
            UserToolCategory category = toolExtension.getUserToolCategory();
            boolean shortCutOnly = toolExtension.isShortCutOnly();
            if (!shortCutOnly && !selectedToolSet.contains(toolExtension.getUniqueExtensionID())) {
                Component link = tool.getMenuComponent(ureq, menuVC);
                String linkName = link.getComponentName();
                switch(category) {
                    case search:
                        searchLinksName.add(linkName);
                        break;
                    case personal:
                        linksName.add(linkName);
                        break;
                    case config:
                        configLinksName.add(linkName);
                        break;
                    case system:
                        systemLinksName.add(linkName);
                        break;
                }
                disposableTools.add(tool);
            }
        }
    }
    menuVC.contextPut("personalTools", linksName);
    menuVC.contextPut("configs", configLinksName);
    menuVC.contextPut("systems", systemLinksName);
    menuVC.contextPut("searchs", searchLinksName);
    menuVC.contextPut("locked", Boolean.FALSE);
}
Also used : UserToolCategory(org.olat.admin.user.tools.UserToolCategory) UserToolExtension(org.olat.admin.user.tools.UserToolExtension) ArrayList(java.util.ArrayList) UserTool(org.olat.admin.user.tools.UserTool) Preferences(org.olat.core.util.prefs.Preferences) Component(org.olat.core.gui.components.Component) HashSet(java.util.HashSet)

Example 39 with Preferences

use of org.olat.core.util.prefs.Preferences in project openolat by klemens.

the class ResumeController method savePreferences.

private void savePreferences(UserRequest ureq, String val) {
    // check if checkbox (dont askagain) is checked
    if (askagainCheckbox.isSelected(0)) {
        Preferences prefs = ureq.getUserSession().getGuiPreferences();
        prefs.put(WindowManager.class, "resume-prefs", val);
        prefs.save();
    }
}
Also used : Preferences(org.olat.core.util.prefs.Preferences)

Example 40 with Preferences

use of org.olat.core.util.prefs.Preferences in project openolat by klemens.

the class ResumeSessionController method isResumeInteractionRequired.

private Redirect isResumeInteractionRequired(UserRequest ureq) {
    UserSession usess = ureq.getUserSession();
    Redirect option;
    if (isREST(ureq)) {
        String url = getRESTRedirectURL(ureq);
        option = new Redirect(url);
    } else if (!historyModule.isResumeEnabled()) {
        String url = toUrl(getLandingBC(ureq));
        option = new Redirect(url);
    } else if (usess.getRoles().isGuestOnly()) {
        String url = toUrl(getLandingBC(ureq));
        option = new Redirect(url);
    } else {
        Preferences prefs = usess.getGuiPreferences();
        String resumePrefs = (String) prefs.get(WindowManager.class, "resume-prefs");
        if (!StringHelper.containsNonWhitespace(resumePrefs)) {
            resumePrefs = historyModule.getResumeDefaultSetting();
        }
        if ("none".equals(resumePrefs)) {
            String url = toUrl(getLandingBC(ureq));
            option = new Redirect(url);
        } else if ("auto".equals(resumePrefs)) {
            HistoryPoint historyEntry = HistoryManager.getInstance().readHistoryPoint(ureq.getIdentity());
            if (historyEntry != null && StringHelper.containsNonWhitespace(historyEntry.getBusinessPath())) {
                List<ContextEntry> cloneCes = BusinessControlFactory.getInstance().cloneContextEntries(historyEntry.getEntries());
                String bc = BusinessControlFactory.getInstance().getAsRestPart(cloneCes, true);
                option = new Redirect(bc);
            } else {
                String url = toUrl(getLandingBC(ureq));
                option = new Redirect(url);
            }
        } else if ("ondemand".equals(resumePrefs)) {
            HistoryPoint historyEntry = historyManager.readHistoryPoint(ureq.getIdentity());
            if (historyEntry != null && StringHelper.containsNonWhitespace(historyEntry.getBusinessPath())) {
                List<ContextEntry> cloneCes = BusinessControlFactory.getInstance().cloneContextEntries(historyEntry.getEntries());
                String url = BusinessControlFactory.getInstance().getAsRestPart(cloneCes, true);
                String landingPage = getLandingBC(ureq);
                option = new Redirect(url, landingPage);
            } else {
                String url = toUrl(getLandingBC(ureq));
                option = new Redirect(url);
            }
        } else {
            String url = toUrl(getLandingBC(ureq));
            option = new Redirect(url);
        }
    }
    return option;
}
Also used : UserSession(org.olat.core.util.UserSession) ArrayList(java.util.ArrayList) List(java.util.List) Preferences(org.olat.core.util.prefs.Preferences) HistoryPoint(org.olat.core.id.context.HistoryPoint) ContextEntry(org.olat.core.id.context.ContextEntry) WindowManager(org.olat.core.gui.WindowManager)

Aggregations

Preferences (org.olat.core.util.prefs.Preferences)92 ArrayList (java.util.ArrayList)12 I18nModule (org.olat.core.util.i18n.I18nModule)8 WindowManager (org.olat.core.gui.WindowManager)6 ContextEntry (org.olat.core.id.context.ContextEntry)6 UserSession (org.olat.core.util.UserSession)6 HashSet (java.util.HashSet)4 Locale (java.util.Locale)4 Map (java.util.Map)4 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)4 UserTool (org.olat.admin.user.tools.UserTool)4 UserToolExtension (org.olat.admin.user.tools.UserToolExtension)4 Component (org.olat.core.gui.components.Component)4 FlexiTableSort (org.olat.core.gui.components.form.flexible.elements.FlexiTableSort)4 ProgressBar (org.olat.core.gui.components.progressbar.ProgressBar)4 HistoryPoint (org.olat.core.id.context.HistoryPoint)4 I18nItem (org.olat.core.util.i18n.I18nItem)4 LocationHistory (org.olat.modules.lecture.model.LocationHistory)4 Date (java.util.Date)2 List (java.util.List)2