« Fun with BitchX | Main | ExtendedComments Progress And Site Changes »

June 04, 2004

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.

Posted by rayners at June 4, 2004 02:41 PM

Trackback Pings

TrackBack URL for this entry:
http://mt.rayners.org/mt-tb.cgi/303

Comments

Post a comment




Remember Me?

(you may use HTML tags for style)