use of org.olat.core.id.context.ContextEntry in project openolat by klemens.
the class WikiHandler method createLaunchController.
@Override
public MainLayoutController createLaunchController(RepositoryEntry re, RepositoryEntrySecurity reSecurity, UserRequest ureq, WindowControl wControl) {
// first handle special case: disabled wiki for security (XSS Attacks) reasons
BaseSecurityModule securityModule = CoreSpringFactory.getImpl(BaseSecurityModule.class);
if (!securityModule.isWikiEnabled()) {
return RepositoyUIFactory.createRepoEntryDisabledDueToSecurityMessageController(ureq, wControl);
}
// check role
boolean isOLatAdmin = ureq.getUserSession().getRoles().isOLATAdmin();
boolean isGuestOnly = ureq.getUserSession().getRoles().isGuestOnly();
boolean isResourceOwner = false;
if (isOLatAdmin) {
isResourceOwner = true;
} else {
isResourceOwner = reSecurity.isOwner();
}
OLATResource res = re.getOlatResource();
BusinessControl bc = wControl.getBusinessControl();
final ContextEntry ce = bc.popLauncherContextEntry();
SubscriptionContext subsContext = new SubscriptionContext(res, WikiManager.WIKI_RESOURCE_FOLDER_NAME);
final WikiSecurityCallback callback = new WikiSecurityCallbackImpl(null, isOLatAdmin, isGuestOnly, false, isResourceOwner, subsContext);
RepositoryEntryRuntimeController runtime = new RepositoryEntryRuntimeController(ureq, wControl, re, reSecurity, new RuntimeControllerCreator() {
@Override
public Controller create(UserRequest uureq, WindowControl wwControl, TooledStackedPanel toolbarPanel, RepositoryEntry entry, RepositoryEntrySecurity security, AssessmentMode assessmentMode) {
CoreSpringFactory.getImpl(UserCourseInformationsManager.class).updateUserCourseInformations(entry.getOlatResource(), uureq.getIdentity());
Controller controller;
if (ce != null) {
// jump to a certain context
OLATResourceable ores = ce.getOLATResourceable();
String typeName = ores.getResourceableTypeName();
String page = typeName.substring("page=".length());
controller = new WikiMainController(uureq, wwControl, entry.getOlatResource(), callback, page);
} else {
controller = new WikiMainController(uureq, wwControl, entry.getOlatResource(), callback, null);
}
return new OLATResourceableListeningWrapperController(uureq, wwControl, entry.getOlatResource(), controller, null, uureq.getIdentity());
}
});
return runtime;
}
use of org.olat.core.id.context.ContextEntry in project openolat by klemens.
the class OverviewRepositoryListController method activate.
@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
if (entries == null || entries.isEmpty()) {
if (currentCtrl == null) {
if (isGuestOnly) {
doOpenMyCourses(ureq);
segmentView.select(myCourseLink);
} else {
boolean markEmpty = doOpenMark(ureq).isEmpty();
if (markEmpty) {
doOpenMyCourses(ureq);
segmentView.select(myCourseLink);
} else {
segmentView.select(favoriteLink);
}
}
}
if (favoritDirty && markedCtrl != null) {
markedCtrl.reloadRows();
}
if (myDirty && myCoursesCtrl != null) {
myCoursesCtrl.reloadRows();
}
addToHistory(ureq, this);
} else {
ContextEntry entry = entries.get(0);
String segment = entry.getOLATResourceable().getResourceableTypeName();
List<ContextEntry> subEntries = entries.subList(1, entries.size());
if ("Favorits".equalsIgnoreCase(segment)) {
if (isGuestOnly) {
doOpenMyCourses(ureq).activate(ureq, subEntries, entry.getTransientState());
segmentView.select(myCourseLink);
} else {
doOpenMark(ureq).activate(ureq, subEntries, entry.getTransientState());
segmentView.select(favoriteLink);
}
} else if ("My".equalsIgnoreCase(segment)) {
doOpenMyCourses(ureq).activate(ureq, subEntries, entry.getTransientState());
segmentView.select(myCourseLink);
} else if (("Catalog".equalsIgnoreCase(segment) || "CatalogEntry".equalsIgnoreCase(segment)) && catalogLink != null) {
CatalogNodeController ctrl = doOpenCatalog(ureq);
if (ctrl != null) {
ctrl.activate(ureq, entries, entry.getTransientState());
segmentView.select(catalogLink);
}
} else if ("Search".equalsIgnoreCase(segment) && searchCourseLink != null) {
doOpenSearchCourses(ureq).activate(ureq, subEntries, entry.getTransientState());
segmentView.select(searchCourseLink);
} else if ("Closed".equalsIgnoreCase(segment) && closedCourseLink != null) {
doOpenClosedCourses(ureq).activate(ureq, subEntries, entry.getTransientState());
segmentView.select(closedCourseLink);
} else {
// default if the others fail
doOpenMyCourses(ureq).activate(ureq, subEntries, entry.getTransientState());
segmentView.select(myCourseLink);
}
}
}
use of org.olat.core.id.context.ContextEntry in project openolat by klemens.
the class CatalogManagerController method activate.
@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
if (entries == null || entries.isEmpty())
return;
ContextEntry entry = entries.get(0);
String type = entry.getOLATResourceable().getResourceableTypeName();
if ("CatalogEntry".equalsIgnoreCase(type)) {
Long entryKey = entry.getOLATResourceable().getResourceableId();
if (entryKey != null && entryKey.longValue() > 0) {
List<ContextEntry> parentLine = new ArrayList<>();
for (CatalogEntry node = catalogManager.getCatalogEntryByKey(entryKey); node != null && node.getParent() != null; node = node.getParent()) {
OLATResourceable nodeRes = OresHelper.createOLATResourceableInstance("Node", node.getKey());
ContextEntry ctxEntry = BusinessControlFactory.getInstance().createContextEntry(nodeRes);
ctxEntry.setTransientState(new CatalogStateEntry(node));
parentLine.add(ctxEntry);
}
Collections.reverse(parentLine);
toolbarPanel.popUpToRootController(ureq);
catalogCtrl.activate(ureq, parentLine, null);
}
}
}
use of org.olat.core.id.context.ContextEntry in project openolat by klemens.
the class CatalogNodeController method activate.
@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
if (entries == null || entries.isEmpty()) {
return;
}
ContextEntry entry = entries.get(0);
String type = entry.getOLATResourceable().getResourceableTypeName();
if ("CatalogEntry".equalsIgnoreCase(type)) {
Long entryKey = entry.getOLATResourceable().getResourceableId();
if (entryKey != null && entryKey.longValue() > 0) {
activateRoot(ureq, entryKey);
}
} else if ("Node".equalsIgnoreCase(type)) {
// the "Node" is only for internal usage
StateEntry stateEntry = entry.getTransientState();
if (stateEntry instanceof CatalogStateEntry) {
CatalogEntry catalogEntry = ((CatalogStateEntry) stateEntry).getEntry();
CatalogNodeController nextCtrl = selectCatalogEntry(ureq, catalogEntry);
if (nextCtrl != null && entries.size() > 1) {
nextCtrl.activate(ureq, entries.subList(1, entries.size()), null);
}
}
}
}
use of org.olat.core.id.context.ContextEntry in project openolat by klemens.
the class CatalogNodeManagerController method activateRoot.
/**
* Build an internal business path made of "Node" with the category
* as state entry to prevent loading several times the same entries.
*
* @param ureq
* @param entryKey
*/
private void activateRoot(UserRequest ureq, Long entryKey) {
List<ContextEntry> parentLine = new ArrayList<>();
for (CatalogEntry node = catalogManager.getCatalogEntryByKey(entryKey); node.getParent() != null; node = node.getParent()) {
OLATResourceable nodeRes = OresHelper.createOLATResourceableInstance("Node", node.getKey());
ContextEntry ctxEntry = BusinessControlFactory.getInstance().createContextEntry(nodeRes);
ctxEntry.setTransientState(new CatalogStateEntry(node));
parentLine.add(ctxEntry);
}
Collections.reverse(parentLine);
activate(ureq, parentLine, null);
}
Aggregations