Search in sources :

Example 6 with UserCommentsAndRatingsController

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

the class EPTOCReadOnlyController method refreshTOC.

public void refreshTOC(UserRequest ureq) {
    // do recursively
    int level = 0;
    List<TOCElement> tocList = new ArrayList<TOCElement>();
    buildTOCModel(map, tocList, level);
    vC.contextPut("tocList", tocList);
    if (secCallback.canCommentAndRate()) {
        removeAsListenerAndDispose(commentsAndRatingCtr);
        boolean anonym = ureq.getUserSession().getRoles().isGuestOnly();
        CommentAndRatingSecurityCallback callback = new CommentAndRatingDefaultSecurityCallback(getIdentity(), false, anonym);
        commentsAndRatingCtr = new UserCommentsAndRatingsController(ureq, getWindowControl(), map.getOlatResource(), null, callback, true, true, true);
        listenTo(commentsAndRatingCtr);
        vC.put("commentCtrl", commentsAndRatingCtr.getInitialComponent());
    }
}
Also used : CommentAndRatingSecurityCallback(org.olat.core.commons.services.commentAndRating.CommentAndRatingSecurityCallback) UserCommentsAndRatingsController(org.olat.core.commons.services.commentAndRating.ui.UserCommentsAndRatingsController) ArrayList(java.util.ArrayList) CommentAndRatingDefaultSecurityCallback(org.olat.core.commons.services.commentAndRating.CommentAndRatingDefaultSecurityCallback)

Example 7 with UserCommentsAndRatingsController

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

the class PageRunController method loadModel.

private void loadModel(UserRequest ureq, boolean reloadComments) {
    mainVC.contextPut("pageTitle", page.getTitle());
    pageCtrl.loadElements(ureq);
    dirtyMarker = false;
    if (secCallback.canComment(page)) {
        if (reloadComments && commentsCtrl != null) {
            mainVC.remove(commentsCtrl.getInitialComponent());
            removeAsListenerAndDispose(commentsCtrl);
            commentsCtrl = null;
        }
        if (commentsCtrl == null) {
            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 UserCommentsAndRatingsController(ureq, getWindowControl(), ores, null, commentSecCallback, true, false, true);
            commentsCtrl.expandComments(ureq);
            listenTo(commentsCtrl);
        }
        mainVC.put("comments", commentsCtrl.getInitialComponent());
    } else if (commentsCtrl != null) {
        mainVC.remove(commentsCtrl.getInitialComponent());
        removeAsListenerAndDispose(commentsCtrl);
        commentsCtrl = null;
    }
    if (editLink != null) {
        editLink.setVisible(secCallback.canEditPage(page));
    }
    if (editMetadataLink != null) {
        editMetadataLink.setVisible(secCallback.canEditMetadataBinder());
    }
    if (moveToTrashLink != null) {
        moveToTrashLink.setVisible(secCallback.canDeletePage(page));
    }
}
Also used : CommentAndRatingSecurityCallback(org.olat.core.commons.services.commentAndRating.CommentAndRatingSecurityCallback) UserCommentsAndRatingsController(org.olat.core.commons.services.commentAndRating.ui.UserCommentsAndRatingsController) OLATResourceable(org.olat.core.id.OLATResourceable) ReadOnlyCommentsSecurityCallback(org.olat.modules.portfolio.ui.model.ReadOnlyCommentsSecurityCallback) CommentAndRatingDefaultSecurityCallback(org.olat.core.commons.services.commentAndRating.CommentAndRatingDefaultSecurityCallback)

Example 8 with UserCommentsAndRatingsController

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

the class QuestionItemDetailsController method setCommentsController.

private void setCommentsController(UserRequest ureq) {
    Roles roles = ureq.getUserSession().getRoles();
    boolean moderator = roles.isOLATAdmin();
    boolean anonymous = roles.isGuestOnly() || roles.isInvitee();
    commentAndRatingSecurityCallback = new CommentAndRatingDefaultSecurityCallback(getIdentity(), moderator, anonymous);
    removeAsListenerAndDispose(commentsAndRatingCtr);
    commentsAndRatingCtr = new UserCommentsAndRatingsController(ureq, getWindowControl(), metadatasCtrl.getItem(), null, commentAndRatingSecurityCallback, true, this.qItemSecurityCallback.canRate(), true);
    listenTo(commentsAndRatingCtr);
    mainVC.put("comments", commentsAndRatingCtr.getInitialComponent());
}
Also used : UserCommentsAndRatingsController(org.olat.core.commons.services.commentAndRating.ui.UserCommentsAndRatingsController) Roles(org.olat.core.id.Roles) CommentAndRatingDefaultSecurityCallback(org.olat.core.commons.services.commentAndRating.CommentAndRatingDefaultSecurityCallback)

Example 9 with UserCommentsAndRatingsController

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

the class PageRunController method loadModel.

private void loadModel(UserRequest ureq, boolean reloadComments) {
    mainVC.contextPut("pageTitle", page.getTitle());
    pageCtrl.loadElements(ureq);
    dirtyMarker = false;
    if (secCallback.canComment(page)) {
        if (reloadComments && commentsCtrl != null) {
            mainVC.remove(commentsCtrl.getInitialComponent());
            removeAsListenerAndDispose(commentsCtrl);
            commentsCtrl = null;
        }
        if (commentsCtrl == null) {
            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 UserCommentsAndRatingsController(ureq, getWindowControl(), ores, null, commentSecCallback, true, false, true);
            commentsCtrl.expandComments(ureq);
            listenTo(commentsCtrl);
        }
        mainVC.put("comments", commentsCtrl.getInitialComponent());
    } else if (commentsCtrl != null) {
        mainVC.remove(commentsCtrl.getInitialComponent());
        removeAsListenerAndDispose(commentsCtrl);
        commentsCtrl = null;
    }
    if (editLink != null) {
        editLink.setVisible(secCallback.canEditPage(page));
    }
    if (editMetadataLink != null) {
        editMetadataLink.setVisible(secCallback.canEditMetadataBinder());
    }
    if (moveToTrashLink != null) {
        moveToTrashLink.setVisible(secCallback.canDeletePage(page));
    }
}
Also used : CommentAndRatingSecurityCallback(org.olat.core.commons.services.commentAndRating.CommentAndRatingSecurityCallback) UserCommentsAndRatingsController(org.olat.core.commons.services.commentAndRating.ui.UserCommentsAndRatingsController) OLATResourceable(org.olat.core.id.OLATResourceable) ReadOnlyCommentsSecurityCallback(org.olat.modules.portfolio.ui.model.ReadOnlyCommentsSecurityCallback) CommentAndRatingDefaultSecurityCallback(org.olat.core.commons.services.commentAndRating.CommentAndRatingDefaultSecurityCallback)

Example 10 with UserCommentsAndRatingsController

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

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)

Aggregations

UserCommentsAndRatingsController (org.olat.core.commons.services.commentAndRating.ui.UserCommentsAndRatingsController)12 CommentAndRatingDefaultSecurityCallback (org.olat.core.commons.services.commentAndRating.CommentAndRatingDefaultSecurityCallback)10 CommentAndRatingSecurityCallback (org.olat.core.commons.services.commentAndRating.CommentAndRatingSecurityCallback)8 ArrayList (java.util.ArrayList)4 Dated (org.olat.core.commons.controllers.navigation.Dated)2 NavigationEvent (org.olat.core.commons.controllers.navigation.NavigationEvent)2 FileElement (org.olat.core.gui.components.form.flexible.elements.FileElement)2 Link (org.olat.core.gui.components.link.Link)2 DialogBoxController (org.olat.core.gui.control.generic.modal.DialogBoxController)2 OLATResourceable (org.olat.core.id.OLATResourceable)2 Roles (org.olat.core.id.Roles)2 ContextEntry (org.olat.core.id.context.ContextEntry)2 ReadOnlyCommentsSecurityCallback (org.olat.modules.portfolio.ui.model.ReadOnlyCommentsSecurityCallback)2 Item (org.olat.modules.webFeed.Item)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 EPCollectRestrictionResultController (org.olat.portfolio.ui.structel.edit.EPCollectRestrictionResultController)2