<<

NAME

MT::Association - Relational table for Author/Group-Role-Blog relationships.

SYNOPSIS

    use MT::Association;

    # Define a Group - Role - Blog relationship
    MT::Association->link( $group => $role => $blog );

    # Define a User - Role - Blog relationship
    MT::Association->link( $user => $role => $blog );

    # Define a User - Group relationship
    MT::Association->link( $user => $group );

DESCRIPTION

This module handles relational mappings between MT::Author, MT::Group, MT::Role and MT::Blog objects.

METHODS

$assoc->save()

Saves the association and calls the rebuild_permissions method to ensure the related permissions are updated.

$assoc->remove()

Removes the association and calls the rebuild_permissions method to ensure the related permissions are updated.

$assoc->rebuild_permissions()

An alias for calling MT::Permission-rebuild($assoc)>.

$assoc->user()

Returns the MT::Author object tied to this association. Returns undef if the author_id property is undefined.

$assoc->blog()

Returns the MT::Blog object tied to this association. Returns undef if the blog_id property is undefined.

$assoc->group()

Returns the MT::Group object tied to this association. Returns undef if the group_id property is undefined.

$assoc->role()

Returns the MT::Role object tied to this association. Returns undef if the role_id property is undefined.

MT::Association->link(@things)

Creates a new association record that ties the elements of @things together. The list of @things may contain:

1. user, role, blog
2. group, role, blog
3. user, group

Any other combination will fail horribly.

MT::Association->unlink(@things)

Removes any association record that exists that ties the elements of @things together. See the link method for valid values to pass for the @things parameter.

MT::Association->objects_to_terms(@things)

Utility method that takes an array containing user, group, role, blog objects and returns a hashref suitable to use for terms for the MT::Association->load method.

DATA ACCESS METHODS

The MT::Association object holds the following pieces of data. These fields can be accessed and set using the standard data access methods described in the MT::Object documentation.

  • id

    Primary key for the association object.

  • type

    Identifies the type of relationship. Valid types are defined by the following constants:

    • MT::Association::USER_BLOG_ROLE
    • MT::Association::GROUP_BLOG_ROLE
    • MT::Association::USER_GROUP
  • author_id

    MT::Author id for associations related to a user. For other association types, this value is undefined.

  • blog_id

    MT::Blog id for associations related to a blog. For other association types, this value is undefined.

  • group_id

    MT::Group id for associations related to a group. For other association types, this value is undefined.

  • role_id

    MT::Role id for associations related to a role. For other association types, this value is undefined.

AUTHOR & COPYRIGHT

Please see the MT manpage for author, copyright, and license information.

<<