Search in sources :

Example 1 with CommentAndRatingSecurityCallback

use of org.olat.core.commons.services.commentAndRating.CommentAndRatingSecurityCallback in project OpenOLAT by OpenOLAT.

the class ItemsController method createCommentsAndRatingsLink.

/**
 * Create comments and rating component link for given feed item
 *
 * @param ureq
 * @param feed
 * @param item
 */
private void createCommentsAndRatingsLink(UserRequest ureq, Feed feed, Item item) {
    if (feed == null || item == null)
        // check against concurrent changes
        return;
    if (CoreSpringFactory.containsBean(CommentAndRatingService.class)) {
        if (commentsLinks == null) {
            commentsLinks = new HashMap<>();
        } else if (commentsLinks.containsKey(item)) {
            removeAsListenerAndDispose(commentsLinks.get(item));
        }
        boolean anonym = ureq.getUserSession().getRoles().isGuestOnly();
        CommentAndRatingSecurityCallback secCallback = new CommentAndRatingDefaultSecurityCallback(getIdentity(), callback.mayEditMetadata(), anonym);
        UserCommentsAndRatingsController commentsAndRatingCtr = new UserCommentsAndRatingsController(ureq, getWindowControl(), feed, item.getGuid(), secCallback, true, true, false);
        commentsAndRatingCtr.setUserObject(item);
        listenTo(commentsAndRatingCtr);
        commentsLinks.put(item, commentsAndRatingCtr);
        String guid = item.getGuid();
        vcItems.put("commentsAndRating." + guid, commentsAndRatingCtr.getInitialComponent());
    }
}
Also used : CommentAndRatingSecurityCallback(org.olat.core.commons.services.commentAndRating.CommentAndRatingSecurityCallback) UserCommentsAndRatingsController(org.olat.core.commons.services.commentAndRating.ui.UserCommentsAndRatingsController) CommentAndRatingDefaultSecurityCallback(org.olat.core.commons.services.commentAndRating.CommentAndRatingDefaultSecurityCallback)

Example 2 with CommentAndRatingSecurityCallback

use of org.olat.core.commons.services.commentAndRating.CommentAndRatingSecurityCallback in project OpenOLAT by OpenOLAT.

the class BinderOnePageController method loadPage.

private void loadPage(UserRequest ureq, Page page) {
    String id = "page_w_" + (++counter);
    VelocityContainer pageVC = createVelocityContainer(id, "page_content_print");
    mainVC.put(id, pageVC);
    components.add(id);
    BinderSecurityCallback secCallback = BinderSecurityCallbackFactory.getReadOnlyCallback();
    PageMetadataController metadatCtrl = new PageMetadataController(ureq, getWindowControl(), secCallback, page);
    listenTo(metadatCtrl);
    Component pageMetaCmp = metadatCtrl.getInitialComponent();
    pageVC.put("meta", pageMetaCmp);
    PageController pageCtrl = new PageController(ureq, getWindowControl(), new PortfolioPageProvider(page), renderingHints);
    listenTo(pageCtrl);
    pageCtrl.loadElements(ureq);
    Component pageCmp = pageCtrl.getInitialComponent();
    pageVC.put("page", pageCmp);
    CommentAndRatingSecurityCallback commentSecCallback = new ReadOnlyCommentsSecurityCallback();
    OLATResourceable ores = OresHelper.createOLATResourceableInstance(Page.class, page.getKey());
    UserCommentsController commentsCtrl = new UserCommentsController(ureq, getWindowControl(), ores, null, commentSecCallback);
    listenTo(commentsCtrl);
    if (commentsCtrl.getNumOfComments() > 0) {
        pageVC.put("comments", commentsCtrl.getInitialComponent());
    }
}
Also used : CommentAndRatingSecurityCallback(org.olat.core.commons.services.commentAndRating.CommentAndRatingSecurityCallback) PageController(org.olat.modules.portfolio.ui.editor.PageController) OLATResourceable(org.olat.core.id.OLATResourceable) ReadOnlyCommentsSecurityCallback(org.olat.modules.portfolio.ui.model.ReadOnlyCommentsSecurityCallback) UserCommentsController(org.olat.core.commons.services.commentAndRating.ui.UserCommentsController) BinderSecurityCallback(org.olat.modules.portfolio.BinderSecurityCallback) Component(org.olat.core.gui.components.Component) VelocityContainer(org.olat.core.gui.components.velocity.VelocityContainer)

