NAME

Bric::Util::Event - Interface to Bricolage Events

VERSION

$Revision: 1.1.1.1.2.2 $

DATE

$Date: 2001/11/06 23:18:34 $

SYNOPSIS

# Constructors.
my $event = Bric::Util::Event->new($init);
my $event = Bric::Util::Event->lookup({id => $id});
my @events = Bric::Util::Event->list(params)

# Class Methods.
my @eids = Bric::Util::Event->list_ids($params)

# Instance Methods.
my $id = $event->get_id;
my $et = $event->get_event_type;
my $et_id = $event->get_event_type_id;
my $user = $event->get_user;
my $user_id = $event->get_user_id;
my $obj = $event->get_obj;
my $obj_id = $event->get_obj_id;
my $time = $event->get_timestamp;
my $key_name = $event->get_key_name; # Same as returned by $et.
my $name = $event->get_name;         # Same as returned by $et.
my $desc = $event->get_description;  # Same as returned by $et.
my $class = $event->get_class;       # Same as returned by $et.

DESCRIPTION

Bric::Util::Event provides an interface to individual Bricolage events. It is used primarily to create a list of events relative to a particular Bricolage object. Events can only be de logged for a pre-specified list of event types as defined by Bric::Util::EventType. In fact, I recommend that you use the log_event() method on an Bric::Util::EventType object to log individual events, rather than creating them here with the new() method. Either way, the event will be logged and all necessary alerts defined via the Bric::Util::AlertType class will be sent.

While the primary purpose of this class is to create lists of events, I have provided a number of methods to make it as flexible an API as possible. These include the ability to automatically instantiate the object for which an event was logged, or the Bric::Biz::Person::User object representing the user who triggered the event.

INTERFACE

Constructors

my $event = Bric::Util::Event->new($init)

Instantiates and saves a Bric::Util::Event object. Returns the new event object on success and undef on failure. An anonymous hash of initial values must be passed with the following keys:

Throws:

Side Effects: Creates the new event and saves it to the database.

Notes: Use new() only to create a completely new event object. It will automatically be saved before returning the new event object. Use lookup() or list() to fetch pre-existing event objects.

In the future, attributes may not need to be passed for all attribute logging. That is, if the attributes can be collected direct from the object of this event via accessors, they need not be passed in via this anonymous hash. The accessors must be named 'get_' plus the name of the attribute to be fetched (such as 'get_slug') in order for the method-call approach to collecting atrributes to work. But this is not yet implemented.

my $event = Bric::Util::Event->lookup({id => $id})

Looks up and instantiates a new Bric::Util::Event object based on the Bric::Util::Event object ID. If the existing object is not found in the database, lookup() returns undef. If the ID or name is found more than once, lookup() returns zero (0). This should not happen.

Throws:

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

Notes: NONE.

my (@events || $events_aref) = Bric::Util::Event->list($params)

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

If timestamp is passed as a scalar, events that occurred at that exact time will be returned. If it is passed as an anonymous hash, the first two values will be assumed to represent a range of dates between which to retrieve Bric::Util::Event objects. Any combination of the above keys may be used, although the most common may be a combination of class_id and obj_id.

Throws:

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

Notes: NONE.

$meths = Bric::Biz::Person->my_meths
(@meths || $meths_aref) = Bric::Biz::Person->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.

Destructors

$p->DESTROY

Dummy method to prevent wasting time trying to AUTOLOAD DESTROY.

Throws: NONE.

Side Effects: NONE.

Notes: NONE.

Public Class Methods

################################################################################

my (@eids || $eids_aref) = Bric::Biz::Person->list_ids($params)

Functionally identical to list(), but returns Bric::Util::Event object IDs rather than objects. See list() for a description of its interface.

Throws:

Side Effects: NONE.

Notes: NONE.

Public Instance Methods

my $id = $event->get_id

Returns the event object ID.

Throws:

Side Effects: NONE.

Notes: NONE.

my $et = $event->get_event_type

