The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Foorum::ResultSet::Comment - Foorum Comment System

SYNOPSIS

        # get comments
        my ($view_mode)  = ( $c->req->path =~ /\/view_mode=(thread|flat)(\/|$)/ );
        my ($comment_id) = ( $c->req->path =~ /\/comment_id=(\d+)(\/|$)/ );
        ( $c->stash->{comments}, $c->stash->{comments_pager} )
            = $c->model('DBIC::Comment')->get_comments_by_object(
            {   object_type => 'topic',
                object_id   => $topic_id,
                page        => $page,
                view_mode   => $view_mode,
                comment_id  => $comment_id,
            }
            );

FUNCTIONS

get_comments_by_object

Usually it's used in Topic or User page, to show the comments up. opts:

    object_type => 'topic',     # or 'user_profile'
    object_type => $topic_id,   # or $user_id,
    page        => $page,       # show which page
    rows        => 20,          # optional, default as c.config.per_page.topic || 10;
    view_mode   => 'flat',      # flat or thread
    comment_id  => $comment_id, # for URL like /topic/$topic_id/comment_id=12/
                                # go comment_id=12's page
get_children_comments

That's mainly for thread mode. when comment_id=2's reply_to=1, that means comment_id=2 is the child of comment_id=1. meanwhile comment_id=3's reply_to=2, when we get children of comment_id=1, that's included too.

For get_comment_by_object and remove_children using.

get_all_comments_by_object($object_type, $object_id)

just get the @comments from table. no other action. with upload and text filtered.

get($comment_id, $attrs)

get one comment. attrs:

    with_text => 1, # get the $comment->{text} filtered.
remove_by_object($object_type, $object_id)

remove all comments belong to one certain object.

remove_children($comment)

check the CONCEPT above.

remove_one_item($comment)

remove one comment with upload and others.

AUTHOR

Fayland Lam <fayland at gmail.com>