Search in sources :

Example 21 with BusinessControl

use of org.olat.core.id.context.BusinessControl in project openolat by klemens.

the class ViteroBookingsAdminController method openResource.

protected void openResource(UserRequest ureq, ViteroBooking booking) {
    Property prop = booking.getProperty();
    if (prop != null) {
        String url;
        if (prop.getGrp() != null) {
            url = "[BusinessGroup:" + prop.getGrp().getKey() + "]";
        } else {
            OLATResourceable ores = OresHelper.createOLATResourceableInstance(prop.getResourceTypeName(), prop.getResourceTypeId());
            RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntry(ores, false);
            if (re != null) {
                url = "[RepositoryEntry:" + re.getKey() + "]";
            } else {
                showWarning("resource.dont.exist");
                return;
            }
        }
        BusinessControl bc = BusinessControlFactory.getInstance().createFromString(url);
        WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(bc, getWindowControl());
        NewControllerFactory.getInstance().launch(ureq, bwControl);
    }
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) BusinessControl(org.olat.core.id.context.BusinessControl) RepositoryEntry(org.olat.repository.RepositoryEntry) WindowControl(org.olat.core.gui.control.WindowControl) Property(org.olat.properties.Property)

Example 22 with BusinessControl

use of org.olat.core.id.context.BusinessControl in project openolat by klemens.

the class BlogArtefactHandler method prefillBlogArtefact.

private void prefillBlogArtefact(AbstractArtefact artefact, Feed feed, Item item) {
    VFSContainer itemContainer = FeedManager.getInstance().getItemContainer(item);
    artefact.setFileSourceContainer(itemContainer);
    artefact.setTitle(item.getTitle());
    artefact.setDescription(item.getDescription());
    VFSLeaf itemXml = (VFSLeaf) itemContainer.resolve(BlogArtefact.BLOG_FILE_NAME);
    if (itemXml != null) {
        InputStream in = itemXml.getInputStream();
        String xml = FileUtils.load(in, "UTF-8");
        artefact.setFulltextContent(xml);
        FileUtils.closeSafely(in);
    }
    String origBPath = artefact.getBusinessPath();
    String artSource = "";
    BusinessControl bc = BusinessControlFactory.getInstance().createFromString(origBPath);
    if (origBPath.contains(CourseNode.class.getSimpleName())) {
        // blog-post from inside a course, rebuild "course-name - feed-name"
        OLATResourceable ores = bc.popLauncherContextEntry().getOLATResourceable();
        RepositoryEntry repoEntry = RepositoryManager.getInstance().lookupRepositoryEntry(ores.getResourceableId());
        artSource = repoEntry.getDisplayname();
        if (feed != null) {
            artSource += " - " + feed.getTitle();
        }
    } else if (origBPath.contains(RepositoryEntry.class.getSimpleName())) {
        // blog-post from blog-LR, only get name itself
        if (feed != null) {
            artSource = feed.getTitle();
        }
    } else {
        // collecting a post from live-blog, [Identity:xy]
        if (feed != null) {
            artSource = feed.getTitle();
        }
    }
    artefact.setSource(artSource);
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) OLATResourceable(org.olat.core.id.OLATResourceable) InputStream(java.io.InputStream) VFSContainer(org.olat.core.util.vfs.VFSContainer) BusinessControl(org.olat.core.id.context.BusinessControl) CourseNode(org.olat.course.nodes.CourseNode) RepositoryEntry(org.olat.repository.RepositoryEntry)

Example 23 with BusinessControl

use of org.olat.core.id.context.BusinessControl in project openolat by klemens.

the class EventsModel method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
 *      org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
 */
@Override
public void event(UserRequest ureq, Controller source, Event event) {
    if (source == tableController) {
        if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
            TableEvent te = (TableEvent) event;
            String actionid = te.getActionId();
            if (actionid.equals(CMD_LAUNCH)) {
                int rowid = te.getRowId();
                KalendarEvent kalendarEvent = ((EventsModel) tableController.getTableDataModel()).getObject(rowid);
                String resourceUrl = "[HomeSite:" + ureq.getIdentity().getKey() + "][calendar:0]" + BusinessControlFactory.getInstance().getContextEntryStringForDate(kalendarEvent.getBegin());
                BusinessControl bc = BusinessControlFactory.getInstance().createFromString(resourceUrl);
                WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(bc, getWindowControl());
                NewControllerFactory.getInstance().launch(ureq, bwControl);
            }
        }
    }
}
Also used : TableEvent(org.olat.core.gui.components.table.TableEvent) BusinessControl(org.olat.core.id.context.BusinessControl) KalendarEvent(org.olat.commons.calendar.model.KalendarEvent) WindowControl(org.olat.core.gui.control.WindowControl)

