Skip to content
Snippets Groups Projects
Commit 175733e6 authored by srosse's avatar srosse
Browse files

OO-3414: hardened the event handling in share link

parent ee27fdbd
No related branches found
No related tags found
No related merge requests found
...@@ -23,7 +23,6 @@ package org.olat.social.shareLink; ...@@ -23,7 +23,6 @@ package org.olat.social.shareLink;
import java.util.List; import java.util.List;
import org.olat.core.CoreSpringFactory;
import org.olat.core.gui.UserRequest; import org.olat.core.gui.UserRequest;
import org.olat.core.gui.WindowManager; import org.olat.core.gui.WindowManager;
import org.olat.core.gui.components.Component; import org.olat.core.gui.components.Component;
...@@ -40,6 +39,7 @@ import org.olat.core.util.StringHelper; ...@@ -40,6 +39,7 @@ import org.olat.core.util.StringHelper;
import org.olat.core.util.UserSession; import org.olat.core.util.UserSession;
import org.olat.core.util.prefs.Preferences; import org.olat.core.util.prefs.Preferences;
import org.olat.social.SocialModule; import org.olat.social.SocialModule;
import org.springframework.beans.factory.annotation.Autowired;
/** /**
* <h3>Description:</h3> * <h3>Description:</h3>
...@@ -59,10 +59,12 @@ import org.olat.social.SocialModule; ...@@ -59,10 +59,12 @@ import org.olat.social.SocialModule;
* *
* @author Florian Gnaegi, frentix GmbH, http://www.frentix.com * @author Florian Gnaegi, frentix GmbH, http://www.frentix.com
*/ */
public class ShareLinkController extends BasicController { public class ShareLinkController extends BasicController {
private final VelocityContainer shareLinkVC; private final VelocityContainer shareLinkVC;
@Autowired
private SocialModule socialModule;
/** /**
* Standard constructor for the share link controller * Standard constructor for the share link controller
* @param ureq * @param ureq
...@@ -75,7 +77,6 @@ public class ShareLinkController extends BasicController { ...@@ -75,7 +77,6 @@ public class ShareLinkController extends BasicController {
// Add the OpenOLAT base URL from the config // Add the OpenOLAT base URL from the config
shareLinkVC.contextPut("baseURL", Settings.getServerContextPathURI()); shareLinkVC.contextPut("baseURL", Settings.getServerContextPathURI());
// Load configured share link buttons from the SocialModule configuration // Load configured share link buttons from the SocialModule configuration
SocialModule socialModule = (SocialModule) CoreSpringFactory.getBean("socialModule");
shareLinkVC.contextPut("shareLinks", socialModule.getEnabledShareLinkButtons()); shareLinkVC.contextPut("shareLinks", socialModule.getEnabledShareLinkButtons());
// Tell if user is logged in // Tell if user is logged in
UserSession usess = ureq.getUserSession(); UserSession usess = ureq.getUserSession();
...@@ -85,8 +86,9 @@ public class ShareLinkController extends BasicController { ...@@ -85,8 +86,9 @@ public class ShareLinkController extends BasicController {
@Override @Override
protected void event(UserRequest ureq, Component source, Event event) { protected void event(UserRequest ureq, Component source, Event event) {
if (source == shareLinkVC && event.getCommand().equals("setLandingPage") && ureq.getUserSession().isAuthenticated()) { UserSession usess = ureq.getUserSession();
HistoryPoint p = ureq.getUserSession().getLastHistoryPoint(); if (source == shareLinkVC && "setLandingPage".equals(event.getCommand()) && usess != null && usess.isAuthenticated()) {
HistoryPoint p = usess.getLastHistoryPoint();
if(p != null && StringHelper.containsNonWhitespace(p.getBusinessPath())) { if(p != null && StringHelper.containsNonWhitespace(p.getBusinessPath())) {
List<ContextEntry> ces = p.getEntries(); List<ContextEntry> ces = p.getEntries();
String landingPage = BusinessControlFactory.getInstance().getAsURIString(ces, true); String landingPage = BusinessControlFactory.getInstance().getAsURIString(ces, true);
...@@ -96,7 +98,7 @@ public class ShareLinkController extends BasicController { ...@@ -96,7 +98,7 @@ public class ShareLinkController extends BasicController {
landingPage = landingPage.substring(start + 4); landingPage = landingPage.substring(start + 4);
} }
// update user prefs // update user prefs
Preferences prefs = ureq.getUserSession().getGuiPreferences(); Preferences prefs = usess.getGuiPreferences();
prefs.put(WindowManager.class, "landing-page", landingPage); prefs.put(WindowManager.class, "landing-page", landingPage);
prefs.save(); prefs.save();
getWindowControl().getWindowBackOffice().sendCommandTo(new JSCommand("showInfoBox(\"" + translate("info.header") + "\",\"" + translate("landingpage.set.message") + "\");")); getWindowControl().getWindowBackOffice().sendCommandTo(new JSCommand("showInfoBox(\"" + translate("info.header") + "\",\"" + translate("landingpage.set.message") + "\");"));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment