Search in sources :

Example 1 with CommentAndRatingDefaultSecurityCallback

use of org.olat.core.commons.services.commentAndRating.CommentAndRatingDefaultSecurityCallback 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 CommentAndRatingDefaultSecurityCallback

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

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 3 with CommentAndRatingDefaultSecurityCallback

use of org.olat.core.commons.services.commentAndRating.CommentAndRatingDefaultSecurityCallback 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 4 with CommentAndRatingDefaultSecurityCallback

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

the class RepositoryEntryDetailsController method doOpenComments.

protected void doOpenComments(UserRequest ureq) {
    if (commentsCtrl != null)
        return;
    boolean anonym = ureq.getUserSession().getRoles().isGuestOnly();
    CommentAndRatingSecurityCallback secCallback = new CommentAndRatingDefaultSecurityCallback(getIdentity(), false, anonym);
    OLATResourceable ores = OresHelper.createOLATResourceableInstance("RepositoryEntry", entry.getKey());
    commentsCtrl = new UserCommentsController(ureq, getWindowControl(), ores, null, secCallback);
    listenTo(commentsCtrl);
    cmc = new CloseableModalController(getWindowControl(), "close", commentsCtrl.getInitialComponent(), true, translate("comments"));
    listenTo(cmc);
    cmc.activate();
}
Also used : CommentAndRatingSecurityCallback(org.olat.core.commons.services.commentAndRating.CommentAndRatingSecurityCallback) OLATResourceable(org.olat.core.id.OLATResourceable) 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 CommentAndRatingDefaultSecurityCallback

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

the class EPPageViewController method init.

private void init(UserRequest ureq) {
    vC.contextPut("page", page);
    PortfolioStructureMap parentOfPage = (PortfolioStructureMap) ePFMgr.loadStructureParent(page);
    boolean parentMapClosed = StructureStatusEnum.CLOSED.equals(parentOfPage.getStatus());
    vC.remove(vC.getComponent("checkResults"));
    if (secCallback.isRestrictionsEnabled()) {
        removeAsListenerAndDispose(resultCtrl);
        List<CollectRestriction> restrictions = page.getCollectRestrictions();
        if (!restrictions.isEmpty()) {
            boolean check = ePFMgr.checkCollectRestriction(page);
            resultCtrl = new EPCollectRestrictionResultController(ureq, getWindowControl());
            resultCtrl.setMessage(restrictions, check);
            vC.put("checkResults", resultCtrl.getInitialComponent());
            listenTo(resultCtrl);
        }
    }
    vC.remove(vC.getComponent("artefacts"));
    List<AbstractArtefact> artefacts = ePFMgr.getArtefacts(page);
    if (artefacts.size() != 0) {
        EPMultiArtefactsController artefactCtrl = EPUIFactory.getConfigDependentArtefactsControllerForStructure(ureq, getWindowControl(), artefacts, page, secCallback);
        vC.put("artefacts", artefactCtrl.getInitialComponent());
        listenTo(artefactCtrl);
    }
    vC.remove(vC.getComponent("structElements"));
    List<PortfolioStructure> structElements = ePFMgr.loadStructureChildren(page);
    if (structElements.size() != 0) {
        EPStructureElementsController structElCtrl = new EPStructureElementsController(ureq, getWindowControl(), structElements, secCallback, parentMapClosed);
        vC.put("structElements", structElCtrl.getInitialComponent());
        listenTo(structElCtrl);
    }
    vC.remove(vC.getComponent("addButton"));
    if (!parentMapClosed && (secCallback.canAddArtefact() || secCallback.canAddStructure())) {
        addButtonCtrl = new EPAddElementsController(ureq, getWindowControl(), page);
        listenTo(addButtonCtrl);
        if (secCallback.canAddArtefact()) {
            addButtonCtrl.setShowLink(EPAddElementsController.ADD_ARTEFACT);
        }
        if (secCallback.canAddStructure()) {
            addButtonCtrl.setShowLink(EPAddElementsController.ADD_STRUCTUREELEMENT);
        }
        vC.put("addButton", addButtonCtrl.getInitialComponent());
    }
    vC.remove(vC.getComponent("commentCtrl"));
    if (secCallback.canCommentAndRate()) {
        removeAsListenerAndDispose(commentsAndRatingCtr);
        boolean anonym = ureq.getUserSession().getRoles().isGuestOnly();
        CommentAndRatingSecurityCallback ratingSecCallback = new CommentAndRatingDefaultSecurityCallback(getIdentity(), false, anonym);
        commentsAndRatingCtr = new UserCommentsAndRatingsController(ureq, getWindowControl(), map.getOlatResource(), page.getKey().toString(), ratingSecCallback, true, true, true);
        listenTo(commentsAndRatingCtr);
        vC.put("commentCtrl", commentsAndRatingCtr.getInitialComponent());
    }
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) EPCollectRestrictionResultController(org.olat.portfolio.ui.structel.edit.EPCollectRestrictionResultController) CommentAndRatingSecurityCallback(org.olat.core.commons.services.commentAndRating.CommentAndRatingSecurityCallback) EPMultiArtefactsController(org.olat.portfolio.ui.artefacts.view.EPMultiArtefactsController) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) CommentAndRatingDefaultSecurityCallback(org.olat.core.commons.services.commentAndRating.CommentAndRatingDefaultSecurityCallback) UserCommentsAndRatingsController(org.olat.core.commons.services.commentAndRating.ui.UserCommentsAndRatingsController) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) CollectRestriction(org.olat.portfolio.model.restriction.CollectRestriction)

Aggregations

CommentAndRatingDefaultSecurityCallback (org.olat.core.commons.services.commentAndRating.CommentAndRatingDefaultSecurityCallback)18 CommentAndRatingSecurityCallback (org.olat.core.commons.services.commentAndRating.CommentAndRatingSecurityCallback)16 UserCommentsAndRatingsController (org.olat.core.commons.services.commentAndRating.ui.UserCommentsAndRatingsController)10 UserCommentsController (org.olat.core.commons.services.commentAndRating.ui.UserCommentsController)8 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)8 OLATResourceable (org.olat.core.id.OLATResourceable)8 ReadOnlyCommentsSecurityCallback (org.olat.modules.portfolio.ui.model.ReadOnlyCommentsSecurityCallback)6 ArrayList (java.util.ArrayList)2 Roles (org.olat.core.id.Roles)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