Search in sources :

Example 71 with OLATResourceable

use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.

the class LectureRepositoryAdminController method doOpenParticipants.

private void doOpenParticipants(UserRequest ureq) {
    if (participantsCtrl == null) {
        OLATResourceable ores = OresHelper.createOLATResourceableType("Participants");
        WindowControl swControl = addToHistory(ureq, ores, null);
        participantsCtrl = new ParticipantListRepositoryController(ureq, swControl, entry, false, true);
        listenTo(participantsCtrl);
    } else {
        addToHistory(ureq, participantsCtrl);
    }
    mainVC.put("segmentCmp", participantsCtrl.getInitialComponent());
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) WindowControl(org.olat.core.gui.control.WindowControl)

Example 72 with OLATResourceable

use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.

the class WikiMainController method activate.

@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
    if (entries == null || entries.isEmpty())
        return;
    Wiki wiki = getWiki();
    if (wiki == null) {
        return;
    }
    ContextEntry ce = entries.get(0);
    String typ = ce.getOLATResourceable().getResourceableTypeName();
    if ("az".equalsIgnoreCase(typ)) {
        openAtoZPage(ureq, wiki);
    } else if ("lastChanges".equalsIgnoreCase(typ)) {
        openLastChangesPage(ureq, wiki);
    } else if ("index".equalsIgnoreCase(typ)) {
        WikiPage page = openIndexPage(ureq, wiki);
        pageId = page.getPageId();
    } else if ("Forum".equalsIgnoreCase(typ)) {
        Long forumKey = ce.getOLATResourceable().getResourceableId();
        for (WikiPage page : wiki.getAllPagesWithContent()) {
            if (forumKey.longValue() == page.getForumKey()) {
                if (page != null) {
                    this.pageId = page.getPageId();
                }
                updatePageContext(ureq, page);
                OLATResourceable tabOres = OresHelper.createOLATResourceableInstance("tab", 1l);
                ContextEntry tabCe = BusinessControlFactory.getInstance().createContextEntry(tabOres);
                tabs.activate(ureq, Collections.singletonList(tabCe), null);
                if (forumController != null && entries.size() > 1) {
                    List<ContextEntry> subEntries = entries.subList(1, entries.size());
                    forumController.activate(ureq, subEntries, null);
                }
                break;
            }
        }
    } else {
        String path = BusinessControlFactory.getInstance().getPath(ce);
        if (path.startsWith("page=")) {
            path = path.substring(5, path.length());
        }
        String activatePageId = WikiManager.generatePageId(FilterUtil.normalizeWikiLink(path));
        if (wiki.pageExists(activatePageId)) {
            WikiPage page = wiki.getPage(activatePageId, true);
            if (page != null) {
                this.pageId = page.getPageId();
            }
            updatePageContext(ureq, page);
            if (entries.size() > 1) {
                List<ContextEntry> subEntries = entries.subList(1, entries.size());
                String subTyp = subEntries.get(0).getOLATResourceable().getResourceableTypeName();
                if ("tab".equalsIgnoreCase(subTyp)) {
                    tabs.activate(ureq, subEntries, ce.getTransientState());
                } else if ("message".equalsIgnoreCase(subTyp)) {
                    OLATResourceable tabOres = OresHelper.createOLATResourceableInstance("tab", 1l);
                    ContextEntry tabCe = BusinessControlFactory.getInstance().createContextEntry(tabOres);
                    tabs.activate(ureq, Collections.singletonList(tabCe), null);
                    forumController.activate(ureq, subEntries, null);
                }
            }
        }
    }
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) List(java.util.List) ArrayList(java.util.ArrayList) ContextEntry(org.olat.core.id.context.ContextEntry)

Example 73 with OLATResourceable

use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.

the class WikiMainController method updatePageContext.

/**
 * update depended velocity contexts and componetens with latest globally
 * used page
 */
