NAME

Bric::Util::Alerted - Interface to Alerts as they are sent to individual users.

VERSION

$Revision: 1.9 $

DATE

$Date: 2002/08/30 22:13:41 $

SYNOPSIS

use Bric::Util::Alerted;

# Constructors.
my $alerted = Bric::Util::Alerted->lookup({ id => 1 });
my @alerteds = Bric::Util::Alerted->list($params);

# Class Methods.
my @alerted_ids = Bric::Util::Alerted->list_ids($params);
my $bool = Bric::Util::Alerted->ack_by_id(@alerted_ids);

# Instance Methods.
my $id = $alerted->get_id;
my $at_id = $alerted->get_alert_id;
my $alert = $alerted->get_alert;
my $uid = $alerted->get_user_id;
my $user = $alerted->get_user;
my @sent = $alerted->get_sent;

$alerted = $alered->acknowledge;
my $ack_time = $alerted->get_ack_time($format);

DESCRIPTION

This class is the interface to individual user Alerts. While Bric::Util::Alert objects are created once for a given event, many different users may receive those alerts. Bric::Util::Alerted provides access to those user-specific instances of a particular alert. All methods by which a user is alerted are covered by a single Bric::Util::Alerted object for that Bric::Util::Alert alert, and when a user acknowledges an alert, all methods by which it was sent are acknowledged.

INTERFACE

Constructors

my $c = Bric::Util::Alerted->lookup({ id => $id })

Looks up and instantiates a new Bric::Util::Alerted object based on the Bric::Util::Alerted object ID passed. If $id is not found in the database, lookup() returns undef.

Throws:

Side Effects: If $id is found, populates the new Bric::Util::Alerted object with data from the database before returning it.

Notes: NONE.

my (@alerteds || $alerteds_aref) = Bric::Util::Alerted->list($params)

Returns a list or anonymous array of Bric::Util::Alerted objects based on the search parameters passed via an anonymous hash. The supported lookup keys are:

The last two lookup keys, time_start and time_end, must be used together, as they represent a range of dates between which to retrieve Bric::Util::Alerted objects.

Any combination of these keys may be used, although the most common may be alert_id or user_id.

Throws:

Side Effects: Populates each Bric::Util::Alerted object with data from the database before returning them all.

Notes: NONE.

Destructors

$p->DESTROY

Dummy method to prevent wasting time trying to AUTOLOAD DESTROY.

Throws: NONE.

Side Effects: NONE.

Notes: NONE.

Public Class Methods

my (@alrtd_ids || $alrtd_ids_aref) = Bric::Util::Alerted->list_ids($params)

Returns a list or anonymous array of Bric::Util::Alerted object IDs based on the search parameters passed via an anonymous hash. The supported lookup keys are the same as those for list().

Throws:

Side Effects: NONE.

Notes: NONE.

$meths = Bric::Util::Alerted->my_meths
(@meths || $meths_aref) = Bric::Util::Alerted->my_meths(TRUE)

Returns an anonymous hash of instrospection data for this object. If called with a true argument, it will return an ordered list or anonymous array of intrspection data. The format for each introspection item introspection is as follows:

Each hash key is the name of a property or attribute of the object. The value for a hash key is another anonymous hash containing the following keys:

Throws: NONE.

Side Effects: NONE.

Notes: NONE.

my $bool = Bric::Util::Alerted->ack_by_id(@alerted_ids)

If a whole bunch of alerteds need to be acknowledged at once, use this method and simply pass in all of their IDs, rather than instantiating each one and acknowledging it in turn. This will dramatically cut down on the overhead, as ack_by_id() will execute fewer queries.

Throws:

Side Effects: NONE.

Notes: NONE.

Public Instance Methods

my $id = $alerted->get_id

Returns the ID of the Bric::Util::Alerted object.

Throws:

Side Effects: NONE.

Notes: If the Bric::Util::Alerted object has been instantiated via the new() constructor and has not yet been saved, the object will not yet have an ID, so this method call will return undef.

my $user = $alerted->get_user

Returns the Bric::Biz::Person::User object representing the user to whom the alert was sent.

