Пример #1
0
void Footer::refresh() {
    int comment_id = Options::instance()->footer_content_id();
    if (comment_id > 0) {
        dbo::Transaction t(tApp->session());
        try {
            CommentPtr comment = tApp->session().load<Comment>(comment_id,
                                 /* forceReread */ true);
            if (comment->type() == Comment::FORUM_COMMENT ||
                    comment->type() == Comment::FORUM_POST_TEXT) {
                setText(comment->text());
            }
        } catch (...)
        { }
    }
}
Пример #2
0
ForumCommentWidget::ForumCommentWidget(const CommentPtr& comment) {
    dbo::Transaction t(tApp->session());
    if (comment->type() != Comment::FORUM_COMMENT) {
        return;
    }
    new Header(tr("tc.forum.Comment"), this);
    Wt::WText* text = new Wt::WText(forum_comment_text(comment), this);
    text->addStyleClass("thechess-forum-comments");
    UserPtr user = comment->init();
    if (user) {
        new Wt::WBreak(this);
        user_anchor(user, this);
    }
    CommentPtr post_text = comment->root();
    CommentPtr post = post_text->parent();
    new Wt::WBreak(this);
    Wt::WAnchor* a = new Wt::WAnchor(this);
    a->setLink(tApp->path().post()->get_link(post.id()));
    a->setText(tr("tc.forum.post_header")
               .arg(post.id()).arg(post->text_or_removed(tApp->user())));
    CommentPtr parent = comment->parent();
    if (parent->type() == Comment::FORUM_COMMENT) {
        new Wt::WBreak(this);
        Wt::WAnchor* g = new Wt::WAnchor(this);
        g->setLink(tApp->path().post_comment()->get_link(parent.id()));
        g->setText(tr("tc.forum.Goto_parent").arg(parent.id()));
    }
    if (comment->can_edit(tApp->user())) {
        new Wt::WBreak(this);
        Wt::WAnchor* e = new Wt::WAnchor(this);
        e->setLink(tApp->path().forum_edit()->get_link(comment.id()));
        e->setText(tr("tc.forum.Edit"));
    }
    Wt::WTextEdit* edit = new Wt::WTextEdit(this);
    patch_text_edit(edit);
    new Wt::WBreak(this);
    if (Comment::can_create(tApp->user(), Comment::FORUM_COMMENT, comment)) {
        Wt::WPushButton* add = new Wt::WPushButton(tr("tc.comment.Add"), this);
        add->clicked().connect(boost::bind(add_comment, comment, edit, this));
    }
    add_remover_buttons(comment, this);
}
Пример #3
0
ChatCommentWidget::ChatCommentWidget(const CommentPtr& comment) {
    dbo::Transaction t(tApp->session());
    if (comment->type() != Comment::CHAT_MESSAGE &&
            comment->type() != Comment::PRIVATE_MESSAGE) {
        return;
    }
    if (!comment->can_read_chat_logs(tApp->user())) {
        return;
    }
    new Header(tr("tc.forum.Comment"), this);
    new Wt::WText(forum_comment_text(comment), this);
    UserPtr user = comment->init();
    if (user) {
        new Wt::WBreak(this);
        user_anchor(user, this);
    }
    Wt::WAnchor* a = anchor_to_host(comment);
    if (a) {
        new Wt::WBreak(this);
        addWidget(a);
    }
    add_remover_buttons(comment, this);
    addWidget(new MessageForm(user));
}