private void updatePageContext(UserRequest ureq, WikiPage page) {
    if (page.getPageName().equals(WikiPage.WIKI_ERROR)) {
        wikiArticleComp.setWikiContent(translate(page.getContent()));
    } else {
        wikiArticleComp.setWikiContent(page.getContent());
    }
    wikiEditForm.setPage(page);
    diffs.clear();
    content.contextPut("page", page);
    articleContent.contextPut("page", page);
    discussionContent.contextPut("page", page);
    editContent.remove(wikiVersionDisplayComp);
    editContent.contextPut("page", page);
    versioningContent.remove(wikiVersionDisplayComp);
    versioningContent.contextPut("page", page);
    boolean userIsPageCreator = getIdentity().getKey().equals(page.getInitalAuthor());
    if (userIsPageCreator) {
        String subPath = page.getPageName();
        String businessPath = getWindowControl().getBusinessControl().getAsString();
        businessPath += "[page=" + subPath + ":0]";
        OLATResourceable wikiRes = OresHelper.createOLATResourceableInstance(WikiArtefact.ARTEFACT_TYPE, ores.getResourceableId());
        if (portfolioModule.isEnabled()) {
            MediaCollectorComponent collectorCmp = new MediaCollectorComponent("portfolio-link", getWindowControl(), page, wikiMediaHandler, businessPath);
            navigationContent.put("portfolio-link", collectorCmp);
        } else {
            Controller ePFCollCtrl = EPUIFactory.createArtefactCollectWizzardController(ureq, getWindowControl(), wikiRes, businessPath);
            if (ePFCollCtrl != null) {
                navigationContent.put("portfolio-link", ePFCollCtrl.getInitialComponent());
            }
        }
    } else {
        clearPortfolioLink();
    }
    OLATResourceable pageRes = OresHelper.createOLATResourceableInstanceWithoutCheck("path=" + page.getPageName(), 0l);
    addToHistory(ureq, pageRes, null);
}
Also used : MediaCollectorComponent(org.olat.modules.portfolio.ui.component.MediaCollectorComponent) OLATResourceable(org.olat.core.id.OLATResourceable) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) DialogBoxController(org.olat.core.gui.control.generic.modal.DialogBoxController) BasicController(org.olat.core.gui.control.controller.BasicController) CloseableCalloutWindowController(org.olat.core.gui.control.generic.closablewrapper.CloseableCalloutWindowController) CloneableController(org.olat.core.gui.control.generic.clone.CloneableController) ContextualSubscriptionController(org.olat.core.commons.services.notifications.ui.ContextualSubscriptionController) ForumController(org.olat.modules.fo.ui.ForumController) Controller(org.olat.core.gui.control.Controller) TableController(org.olat.core.gui.components.table.TableController)

Example 74 with OLATResourceable

use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.

the class NoteManager method fireBookmarkEvent.

/**
 * Fire NoteEvent for a specific user after save/update/delete note.
 * @param identity
 */
private void fireBookmarkEvent(Identity identity) {
    // event this identity
    NoteEvent noteEvent = new NoteEvent(identity.getKey());
    OLATResourceable eventBusOres = OresHelper.createOLATResourceableInstance(Identity.class, identity.getKey());
    // TODO: LD: use SingleUserEventCenter
    CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(noteEvent, eventBusOres);
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable)

Example 75 with OLATResourceable

use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.

the class DialogCourseNodeIndexer method checkAccess.

@Override
public boolean checkAccess(ContextEntry contextEntry, BusinessControl businessControl, Identity identity, Roles roles) {
    ContextEntry ce = businessControl.popLauncherContextEntry();
    if (ce == null || ce.getOLATResourceable() == null || ce.getOLATResourceable().getResourceableId() == null) {
        // it's the node itself
        return true;
    }
    OLATResourceable ores = ce.getOLATResourceable();
    if (isLogDebugEnabled())
        logDebug("OLATResourceable=" + ores);
    if (ores.getResourceableTypeName().startsWith("path=")) {
        // => it is a file element, typeName format: 'path=/test1/test2/readme.txt'
        return true;
    } else if (ores.getResourceableTypeName().equals(OresHelper.calculateTypeName(Message.class))) {
        // it is message => check message access
        Long resourceableId = ores.getResourceableId();
        Message message = ForumManager.getInstance().loadMessage(resourceableId);
        Message threadtop = message.getThreadtop();
        if (threadtop == null) {
            threadtop = message;
        }
        boolean isMessageHidden = Status.getStatus(threadtop.getStatusCode()).isHidden();
        // TODO: (LD) fix this!!! - the contextEntry is not the right context for this check
        if (isMessageHidden) {
            boolean isOwner = BaseSecurityManager.getInstance().isIdentityPermittedOnResourceable(identity, Constants.PERMISSION_ACCESS, contextEntry.getOLATResourceable());
            return isOwner;
        }
        return true;
    } else {
        logWarn("In DialogCourseNode unkown OLATResourceable=" + ores, null);
        return false;
    }
}
Also used : Message(org.olat.modules.fo.Message) OLATResourceable(org.olat.core.id.OLATResourceable) ContextEntry(org.olat.core.id.context.ContextEntry)

Aggregations

OLATResourceable (org.olat.core.id.OLATResourceable)924 WindowControl (org.olat.core.gui.control.WindowControl)304 Test (org.junit.Test)158 Identity (org.olat.core.id.Identity)154 RepositoryEntry (org.olat.repository.RepositoryEntry)130 ContextEntry (org.olat.core.id.context.ContextEntry)82 ArrayList (java.util.ArrayList)68 OLATResource (org.olat.resource.OLATResource)60 Controller (org.olat.core.gui.control.Controller)48 Date (java.util.Date)46 AssertException (org.olat.core.logging.AssertException)32 StateSite (org.olat.core.id.context.StateSite)30 SyncerExecutor (org.olat.core.util.coordinate.SyncerExecutor)30 ICourse (org.olat.course.ICourse)30 CourseNode (org.olat.course.nodes.CourseNode)28 DBCheckbox (org.olat.course.nodes.cl.model.DBCheckbox)28 BusinessControl (org.olat.core.id.context.BusinessControl)24 BusinessGroup (org.olat.group.BusinessGroup)24 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)22 BinderSecurityCallback (org.olat.modules.portfolio.BinderSecurityCallback)22