Bric::Util::EventType(3)

NAME
Bric::Util::EventType - Interface to Types of Events

VERSION
$LastChangedRevision$

DATE
$LastChangedDate: 2004-06-04 12:21:12 -0700 (Fri, 04 Jun 2004) $

SYNOPSIS
  # Constructors
  my $et = Bric::Util::EventType->lookup({name => 'Story Published'});
  my @ets = Bric::Util::EventType->list($params);

  # Class Methods.
  my @et_ids = Bric::Util::EventType->list_ids($params);
  my $trig_meths = Bric::Util::EventType->my_trig_meths;

  # Instance Methods
  my $id = $et->get_id;
  my $key_name = $et->get_key_name;
  my $name = $et->get_name;
  my $desc = $et->get_description;
  my $class = $et->get_class;
  my @attr = $et->get_attr;
  $et = $ae->activate;
  $et = $ae->deactivate;
  $et = $ae->is_active;
  my $event = $et->log_event($user, $obj);

DESCRIPTION
Bric::Util::EventType is designed to be the interface to the different types of events Bricolage. New events cannot be created; they are defined ahead of time in the database. Thus, the primary purpose of this class is to offer up a list of events for which alerts can be set by Bric::Util::AlertType. Internally, it can be used by the Bricolage APIs to log individual events.

INTERFACE

  Constructors

my $et = Bric::Util::EventType->lookup({id => $et_id})
my $et = Bric::Util::EventType->lookup({key_name => $key_name})
    Looks up and instantiates a new Bric::Util::EventType object based on a Bric::Util::EventType object ID or name. If the existing object is not found in the database, lookup() returns undef.

    Throws:

    *   Too many Bric::Util::EventType objects found.

    *   Unable to prepare SQL statement.

    *   Unable to connect to database.

    *   Unable to select column into arrayref.

    *   Unable to execute SQL statement.

    *   Unable to bind to columns to statement handle.

    *   Unable to fetch row from statement handle.

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

    Notes: NONE.

my (@ets || $ets_aref) = Bric::Util::EventType->list($params)
    Returns a list or anonymous array of Bric::Util::EventType objects based on the search parameters passed via a hashref. The supported lookup keys are:

    *   name

    *   description

    *   class

    *   class_id

    Throws:

    *   Unable to connect to database.

    *   Unable to prepare SQL statement.

    *   Unable to select column into arrayref.

    *   Unable to execute SQL statement.

    *   Unable to bind to columns to statement handle.

    *   Unable to fetch row from statement handle.

    Side Effects: Populates each Bric::Util::EventType 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 (@et_ids || $et_ids_aref) = Bric::Util::EventType->list_ids($params)
    Returns a list or anonymous array of Bric::Util::EventType object IDs based on the search parameters passed via anonymous hash. The search parameters are the same as those for list() above.

    Throws:

    *   Unable to connect to database.

    *   Unable to prepare SQL statement.

    *   Unable to select column into arrayref.

    *   Unable to execute SQL statement.

    *   Unable to bind to columns to statement handle.

    *   Unable to fetch row from statement handle.

    Side Effects: NONE.

    Notes: NONE.

my (@classes || $classes_aref) = Bric::Util::EventType->list_classes()
    Returns a list or an anonymous array of anonymous arrays of Bricolage classes for which types of events have been defined in the database. The each array ref in the list contains two values: the first is the ID of the class, and the second is its display name.

    Throws:

    *   Unable to connect to database.

    *   Unable to prepare SQL statement.

    *   Unable to execute SQL statement.

    *   Unable to bind to columns to statement handle.

    *   Unable to fetch row from statement handle.

    Side Effects: NONE.

    Notes: NONE.

$meths = Bric::Util::EventType->my_meths
(@meths || $meths_aref) = Bric::Util::EventType->my_meths(TRUE)
my (@meths || $meths_aref) = Bric::Util::EventType->my_meths(0, TRUE)
    Returns an anonymous hash of introspection data for this object. If called with a true argument, it will return an ordered list or anonymous array of introspection data. If a second true argument is passed instead of a first, then a list or anonymous array of introspection data will be returned for properties that uniquely identify an object (excluding "id", which is assumed).

    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:

    name
        The name of the property or attribute. Is the same as the hash key when an anonymous hash is returned.

    disp
        The display name of the property or attribute.

    get_meth
        A reference to the method that will retrieve the value of the property or attribute.

    get_args
        An anonymous array of arguments to pass to a call to get_meth in order to retrieve the value of the property or attribute.

    set_meth
        A reference to the method that will set the value of the property or attribute.

    set_args
        An anonymous array of arguments to pass to a call to set_meth in order to set the value of the property or attribute.

    type
        The type of value the property or attribute contains. There are only three types:

        short
        date
        blob
    len If the value is a 'short' value, this hash key contains the length of the field.

    search
        The property is searchable via the list() and list_ids() methods.

    req The property or attribute is required.

    props
        An anonymous hash of properties used to display the property or attribute. Possible keys include:

        type
            The display field type. Possible values are

            text
            textarea
            password
            hidden
            radio
            checkbox
            select
        length
            The Length, in letters, to display a text or password field.

        maxlength
            The maximum length of the property or value - usually defined by the SQL DDL.

    rows
        The number of rows to format in a textarea field.

    cols
        The number of columns to format in a textarea field.

    vals
        An anonymous hash of key/value pairs reprsenting the values and display names to use in a select list.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

my $meths = Bric::Util::EventType->my_trig_meths
my @meths = Bric::Util::EventType->my_trig_meths(1)
    Functions similarly to the my_meths() method on most business objects, except that it returns that metadata for accessing data on users.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

  Public Instance Methods

