Jifty::Plugin::Comment::Notification::CommentPublished - new comments made


Jifty-Plugin-Comment documentation Contained in the Jifty-Plugin-Comment distribution.

Index


Code Index:

NAME

Top

Jifty::Plugin::Comment::Notification::CommentPublished - new comments made

SYNOPSIS

Top

To activate this notification, you must override the notification in your application.

  use strict;
  use warnings;

  package MyApp::Notification::CommentPublished;
  use base qw/ Jifty::Plugin::Comment::Notification::CommentPublished /;

  sub setup {
      my $self = shift;

      # Send to the author of the post
      $self->to_list($self->parent->author);

      $self->SUPER::setup(@_);
  }

  sub url {
      my $self = shift;
      return Jifty->config->framework('Web')->{'BaseURL'}
          . $self->parent->permalink
          . '#comment-'.$self->comment->id;
  }

  1;

DESCRIPTION

Top

This notification (when properly configured) is sent out to any who need to know when a comment has been published.

METHODS

Top

setup

This method sets up the notification. This method should be overridden to setup to_list in Jifty::Notification to select who will receive this message. See the SYNOPSIS.

comment

This will contain the Jifty::Plugin::Comment::Model::Comment that has been published.

parent

This will contain the object that the comment has been attached to.

url

This returns the URL that the message will link to. This should be overridden to provide application-specific URLs. The default implementation returns the BaseURL setting for the application.

SEE ALSO

Top

Jifty::Notification, Jifty::Plugin::Comment::Notification::CommentNeedsModeration

AUTHOR

Top

Andrew Sterling Hanenkamp, <hanenkamp@cpan.org>

COPYRIGHT AND LICENSE

Top


Jifty-Plugin-Comment documentation Contained in the Jifty-Plugin-Comment distribution.
use strict;
use warnings;

package Jifty::Plugin::Comment::Notification::CommentPublished;
use base qw/ Jifty::Notification /;

__PACKAGE__->mk_accessors(qw/ comment parent /);

sub setup {
    my $self = shift;

    my $appname = Jifty->config->framework('ApplicationName');
    my $comment = $self->comment;

    my $from = $comment->your_name || 'Anonymous Coward';
    $from .= ' <'.$comment->email.'>' if $comment->email;
    $from .= ' ('.$comment->web_site.')'      if $comment->web_site;

    my $url = $self->url;

    $self->subject(_("[%1] New comment: %2", $appname, $comment->title));
    $self->body(_("
View Comment: %1

On Post: %2
Subject: %3
From: %4
Date: %5

%6
", 
        $url,
        $self->parent->title,
        $comment->title, 
        $from, 
        $comment->created_on->strftime('%A, %B %d, %Y @ %H:%M%P'), 
        $comment->body
    ));
}

sub url {
    my $self = shift;
    return Jifty->config->framework('Web')->{'BaseURL'};
}

1;