man Bric::Biz::Site () - Interface to Bricolage Site Objects

NAME

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

VITALS

Version
$LastChangedRevision$
Date
$LastChangedDate: 2004-08-12 17:13:34 -0700 (Thu, 12 Aug 2004) $
Subversion ID
$Id: Site.pm 5791 2004-08-13 00:13:34Z 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 CWname and CWdomain_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 CWlookup() will return CWundef.

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 supported lookup keys that must be an exact value are:

active
A boolean value indicating if the site is active.
grp_id
A Bric::Util::Grp::Site object ID.
element_id
A Bric::Biz::AssetType (element) ID.
output_channel_id
A Bric::Biz:OutputChannel ID. Pass in CWundef to check for when it's CWNULL, and not null to check for when it's CWNOT NULL.

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 CWlist().

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 CWlist() 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 CWset_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 CWset_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. CWactivate() and CWdeactivate() each return the site object. CWis_active() returns the site object when the site is active, and CWundef 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 CWgrp_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::AssetType
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.