Solstice::PersonFactory - Solstice::PersonFactory documentation


Solstice documentation Contained in the Solstice distribution.

Index


Code Index:

NAME

Top

Solstice::PersonFactory -

SYNOPSIS

Top

DESCRIPTION

Top

This package is deprecated. Use Solstice::Factory::Person instead.

Export

No symbols exported.

Methods

isValidLogin($login)

Returns true if the login specified is a username in the current realm, false otherwise.

createByIDs(\@ids)

Returns an array ref of person objects, for as many of the ids as it can.

createAllLogins()

Returns a list of Person objects, one for each member of the login realm.

createByLogins($login_name_array_ref)

Returns an array ref of people objects. If the loginrealm has not been set, we'll read the default realm from Solstice::ConfigService. If the default realm can't be used, an empty array ref is returned.

AUTHOR

Top

Catalyst Group, <catalyst@u.washington.edu>

VERSION

Top

$ Revision: $

COPYRIGHT

Top


Solstice documentation Contained in the Solstice distribution.
package Solstice::PersonFactory;

use 5.006_000;
use strict;
use warnings;

use base qw(Solstice);

use Solstice::Database;
use Solstice::Person;
use Solstice::Factory::Person;
use Solstice::Service::LoginRealm;

our ($VERSION) = ('$Revision: 2253 $' =~ /^\$Revision:\s*([\d.]*)/);

use constant TRUE     => 1;
use constant FALSE    => 0;

sub createByID {
    my $self = shift;
    return $self->createByIDs([shift])->[0];
}

*createById = *createByID;

sub createByLogin {
    my $self = shift;
    return $self->createByLogins([shift])->[0];
}

sub isValidLogin {
    my $self = shift;
    my $login = shift;

    my $lr_service = Solstice::Service::LoginRealm->new();
    
    my $login_name = $lr_service->getLoginNameForLogin($login);
    return FALSE unless defined $login_name;
    
    my $login_realm = $lr_service->getByLogin($login);
    return FALSE unless defined $login_realm;

    my $db = Solstice::Database->new();
    my $db_name = $self->getConfigService()->getDBName();

    $db->readQuery('SELECT person_id
                FROM '.$db_name.'.Person
                WHERE login_realm_id = ? AND login_name = ?',
        $login_realm->getID(), $login_name);

    my $valid_entry = $db->fetchRow();

    return (defined $valid_entry && $valid_entry->{'person_id'}) ? TRUE : FALSE; 
}

sub createByIDs {
    my $self = shift;
    return Solstice::Factory::Person->new()->createByIDs(@_)->getAll();
}

*createByIds = *createByIDs;

sub getAllLoginNamesByDate {
    my $self = shift;
    return Solstice::Factory::Person->new()->getAllLoginNamesByDate(@_);
}

sub createByLogins {
    my $self = shift;
    return Solstice::Factory::Person->new()->createByLogins(@_)->getAll();
}

1;

__END__