use of org.olat.core.util.prefs.Preferences in project OpenOLAT by OpenOLAT.
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);
}
use of org.olat.core.util.prefs.Preferences in project OpenOLAT by OpenOLAT.
the class MessageListController method getViewSettings.
private String getViewSettings(UserRequest ureq) {
Preferences prefs = ureq.getUserSession().getGuiPreferences();
Object setting = prefs.get(GUI_PREFS_VIEWMODE_CLASS, GUI_PREFS_VIEWMODE_KEY);
if (VIEWMODE_THREAD.equals(setting) || VIEWMODE_FLAT.equals(setting) || VIEWMODE_MESSAGE.equals(setting)) {
return (String) setting;
}
return VIEWMODE_THREAD;
}
use of org.olat.core.util.prefs.Preferences in project OpenOLAT by OpenOLAT.
the class MessageListController method saveViewSettings.
private void saveViewSettings(UserRequest ureq, String viewMode) {
Preferences prefs = ureq.getUserSession().getGuiPreferences();
prefs.putAndSave(GUI_PREFS_VIEWMODE_CLASS, GUI_PREFS_VIEWMODE_KEY, viewMode);
}
use of org.olat.core.util.prefs.Preferences in project OpenOLAT by OpenOLAT.
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;
}
use of org.olat.core.util.prefs.Preferences in project OpenOLAT by OpenOLAT.
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);
}
Aggregations