Six Apart Code

<<

NAME

MT::Permission - Movable Type permissions record

SYNOPSIS

    use MT::Permission;
    my $perms = MT::Permission->load({ blog_id => $blog->id,
                                       author_id => $author->id })
        or die "Author has no permissions for blog";
    $perms->can_post
        or die "Author cannot post to blog";

    $perms->can_edit_config(0);
    $perms->save
        or die $perms->errstr;

DESCRIPTION

An MT::Permission object represents the permissions settings for an author in a particular blog. Permissions are set on a role basis, and each permission is either on or off for an author-blog combination; permissions are stored as a bitmask.

USAGE

As a subclass of MT::Object, MT::Permission inherits all of the data-management and -storage methods from that class; thus you should look at the MT::Object documentation for details about creating a new object, loading an existing object, saving an object, etc.

The following methods are unique to the MT::Permission interface. Each of these methods, except for set_full_permissions, can be called with an optional argument to turn the permission on or off. If the argument is some true value, the permission is enabled; otherwise, the permission is disabled. If no argument is provided at all, the existing permission setting is returned.

$perms->set_full_permissions

Turns on all permissions for the author and blog represented by $perms.

$perms->can_post

Returns true if the author can post to the blog, and edit the entries that he/she has posted; false otherwise.

$perms->can_upload

Returns true if the author can upload files to the blog directories specified for this blog, false otherwise.

$perms->can_edit_all_posts

Returns true if the author can edit all entries posted to this blog (even entries that he/she did not write), false otherwise.

$perms->can_edit_templates

Returns true if the author can edit the blog's templates, false otherwise.

$perms->can_send_notifications

Returns true if the author can send messages to the notification list, false otherwise.

$perms->can_edit_categories

Returns true if the author can edit the categories defined for the blog, false otherwise.

$perms->can_edit_notifications

Returns true if the author can edit the notification list for the blog, false otherwise.

$perms->can_edit_authors

Returns true if the author can edit author permissions for the blog, and add new authors who have access to the blog; false otherwise.

Note: you should be very careful when giving this permission to authors, because an author could easily then block your access to the blog.

$perms->can_edit_config

Returns true if the author can edit the blog configuration, false otherwise. Note that this setting also controls whether the author can import entries to the blog, and export entries from the blog.

DATA ACCESS METHODS

The MT::Comment 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
  • The numeric ID of this permissions record.

  • author_id
  • The numeric ID of the author associated with this permissions record.

  • blog_id
  • The numeric ID of the blog associated with this permissions record.

  • role_mask
  • The permissions bitmask. You should not access this value directly; instead use the can_* methods, above.

  • entry_prefs
  • The setting of display fields of "edit entry" page. The value at author_id 0 means default setting of a blog.

  • template_prefs
  • The setting of display "edit template" page. The value at author_id 0 means default setting of a blog.

DATA LOOKUP

In addition to numeric ID lookup, you can look up or sort records by any combination of the following fields. See the load documentation in MT::Object for more information.

  • blog_id
  • author_id

AUTHOR & COPYRIGHTS

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

<<

Six Apart
Makers of weblog software and services for individuals, organizations and businesses.