my $id = $et->get_id
    Returns the event type object ID.

    Throws:

    *   Bad AUTOLOAD method format.

    *   Cannot AUTOLOAD private methods.

    *   Access denied: READ access for field 'id' required.

    *   No AUTOLOAD method.

    Side Effects: NONE.

    Notes: NONE.

my $key_name = $et->get_key_name
    Returns the event type key name.

    Throws:

    *   Bad AUTOLOAD method format.

    *   Cannot AUTOLOAD private methods.

    *   Access denied: READ access for field 'key_name' required.

    *   No AUTOLOAD method.

    Side Effects: NONE.

    Notes: NONE.

my $name = $et->get_name
    Returns the event type name.

    Throws:

    *   Bad AUTOLOAD method format.

    *   Cannot AUTOLOAD private methods.

    *   Access denied: READ access for field 'name' required.

    *   No AUTOLOAD method.

    Side Effects: NONE.

    Notes: NONE.

my $description = $et->get_description
    Returns the event type description.

    Throws:

    *   Bad AUTOLOAD method format.

    *   Cannot AUTOLOAD private methods.

    *   Access denied: READ access for field 'description' required.

    *   No AUTOLOAD method.

    Side Effects: NONE.

    Notes: NONE.

my $class = $et->get_class
    Returns name of the class of object for which events of this type may be logged.

    Throws:

    *   Bad AUTOLOAD method format.

    *   Cannot AUTOLOAD private methods.

    *   Access denied: READ access for field 'class' required.

    *   No AUTOLOAD method.

    Side Effects: NONE.

    Notes: NONE.

my $attr_href = $et->get_attr
    Returns an anonymous hash of the attributes required of Bric::Util::Event objects of this Bric::Util::EventType type. The keys are the attribute names and the values are the default values.

    Throws:

    *   Bric::_get() - Problems retrieving fields.

    *   Too many Bric::Util::Grp::Event objects found.

    *   Unable to prepare SQL statement.

    *   Unable to connect to database.

    *   Unable to select column into arrayref.

    *   Unable to execute SQL statement.

    *   Unable to bind to columns to statement handle.

    *   Unable to fetch row from statement handle.

    *   Incorrect number of args to _set.

    *   Bric::_set() - Problems setting fields.

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

    Notes: NONE.

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

$self = $et->is_active
    Returns $self if the Bric::Util::EventType object is active, and undef if it is not.

    Throws:

    *   Bric::_get() - Problems retrieving fields.

    Side Effects: NONE.

    Notes: NONE.

my $event =  $et->log_event($user, $obj)
my $event =  $et->log_event($user, $obj, $ettr)
    A shortcut to "Bric::Util::Event->new". Pass in a Bric::Biz::Person::User object and an object of the type defined by get_class(), along with any attribute/value pairs, and a new event of this type will be logged for the object passed. Note that not all attributes need to be explicitly passed in order to log a new event. Any that can be called via a get_ accessor on $obj, where the method combines 'get_' with an attribute's name, will automatically call that accessor.

    See Bric::Util::Event for more information and for details on how it expects arugments to be passed.

    Throws:

    *   No Bric::Util::EventType object, ID, or name passed to Bric::Util::Event::new().

    *   Too many Bric::Util::EventType objects found.

    *   Unable to prepare SQL statement.

    *   Unable to connect to database.

    *   Unable to select column into arrayref.

    *   Unable to execute SQL statement.

    *   Unable to bind to columns to statement handle.

    *   Unable to fetch row from statement handle.

    *   Incorrect number of args to Bric::_set().

    *   Bric::set() - Problems setting fields.

    *   Bric::Util::Event::new() expects an object of type $class.

    *   No Bric::Biz::Person::User object passed to Bric::Util::Event::new().

    Side Effects: Uses Bric::Util::Event->new() internally.

    Notes: NONE.

my (@props || $props_aref) = $et->get_alert_props
    Returns a list or anonymous array of anonymous arrays that define properties that a user can use to refine which events of a specific type will trigger alerts. Each anonymous array within the list of alert properties contains two values. The first is the name of the property, and the second is the display name.

    Throws: NONE.

    Side Effects: NONE.

    Notes: NONE.

PRIVATE

  Private Class Methods
NONE.

  Private Instance Methods
NONE.

  Private Functions

my $event_types_aref = &$get_em( $pkg, $params )
my $event_types_aref = &$get_em( $pkg, $params, 1 )
    Function used by lookup() and list() to return a list of Bric::Util::EventType objects or, if called with an optional third argument, returns a listof Bric::Util::EventType object IDs (used by list_ids()).

    Throws:

    *   Unable to prepare SQL statement.

    *   Unable to connect to database.

    *   Unable to select column into arrayref.

    *   Unable to execute SQL statement.

    *   Unable to bind to columns to statement handle.

    *   Unable to fetch row from statement handle.

    Side Effects: NONE.

    Notes: NONE.

my $et = &$make_obj( $pkg, $init )
    Instantiates a Bric::Util::EventType object. Used by &$get_em().

    Throws:

    *   Unable to load action subclass.

    *   Invalid parameter passed to constructor method.

    *   Incorrect number of args to Bric::_set().

    *   Bric::set() - Problems setting fields.

    Side Effects: NONE.

    Notes: NONE.

NOTES
NONE.

AUTHOR
David Wheeler <david@wheeler.net>

SEE ALSO
Bric, Bric::Util::Event, Bric::Util::AlertType, Bric::Util::Alert