Bric::Util::Alerted - Interface to Alerts as they are sent to individual users. $LastChangedRevision$ $LastChangedDate: 2004-06-04 12:21:12 -0700 (Fri, 04 Jun 2004) $ 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); 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.

Constructors
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: Too many Bric::Util::Alerted 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 is found, populates the new Bric::Util::Alerted object with data from the database before returning it. Notes: NONE. 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: alert_id user_id ack_time - May pass in as an anonymous array of two values, the first the minimum acknowledged time, the second the maximum acknowledged time. If the first array item is undefined, then the second will be considered the date that ack_time must be less than. If the second array item is undefined, then the first will be considered the date that ack_time must be greater than. If the value passed in is undefined, then the query will specify 'IS NULL'. 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: 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::Alerted object with data from the database before returning them all. Notes: NONE.

Destructors
Dummy method to prevent wasting time trying to AUTOLOAD DESTROY. Throws: NONE. Side Effects: NONE. Notes: NONE.

Public Class Methods
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: 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. 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: The name of the property or attribute. Is the same as the hash key when an anonymous hash is returned. The display name of the property or attribute. A reference to the method that will retrieve the value of the property or attribute. An anonymous array of arguments to pass to a call to get_meth in order to retrieve the value of the property or attribute. A reference to the method that will set the value of the property or attribute. An anonymous array of arguments to pass to a call to set_meth in order to set the value of the property or attribute. The type of value the property or attribute contains. There are only three types: If the value is a 'short' value, this hash key contains the length of the field. The property is searchable via the list() and list_ids() methods. The property or attribute is required. An anonymous hash of properties used to display the property or attribute. Possible keys include: The display field type. Possible values are The Length, in letters, to display a text or password field. The maximum length of the property or value - usually defined by the SQL DDL. The number of rows to format in a textarea field. The number of columns to format in a textarea field. 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. 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: Unable to connect to database. Unable to prepare SQL statement. Unable to execute SQL statement. Side Effects: NONE. Notes: NONE.

Public Instance Methods
Returns the ID of the Bric::Util::Alerted object. Throws: Bad AUTOLOAD method format. Cannot AUTOLOAD private methods. Access denied: READ access for field 'id' required. 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. Returns the Bric::Biz::Person::User object representing the user to whom the alert was sent. Throws: Bric::_get() - Problems retrieving fields. Too many Bric::Biz::Person::User 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: Uses Bric::Biz::Person::User->lookup() internally. Notes: NONE. Returns the Bric::Biz::Person::User object ID representing the user to whom the alert was sent. Throws: Bad AUTOLOAD method format. Cannot AUTOLOAD private methods. Access denied: READ access for field 'user_id' required. No AUTOLOAD method. Side Effects: NONE. Notes: NONE. Returns the Bric::Util::Alert object representing the alert for which this Bric::Util::Alerted object was created. Throws: Bric::_get() - Problems retrieving fields. Too many Bric::Util::Alert 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: NONE. Notes: NONE. Returns the id of the Bric::Util::Alert object representing the alert for which this Bric::Util::Alerted object was created. Throws: Bad AUTOLOAD method format. Cannot AUTOLOAD private methods. Access denied: READ access for field 'alert_id' required. No AUTOLOAD method. Side Effects: NONE. Notes: NONE. Returns the subject of the alert for which this recipient was notified. Throws: Bad AUTOLOAD method format. Cannot AUTOLOAD private methods. Access denied: READ access for field 'message' required. No AUTOLOAD method. Problems retrieving fields. Side Effects: NONE. Notes: NONE. Returns the message of the alert for which this recipient was notified. Throws: Bad AUTOLOAD method format. Cannot AUTOLOAD private methods. Access denied: READ access for field 'message' required. No AUTOLOAD method. Side Effects: NONE. Notes: NONE. 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: Bric::_get() - Problems retrieving fields. Unable to unpack date. Unable to format date. Side Effects: NONE. Notes: NONE. 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: Bric::_get() - Problems retrieving fields. Unable to unpack date. Unable to format date. Side Effects: NONE. Notes: NONE. 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: Bric::_get() - Problems retrieving fields. Unable to connect to database. Unable to prepare SQL statement. Unable to execute SQL statement. Side Effects: NONE. Notes: NONE. 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: Bric::_get() - Problems retrieving fields. Side Effects: NONE. Notes: NONE. No-op. Throws: NONE. Side Effects: NONE. Notes: NONE.

Private Class Methods
NONE.

Private Instance Methods
NONE.

Private Functions
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: 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. Instantiates a new object. Used in place of new() by &$get_em(), since new isn't implemented for this class. Throws: Incorrect number of args to Bric::_set(). Bric::set() - Problems setting fields. Side Effects: NONE. Notes: NONE. NONE. David Wheeler <david@wheeler.net> Bric, Bric::Util::AlertType, Bric::Util::EventType, Bric::Util::Event