Search in sources :

Example 96 with ContextEntry

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);
    }
}
Also used : HistoryPointImpl(org.olat.core.id.context.HistoryPointImpl) HistoryPoint(org.olat.core.id.context.HistoryPoint) HistoryPoint(org.olat.core.id.context.HistoryPoint) ContextEntry(org.olat.core.id.context.ContextEntry) AssertException(org.olat.core.logging.AssertException)

Example 97 with ContextEntry

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(" &raquo;</a></div>");
    sb.append("</div>");
    return sb.toString();
}
Also used : BusinessControlFactory(org.olat.core.id.context.BusinessControlFactory) ContextEntry(org.olat.core.id.context.ContextEntry)

Example 98 with ContextEntry

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);
    }
}
Also used : StackedBusinessControl(org.olat.core.id.context.StackedBusinessControl) ContextEntry(org.olat.core.id.context.ContextEntry)

Example 99 with ContextEntry

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;
    }
}
Also used : Translator(org.olat.core.gui.translator.Translator) RepositoryEntrySecurity(org.olat.repository.model.RepositoryEntrySecurity) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) RunMainController(org.olat.course.run.RunMainController) RepositoryManager(org.olat.repository.RepositoryManager) RepositoryEntry(org.olat.repository.RepositoryEntry) WindowControl(org.olat.core.gui.control.WindowControl) ContextEntry(org.olat.core.id.context.ContextEntry) RepositoryService(org.olat.repository.RepositoryService)

Example 100 with ContextEntry

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;
}
Also used : FeedMainController(org.olat.modules.webFeed.ui.FeedMainController) FeedSecurityCallback(org.olat.modules.webFeed.FeedSecurityCallback) RepositoryEntry(org.olat.repository.RepositoryEntry) TabbableController(org.olat.core.gui.control.generic.tabbable.TabbableController) FeedMainController(org.olat.modules.webFeed.ui.FeedMainController) PodcastNodeEditController(org.olat.course.nodes.feed.podcast.PodcastNodeEditController) FeedNodeEditController(org.olat.course.nodes.feed.FeedNodeEditController) Controller(org.olat.core.gui.control.Controller) NodeEditController(org.olat.course.editor.NodeEditController) FeedPeekviewController(org.olat.course.nodes.feed.FeedPeekviewController) NodeRunConstructionResult(org.olat.course.run.navigation.NodeRunConstructionResult) ContextEntry(org.olat.core.id.context.ContextEntry) FeedNodeSecurityCallback(org.olat.course.nodes.feed.FeedNodeSecurityCallback) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) FeedReadOnlySecurityCallback(org.olat.modules.webFeed.FeedReadOnlySecurityCallback)

Aggregations

ContextEntry (org.olat.core.id.context.ContextEntry)270 OLATResourceable (org.olat.core.id.OLATResourceable)78 WindowControl (org.olat.core.gui.control.WindowControl)58 Activateable2 (org.olat.core.gui.control.generic.dtabs.Activateable2)44 ArrayList (java.util.ArrayList)42 TreeNode (org.olat.core.gui.components.tree.TreeNode)30 Controller (org.olat.core.gui.control.Controller)26 RepositoryEntry (org.olat.repository.RepositoryEntry)24 List (java.util.List)22 Identity (org.olat.core.id.Identity)22 BusinessControl (org.olat.core.id.context.BusinessControl)22 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)20 BusinessControlFactory (org.olat.core.id.context.BusinessControlFactory)18 HistoryPoint (org.olat.core.id.context.HistoryPoint)18 CollaborationTools (org.olat.collaboration.CollaborationTools)16 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)14 UserSession (org.olat.core.util.UserSession)14 CourseNode (org.olat.course.nodes.CourseNode)14 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)12 Translator (org.olat.core.gui.translator.Translator)12