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);
}
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;
}
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();
}
}
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));
}
}
}
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;
}
Aggregations