Bric::Biz::Site(3)

NAME
Bric::Biz::Site - Interface to Bricolage Site Objects

VITALS

Version
    $LastChangedRevision$

Date
    $LastChangedDate: 2006-06-17 00:51:26 +0200 (Sat, 17 Jun 2006) $

Subversion ID
    $Id: Site.pm 7538 2006-06-16 22:51:26Z theory $

SYNOPSIS
  use Bric::Biz::Site;

  # Constructors.
  my $site = Bric::Biz::Site->new($init);
  $site = Bric::Biz::Site->lookup({ id => $id });
  my @sites = Bric::Biz::Site->list($params);

  # Class Methods.
  my @site_ids = Bric::Biz::Site->list_ids($params);
  my $meths = Bric::Biz::Site->my_meths;

  # Instance methods.
  $id = $site->get_id;
  my $name = $site->get_name;
  $site = $site->set_name($name)
  my $desc = $site->get_description;
  $site = $site->set_description($desc);
  my $domain_name = $site->get_domain_name;
  $site = $site->set_domain_name($domain_name);

  $site = $site->activate;
  $site = $site->deactivate;
  $site = $site->is_active;

  # Save the changes to the database
  $site = $site->save;

DESCRIPTION
Sites are first-class Bricolage objects designed to manage different sites from within a single Bricolage instance.

INTERFACE

  Constructors
new

  my $site = Bric::Biz::Site->new;
  $site = Bric::Biz::Site->new($init);

Constructs a new site object and returns it. An anonymous hash of initial values may be passed. The supported keys for that hash references are:

name
description
domain_name

The "name" and "domain_name" attributes must be globally unique or an exception will be thrown.

Throws:

Exception::DA
Error::Undef
Error::NotUnique

lookup

  my $site = Bric::Biz::Site->lookup({ id => $id });
  $site = Bric::Biz::Site->lookup({ name => $name });
  $site = Bric::Biz::Site->lookup({ domain_name => $domain_name });

Looks up and constructs an existing site object in the database and returns it. A Site ID, name, or domain name can be used as the site object unique identifier to look up. If no site object is found in the database, then "lookup()" will return "undef".

Throws:

Exception::DA

list

  my @sites = Bric::Biz::Site->list($params);
  my $sites_aref = Bric::Biz::Site->list($params);

Returns a list or anonymous array of site objects based on the search parameters passed via an anonymous hash. The supported lookup keys that may use valid SQL wild card characters are:

name
description
domain_name

The "ANY()" operator may be used to specify a list of values for any of these parameters.

The supported lookup keys that must be an exact value are:

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

active
    A boolean value indicating if the site is active.

grp_id
    A Bric::Util::Grp::Site object ID. May use "ANY" for a list of possible values.

element_type_id
element_id
    A Bric::Biz::ElementType (element type) ID. May use "ANY" for a list of possible values.

output_channel_id
    A Bric::Biz:OutputChannel ID. Pass in "undef" to check for when it's "NULL", and "not null" to check for when it's "NOT NULL". May use "ANY" for a list of possible values.

Throws:

Exception::DA

href

  my $sites_href = Bric::Biz::Site->href($params);

Returns an anonymous hash of site objects based on the search parameters passed via an anonymous hash. The hash keys will be the site IDs, and the values will be the corresponding sites. The supported lookup keys are the same as those for "list()".

Throws:

Exception::DA

  Class Methods
list_ids

  my @site_ids = Bric::Biz::Site->list_ids($params);
  my $site_ids_aref = Bric::Biz::Site->list_ids($params);

Returns a list or anonymous array of site object IDs based on the search parameters passed via an anonymous hash. The supported lookup keys are the same as for the "list()" method.

Throws:

Exception::DA

my_meths

  my $meths = Bric::Biz::Site->my_meths
  my @meths = Bric::Biz::Site->my_meths(1);
  my $meths_aref = Bric::Biz::Site->my_meths(1);
  @meths = Bric::Biz::Site->my_meths(0, 1);
  $meths_aref = Bric::Biz::Site->my_meths(0, 1);

Returns Bric::Biz::Site attribute accessor introspection data. See Bric for complete documtation of the format of that data. Returns accessor introspection data for the following attributes:

name
    The site name. A unique identifier attribute.

domain_name
    The site domain name. A unique identifier attribute.

description
    A description of the site.

active
    The site's active status boolean.

  Accessors
id

  my $id = $site->get_id;

Returns the site object's unique database ID.

name

  my $name = $site->get_name;
  $site = $site->set_name($name);

Get and set the site object's unique name. The value of this attribute must be case-insensitively globally unique. If a non-unique value is passed to "set_name()", an exception will be thrown.

Throws:

Error::Undef
Error::NotUnique

description

  my $description = $site->get_description;
  $site = $site->set_description($description);

Get and set the site object's description.

domain_name

  my $domain_name = $site->get_domain_name;
  $site = $site->set_domain_name($domain_name);

Get and set the site object's unique domain name. The value of this attribute must be case-insensitively globally unique. If a non-unique value is passed to "set_domain_name()", an exception will be thrown.

Throws:

Error::Undef
Error::NotUnique

active

  $site = $site->activate;
  $site = $site->deactivate;
  $site = $site->is_active;

Get and set the site object's active status. "activate()" and "deactivate()" each return the site object. "is_active()" returns the site object when the site is active, and "undef" when it is not.

  Instance Methods
save

  $site = $site->save;

Saves any changes to the site object to the database. Returns the site object on success and throws an exception on failure.

Side Effects: Creates five internal permanent groups. One is a Bric::Util::Grp::Asset group. Its ID is used for the site ID, so that it can easily be used by Bric::Biz::Asset to add the ID to its "grp_ids" attribute because every asset is related to a site. The other four are Bric::Util::Grp::User groups, and one is created for each permission, READ, EDIT, CREATE, and DENY. Furthermore, a Bric::Util::Priv object is created for each of these user groups in turn, to grant their users the appropriate permissions to any assets associated with the site.

Thows:

Error::Undef
Exception::DA

AUTHOR
David Wheeler <david@kineticode.com>

SEE ALSO

Bric::Biz::Category
    Each category object is associated with a site.

Bric::Biz::OutputChannel
    Each output channel object is associated with a site.

Bric::Biz::ElementType
    Each top-level element object is associated with one or more site.

Bric::Biz::Workflow
    Each workflow object is associated with a site.

Bric::Biz::Asset
    Each asseet object is associated with a site.

Bric::Dist::ServerType
    Each destination object is associated with a site.

COPYRIGHT AND LICENSE
Copyright (c) 2003 Kineticode, Inc. See Bric::License for complete license terms and conditions.