Returns the event type object defining the event.

Throws:

Side Effects: NONE.

Notes: NONE.

my $et_id = $event->get_event_type_id

Returns the ID of the event type object defining the event.

Throws:

Side Effects: NONE.

Notes: NONE.

my $u = $event->get_user

Returns the Bric::Biz::Person::User object representing the person who triggered the event.

Throws:

Side Effects: NONE.

Notes: NONE.

my $uid = $event->get_user_id

Returns the ID of the Bric::Biz::Person::User object representing the person who triggered the event.

Throws:

Side Effects: NONE.

Notes: NONE.

my $obj = $event->get_obj

Returns the object for which this event was logged. The class of the object may be fetched from $event->get_class.

Throws:

Side Effects: NONE.

Notes: NONE.

my $obj_id = $event->get_obj_id

Returns the ID of the object for which this event was logged. The class of the object may be fetched from $event->get_class.

Throws:

Side Effects: NONE.

Notes: NONE.

my $timestamp = $event->get_timestamp

Returns the time at which the event was triggered.

Throws:

Side Effects: NONE.

Notes: NONE.

my $key_name = $event->get_key_name

Returns the event key name. Same as the key name specified for the event type defining this event.

Throws:

Side Effects: NONE.

Notes: NONE.

my $name = $event->get_name

Returns the event name. Same as the name specified for the event type defining this event.

Throws:

Side Effects: NONE.

Notes: NONE.

my $description = $event->get_description

Returns the event description. Same as the name specified for the event type defining this event.

Throws:

Side Effects: NONE.

Notes: NONE.

my $class = $event->get_class

Returns name of the class of object for which the event was logged.

Throws:

Side Effects: NONE.

Notes: NONE.

my $attr_href = $event->get_attr

Returns an anonymous hash of the attributes of the event.

Throws:

Side Effects: Uses Bric::Util::Attribute::Event internally.

Notes: NONE.

$self = $event->has_alerts

Returns true if alerts are associated with the event, and false if no alerts are associated with the event.

Throws:

Side Effects: NONE.

Notes: NONE.

$self = $event->save;

Dummy method for those who try to call save() without realizing that saving is automatic. Returns $self, but otherwise does noththing.

Throws: NONE.

Side Effects: NONE.

Notes: NONE.

PRIVATE

Private Class Methods

NONE.

Private Instance Methods

NONE.

Private Functions

my $events_aref = &$get_em( $pkg, $search_href )
my $events_ids_aref = &$get_em( $pkg, $search_href, 1 )

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

Throws:

Side Effects: NONE.

Notes: NONE.

&$save($self)

Saves the contents of an event.

Throws:

Side Effects: NONE.

Notes: NONE.

&$save_attr($event_id, $et, $attr)

Saves the attributes of an event.

Throws:

Side Effects: NONE.

Notes: NONE.

my $event = &$make_obj( $pkg, $init )

Instantiates a Bric::Util::Event object. Used by &$get_em().

Throws:

Side Effects: NONE.

Notes: NONE.

&$get_et($self)

Returns the Bric::Util::EventType object identifying the type of this Bric::Util::Event object.

Throws:

Side Effects: NONE.

Notes: Uses Bric::Util::EventType->lookup() internally and caches the object.

NOTES

NONE.

AUTHOR

David Wheeler <david@wheeler.net>

SEE ALSO

perl(1), Bric (2), Bric::Util::EventType(3) Bric::Util::AlertType(5) Bric::Util::Alert(6)

POD ERRORS

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

Around line 551:

Expected '=item *'

Around line 553:

Expected '=item *'

Around line 555:

Expected '=item *'

Around line 557:

Expected '=item *'

Around line 559:

Expected '=item *'

Around line 561:

Expected '=item *'

Around line 563:

Expected '=item *'

Around line 664:

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

Around line 692:

'=item' outside of any '=over'

Around line 737:

You forgot a '=back' before '=head2'

Around line 1262:

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