NAME

    pkg('Alert') -  interface to specify events to alert upon, 
                    schedule alerts, and mail out alerts.


SYNOPSIS

    use Krang::ClassLoader 'Alert';
    # add new alert scenario - user 1 will be notified with a custom message when story 14 is published
    my $alert = pkg('Alert')->new(  user_id => '1',
                                    action => 'publish',
                                    object_type => 'story',
                                    object_id => '13',
                                    custom_msg_subject => 'THIRTEEN HAS GONE LIVE!',
                                    custom_msg_body => 'Story 13 has gone live -- numerologically this does not bode well' );
    # add new alert scenario - user 1 will be notified when any new story is 
    # created in category 3 (or its descendants)
    my $alert = pkg('Alert')->new(  user_id => '1',
                                    action => 'new',
                                    category_id => '3' );
    # save the alert
    $alert->save;
    # add new alert scenario - user 1 will be notified when any story is
    # moved to desk 4
    my $alert2 = pkg('Alert')->new( user_id => '1',
                                    action => 'move',
                                    desk_id => '4' );
    # save the alert
    $alert2->save;
    # Let's pretend that category 5 is a decendant of category 3.
    # This find should return the $alert object from the above example. 
    my @found = pkg('Alert')->find( user_id => '1',
                                    action => 'new',
                                    category_id => '5' );
    # check to see if history event should trigger an alert
    # for specified object.  If a match is found, an alert 
    # will be scheduled to be mailed with Krang::Schedule
    # This is a convenience method that uses Krang::Alert->find() 
    # and Krang::Schedule->new()
    pkg('Alert')->check_alert(  history_object => $history_object,  
                                story_object => $story_object );
    
    # delete alert scenario
    $alert->delete();


DESCRIPTION

This class handles the storage of events to alert upon. It also checks Krang::History objects to see if an alert is matched. If so, an alert mailing ( Krang::Alert->send() ) will be scheduled in Krang::Schedule.


INTERFACE

METHODS