Search in sources :

Example 16 with UserComment

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

the class CommentAndRatingServiceImpl method replyTo.

@Override
public UserComment replyTo(UserComment originalComment, Identity creator, String replyCommentText) {
    UserComment reply = userCommentsDao.replyTo(originalComment, creator, replyCommentText);
    markPublisherNews(reply);
    return reply;
}
Also used : UserComment(org.olat.core.commons.services.commentAndRating.model.UserComment)

Example 17 with UserComment

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

the class CommentAndRatingServiceImpl method updateComment.

@Override
public UserComment updateComment(UserComment comment, String newCommentText) {
    UserComment updatedComment = userCommentsDao.updateComment(comment, newCommentText);
    markPublisherNews(updatedComment);
    return updatedComment;
}
Also used : UserComment(org.olat.core.commons.services.commentAndRating.model.UserComment)

Example 18 with UserComment

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

the class CommentAndRatingServiceImpl method createComment.

@Override
public UserComment createComment(Identity creator, OLATResourceable ores, String resSubPath, String commentText) {
    UserComment comment = userCommentsDao.createComment(creator, ores, resSubPath, commentText);
    markPublisherNews(comment);
    return comment;
}
Also used : UserComment(org.olat.core.commons.services.commentAndRating.model.UserComment)

Example 19 with UserComment

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

the class UserCommentDisplayController method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
 *      org.olat.core.gui.components.Component,
 *      org.olat.core.gui.control.Event)
 */
@Override
protected void event(UserRequest ureq, Component source, Event event) {
    if (source == replyLink) {
        // Init reply workflow
        replyCommentFormCtr = new UserCommentFormController(ureq, getWindowControl(), userComment, null, ores, resSubPath);
        listenTo(replyCommentFormCtr);
        User parentUser = userComment.getCreator().getUser();
        String title = translate("comments.coment.reply.title", new String[] { parentUser.getProperty(UserConstants.FIRSTNAME, null), parentUser.getProperty(UserConstants.LASTNAME, null) });
        TitleInfo titleInfo = new TitleInfo(null, title);
        replyTitledWrapperCtr = new TitledWrapperController(ureq, getWindowControl(), replyCommentFormCtr, null, titleInfo);
        listenTo(replyTitledWrapperCtr);
        replyCmc = new CloseableModalController(getWindowControl(), "close", replyTitledWrapperCtr.getInitialComponent());
        replyCmc.activate();
    } else if (source == deleteLink) {
        // Init delete workflow
        List<String> buttonLabels = new ArrayList<String>();
        boolean hasReplies = false;
        for (UserComment comment : allComments) {
            if (comment.getParent() != null && comment.getParent().getKey().equals(userComment.getKey())) {
                hasReplies = true;
                break;
            }
        }
        if (hasReplies) {
            buttonLabels.add(translate("comments.button.delete.without.replies"));
            buttonLabels.add(translate("comments.button.delete.with.replies"));
        } else {
            buttonLabels.add(translate("delete"));
        }
        buttonLabels.add(translate("cancel"));
        String deleteText;
        if (hasReplies) {
            deleteText = translate("comments.dialog.delete.with.replies");
        } else {
            deleteText = translate("comments.dialog.delete");
        }
        deleteDialogCtr = DialogBoxUIFactory.createGenericDialog(ureq, getWindowControl(), translate("comments.dialog.delete.title"), deleteText, buttonLabels);
        listenTo(deleteDialogCtr);
        deleteDialogCtr.activate();
        // Add replies info as user object to retrieve it later when evaluating the events
        deleteDialogCtr.setUserObject(Boolean.valueOf(hasReplies));
    }
}
Also used : User(org.olat.core.id.User) TitledWrapperController(org.olat.core.gui.control.generic.title.TitledWrapperController) UserComment(org.olat.core.commons.services.commentAndRating.model.UserComment) TitleInfo(org.olat.core.gui.control.generic.title.TitleInfo) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) ArrayList(java.util.ArrayList) List(java.util.List)

Example 20 with UserComment

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

the class FeedNotificationsHandler method appendSubscriptionItem.

private void appendSubscriptionItem(Item item, Publisher p, Date compareDate, Translator translator, List<SubscriptionListItem> items) {
    String title = item.getTitle();
    String author = item.getAuthor();
    String businessPath = p.getBusinessPath();
    String urlToSend = BusinessControlFactory.getInstance().getURLFromBusinessPathString(businessPath);
    String iconCssClass = item.extraCSSClass();
    Date publishDate = item.getPublishDate();
    if (publishDate != null) {
        if (compareDate.before(publishDate)) {
            String desc = translator.translate("notifications.entry.published", new String[] { title, author });
            items.add(new SubscriptionListItem(desc, urlToSend, businessPath, publishDate, iconCssClass));
        }
        // modified date.
        if (item.getModifierKey() != null || (item.getFeed().isExternal() && !item.getCreationDate().equals(item.getLastModified()) && item.getPublishDate().before(item.getLastModified()))) {
            Date modDate = item.getLastModified();
            if (compareDate.before(modDate)) {
                String desc;
                String modifier = item.getModifier();
                if (StringHelper.containsNonWhitespace(modifier)) {
                    desc = translator.translate("notifications.entry.modified", new String[] { title, modifier });
                } else {
                    desc = translator.translate("notifications.entry.modified", new String[] { title, "???" });
                }
                items.add(new SubscriptionListItem(desc, urlToSend, businessPath, modDate, iconCssClass));
            }
        }
        List<UserComment> comments = commentAndRatingService.getComments(item.getFeed(), item.getGuid());
        for (UserComment comment : comments) {
            if (compareDate.before(comment.getCreationDate())) {
                String desc;
                String modifier = UserManager.getInstance().getUserDisplayName(comment.getCreator().getKey());
                if (StringHelper.containsNonWhitespace(modifier)) {
                    desc = translator.translate("notifications.entry.commented", new String[] { title, modifier });
                } else {
                    desc = translator.translate("notifications.entry.commented", new String[] { title, "???" });
                }
                items.add(new SubscriptionListItem(desc, urlToSend, businessPath, comment.getCreationDate(), iconCssClass));
            }
        }
    }
}
Also used : SubscriptionListItem(org.olat.core.commons.services.notifications.model.SubscriptionListItem) UserComment(org.olat.core.commons.services.commentAndRating.model.UserComment) Date(java.util.Date)

Aggregations

UserComment (org.olat.core.commons.services.commentAndRating.model.UserComment)24 ArrayList (java.util.ArrayList)4 Controller (org.olat.core.gui.control.Controller)4 BasicController (org.olat.core.gui.control.controller.BasicController)4 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)4 TitledWrapperController (org.olat.core.gui.control.generic.title.TitledWrapperController)4 Identity (org.olat.core.id.Identity)4 OLATResourceable (org.olat.core.id.OLATResourceable)4 Date (java.util.Date)2 List (java.util.List)2 Test (org.junit.Test)2 UserCommentImpl (org.olat.core.commons.services.commentAndRating.model.UserCommentImpl)2 SubscriptionListItem (org.olat.core.commons.services.notifications.model.SubscriptionListItem)2 DialogBoxController (org.olat.core.gui.control.generic.modal.DialogBoxController)2 TitleInfo (org.olat.core.gui.control.generic.title.TitleInfo)2 User (org.olat.core.id.User)2 EPPage (org.olat.portfolio.model.structel.EPPage)2 PortfolioStructure (org.olat.portfolio.model.structel.PortfolioStructure)2