SIOC::User - SIOC User class


SIOC documentation Contained in the SIOC distribution.

Index


Code Index:

NAME

Top

SIOC::User -- SIOC User class

VERSION

Top

This documentation refers to SIOC::User version 1.0.0.

SYNOPSIS

Top

   use SIOC::User;




DESCRIPTION

Top

A User is an online account of a member of an online community. It is connected to Items and Posts that a User creates or edits, to Containers and Forums that it is subscribed to or moderates and to Sites that it administers. Users can be grouped for purposes of allowing access to certain Forums or enhanced community site features (weblogs, webmail, etc.).

A foaf:Person will normally hold a registered User account on a Site (through the property foaf:holdsAccount), and will use this account to create content and interact with the community.

sioc:User describes properties of an online account, and is used in combination with a foaf:Person (using the property sioc:account_of) which describes information about the individual itself.

CLASS ATTRIBUTES

Top

email

An electronic mail address of the User.

foaf_uri

Link to a FOAF record.

email_sha1

An electronic mail address of the User, encoded using SHA1.

account_of

Refers to the foaf:Agent or foaf:Person who owns this sioc:User online account.

avatar

An image or depiction used to represent this User.

functions

Roles that this User has.

usergroups

A Usergroup that this User is a member of.

created_items

Items that the User is a creator of.

modified_items

Items that this User has modified.

administered_sites

Sites that the User is an administrator of.

moderated_forums

Forums that User is a moderator of.

owned_containers

Containers owned by a particular User, for example, a weblog or image gallery.

subscriptions

Containers that a User is subscribed to.

SUBROUTINES/METHODS

Top

TODO: document methods

DIAGNOSTICS

Top

For diagnostics information, see the SIOC base class.

CONFIGURATION AND ENVIRONMENT

Top

This module doesn't need configuration.

DEPENDENCIES

Top

This module depends on the following modules:

INCOMPATIBILITIES

Top

There are no known incompatibilities.

BUGS AND LIMITATIONS

Top

There are no known bugs in this module.

Please report problems via the bug tracking system on the perl-SIOC project website: http://developer.berlios.de/projects/perl-sioc/.

Patches are welcome.

AUTHOR

Top

Jochen Lillich <geewiz@cpan.org>

LICENSE AND COPYRIGHT

Top


SIOC documentation Contained in the SIOC distribution.

###########################################################
# SIOC::User
# User class for the SIOC ontology
###########################################################
#
# $Id: User.pm 10 2008-03-01 21:38:39Z geewiz $
#

package SIOC::User;

use strict;
use warnings;
use Carp;
use Data::Dumper qw( Dumper );

use version; our $VERSION = qv(1.0.0);

use Moose;
use MooseX::AttributeHelpers;

extends 'SIOC';

### required attributes

has 'email' => (
    isa => 'Str',
    is => 'rw',
    required => 1,
);
    
has 'foaf_uri' => (
    isa => 'Str',
    is => 'rw',
    required => 1,
    );

### optional attributes

has 'email_sha1' => (
    isa => 'Str',
    is => 'rw',
);

has 'account_of' => (
    is => 'rw',
);

has 'avatar' => (
    is => 'rw',
);

has 'function' => (
    isa => 'ArrayRef[SIOC::Role]',
    metaclass => 'Collection::Array',
    is => 'rw',
    provides => {
        'push' => 'add_function',
    },
);

has 'usergroups' => (
    isa => 'ArrayRef[SIOC::Usergroup]',
    metaclass => 'Collection::Array',
    is => 'rw',
    provides => {
        'push' => 'add_usergroup',
    },
);

has 'created_items' => (
    isa => 'ArrayRef[SIOC::Item]',
    metaclass => 'Collection::Array',
    is => 'rw',
    provides => {
        'push' => 'add_created_forum',
    },
);

has 'modified_items' => (
    isa => 'ArrayRef[SIOC::Item]',
    metaclass => 'Collection::Array',
    is => 'rw',
    provides => {
        'push' => 'add_modified_forum',
    },
);

has 'administered_sites' => (
    isa => 'ArrayRef[SIOC::Site]',
    metaclass => 'Collection::Array',
    is => 'rw',
    provides => {
        'push' => 'add_administered_site',
    },
);

has 'moderated_forums' => (
    isa => 'ArrayRef[SIOC::Forum]',
    metaclass => 'Collection::Array',
    is => 'rw',
    provides => {
        'push' => 'add_moderated_forum',
    },
);

has 'owned_containers' => (
    isa => 'ArrayRef[SIOC::Container]',
    metaclass => 'Collection::Array',
    is => 'rw',
    provides => {
        'push' => 'add_owned_container',
    },
);

has 'subscriptions' => (
    isa => 'ArrayRef[SIOC::Container]',
    metaclass => 'Collection::Array',
    is => 'rw',
    default => sub { [] },
    provides => {
        'push' => 'add_subscription',
    },
);

### methods

after 'fill_template' => sub {
    my ($self) = @_;
    
    $self->set_template_var(name => $self->name);
    $self->set_template_var(email => $self->email); 
    $self->set_template_var(foaf_uri => $self->foaf_uri);
    $self->set_template_var(email_sha1 => $self->email_sha1);
    $self->set_template_var(avatar => $self->avatar);
};

1;

__DATA__
__rdfoutput__
<foaf:Person rdf:about="[% foaf_uri | url %]">
[% IF name %]
    <foaf:name>[% name %]</foaf:name>
[% END %]
[% IF email_sha1 %]
    <foaf:mbox_sha1sum>[% email_sha1 %]</foaf:mbox_sha1sum>
[% END %]
    <foaf:holdsAccount>
        <sioc:User rdf:about="[% url | url %]">
[% IF nick %]
            <sioc:name>[% name %]</sioc:name>
[% END %]
[% IF email %]
            <sioc:email rdf:resource="[% email %]"/>
[% END %]
[% IF email_sha1 %]
            <sioc:email_sha1>[% email_sha1 %]</sioc:email_sha1>
[% END %]
[% IF role %]
            <sioc:has_function>
                <sioc:Role>
                    <sioc:name>[% role %]</sioc:name>
                </sioc:Role>
            </sioc:has_function>
[% END %]
        </sioc:User>  
    </foaf:holdsAccount>
</foaf:Person>
__END__