use of org.olat.core.id.context.ContextEntry in project openolat by klemens.
the class BaseFullWebappController method updateBusinessPath.
private void updateBusinessPath(UserRequest ureq, DTab tab) {
// dtabToBusinessPath is null if the controller is disposed
if (tab == null || dtabToBusinessPath == null)
return;
try {
String businessPath = tab.getController().getWindowControlForDebug().getBusinessControl().getAsString();
HistoryPoint point = ureq.getUserSession().getLastHistoryPoint();
int index = businessPath.indexOf(']');
if (index > 0 && point != null && point.getBusinessPath() != null) {
String start = businessPath.substring(0, index);
if (!point.getBusinessPath().startsWith(start)) {
// if a controller has not set its business path, don't pollute the mapping
List<ContextEntry> entries = tab.getController().getWindowControlForDebug().getBusinessControl().getEntries();
dtabToBusinessPath.put(tab, new HistoryPointImpl(ureq.getUuid(), businessPath, entries));
return;
}
}
dtabToBusinessPath.put(tab, point);
} catch (Exception e) {
logError("", e);
}
}
use of org.olat.core.id.context.ContextEntry in project openolat by klemens.
the class SendInfoMailFormatter method getBody.
@Override
public String getBody(InfoMessage msg) {
BusinessControlFactory bCF = BusinessControlFactory.getInstance();
List<ContextEntry> ceList = bCF.createCEListFromString(businessPath);
String busPath = BusinessControlFactory.getInstance().getBusinessPathAsURIFromCEList(ceList);
String author = msg.getAuthor().getUser().getProperty(UserConstants.FIRSTNAME, null) + " " + msg.getAuthor().getUser().getProperty(UserConstants.LASTNAME, null);
String date = DateFormat.getDateInstance(DateFormat.MEDIUM, translator.getLocale()).format(msg.getCreationDate());
String link = Settings.getServerContextPathURI() + "/url/" + busPath;
StringBuilder sb = new StringBuilder();
sb.append("<div style='background: #FAFAFA; border: 1px solid #eee; border-radius: 5px; padding: 0 0.5em 0.5em 0.5em; margin: 1em 0 1em 0;' class='o_m_h'>");
sb.append("<h3>").append(translator.translate("mail.body.title", new String[] { title })).append("</h3>");
sb.append("<div style='font-size: 90%; color: #888' class='o_m_a'>").append(translator.translate("mail.body.from", new String[] { author, date })).append("</div>");
sb.append("</div>");
sb.append("<div style='background: #FAFAFA; padding: 5px 5px; margin: 10px 0;' class='o_m_c'>");
sb.append(msg.getMessage());
sb.append("<div style='margin: 2em 0 1em 0;' class='o_m_m'>").append("<a href='").append(link).append("'>");
sb.append(translator.translate("mail.body.more"));
sb.append(" »</a></div>");
sb.append("</div>");
return sb.toString();
}
use of org.olat.core.id.context.ContextEntry in project openolat by klemens.
the class UserActivityLoggerImpl method frameworkSetBusinessPathFromWindowControl.
@Override
public void frameworkSetBusinessPathFromWindowControl(WindowControl wControl) {
if (wControl != null && wControl.getBusinessControl() != null) {
if (wControl.getBusinessControl() instanceof StackedBusinessControl) {
StackedBusinessControl sbc = (StackedBusinessControl) wControl.getBusinessControl();
final List<ContextEntry> ces = sbc.getContextEntryStack();
if (ces != null) {
frameworkSetBCContextEntries(new LinkedList<ContextEntry>(ces));
}
}
final String bp = wControl.getBusinessControl().getAsString();
frameworkSetBusinessPath(bp);
}
}
use of org.olat.core.id.context.ContextEntry in project openolat by klemens.
the class ModifyCourseEvent method createHelpCourseLaunchController.
/**
* Create a user locale dependent help-course run controller
*
* @param ureq The user request
* @param wControl The current window controller
* @return The help-course run controller
*/
public static Controller createHelpCourseLaunchController(UserRequest ureq, WindowControl wControl) {
// Find repository entry for this course
String helpCourseSoftKey = CoreSpringFactory.getImpl(CourseModule.class).getHelpCourseSoftKey();
RepositoryManager rm = RepositoryManager.getInstance();
RepositoryService rs = CoreSpringFactory.getImpl(RepositoryService.class);
RepositoryEntry entry = null;
if (StringHelper.containsNonWhitespace(helpCourseSoftKey)) {
entry = rm.lookupRepositoryEntryBySoftkey(helpCourseSoftKey, false);
}
if (entry == null) {
Translator translator = Util.createPackageTranslator(CourseFactory.class, ureq.getLocale());
wControl.setError(translator.translate("error.helpcourse.not.configured"));
// create empty main controller
LayoutMain3ColsController emptyCtr = new LayoutMain3ColsController(ureq, wControl, null, null, null);
return emptyCtr;
} else {
// Increment launch counter
rs.incrementLaunchCounter(entry);
ICourse course = loadCourse(entry);
ContextEntry ce = BusinessControlFactory.getInstance().createContextEntry(entry);
WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ce, wControl);
RepositoryEntrySecurity reSecurity = new RepositoryEntrySecurity(false, false, false, false, false, false, false, true, false);
RunMainController launchC = new RunMainController(ureq, bwControl, null, course, entry, reSecurity, null);
return launchC;
}
}
use of org.olat.core.id.context.ContextEntry in project openolat by klemens.
the class PodcastCourseNode method createNodeRunConstructionResult.
/**
* @see org.olat.course.nodes.AbstractAccessableCourseNode#createNodeRunConstructionResult(org.olat.core.gui.UserRequest,
* org.olat.core.gui.control.WindowControl,
* org.olat.course.run.userview.UserCourseEnvironment,
* org.olat.course.run.userview.NodeEvaluation, java.lang.String)
*/
@Override
public NodeRunConstructionResult createNodeRunConstructionResult(UserRequest ureq, WindowControl control, UserCourseEnvironment userCourseEnv, NodeEvaluation ne, String nodecmd) {
RepositoryEntry entry = getReferencedRepositoryEntry();
// create business path courseID:nodeID
// userCourseEnv.getCourseEnvironment().getCourseResourceableId();
// getIdent();
Long courseId = userCourseEnv.getCourseEnvironment().getCourseResourceableId();
String nodeId = this.getIdent();
boolean isAdmin = ureq.getUserSession().getRoles().isOLATAdmin();
boolean isGuest = ureq.getUserSession().getRoles().isGuestOnly();
boolean isOwner = RepositoryManager.getInstance().isOwnerOfRepositoryEntry(ureq.getIdentity(), entry);
FeedSecurityCallback callback;
if (userCourseEnv.isCourseReadOnly()) {
callback = new FeedReadOnlySecurityCallback();
} else {
callback = new FeedNodeSecurityCallback(ne, isAdmin, isOwner, isGuest);
}
SubscriptionContext subsContext = CourseModule.createSubscriptionContext(userCourseEnv.getCourseEnvironment(), this);
callback.setSubscriptionContext(subsContext);
ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrap(this));
FeedMainController podcastCtr = PodcastUIFactory.getInstance(ureq.getLocale()).createMainController(entry.getOlatResource(), ureq, control, callback, courseId, nodeId);
List<ContextEntry> entries = BusinessControlFactory.getInstance().createCEListFromResourceType(nodecmd);
podcastCtr.activate(ureq, entries, null);
Controller wrapperCtrl = TitledWrapperHelper.getWrapper(ureq, control, podcastCtr, this, "o_podcast_icon");
NodeRunConstructionResult result = new NodeRunConstructionResult(wrapperCtrl);
return result;
}
Aggregations