Example 3 with CommentAndRatingSecurityCallback

use of org.olat.core.commons.services.commentAndRating.CommentAndRatingSecurityCallback in project OpenOLAT by OpenOLAT.

the class ExportBinderAsCPResource method exportPage.

private void exportPage(Page page, ZipOutputStream zout) throws IOException {
    WindowControl mockwControl = new WindowControlMocker();
    BinderSecurityCallback secCallback = BinderSecurityCallbackFactory.getReadOnlyCallback();
    PageMetadataController metadatCtrl = new PageMetadataController(ureq, mockwControl, secCallback, page);
    PageController pageCtrl = new PageController(ureq, mockwControl, new PortfolioPageProvider(page), ExtendedMediaRenderingHints.toPrint());
    pageCtrl.loadElements(ureq);
    CommentAndRatingSecurityCallback commentSecCallback = new ReadOnlyCommentsSecurityCallback();
    OLATResourceable ores = OresHelper.createOLATResourceableInstance(Page.class, page.getKey());
    UserCommentsController commentsCtrl = new UserCommentsController(ureq, mockwControl, ores, null, commentSecCallback);
    Component metadata = metadatCtrl.getInitialComponent();
    Component component = pageCtrl.getInitialComponent();
    Component comments = commentsCtrl.getNumOfComments() > 0 ? commentsCtrl.getInitialComponent() : null;
    String html = createResultHTML(metadata, component, comments, "o_page_export");
    html = exportMedia(html, zout);
    convertToZipEntry(zout, pageFilename(page), html);
    pageCtrl.dispose();
    metadatCtrl.dispose();
}
Also used : CommentAndRatingSecurityCallback(org.olat.core.commons.services.commentAndRating.CommentAndRatingSecurityCallback) PageController(org.olat.modules.portfolio.ui.editor.PageController) OLATResourceable(org.olat.core.id.OLATResourceable) ReadOnlyCommentsSecurityCallback(org.olat.modules.portfolio.ui.model.ReadOnlyCommentsSecurityCallback) UserCommentsController(org.olat.core.commons.services.commentAndRating.ui.UserCommentsController) BinderSecurityCallback(org.olat.modules.portfolio.BinderSecurityCallback) WindowControl(org.olat.core.gui.control.WindowControl) Component(org.olat.core.gui.components.Component) WindowControlMocker(org.olat.core.gui.util.WindowControlMocker) PageMetadataController(org.olat.modules.portfolio.ui.PageMetadataController)

Example 4 with CommentAndRatingSecurityCallback

use of org.olat.core.commons.services.commentAndRating.CommentAndRatingSecurityCallback in project openolat by klemens.

the class AbstractPageListController method doComment.

private void doComment(UserRequest ureq, Page page) {
    CommentAndRatingSecurityCallback commentSecCallback;
    if (PageStatus.isClosed(page)) {
        commentSecCallback = new ReadOnlyCommentsSecurityCallback();
    } else {
        commentSecCallback = new CommentAndRatingDefaultSecurityCallback(getIdentity(), false, false);
    }
    OLATResourceable ores = OresHelper.createOLATResourceableInstance(Page.class, page.getKey());
    commentsCtrl = new UserCommentsController(ureq, getWindowControl(), ores, null, commentSecCallback);
    listenTo(commentsCtrl);
    String title = translate("comment.title");
    cmc = new CloseableModalController(getWindowControl(), null, commentsCtrl.getInitialComponent(), true, title, true);
    listenTo(cmc);
    cmc.activate();
}
Also used : CommentAndRatingSecurityCallback(org.olat.core.commons.services.commentAndRating.CommentAndRatingSecurityCallback) OLATResourceable(org.olat.core.id.OLATResourceable) ReadOnlyCommentsSecurityCallback(org.olat.modules.portfolio.ui.model.ReadOnlyCommentsSecurityCallback) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) UserCommentsController(org.olat.core.commons.services.commentAndRating.ui.UserCommentsController) CommentAndRatingDefaultSecurityCallback(org.olat.core.commons.services.commentAndRating.CommentAndRatingDefaultSecurityCallback)

