Search in sources :

Example 11 with UserCommentsAndRatingsController

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

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)

Example 12 with UserCommentsAndRatingsController

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

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)

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