Skip to content
Snippets Groups Projects
Commit 3a989bf0 authored by srosse's avatar srosse
Browse files

OO-111: update business path in e-portfolio, improve back suppport, reenable...

OO-111: update business path in e-portfolio, improve back suppport, reenable full text search with jump to the right menu item in home, enable jump from notifications to the right menu item in home... refactor slightly the ContextEntry to enable rewrite of the business path before the jump
parent e079b837
No related branches found
No related tags found
No related merge requests found
Showing
with 324 additions and 102 deletions
...@@ -45,7 +45,7 @@ import org.olat.core.id.context.BusinessControl; ...@@ -45,7 +45,7 @@ import org.olat.core.id.context.BusinessControl;
import org.olat.core.id.context.BusinessControlFactory; import org.olat.core.id.context.BusinessControlFactory;
import org.olat.core.id.context.ContextEntry; import org.olat.core.id.context.ContextEntry;
import org.olat.core.id.context.ContextEntryControllerCreator; import org.olat.core.id.context.ContextEntryControllerCreator;
import org.olat.core.id.context.ContextEntryControllerCreator2; import org.olat.core.id.context.TabContext;
import org.olat.core.logging.AssertException; import org.olat.core.logging.AssertException;
import org.olat.core.logging.LogDelegator; import org.olat.core.logging.LogDelegator;
import org.olat.core.util.resource.OresHelper; import org.olat.core.util.resource.OresHelper;
...@@ -177,12 +177,7 @@ public class NewControllerFactory extends LogDelegator { ...@@ -177,12 +177,7 @@ public class NewControllerFactory extends LogDelegator {
} }
//fxdiff BAKS-7 Resume function //fxdiff BAKS-7 Resume function
String siteClassName; String siteClassName = typeHandler.getSiteClassName(mainCe, ureq);
if(typeHandler instanceof ContextEntryControllerCreator2) {
siteClassName = ((ContextEntryControllerCreator2)typeHandler).getSiteClassName(ureq, mainCe);
} else {
siteClassName = typeHandler.getSiteClassName(mainCe);
}
// open in existing site // open in existing site
if (siteClassName != null) { if (siteClassName != null) {
...@@ -218,23 +213,23 @@ public class NewControllerFactory extends LogDelegator { ...@@ -218,23 +213,23 @@ public class NewControllerFactory extends LogDelegator {
} }
} }
} }
dts.activateStatic(ureq, siteClassName, viewIdentifyer, entries);
TabContext context = typeHandler.getTabContext(ureq, ores, mainCe, entries);
dts.activateStatic(ureq, siteClassName, viewIdentifyer, context.getContext());
} else { } else {
List<ContextEntry> entries = new ArrayList<ContextEntry>(); List<ContextEntry> entries = new ArrayList<ContextEntry>();
while(bc.hasContextEntry()) {
entries.add(bc.popLauncherContextEntry());
}
TabContext context = typeHandler.getTabContext(ureq, ores, mainCe, entries);
// or create new tab // or create new tab
String tabName = typeHandler.getTabName(mainCe); //String tabName = typeHandler.getTabName(mainCe, ureq);
// create and add Tab // create and add Tab
dt = dts.createDTab(ores, re, tabName); dt = dts.createDTab(context.getTabResource(), re, context.getName());
if (dt == null) { if (dt == null) {
// tabs are full: TODO // user error message is generated in BaseFullWebappController, nothing to do here
// user error message is generated in BaseFullWebappController, nothing
// to do here
} else { } else {
while(bc.hasContextEntry()) {
entries.add(bc.popLauncherContextEntry());
}
WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(bc, dt.getWindowControl()); WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(bc, dt.getWindowControl());
Controller launchC = typeHandler.createController(mainCe, ureq, bwControl); Controller launchC = typeHandler.createController(mainCe, ureq, bwControl);
if (launchC == null) { if (launchC == null) {
...@@ -244,7 +239,7 @@ public class NewControllerFactory extends LogDelegator { ...@@ -244,7 +239,7 @@ public class NewControllerFactory extends LogDelegator {
dt.setController(launchC); dt.setController(launchC);
dts.addDTab(dt); dts.addDTab(dt);
dts.activate(ureq, dt, null, entries); // null: do not activate to a certain view dts.activate(ureq, dt, null, context.getContext()); // null: do not activate to a certain view
} }
} }
} }
......
...@@ -24,7 +24,7 @@ import org.olat.core.gui.UserRequest; ...@@ -24,7 +24,7 @@ import org.olat.core.gui.UserRequest;
import org.olat.core.gui.control.Controller; import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.WindowControl; import org.olat.core.gui.control.WindowControl;
import org.olat.core.id.context.ContextEntry; import org.olat.core.id.context.ContextEntry;
import org.olat.core.id.context.ContextEntryControllerCreator; import org.olat.core.id.context.DefaultContextEntryControllerCreator;
/** /**
* Description:<br> * Description:<br>
...@@ -35,7 +35,7 @@ import org.olat.core.id.context.ContextEntryControllerCreator; ...@@ -35,7 +35,7 @@ import org.olat.core.id.context.ContextEntryControllerCreator;
* *
* @author srosse * @author srosse
*/ */
public class UserAdminContextEntryControllerCreator implements ContextEntryControllerCreator { public class UserAdminContextEntryControllerCreator extends DefaultContextEntryControllerCreator {
/** /**
* @see org.olat.core.id.context.ContextEntryControllerCreator#createController(org.olat.core.id.context.ContextEntry, * @see org.olat.core.id.context.ContextEntryControllerCreator#createController(org.olat.core.id.context.ContextEntry,
...@@ -49,7 +49,8 @@ public class UserAdminContextEntryControllerCreator implements ContextEntryContr ...@@ -49,7 +49,8 @@ public class UserAdminContextEntryControllerCreator implements ContextEntryContr
/** /**
* @see org.olat.core.id.context.ContextEntryControllerCreator#getSiteClassName(org.olat.core.id.context.ContextEntry) * @see org.olat.core.id.context.ContextEntryControllerCreator#getSiteClassName(org.olat.core.id.context.ContextEntry)
*/ */
public String getSiteClassName(ContextEntry ce) { @Override
public String getSiteClassName(ContextEntry ce, UserRequest ureq) {
// opened as site not tab // opened as site not tab
return UserAdminSite.class.getName(); return UserAdminSite.class.getName();
} }
...@@ -57,7 +58,8 @@ public class UserAdminContextEntryControllerCreator implements ContextEntryContr ...@@ -57,7 +58,8 @@ public class UserAdminContextEntryControllerCreator implements ContextEntryContr
/** /**
* @see org.olat.core.id.context.ContextEntryControllerCreator#getTabName(org.olat.core.id.context.ContextEntry) * @see org.olat.core.id.context.ContextEntryControllerCreator#getTabName(org.olat.core.id.context.ContextEntry)
*/ */
public String getTabName(ContextEntry ce) { @Override
public String getTabName(ContextEntry ce, UserRequest ureq) {
return null; return null;
} }
......
...@@ -647,6 +647,22 @@ public class TableController extends BasicController { ...@@ -647,6 +647,22 @@ public class TableController extends BasicController {
public void setSelectedRowId(final int selectedRowId) { public void setSelectedRowId(final int selectedRowId) {
table.setSelectedRowId(selectedRowId); table.setSelectedRowId(selectedRowId);
} }
/**
* Set the page viewed if pageing is enabled
* @param pageNr
*/
public void setPage(Integer pageNr) {
table.updatePageing(pageNr);
}
/**
* Return the number of items per page if pageing is enable
* @return
*/
public int getPageSize() {
return table.getResultsPerPage();
}
/** /**
* Sets the sortColumn to a specific colun id. Check if the column can be accessed * Sets the sortColumn to a specific colun id. Check if the column can be accessed
......
...@@ -28,9 +28,12 @@ ...@@ -28,9 +28,12 @@
*/ */
package org.olat.core.id.context; package org.olat.core.id.context;
import java.util.List;
import org.olat.core.gui.UserRequest; import org.olat.core.gui.UserRequest;
import org.olat.core.gui.control.Controller; import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.WindowControl; import org.olat.core.gui.control.WindowControl;
import org.olat.core.id.OLATResourceable;
/** /**
* Description:<br> * Description:<br>
...@@ -61,16 +64,6 @@ public interface ContextEntryControllerCreator { ...@@ -61,16 +64,6 @@ public interface ContextEntryControllerCreator {
*/ */
public Controller createController(ContextEntry ce, UserRequest ureq, WindowControl wControl); public Controller createController(ContextEntry ce, UserRequest ureq, WindowControl wControl);
/**
* The name of the dynamic tab if such a tab should be created or NULL if
* opened as Site
*
* @param ce
* @return Return tab name for certain context entry or NULL if the target is
* the opeing of an existing site
*/
public String getTabName(ContextEntry ce);
/** /**
* The class name of the site that must be activated or NULL if opened as dTab * The class name of the site that must be activated or NULL if opened as dTab
* *
...@@ -78,7 +71,7 @@ public interface ContextEntryControllerCreator { ...@@ -78,7 +71,7 @@ public interface ContextEntryControllerCreator {
* @return Return the class name that is used to activate an existing site or * @return Return the class name that is used to activate an existing site or
* NULL if the target is a new dtab * NULL if the target is a new dtab
*/ */
public String getSiteClassName(ContextEntry ce); public String getSiteClassName(ContextEntry ce, UserRequest ureq);
/** /**
* *
...@@ -88,4 +81,12 @@ public interface ContextEntryControllerCreator { ...@@ -88,4 +81,12 @@ public interface ContextEntryControllerCreator {
* @return true, if this contextentry can be launched * @return true, if this contextentry can be launched
*/ */
public boolean validateContextEntryAndShowError(ContextEntry ce, UserRequest ureq, WindowControl wControl); public boolean validateContextEntryAndShowError(ContextEntry ce, UserRequest ureq, WindowControl wControl);
/**
* Allow to rewrite the business path
* @param ureq
* @param entries
* @return
*/
public TabContext getTabContext(UserRequest ureq, OLATResourceable ores, ContextEntry mainEntry, List<ContextEntry> entries);
} }
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.core.id.context;
import java.util.List;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.WindowControl;
import org.olat.core.id.OLATResourceable;
/**
*
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*
*/
public class DefaultContextEntryControllerCreator implements ContextEntryControllerCreator {
public Controller createController(ContextEntry ce, UserRequest ureq, WindowControl wControl) {
return null;
}
public String getTabName(ContextEntry ce, UserRequest ureq) {
return null;
}
public String getSiteClassName(ContextEntry ce, UserRequest ureq) {
return null;
}
public boolean validateContextEntryAndShowError(ContextEntry ce, UserRequest ureq, WindowControl wControl) {
return true;
}
@Override
public TabContext getTabContext(UserRequest ureq, OLATResourceable ores, ContextEntry mainEntry, List<ContextEntry> entries) {
return new TabContext(getTabName(mainEntry, ureq), ores, entries);
}
}
\ No newline at end of file
...@@ -34,7 +34,7 @@ import org.olat.core.gui.control.navigation.SiteInstance; ...@@ -34,7 +34,7 @@ import org.olat.core.gui.control.navigation.SiteInstance;
* *
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*/ */
public class SiteContextEntryControllerCreator implements ContextEntryControllerCreator { public class SiteContextEntryControllerCreator extends DefaultContextEntryControllerCreator {
private final Class<? extends SiteInstance> site; private final Class<? extends SiteInstance> site;
public SiteContextEntryControllerCreator(Class<? extends SiteInstance> site) { public SiteContextEntryControllerCreator(Class<? extends SiteInstance> site) {
...@@ -45,11 +45,13 @@ public class SiteContextEntryControllerCreator implements ContextEntryController ...@@ -45,11 +45,13 @@ public class SiteContextEntryControllerCreator implements ContextEntryController
return null; return null;
} }
public String getSiteClassName(ContextEntry ce) { @Override
public String getSiteClassName(ContextEntry ce, UserRequest ureq) {
return site.getName(); return site.getName();
} }
public String getTabName(ContextEntry ce) { @Override
public String getTabName(ContextEntry ce, UserRequest ureq) {
return null; return null;
} }
......
...@@ -19,11 +19,46 @@ ...@@ -19,11 +19,46 @@
*/ */
package org.olat.core.id.context; package org.olat.core.id.context;
import org.olat.core.gui.UserRequest; import java.util.List;
//fxdiff BAKS-7 Resume function import org.olat.core.id.OLATResourceable;
public interface ContextEntryControllerCreator2 extends ContextEntryControllerCreator {
/**
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*/
public class TabContext {
private final String name;
private final OLATResourceable resource;
private final List<ContextEntry> contextEntries;
public TabContext (String name, OLATResourceable resource, List<ContextEntry> contextEntries) {
this.name = name;
this.resource = resource;
this.contextEntries = contextEntries;
}
/**
* The name of the tab
* @return
*/
public String getName() {
return name;
}
/**
* The resource which identified the tab
* @return
*/
public OLATResourceable getTabResource() {
return resource;
}
public String getSiteClassName(UserRequest ureq, ContextEntry ce); /**
} *
* @return
*/
public List<ContextEntry> getContext() {
return contextEntries;
}
}
\ No newline at end of file
...@@ -32,7 +32,7 @@ import org.olat.core.id.Identity; ...@@ -32,7 +32,7 @@ import org.olat.core.id.Identity;
import org.olat.core.id.context.BusinessControl; import org.olat.core.id.context.BusinessControl;
import org.olat.core.id.context.BusinessControlFactory; import org.olat.core.id.context.BusinessControlFactory;
import org.olat.core.id.context.ContextEntry; import org.olat.core.id.context.ContextEntry;
import org.olat.core.id.context.ContextEntryControllerCreator; import org.olat.core.id.context.DefaultContextEntryControllerCreator;
import org.olat.core.logging.OLog; import org.olat.core.logging.OLog;
import org.olat.core.logging.Tracing; import org.olat.core.logging.Tracing;
import org.olat.core.manager.BasicManager; import org.olat.core.manager.BasicManager;
...@@ -67,20 +67,20 @@ public class MailBoxExtension extends BasicManager implements MailContextResolve ...@@ -67,20 +67,20 @@ public class MailBoxExtension extends BasicManager implements MailContextResolve
} }
public void init() { public void init() {
NewControllerFactory.getInstance().addContextEntryControllerCreator("Inbox", new ContextEntryControllerCreator(){ NewControllerFactory.getInstance().addContextEntryControllerCreator("Inbox", new DefaultContextEntryControllerCreator(){
@Override @Override
public Controller createController(ContextEntry ce, UserRequest ureq, WindowControl wControl) { public Controller createController(ContextEntry ce, UserRequest ureq, WindowControl wControl) {
return null; return null;
} }
@Override @Override
public String getTabName(ContextEntry ce) { public String getTabName(ContextEntry ce, UserRequest ureq) {
// opens in home-tab // opens in home-tab
return null; return null;
} }
@Override @Override
public String getSiteClassName(ContextEntry ce) { public String getSiteClassName(ContextEntry ce, UserRequest ureq) {
return HomeSite.class.getName(); return HomeSite.class.getName();
} }
......
...@@ -27,7 +27,7 @@ import org.olat.core.gui.control.Controller; ...@@ -27,7 +27,7 @@ import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.WindowControl; import org.olat.core.gui.control.WindowControl;
import org.olat.core.id.OLATResourceable; import org.olat.core.id.OLATResourceable;
import org.olat.core.id.context.ContextEntry; import org.olat.core.id.context.ContextEntry;
import org.olat.core.id.context.ContextEntryControllerCreator; import org.olat.core.id.context.DefaultContextEntryControllerCreator;
import org.olat.group.ui.BGControllerFactory; import org.olat.group.ui.BGControllerFactory;
import org.olat.resource.OLATResource; import org.olat.resource.OLATResource;
import org.olat.resource.OLATResourceManager; import org.olat.resource.OLATResourceManager;
...@@ -44,7 +44,7 @@ import org.olat.resource.accesscontrol.manager.ACFrontendManager; ...@@ -44,7 +44,7 @@ import org.olat.resource.accesscontrol.manager.ACFrontendManager;
* *
* @author gnaegi, gnaegi@frentix.com, www.frentix.com * @author gnaegi, gnaegi@frentix.com, www.frentix.com
*/ */
public class BusinessGroupContextEntryControllerCreator implements ContextEntryControllerCreator { public class BusinessGroupContextEntryControllerCreator extends DefaultContextEntryControllerCreator {
/** /**
* @see org.olat.core.id.context.ContextEntryControllerCreator#createController(org.olat.core.id.context.ContextEntry, * @see org.olat.core.id.context.ContextEntryControllerCreator#createController(org.olat.core.id.context.ContextEntry,
...@@ -71,7 +71,8 @@ public class BusinessGroupContextEntryControllerCreator implements ContextEntryC ...@@ -71,7 +71,8 @@ public class BusinessGroupContextEntryControllerCreator implements ContextEntryC
/** /**
* @see org.olat.core.id.context.ContextEntryControllerCreator#getTabName(org.olat.core.id.context.ContextEntry) * @see org.olat.core.id.context.ContextEntryControllerCreator#getTabName(org.olat.core.id.context.ContextEntry)
*/ */
public String getTabName(ContextEntry ce) { @Override
public String getTabName(ContextEntry ce, UserRequest ureq) {
OLATResourceable ores = ce.getOLATResourceable(); OLATResourceable ores = ce.getOLATResourceable();
Long gKey = ores.getResourceableId(); Long gKey = ores.getResourceableId();
BusinessGroupManager bman = BusinessGroupManagerImpl.getInstance(); BusinessGroupManager bman = BusinessGroupManagerImpl.getInstance();
...@@ -79,13 +80,6 @@ public class BusinessGroupContextEntryControllerCreator implements ContextEntryC ...@@ -79,13 +80,6 @@ public class BusinessGroupContextEntryControllerCreator implements ContextEntryC
return bgroup.getName(); return bgroup.getName();
} }
/**
* @see org.olat.core.id.context.ContextEntryControllerCreator#getSiteClassName(org.olat.core.id.context.ContextEntry)
*/
public String getSiteClassName(ContextEntry ce) {
return null;
}
@Override @Override
public boolean validateContextEntryAndShowError(ContextEntry ce, UserRequest ureq, WindowControl wControl) { public boolean validateContextEntryAndShowError(ContextEntry ce, UserRequest ureq, WindowControl wControl) {
OLATResourceable ores = ce.getOLATResourceable(); OLATResourceable ores = ce.getOLATResourceable();
......
...@@ -23,7 +23,7 @@ import org.olat.core.gui.UserRequest; ...@@ -23,7 +23,7 @@ import org.olat.core.gui.UserRequest;
import org.olat.core.gui.control.Controller; import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.WindowControl; import org.olat.core.gui.control.WindowControl;
import org.olat.core.id.context.ContextEntry; import org.olat.core.id.context.ContextEntry;
import org.olat.core.id.context.ContextEntryControllerCreator; import org.olat.core.id.context.DefaultContextEntryControllerCreator;
import org.olat.home.HomeSite; import org.olat.home.HomeSite;
/** /**
...@@ -35,7 +35,7 @@ import org.olat.home.HomeSite; ...@@ -35,7 +35,7 @@ import org.olat.home.HomeSite;
* Initial Date: 15 juil. 2011 <br> * Initial Date: 15 juil. 2011 <br>
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*/ */
public class GuestHomeCEControllerCreator implements ContextEntryControllerCreator { public class GuestHomeCEControllerCreator extends DefaultContextEntryControllerCreator {
public GuestHomeCEControllerCreator() { public GuestHomeCEControllerCreator() {
...@@ -45,11 +45,11 @@ public class GuestHomeCEControllerCreator implements ContextEntryControllerCrea ...@@ -45,11 +45,11 @@ public class GuestHomeCEControllerCreator implements ContextEntryControllerCrea
return null; return null;
} }
public String getSiteClassName(ContextEntry ce) { public String getSiteClassName(ContextEntry ce, UserRequest ureq) {
return HomeSite.class.getName(); return HomeSite.class.getName();
} }
public String getTabName(ContextEntry ce) { public String getTabName(ContextEntry ce, UserRequest ureq) {
return null; return null;
} }
......
...@@ -28,7 +28,7 @@ import org.olat.core.gui.control.Controller; ...@@ -28,7 +28,7 @@ import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.WindowControl; import org.olat.core.gui.control.WindowControl;
import org.olat.core.id.OLATResourceable; import org.olat.core.id.OLATResourceable;
import org.olat.core.id.context.ContextEntry; import org.olat.core.id.context.ContextEntry;
import org.olat.core.id.context.ContextEntryControllerCreator; import org.olat.core.id.context.DefaultContextEntryControllerCreator;
import org.olat.core.logging.OLog; import org.olat.core.logging.OLog;
import org.olat.core.logging.Tracing; import org.olat.core.logging.Tracing;
import org.olat.modules.webFeed.FeedResourceSecurityCallback; import org.olat.modules.webFeed.FeedResourceSecurityCallback;
...@@ -53,7 +53,7 @@ public class LiveBlogContextEntryControllerCreator { ...@@ -53,7 +53,7 @@ public class LiveBlogContextEntryControllerCreator {
public LiveBlogContextEntryControllerCreator(final FeedManager feedManager) { public LiveBlogContextEntryControllerCreator(final FeedManager feedManager) {
NewControllerFactory.getInstance().addContextEntryControllerCreator("LiveBlog", new ContextEntryControllerCreator(){ NewControllerFactory.getInstance().addContextEntryControllerCreator("LiveBlog", new DefaultContextEntryControllerCreator(){
@Override @Override
public Controller createController(ContextEntry ce, UserRequest ureq, WindowControl wControl) { public Controller createController(ContextEntry ce, UserRequest ureq, WindowControl wControl) {
...@@ -67,14 +67,14 @@ public class LiveBlogContextEntryControllerCreator { ...@@ -67,14 +67,14 @@ public class LiveBlogContextEntryControllerCreator {
} }
@Override @Override
public String getTabName(ContextEntry ce) { public String getTabName(ContextEntry ce, UserRequest ureq) {
OLATResourceable ores = ce.getOLATResourceable(); OLATResourceable ores = ce.getOLATResourceable();
Feed feed = feedManager.getFeed(ores); Feed feed = feedManager.getFeed(ores);
return feed.getTitle(); return feed.getTitle();
} }
@Override @Override
public String getSiteClassName(ContextEntry ce) { public String getSiteClassName(ContextEntry ce, UserRequest ureq) {
return null; return null;
} }
......
...@@ -19,12 +19,19 @@ ...@@ -19,12 +19,19 @@
*/ */
package org.olat.portfolio; package org.olat.portfolio;
import java.util.ArrayList;
import java.util.List;
import org.olat.NewControllerFactory; import org.olat.NewControllerFactory;
import org.olat.core.gui.UserRequest; import org.olat.core.gui.UserRequest;
import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.WindowControl; import org.olat.core.gui.control.WindowControl;
import org.olat.core.id.Identity;
import org.olat.core.id.OLATResourceable;
import org.olat.core.id.context.BusinessControlFactory;
import org.olat.core.id.context.ContextEntry; import org.olat.core.id.context.ContextEntry;
import org.olat.core.id.context.ContextEntryControllerCreator; import org.olat.core.id.context.DefaultContextEntryControllerCreator;
import org.olat.core.id.context.TabContext;
import org.olat.core.util.resource.OresHelper;
import org.olat.home.HomeSite; import org.olat.home.HomeSite;
import org.olat.portfolio.model.artefacts.AbstractArtefact; import org.olat.portfolio.model.artefacts.AbstractArtefact;
...@@ -41,29 +48,30 @@ public class EPArtefactPoolExtension { ...@@ -41,29 +48,30 @@ public class EPArtefactPoolExtension {
public EPArtefactPoolExtension() { public EPArtefactPoolExtension() {
NewControllerFactory.getInstance().addContextEntryControllerCreator(AbstractArtefact.class.getSimpleName(), new ContextEntryControllerCreator(){ NewControllerFactory.getInstance().addContextEntryControllerCreator(AbstractArtefact.class.getSimpleName(), new DefaultContextEntryControllerCreator(){
@Override @Override
public Controller createController(ContextEntry ce, UserRequest ureq, WindowControl wControl) { public String getSiteClassName(ContextEntry ce, UserRequest ureq) {
return null; return HomeSite.class.getName();
} }
@Override @Override
public String getTabName(ContextEntry ce) { public boolean validateContextEntryAndShowError(ContextEntry ce, UserRequest ureq, WindowControl wControl) {
// opens in home-tab return true;
return null;
} }
@Override @Override
public String getSiteClassName(ContextEntry ce) { public TabContext getTabContext(UserRequest ureq, OLATResourceable ores, ContextEntry mainEntry, List<ContextEntry> entries) {
return HomeSite.class.getName(); Identity identity = ureq.getIdentity();
}
@Override OLATResourceable mapsRes = OresHelper.createOLATResourceableType("EPArtefacts");
public boolean validateContextEntryAndShowError(ContextEntry ce, UserRequest ureq, WindowControl wControl) { ContextEntry mapsEntry = BusinessControlFactory.getInstance().createContextEntry(mapsRes);
return true; List<ContextEntry> rewritedEntries = new ArrayList<ContextEntry>();
rewritedEntries.add(mapsEntry);//Menu node
rewritedEntries.add(mainEntry);//Map
OLATResourceable homeRes = OresHelper.createOLATResourceableInstance("HomeSite", identity.getKey());
return new TabContext("", homeRes, rewritedEntries);
} }
}); });
} }
} }
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.portfolio;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.olat.NewControllerFactory;
import org.olat.core.CoreSpringFactory;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.control.WindowControl;
import org.olat.core.id.Identity;
import org.olat.core.id.OLATResourceable;
import org.olat.core.id.context.BusinessControlFactory;
import org.olat.core.id.context.ContextEntry;
import org.olat.core.id.context.DefaultContextEntryControllerCreator;
import org.olat.core.id.context.TabContext;
import org.olat.core.util.resource.OresHelper;
import org.olat.home.HomeSite;
import org.olat.portfolio.manager.EPFrontendManager;
import org.olat.portfolio.model.structel.EPDefaultMap;
import org.olat.resource.OLATResource;
/**
* Rewrite the business path to map
* @author srosse
*
*/
public class EPMapExtension {
public EPMapExtension() {
NewControllerFactory.getInstance().addContextEntryControllerCreator(EPDefaultMap.class.getSimpleName(), new MapContextEntryControllerCreator());
}
private class MapContextEntryControllerCreator extends DefaultContextEntryControllerCreator {
@Override
public boolean validateContextEntryAndShowError(ContextEntry ce, UserRequest ureq, WindowControl wControl) {
return true;
}
@Override
public String getSiteClassName(ContextEntry ce, UserRequest ureq) {
return HomeSite.class.getName();
}
@Override
public TabContext getTabContext(UserRequest ureq, OLATResourceable ores, ContextEntry mainEntry, List<ContextEntry> entries) {
Identity identity = ureq.getIdentity();
EPFrontendManager ePFMgr = CoreSpringFactory.getImpl(EPFrontendManager.class);
String nodeTypeName = null;
OLATResource mapOres = ePFMgr.loadOlatResourceFromByKey(mainEntry.getOLATResourceable().getResourceableId());
if(mapOres == null) {
//nothing to do;
} else if(ePFMgr.isMapOwner(identity, mapOres)) {
if("EPStructuredMap".equals(mapOres.getResourceableTypeName())) {
nodeTypeName = "EPStructuredMaps";
} else {
nodeTypeName = "EPMaps";
}
} else if(ePFMgr.isMapVisible(ureq.getIdentity(), mapOres)) {
//go to the shared pane
if(ePFMgr.isMapShared(mapOres)) {
nodeTypeName = "EPSharedMaps";
}
}
if(nodeTypeName == null) {
OLATResourceable homeRes = OresHelper.createOLATResourceableInstance("HomeSite", identity.getKey());
return new TabContext("", homeRes, Collections.<ContextEntry>emptyList());
}
OLATResourceable mapsRes = OresHelper.createOLATResourceableType(nodeTypeName);
ContextEntry mapsEntry = BusinessControlFactory.getInstance().createContextEntry(mapsRes);
List<ContextEntry> rewritedEntries = new ArrayList<ContextEntry>();
rewritedEntries.add(mapsEntry);//Menu node
rewritedEntries.add(mainEntry);//Map
if(entries != null && !entries.isEmpty()) {
rewritedEntries.addAll(entries);//more details
}
// -> HomeSite
OLATResourceable homeRes = OresHelper.createOLATResourceableInstance("HomeSite", identity.getKey());
return new TabContext("", homeRes, rewritedEntries);
}
}
}
...@@ -26,7 +26,7 @@ import org.olat.core.gui.UserRequest; ...@@ -26,7 +26,7 @@ import org.olat.core.gui.UserRequest;
import org.olat.core.gui.control.Controller; import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.WindowControl; import org.olat.core.gui.control.WindowControl;
import org.olat.core.id.context.ContextEntry; import org.olat.core.id.context.ContextEntry;
import org.olat.core.id.context.ContextEntryControllerCreator; import org.olat.core.id.context.DefaultContextEntryControllerCreator;
import org.olat.portfolio.manager.EPFrontendManager; import org.olat.portfolio.manager.EPFrontendManager;
import org.olat.portfolio.model.structel.PortfolioStructureMap; import org.olat.portfolio.model.structel.PortfolioStructureMap;
...@@ -45,7 +45,7 @@ public class EPMapOnInvitationExtension { ...@@ -45,7 +45,7 @@ public class EPMapOnInvitationExtension {
public EPMapOnInvitationExtension() { public EPMapOnInvitationExtension() {
NewControllerFactory.getInstance().addContextEntryControllerCreator("MapInvitation", new ContextEntryControllerCreator(){ NewControllerFactory.getInstance().addContextEntryControllerCreator("MapInvitation", new DefaultContextEntryControllerCreator(){
@Override @Override
public Controller createController(ContextEntry ce, UserRequest ureq, WindowControl wControl) { public Controller createController(ContextEntry ce, UserRequest ureq, WindowControl wControl) {
...@@ -64,13 +64,13 @@ public class EPMapOnInvitationExtension { ...@@ -64,13 +64,13 @@ public class EPMapOnInvitationExtension {
} }
@Override @Override
public String getTabName(ContextEntry ce) { public String getTabName(ContextEntry ce, UserRequest ureq) {
PortfolioStructureMap map = getMapFromContext(ce); PortfolioStructureMap map = getMapFromContext(ce);
return map.getTitle(); return map.getTitle();
} }
@Override @Override
public String getSiteClassName(ContextEntry ce) { public String getSiteClassName(ContextEntry ce, UserRequest ureq) {
return null; return null;
} }
......
...@@ -24,7 +24,7 @@ import org.olat.core.gui.UserRequest; ...@@ -24,7 +24,7 @@ import org.olat.core.gui.UserRequest;
import org.olat.core.gui.control.Controller; import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.WindowControl; import org.olat.core.gui.control.WindowControl;
import org.olat.core.id.context.ContextEntry; import org.olat.core.id.context.ContextEntry;
import org.olat.core.id.context.ContextEntryControllerCreator; import org.olat.core.id.context.DefaultContextEntryControllerCreator;
import org.olat.home.HomeSite; import org.olat.home.HomeSite;
import org.olat.portfolio.model.structel.EPDefaultMap; import org.olat.portfolio.model.structel.EPDefaultMap;
...@@ -43,7 +43,7 @@ public class EPMyMapsExtension { ...@@ -43,7 +43,7 @@ public class EPMyMapsExtension {
public EPMyMapsExtension() { public EPMyMapsExtension() {
NewControllerFactory.getInstance().addContextEntryControllerCreator(EPDefaultMap.class.getSimpleName(), new ContextEntryControllerCreator(){ NewControllerFactory.getInstance().addContextEntryControllerCreator(EPDefaultMap.class.getSimpleName(), new DefaultContextEntryControllerCreator(){
@Override @Override
public Controller createController(ContextEntry ce, UserRequest ureq, WindowControl wControl) { public Controller createController(ContextEntry ce, UserRequest ureq, WindowControl wControl) {
...@@ -51,13 +51,13 @@ public class EPMyMapsExtension { ...@@ -51,13 +51,13 @@ public class EPMyMapsExtension {
} }
@Override @Override
public String getTabName(ContextEntry ce) { public String getTabName(ContextEntry ce, UserRequest ureq) {
// opens in home-tab // opens in home-tab
return null; return null;
} }
@Override @Override
public String getSiteClassName(ContextEntry ce) { public String getSiteClassName(ContextEntry ce, UserRequest ureq) {
return HomeSite.class.getName(); return HomeSite.class.getName();
} }
......
...@@ -24,7 +24,7 @@ import org.olat.core.gui.UserRequest; ...@@ -24,7 +24,7 @@ import org.olat.core.gui.UserRequest;
import org.olat.core.gui.control.Controller; import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.WindowControl; import org.olat.core.gui.control.WindowControl;
import org.olat.core.id.context.ContextEntry; import org.olat.core.id.context.ContextEntry;
import org.olat.core.id.context.ContextEntryControllerCreator; import org.olat.core.id.context.DefaultContextEntryControllerCreator;
import org.olat.home.HomeSite; import org.olat.home.HomeSite;
import org.olat.portfolio.model.structel.EPStructuredMap; import org.olat.portfolio.model.structel.EPStructuredMap;
...@@ -41,7 +41,7 @@ public class EPMyStructuredMapsExtension { ...@@ -41,7 +41,7 @@ public class EPMyStructuredMapsExtension {
public EPMyStructuredMapsExtension() { public EPMyStructuredMapsExtension() {
NewControllerFactory.getInstance().addContextEntryControllerCreator(EPStructuredMap.class.getSimpleName(), new ContextEntryControllerCreator(){ NewControllerFactory.getInstance().addContextEntryControllerCreator(EPStructuredMap.class.getSimpleName(), new DefaultContextEntryControllerCreator(){
@Override @Override
public Controller createController(ContextEntry ce, UserRequest ureq, WindowControl wControl) { public Controller createController(ContextEntry ce, UserRequest ureq, WindowControl wControl) {
...@@ -49,13 +49,13 @@ public class EPMyStructuredMapsExtension { ...@@ -49,13 +49,13 @@ public class EPMyStructuredMapsExtension {
} }
@Override @Override
public String getTabName(ContextEntry ce) { public String getTabName(ContextEntry ce, UserRequest ureq) {
// opens in home-tab // opens in home-tab
return null; return null;
} }
@Override @Override
public String getSiteClassName(ContextEntry ce) { public String getSiteClassName(ContextEntry ce, UserRequest ureq) {
return HomeSite.class.getName(); return HomeSite.class.getName();
} }
......
...@@ -24,7 +24,7 @@ import org.olat.core.gui.UserRequest; ...@@ -24,7 +24,7 @@ import org.olat.core.gui.UserRequest;
import org.olat.core.gui.control.Controller; import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.WindowControl; import org.olat.core.gui.control.WindowControl;
import org.olat.core.id.context.ContextEntry; import org.olat.core.id.context.ContextEntry;
import org.olat.core.id.context.ContextEntryControllerCreator; import org.olat.core.id.context.DefaultContextEntryControllerCreator;
import org.olat.home.HomeSite; import org.olat.home.HomeSite;
/** /**
...@@ -43,7 +43,7 @@ public class EPOtherMapsExtension { ...@@ -43,7 +43,7 @@ public class EPOtherMapsExtension {
public EPOtherMapsExtension() { public EPOtherMapsExtension() {
NewControllerFactory.getInstance().addContextEntryControllerCreator("Map", NewControllerFactory.getInstance().addContextEntryControllerCreator("Map",
new ContextEntryControllerCreator() { new DefaultContextEntryControllerCreator() {
@Override @Override
public Controller createController(ContextEntry ce, UserRequest ureq, WindowControl wControl) { public Controller createController(ContextEntry ce, UserRequest ureq, WindowControl wControl) {
...@@ -51,13 +51,13 @@ public class EPOtherMapsExtension { ...@@ -51,13 +51,13 @@ public class EPOtherMapsExtension {
} }
@Override @Override
public String getTabName(ContextEntry ce) { public String getTabName(ContextEntry ce, UserRequest ureq) {
// opens in home-tab // opens in home-tab
return null; return null;
} }
@Override @Override
public String getSiteClassName(ContextEntry ce) { public String getSiteClassName(ContextEntry ce, UserRequest ureq) {
return HomeSite.class.getName(); return HomeSite.class.getName();
} }
......
...@@ -77,16 +77,10 @@ ...@@ -77,16 +77,10 @@
<bean class="org.olat.portfolio.EPArtefactPoolExtension"/> <bean class="org.olat.portfolio.EPArtefactPoolExtension"/>
<!-- Portfolio map view in users Home --> <!-- Portfolio map view in users Home -->
<bean class="org.olat.portfolio.EPMyMapsExtension"/> <bean class="org.olat.portfolio.EPMapExtension"/>
<!-- Portfolio map view for invitee --> <!-- Portfolio map view for invitee -->
<bean class="org.olat.portfolio.EPMapOnInvitationExtension"/> <bean class="org.olat.portfolio.EPMapOnInvitationExtension"/>
<!-- Portfolio map view in users Home -->
<bean class="org.olat.portfolio.EPMyStructuredMapsExtension"/>
<!-- Portfolio map view in users Home -->
<bean class="org.olat.portfolio.EPOtherMapsExtension"/>
<bean name="epArtefactManager" class="org.olat.portfolio.manager.EPArtefactManager"> <bean name="epArtefactManager" class="org.olat.portfolio.manager.EPArtefactManager">
<property name="dbInstance" ref="database"/> <property name="dbInstance" ref="database"/>
......
...@@ -926,6 +926,15 @@ public class EPFrontendManager extends BasicManager { ...@@ -926,6 +926,15 @@ public class EPFrontendManager extends BasicManager {
return structureManager.loadPortfolioStructureByKey(key); return structureManager.loadPortfolioStructureByKey(key);
} }
/**
* Load the OLAT resource with the primary of the structure element
* @param key cannot be null
* @return The resource or null if not found
*/
public OLATResource loadOlatResourceFromByKey(Long key) {
return structureManager.loadOlatResourceFromStructureElByKey(key);
}
/** /**
* Retrieve the parent of the structure * Retrieve the parent of the structure
* @param structure * @param structure
...@@ -1033,6 +1042,10 @@ public class EPFrontendManager extends BasicManager { ...@@ -1033,6 +1042,10 @@ public class EPFrontendManager extends BasicManager {
public boolean isMapShared(PortfolioStructureMap map) { public boolean isMapShared(PortfolioStructureMap map) {
OLATResource resource = map.getOlatResource(); OLATResource resource = map.getOlatResource();
return isMapShared(resource);
}
public boolean isMapShared(OLATResourceable resource) {
List<Policy> policies = securityManager.getPoliciesOfResource(resource, null); List<Policy> policies = securityManager.getPoliciesOfResource(resource, null);
for(Policy policy:policies) { for(Policy policy:policies) {
if(policy.getPermission().contains(Constants.PERMISSION_READ)) { if(policy.getPermission().contains(Constants.PERMISSION_READ)) {
......
...@@ -66,7 +66,8 @@ public class EPNotificationsHandler implements NotificationsHandler { ...@@ -66,7 +66,8 @@ public class EPNotificationsHandler implements NotificationsHandler {
// only do that if a map was found. // only do that if a map was found.
// init the helper; // init the helper;
EPNotificationsHelper helper = new EPNotificationsHelper(p.getBusinessPath(), locale, subscriber.getIdentity()); String businessPath = "[EPDefaultMap:" + amap.getKey() + "]";
EPNotificationsHelper helper = new EPNotificationsHelper(businessPath, locale, subscriber.getIdentity());
// gather all changes for the current map // gather all changes for the current map
if (NotificationsManager.getInstance().isPublisherValid(p)) { if (NotificationsManager.getInstance().isPublisherValid(p)) {
......
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