Example 5 with CommentAndRatingSecurityCallback

use of org.olat.core.commons.services.commentAndRating.CommentAndRatingSecurityCallback in project openolat by klemens.

the class BinderOnePageController method loadPage.

private void loadPage(UserRequest ureq, Page page) {
    String id = "page_w_" + (++counter);
    VelocityContainer pageVC = createVelocityContainer(id, "page_content_print");
    mainVC.put(id, pageVC);
    components.add(id);
    BinderSecurityCallback secCallback = BinderSecurityCallbackFactory.getReadOnlyCallback();
    PageMetadataController metadatCtrl = new PageMetadataController(ureq, getWindowControl(), secCallback, page);
    listenTo(metadatCtrl);
    Component pageMetaCmp = metadatCtrl.getInitialComponent();
    pageVC.put("meta", pageMetaCmp);
    PageController pageCtrl = new PageController(ureq, getWindowControl(), new PortfolioPageProvider(page), renderingHints);
    listenTo(pageCtrl);
    pageCtrl.loadElements(ureq);
    Component pageCmp = pageCtrl.getInitialComponent();
    pageVC.put("page", pageCmp);
    CommentAndRatingSecurityCallback commentSecCallback = new ReadOnlyCommentsSecurityCallback();
    OLATResourceable ores = OresHelper.createOLATResourceableInstance(Page.class, page.getKey());
    UserCommentsController commentsCtrl = new UserCommentsController(ureq, getWindowControl(), ores, null, commentSecCallback);
    listenTo(commentsCtrl);
    if (commentsCtrl.getNumOfComments() > 0) {
        pageVC.put("comments", commentsCtrl.getInitialComponent());
    }
}
Also used : CommentAndRatingSecurityCallback(org.olat.core.commons.services.commentAndRating.CommentAndRatingSecurityCallback) PageController(org.olat.modules.portfolio.ui.editor.PageController) OLATResourceable(org.olat.core.id.OLATResourceable) ReadOnlyCommentsSecurityCallback(org.olat.modules.portfolio.ui.model.ReadOnlyCommentsSecurityCallback) UserCommentsController(org.olat.core.commons.services.commentAndRating.ui.UserCommentsController) BinderSecurityCallback(org.olat.modules.portfolio.BinderSecurityCallback) Component(org.olat.core.gui.components.Component) VelocityContainer(org.olat.core.gui.components.velocity.VelocityContainer)

Aggregations

CommentAndRatingSecurityCallback (org.olat.core.commons.services.commentAndRating.CommentAndRatingSecurityCallback)20 CommentAndRatingDefaultSecurityCallback (org.olat.core.commons.services.commentAndRating.CommentAndRatingDefaultSecurityCallback)16 UserCommentsController (org.olat.core.commons.services.commentAndRating.ui.UserCommentsController)12 OLATResourceable (org.olat.core.id.OLATResourceable)12 ReadOnlyCommentsSecurityCallback (org.olat.modules.portfolio.ui.model.ReadOnlyCommentsSecurityCallback)10 UserCommentsAndRatingsController (org.olat.core.commons.services.commentAndRating.ui.UserCommentsAndRatingsController)8 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)8 Component (org.olat.core.gui.components.Component)4 BinderSecurityCallback (org.olat.modules.portfolio.BinderSecurityCallback)4 PageController (org.olat.modules.portfolio.ui.editor.PageController)4 ArrayList (java.util.ArrayList)2 VelocityContainer (org.olat.core.gui.components.velocity.VelocityContainer)2 WindowControl (org.olat.core.gui.control.WindowControl)2 WindowControlMocker (org.olat.core.gui.util.WindowControlMocker)2 PageMetadataController (org.olat.modules.portfolio.ui.PageMetadataController)2 AbstractArtefact (org.olat.portfolio.model.artefacts.AbstractArtefact)2 CollectRestriction (org.olat.portfolio.model.restriction.CollectRestriction)2 PortfolioStructure (org.olat.portfolio.model.structel.PortfolioStructure)2 PortfolioStructureMap (org.olat.portfolio.model.structel.PortfolioStructureMap)2 EPMultiArtefactsController (org.olat.portfolio.ui.artefacts.view.EPMultiArtefactsController)2