Example 24 with BusinessControl

use of org.olat.core.id.context.BusinessControl in project openolat by klemens.

the class NotesPortletRunController method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest, org.olat.core.gui.components.Component, org.olat.core.gui.control.Event)
 */
public void event(UserRequest ureq, Component source, Event event) {
    if (source == showAllLink) {
        // fxdiff: activate homes tab in top navigation and activate correct menu item
        String resourceUrl = "[HomeSite:" + ureq.getIdentity().getKey() + "][notelist:0]";
        BusinessControl bc = BusinessControlFactory.getInstance().createFromString(resourceUrl);
        WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(bc, getWindowControl());
        NewControllerFactory.getInstance().launch(ureq, bwControl);
    }
}
Also used : BusinessControl(org.olat.core.id.context.BusinessControl) WindowControl(org.olat.core.gui.control.WindowControl)

Example 25 with BusinessControl

use of org.olat.core.id.context.BusinessControl 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;
}
Also used : TooledStackedPanel(org.olat.core.gui.components.stack.TooledStackedPanel) AssessmentMode(org.olat.course.assessment.AssessmentMode) OLATResourceable(org.olat.core.id.OLATResourceable) WikiMainController(org.olat.modules.wiki.WikiMainController) BusinessControl(org.olat.core.id.context.BusinessControl) BaseSecurityModule(org.olat.basesecurity.BaseSecurityModule) OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry) WindowControl(org.olat.core.gui.control.WindowControl) OLATResourceableListeningWrapperController(org.olat.core.util.controller.OLATResourceableListeningWrapperController) StepsMainRunController(org.olat.core.gui.control.generic.wizard.StepsMainRunController) MainLayoutController(org.olat.core.gui.control.generic.layout.MainLayoutController) RepositoryEntryRuntimeController(org.olat.repository.ui.RepositoryEntryRuntimeController) Controller(org.olat.core.gui.control.Controller) WikiMainController(org.olat.modules.wiki.WikiMainController) ContextEntry(org.olat.core.id.context.ContextEntry) RepositoryEntryRuntimeController(org.olat.repository.ui.RepositoryEntryRuntimeController) RuntimeControllerCreator(org.olat.repository.ui.RepositoryEntryRuntimeController.RuntimeControllerCreator) WikiSecurityCallbackImpl(org.olat.modules.wiki.WikiSecurityCallbackImpl) RepositoryEntrySecurity(org.olat.repository.model.RepositoryEntrySecurity) OLATResourceableListeningWrapperController(org.olat.core.util.controller.OLATResourceableListeningWrapperController) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) WikiSecurityCallback(org.olat.modules.wiki.WikiSecurityCallback) UserRequest(org.olat.core.gui.UserRequest)

Aggregations

BusinessControl (org.olat.core.id.context.BusinessControl)80 WindowControl (org.olat.core.gui.control.WindowControl)56 OLATResourceable (org.olat.core.id.OLATResourceable)24 ContextEntry (org.olat.core.id.context.ContextEntry)22 RepositoryEntry (org.olat.repository.RepositoryEntry)16 ArrayList (java.util.ArrayList)14 Controller (org.olat.core.gui.control.Controller)8 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)6 Window (org.olat.core.gui.components.Window)6 HistoryPoint (org.olat.core.id.context.HistoryPoint)6 CourseNode (org.olat.course.nodes.CourseNode)6 Date (java.util.Date)4 UserRequest (org.olat.core.gui.UserRequest)4 DTab (org.olat.core.gui.control.generic.dtabs.DTab)4 DTabs (org.olat.core.gui.control.generic.dtabs.DTabs)4 Identity (org.olat.core.id.Identity)4 Roles (org.olat.core.id.Roles)4 BusinessControlFactory (org.olat.core.id.context.BusinessControlFactory)4 NodeRunConstructionResult (org.olat.course.run.navigation.NodeRunConstructionResult)4 IOException (java.io.IOException)3