Throws:

Side Effects: Uses Bric::Biz::Person::User->lookup() internally.

Notes: NONE.

my $uid = $alerted->get_user_id

Returns the Bric::Biz::Person::User object ID representing the user to whom the alert was sent.

Throws:

Side Effects: NONE.

Notes: NONE.

my $alert = $alerted->get_alert

Returns the Bric::Util::Alert object representing the alert for which this Bric::Util::Alerted object was created.

Throws:

Side Effects: NONE.

Notes: NONE.

my $aid = $alerted->get_alert_id

Returns the id of the Bric::Util::Alert object representing the alert for which this Bric::Util::Alerted object was created.

Throws:

Side Effects: NONE.

Notes: NONE.

my $subject = $alerted->get_subject
my $subject = $alerted->get_name

Returns the subject of the alert for which this recipient was notified.

Throws:

Side Effects: NONE.

Notes: NONE.

my $msg = $alerted->get_message

Returns the message of the alert for which this recipient was notified.

Throws:

Side Effects: NONE.

Notes: NONE.

my $timestamp = $alerted->get_timestamp($format)

Returns the time at which the alert was sent to the user. Pass in a strftime formatting string to get the time formatted by that format; otherwise, the time will be formatted in the format splecified for the 'Date/Time Format' preference.

Throws:

Side Effects: NONE.

Notes: NONE.

my $ack_time = $alerted->get_ack_time($format)

Returns the time at which the alert has been acknowledged by the user to whom it was sent. Pass in a strftime formatting string to get the time formatted by that format; otherwise, the time will be formatted in the format splecified for the 'Date/Time Format' preference. Returns undef if the alert has not yet been acknowledged. Call acknowledge() to acknowledge the alert.

Throws:

Side Effects: NONE.

Notes: NONE.

$self = $alerted->acknowledge

Acknowledges the alert. Call this method when the user who was sent the alert acknowledges receipt of the alert. The ack_time property will then be filled enumerated. This is the only method that updates the Bric::Util::Alerted object, and can only be called once. If the Bric::Util::Alerted object has already been acknowledged, this method will return undef; otherwise it will return $self.

Throws:

Side Effects: NONE.

Notes: NONE.

my (@sent || $sent_aref) = $alerted->get_sent

Returns a list or anonymous array of Bric::Util::Alerted::Parts::Sent objects. These objects describe how the user was alerted and at what time. See Bric::Util::Alerted::Parts::Sent for its interface.

Throws:

Side Effects: NONE.

Notes: NONE.

$self = $p->save

No-op.

Throws: NONE.

Side Effects: NONE.

Notes: NONE.

PRIVATE

Private Class Methods

NONE.

Private Instance Methods

NONE.

Private Functions

my $alerts_aref = &$get_em( $pkg, $params )
my $alert_ids_aref = &$get_em( $pkg, $params, 1 )

Function used by lookup() and list() to return a list of Bric::Util::Alert objects or, if called with an optional third argument, returns a list of Bric::Util::Alert object IDs (used by list_ids()).

Throws:

Side Effects: NONE.

Notes: NONE.

my $addr = &$new($pkg, $init)

Instantiates a new object. Used in place of new() by &$get_em(), since new isn't implemented for this class.

Throws:

Side Effects: NONE.

Notes: NONE.

NOTES

NONE.

AUTHOR

David Wheeler <david@wheeler.net>

SEE ALSO

Bric, Bric::Util::AlertType, Bric::Util::EventType, Bric::Util::Event

POD ERRORS

Hey! The above document had some coding errors, which are explained below:

Around line 264:

=back doesn't take any parameters, but you said =back 4

Around line 420:

Expected '=item *'

Around line 422:

Expected '=item *'

Around line 424:

Expected '=item *'

Around line 426:

Expected '=item *'

Around line 428:

Expected '=item *'

Around line 430:

Expected '=item *'

Around line 432:

Expected '=item *'

Around line 1051:

=back doesn't take any parameters, but you said =back 4

Around line 1231:

You forgot a '=back' before '=head1'