Some Sample ExtendedComments Code

Just to help me think things through, I am in the process of porting code from the provided MT::App::Comments class to "work" with my planned rayners::ExtendedComments class. I plan on making each and every feature available in the default comments script work as a plugin of sorts with my new script.

For example, here is the current code for the callback that operates on the entry_id parameter. It will most likely be setup as one of the first callbacks used when creating a comment. If it errors out, the process is halted and no comment is created. Otherwise, it will continue to the next callback, which can error out and halt the process there, and so on.

sub entry_id_param {
  my ($app, $comment, $entry_id) = @_;

  require MT::Entry;
  my $entry = MT::Entry->load ($entry_id) or
    return $app->error ($app->translate (
          "No such entry '[_1]'.", $entry_id));
  return $app->error($app->translate(
        "No such entry '[_1]'.", $entry_id))
    if $entry->status != RELEASE;

  unless ($entry->allow_comments eq '1') {
    return $app->handle_error($app->translate(
          "Comments are not allowed on this entry."));
  }

  $comment->blog_id ($entry->blog_id);
  $comment->entry_id ($entry_id);
  $comment;
}

What I am working towards is a setup where each of the current features of MT::App::Comments is replicated in rayners::ExtendedComments so that adding on new features (e.g. CommentTitles) will be fairly trivial.

Leave a comment

Recent Entries

  • Plugin Writing 101

    So, I’m planning on writing up some entries about various aspects of plugin development. While I have a couple topics already in mind, I thought...

  • The Olympics Make Me Want To Compete Again

    Every time the Olympics come around (most the summer ones) I always start to delude myself into thinking I could complete once again in the...

  • Minimalist plugins are fun!

    Last night I whipped up one of the smallest plugins I’ve ever written. It is so small in fact that I was able to stuff...

  • Feedburner Widget on MT News

    Movable Type News A WordPress 2.5 Upgrade Guide: And of course there are lots of third-party plugins for the MT dashboard, to integrate statistics and...

  • AD&D Monster Stats for the Presidential Canditates

    Charles Stross (scifi author, D&D nerd, and former perl columnist) posted Politics as she is Played with 3d6: The recent death of Gary Gygax, who...

Close