Bric::Util::Alerted(3)User Contributed Perl DocumentatioBric::Util::Alerted(3)



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

VERSION
       $LastChangedRevision$

DATE
       $LastChangedDate: 2006-03-18 01:26:34 +0100 (Sat, 18 Mar 2006) $

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:

           o   Too many Bric::Util::Alerted objects found.

           o   Unable to prepare SQL statement.

           o   Unable to connect to database.

           o   Unable to select column into arrayref.

           o   Unable to execute SQL statement.

           o   Unable to bind to columns to statement handle.

           o   Unable to fetch row from statement handle.

           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:

           id  Alerted ID. May use "ANY" for a list of possible values.

           alert_id
               A Bric::Util::Alert ID. May use "ANY" for a list of possible
               values.

           user_id
               A Bric::Biz::Person::User ID. May use "ANY" for a list of
               possible values.

           timestamp
           ack_time
               The time at which alerts were sent or acknowledged. May use
               "ANY" for a list of possible values. May also pass an anonymous
               array of two values, the first the minimum time, the second the
               maximum time. If the first array item is undefined, then the
               second will be considered the date that time must be less than.
               If the second array item is undefined, then the first will be
               considered the date that time must be greater than. If the
               value passed in is undefined, then the query will specify 'IS
               NULL'.

           alert_type_id
               A Bric::Util::AlertType ID. May use "ANY" for a list of
               possible values.

           event_id
               A Bric::Util::Event ID. May use "ANY" for a list of possible
               values.

           subject
           name
               An alert subject. "name" is an alias for "subject". May use
               "ANY" for a list of possible values.

           message
               An alert message. May use "ANY" for a list of possible values.

           Throws:

           o   Unable to connect to database.

           o   Unable to prepare SQL statement.

           o   Unable to select column into arrayref.

           o   Unable to execute SQL statement.

           o   Unable to bind to columns to statement handle.

           o   Unable to fetch row from statement handle.

           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:

           o   Unable to connect to database.

           o   Unable to prepare SQL statement.

           o   Unable to select column into arrayref.

           o   Unable to execute SQL statement.

           o   Unable to bind to columns to statement handle.

           o   Unable to fetch row from statement handle.

           Side Effects: NONE.

           Notes: NONE.

       $meths = Bric::Util::Alerted->my_meths
       (@meths || $meths_aref) = Bric::Util::Alerted->my_meths(TRUE)
       my (@meths || $meths_aref) = Bric::Util::Alerted->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 $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:

           o   Unable to connect to database.

           o   Unable to prepare SQL statement.

           o   Unable to execute SQL statement.

           Side Effects: NONE.

           Notes: NONE.

   Public Instance Methods
       my $id = $alerted->get_id
           Returns the ID of the Bric::Util::Alerted object.

           Throws:

           o   Bad AUTOLOAD method format.

           o   Cannot AUTOLOAD private methods.

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

           o   No AUTOLOAD method.

           Side Effects: NONE.

           Notes: If the Bric::Util::Alerted object has been instantiated via
           the new() constructor and has not yet been "save"d, 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:

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

           o   Too many Bric::Biz::Person::User objects found.

           o   Unable to prepare SQL statement.

           o   Unable to connect to database.

           o   Unable to select column into arrayref.

           o   Unable to execute SQL statement.

           o   Unable to bind to columns to statement handle.

           o   Unable to fetch row from statement handle.

           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:

           o   Bad AUTOLOAD method format.

           o   Cannot AUTOLOAD private methods.

           o   Access denied: READ access for field 'user_id' required.

           o   No AUTOLOAD method.

           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:

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

           o   Too many Bric::Util::Alert objects found.

           o   Unable to prepare SQL statement.

           o   Unable to connect to database.

           o   Unable to select column into arrayref.

           o   Unable to execute SQL statement.

           o   Unable to bind to columns to statement handle.

           o   Unable to fetch row from statement handle.

           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:

           o   Bad AUTOLOAD method format.

           o   Cannot AUTOLOAD private methods.

           o   Access denied: READ access for field 'alert_id' required.

           o   No AUTOLOAD method.

           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:

           o   Bad AUTOLOAD method format.

           o   Cannot AUTOLOAD private methods.

           o   Access denied: READ access for field 'message' required.

           o   No AUTOLOAD method.

           o   Problems retrieving fields.

           Side Effects: NONE.

           Notes: NONE.

       my $msg = $alerted->get_message
           Returns the message of the alert for which this recipient was
           notified.

           Throws:

           o   Bad AUTOLOAD method format.

           o   Cannot AUTOLOAD private methods.

           o   Access denied: READ access for field 'message' required.

           o   No AUTOLOAD method.

           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:

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

           o   Unable to unpack date.

           o   Unable to format date.

           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:

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

           o   Unable to unpack date.

           o   Unable to format date.

           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:

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

           o   Unable to connect to database.

           o   Unable to prepare SQL statement.

           o   Unable to execute SQL statement.

           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:

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

           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:

           o   Unable to prepare SQL statement.

           o   Unable to connect to database.

           o   Unable to select column into arrayref.

           o   Unable to execute SQL statement.

           o   Unable to bind to columns to statement handle.

           o   Unable to fetch row from statement handle.

           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:

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

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

           Side Effects: NONE.

           Notes: NONE.

NOTES
       NONE.

AUTHOR
       David Wheeler <david@justatheory.com>

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



perl v5.12.2                      2006-03-17            Bric::Util::Alerted(3)
