Search in sources :

Example 11 with CommentAndRatingDefaultSecurityCallback

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

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

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

the class RepositoryEntryListController method doOpenComments.

protected void doOpenComments(UserRequest ureq, RepositoryEntryRow row) {
    if (commentsCtrl != null)
        return;
    boolean anonym = ureq.getUserSession().getRoles().isGuestOnly();
    CommentAndRatingSecurityCallback secCallback = new CommentAndRatingDefaultSecurityCallback(getIdentity(), false, anonym);
    commentsCtrl = new UserCommentsController(ureq, getWindowControl(), row.getRepositoryEntryResourceable(), null, secCallback);
    commentsCtrl.setUserObject(row);
    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) 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 14 with CommentAndRatingDefaultSecurityCallback

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

the class TableOfContentController method doOpenComments.

private void doOpenComments(UserRequest ureq, PageRow pageRow) {
    CommentAndRatingSecurityCallback commentSecCallback;
    if (PageStatus.isClosed(pageRow.getPage())) {
        commentSecCallback = new ReadOnlyCommentsSecurityCallback();
    } else {
        commentSecCallback = new CommentAndRatingDefaultSecurityCallback(getIdentity(), false, false);
    }
    OLATResourceable ores = OresHelper.createOLATResourceableInstance(Page.class, pageRow.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 15 with CommentAndRatingDefaultSecurityCallback

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

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