Search in sources :

Example 71 with Preferences

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

the class LogoInformations method getLogoLinkUri.

public LogoLinkURI getLogoLinkUri() {
    String logoLinkUri = null;
    String logoLinkType = layoutModule.getLogoLinkType();
    if (LogoURLType.landingpage.name().equals(logoLinkType)) {
        if (userSession != null && userSession.getGuiPreferences() != null) {
            Preferences prefs = userSession.getGuiPreferences();
            String landingPage = (String) prefs.get(WindowManager.class, "landing-page");
            if (StringHelper.containsNonWhitespace(landingPage)) {
                logoLinkUri = Settings.getServerContextPathURI() + "/url/" + Rules.cleanUpLandingPath(landingPage);
            }
        }
        if (!StringHelper.containsNonWhitespace(logoLinkUri)) {
            String landingBc = landingPagesModule.getRules().match(userSession);
            if (StringHelper.containsNonWhitespace(landingBc)) {
                List<ContextEntry> ces = BusinessControlFactory.getInstance().createCEListFromString(landingBc);
                logoLinkUri = BusinessControlFactory.getInstance().getAsURIString(ces, true);
            }
        }
    } else {
        logoLinkUri = layoutModule.getLogoLinkUri();
    }
    if (StringHelper.containsNonWhitespace(logoLinkUri)) {
        String serverURI = Settings.createServerURI();
        if (logoLinkUri.startsWith(serverURI)) {
            logoLinkUri = logoLinkUri.substring(serverURI.length());
            if (!logoLinkUri.startsWith("/")) {
                logoLinkUri = "/" + logoLinkUri;
            }
        }
    } else {
        logoLinkUri = "";
    }
    String target = logoLinkUri.startsWith("http") ? "_blank" : null;
    return new LogoLinkURI(logoLinkUri, target);
}
Also used : Preferences(org.olat.core.util.prefs.Preferences) ContextEntry(org.olat.core.id.context.ContextEntry) WindowManager(org.olat.core.gui.WindowManager)

Example 72 with Preferences

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

the class ResumeSessionController method getLandingBC.

private String getLandingBC(UserRequest ureq) {
    Preferences prefs = ureq.getUserSession().getGuiPreferences();
    String landingPage = (String) prefs.get(WindowManager.class, "landing-page");
    if (StringHelper.containsNonWhitespace(landingPage)) {
        String path = Rules.cleanUpLandingPath(landingPage);
        if (StringHelper.containsNonWhitespace(path)) {
            landingPage = BusinessControlFactory.getInstance().formatFromURI(path);
        }
    }
    if (!StringHelper.containsNonWhitespace(landingPage)) {
        landingPage = lpModule.getRules().match(ureq.getUserSession());
    }
    return landingPage;
}
Also used : Preferences(org.olat.core.util.prefs.Preferences) WindowManager(org.olat.core.gui.WindowManager)

Example 73 with Preferences

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

the class FlexiTableElementImpl method saveCustomSettings.

private void saveCustomSettings(UserRequest ureq) {
    if (StringHelper.containsNonWhitespace(persistentId)) {
        Preferences prefs = ureq.getUserSession().getGuiPreferences();
        boolean sortDirection = false;
        String sortedColKey = null;
        if (orderBy != null && orderBy.length > 0 && orderBy[0] != null) {
            sortDirection = orderBy[0].isAsc();
            String sortKey = orderBy[0].getKey();
            if (sortKey != null) {
                FlexiTableColumnModel colModel = dataModel.getTableColumnModel();
                for (int i = colModel.getColumnCount(); i-- > 0; ) {
                    FlexiColumnModel col = colModel.getColumnModel(i);
                    if (col.getSortKey() != null && sortKey.equals(col.getSortKey())) {
                        sortedColKey = col.getColumnKey();
                    }
                }
            }
            if (sortedColKey == null && sortOptions != null && sortOptions.getSorts() != null) {
                for (FlexiTableSort sortOption : sortOptions.getSorts()) {
                    if (sortOption.getSortKey().getKey().equals(sortKey)) {
                        sortedColKey = sortKey;
                    }
                }
            }
        }
        FlexiTablePreferences tablePrefs = new FlexiTablePreferences(getPageSize(), sortedColKey, sortDirection, convertColumnIndexToKeys(enabledColumnIndex), rendererType);
        prefs.put(FlexiTableElement.class, persistentId, tablePrefs);
        prefs.save();
    }
}
Also used : Preferences(org.olat.core.util.prefs.Preferences) FlexiTableSort(org.olat.core.gui.components.form.flexible.elements.FlexiTableSort)

Example 74 with Preferences

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

the class AbstractPortletRunController method saveSortingConfiguration.

/**
 * Store the sortingCriteria for the current portlet. Auto sorting was choosed.
 * @param ureq
 * @param sortingCriteria
 */
protected void saveSortingConfiguration(UserRequest ureq, SortingCriteria sortingCriteria) {
    Preferences guiPreferences = ureq.getUserSession().getGuiPreferences();
    guiPreferences.putAndSave(Map.class, getPreferenceKey(SORTING_CRITERIA_PREF), sortingCriteria.getPersistable());
    if (sortingCriteria.getSortingType() == SortingCriteria.AUTO_SORTING) {
        Map<Long, Integer> storedPrefs = (Map<Long, Integer>) guiPreferences.get(Map.class, getPreferenceKey(SORTED_ITEMS_PREF));
        if (storedPrefs != null) {
            // if auto sorting choosed, remove any manually sorting info
            List<PortletEntry<T>> sortedItems = new ArrayList<PortletEntry<T>>();
            guiPreferences.putAndSave(Map.class, getPreferenceKey(SORTED_ITEMS_PREF), getSortedItemsMap(sortedItems));
        }
    }
}
Also used : ArrayList(java.util.ArrayList) Preferences(org.olat.core.util.prefs.Preferences) Map(java.util.Map)

Example 75 with Preferences

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

the class AbstractPortletRunController method getPersistentSortingConfiguration.

/**
 * Retrieves the persistent sortingCriteria for the current portlet for the current user.
 * Check the persistent sorting type (auto/manual) if none found auto is the default.
 * This has to be implemented by every portlet since the portlets could have different
 * set of sorting terms.
 * @param ureq
 * @return the persistent sortingCriteria if any found, else a default sortingCriteria.
 */
protected SortingCriteria getPersistentSortingConfiguration(UserRequest ureq) {
    SortingCriteria returnSortingCriteria = null;
    Preferences guiPreferences = ureq.getUserSession().getGuiPreferences();
    Map<String, Integer> storedPrefs = (Map<String, Integer>) guiPreferences.get(Map.class, getPreferenceKey(SORTING_CRITERIA_PREF));
    if (storedPrefs != null) {
        returnSortingCriteria = new SortingCriteria(storedPrefs, sortingTermsList, defaultMaxEntries);
    } else {
        returnSortingCriteria = createDefaultSortingCriteria();
    }
    return returnSortingCriteria;
}
Also used : Preferences(org.olat.core.util.prefs.Preferences) Map(java.util.Map)

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