Bric::Util::Priv - Individual Privileges $LastChangedRevision$ $LastChangedDate: 2006-03-17 16:26:34 -0800 (Fri, 17 Mar 2006) $ use Bric::Util::Priv; use Bric::Util::Priv::Parts::Const qw(:all); my $priv = Bric::Util::Priv->new($init); $priv = Bric::Util::Priv->lookup($params); my @privs = Bric::Util::Priv->list($params); my $privs_href = Bric::Util::Priv->href($params); my @priv_ids = Bric:::Util::Priv->list_ids($params); my $acl = Bric::Util::Priv->get_acl($user); my $vals_href = Bric::Util::Priv->vals_href; my $meths = Bric::Util::Priv->my_meths; my @meths = Bric::Util::Priv->my_meths(1); my $grp = $priv->get_usr_grp; my $grp_id = $priv->get_usr_grp_id; my $obj = $priv->get_obj_grp; my $obj_id = $priv->get_obj_grp_id; my $value = $priv->get_value; $priv = $priv->set_value(READ); $priv = $priv->del; $priv = $priv->save; Objects of the Bric::Util::Priv class represent single privileges granted to a user or user group. The idea is to be able to manage individual privileges in an object-oriented fashion. Thus, this class will be used by the interface of Bric::Biz::Person::User and Bric::Util::Grp::User.

Constructors
Creates a new privilege for a user or group. Expects a single anonymous hash argument consisting of the following keys: usr_grp - The Bric::Util::Grp::User object or ID for which to set the privilege. Required. obj_grp - The Bric::Util::Grp object or ID for whose members the privilege is granted. Required. value - The privilege to grant to the user or group. Required. Must be one of the following constants (which may be imported by "use Bric::Util::Priv::Parts::Const qw(:all)": READ => 1 EDIT => 2 RECALL => 3 CREATE => 4 PUBLISH => 5 DENY => 255 Throws: Must pass user group and object group. Incorrect number of args to Bric::_set(). Bric::set() - Problems setting fields. Side Effects: NONE. Notes: NONE. Looks up and instantiates a Bric::Util::Priv object based on the Bric::Util::Priv object ID passed. If $id is not found in the database, lookup() returns undef. Throws: Too many Bric::Util::Priv 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::Priv object with data from the database before returning it. Notes: NONE. Returns a list or anonymous array of Bric::Util::Priv objects. Supported search keys include: permission ID. May use "ANY" for a list of possible values. A Bric::Util::Grp::User object ID to which privileges have been granted. May use "ANY" for a list of possible values. A Bric::Util::Grp object ID for which privileges have been granted. May use "ANY" for a list of possible values. A privilege value. This could return a *lot* of records, so you're probably not going to want to do this. May use "ANY" for a list of possible values. 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. Works the same as list(), with the same arguments, except it returns a hash or hashref of Bric::Util::Priv objects, where the keys are the contact IDs, and the values are the contact objects. 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::Priv 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::Priv objects. Interface is the same as 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. Returns an access control list of privilege settings for a given user. A description of the ACL's data structure will go here soon. Bric::Util::Priv will also handle caching that data structure. 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: Support for parent groups is not yet supported. Thus, if a user is in a group that does not have a permission set, and that group has a parent where the permission is set, that permission will not be included in the ACL. This inheritance of permissions will be implemented in the future, and at that time the permissions of child groups will override the permissions of their parents. Returns the last modified time for the privileges set for groups of which $user is a member. Throws: Unable to connect to database. Unable to prepare SQL statement. Unable to fetch row from statement handle. Side Effects: NONE. Notes: NONE. Returns an anonymous hash or anonymous array of the possible values for a privilege object. The vals_href() method returns an anonymous array in which the privilege values are the keys and their corresponding names are the values: { &READ => 'READ', &EDIT => 'EDIT', &RECALL => 'RECALL', &CREATE => 'CREATE', &PUBLISH => 'PUBLISH', &DENY => 'DENY' } The vals_aref() method returns an anonymous array of anonymous arrays. The first value of each embedded anonymous array is the privilege value, whereas the second value is the name for that value: [ [ &READ => 'READ' ], [ &EDIT => 'EDIT' ], [ &RECALL => 'RECALL' ], [ &CREATE => 'CREATE' ], [ &PUBLISH => 'PUBLISH' ], [ &DENY => 'DENY' ] ] Throws: NONE. Side Effects: Use Bric::Util::Priv::Pargs::Const internally to import the value constants. 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.

Public Instance Methods
Returns the ID of the Bric::Util::Priv 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::Priv 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::Util::Grp::User object to which the privilege has been granted. Throws: Bric::_get() - Problems retrieving fields. Too many Bric::Util::Grp::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: Calls Bric::Util::Grp::User->new internally. Notes: NONE. Returns the ID of the Bric::Util::Grp::User object to which the privilege has been granted. Throws: Throws: Bad AUTOLOAD method format. Cannot AUTOLOAD private methods. Access denied: READ access for field 'usr_grp_id' required. No AUTOLOAD method. Side Effects: NONE. Notes: NONE. Returns the group object for whose members the privilege has been granted. Throws: Bric::_get() - Problems retrieving fields. Too many Bric::Util::Grp 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: Calls Bric::Util::Grp->new internally. Notes: NONE. Returns the ID of the group object for whose members the privilege has been granted. Throws: Bad AUTOLOAD method format. Cannot AUTOLOAD private methods. Access denied: READ access for field 'obj_grp_id' required. No AUTOLOAD method. Side Effects: NONE. Notes: NONE. Returns the time the privilege was last modified. Pass in a strftime formatting string to get the time back in that format. Throws: Bric::_get() - Problems retrieving fields. Unable to unpack date. Unable to format date. Side Effects: NONE. Notes: NONE. Returns the privilege setting for this Bric::Util::Priv object. Returns a value corresponding to the constants defined above for new(). "use Bric::Util::Priv::Parts::Const qw(:all)" for convenience constants. Throws: Bad AUTOLOAD method format. Cannot AUTOLOAD private methods. Access denied: READ access for field 'value' required. No AUTOLOAD method. Side Effects: NONE. Notes: NONE. Sets the privilege value for this Bric::Util::Priv object. The value must be equivalent to one of the privileges exported by Bric::Util::Priv::Parts::Const. Throws: Not a valid privilege value. Incorrect number of args to _set. Bric::_set() - Problems setting fields. Side Effects: NONE. Notes: NONE. Deletes the privilege. The privilege won't actually be deleted until $priv->save is called. Throws: Incorrect number of args to _set. Bric::_set() - Problems setting fields. Side Effects: NONE. Notes: NONE. Saves the privilege to the database. Throws: Bric::_get() - Problems retrieving fields. Unable to connect to database. Unable to prepare SQL statement. Unable to execute SQL statement. Unable to select row. Incorrect number of args to _set. Bric::_set() - Problems setting fields. 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::Priv objects or, if called with an optional third argument, returns a list of Bric::Util::Priv 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. NONE. David Wheeler <david@justatheory.com> Bric, Bric::Biz::Person, Bric::Biz::Person::User, Bric::Util::Grp::User