The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Solstice::Group - Manages sets of people

SYNOPSIS

my $group = Solstice::Group->new();
$group = Solstice::Group->new($group_id);

$group->setCreator($person);
my $person = $group->getCreator();
  
$group->setName('Group name');
my $name = $group->getName();

$group->setDescription('Group description');
my $desc = $group->getDescription();

my $date = $group->getCreationDate();
my $date = $group->getModificationDate();

$group->setCreationApplication($application);
my $application = $group->getCreationApplication();

my $list = $group->getOwners();
$group->addOwner($person);
$group->removeOwner($person);

my $bool = $group->isMember($person);
my $list = $group->getMembers();
my $list = $group->getAllMembers();
$group->addMember($person);
$group->addMembers($list);
$group->removeMember($person);
$group->removeMembers($list);
$group->removeAllMembers();

my $bool = $group->isMemberGroup($group2);
my $list = $group->getMemberGroups();
$group->addMemberGroup($group2);
$group->removeMemberGroup($group2);

my $bool = $group->isRemoteMemberGroup($group2);
my $list = $group->getRemoteGroups();
$group->addRemoteGroup($group2);
$group->removeRemoteGroup($group2);
$group->removeAllRemoteGroups();

my $list = $group->getSubgroups();
$group->addSubgroup($subgroup);
$group->removeSubgroup($subgroup);

my $member_count = $group->getMemberCount();
$group->store();

DESCRIPTION

This object tracks groups of people. Natively it manages sets of people stored in a local data store. It also can track groups of groups of people, and divide groups of people into subgroups. It can also track lists of groups stored in remote data stores, if they are presented via a remote group.

Export

No symbols exported.

Methods

new([$group_id])

Instantiates a new group object. If given an id of a group, this will return undef unless there is a group in the local data store matching that id.

clone()

Returns a copy of this group, including group members, subgroups, and linked remote groups.

delete()

Delete the group.

store()

Saves the group to the data store. Returns TRUE on success, FALSE otherwise. Saving will fail if the following attributes are not defined: name, creator, and creating application.

getOwners()

This will return a Solstice::List, containing Solstice::Person::<X> objects. All people in the list are considered full owners of this object. If there are no owners of the group, this will return a list with no elements.

addOwners($list)

Add person objs to the Group. This method requires a Solstice::List.

addOwner($person)

Adds the given person as an owner to the group. If the person is already an owner, this won't fail, but it will also not add them a second time. If the person that is passed in is not a stored person, in a subclass of Solstice::Person, this will fail.

removeOwner($person)

Removes the given person from the set of owners. The person object that is given must be a subclass of Solstice::Solstice, and must have been stored.

getMembers()

Returns a Solstice::List, containing Solstice::Person objects. This list consists of all members of the groups, excluding member groups, or people who are in remote groups.

getAllMembers()

Returns a Solstice::List, containing all members of the groups, including members of member groups, and members of remote groups.

getMemberCount()

Returns the number of members for the group.

isMember($person)

Returns TRUE if the given person is a member of this group, recursively, FALSE otherwise.

isLocalMember($person)

Returns TRUE if the given person is a member of this group, non-recursively, FALSE otherwise.

addMember($person)

Adds the given person object to the group. A person can only be added to a group once, though multiple adds will not result in an error being raised.

addMembers($list)

Add person objs to the Group. This method requires a Solstice::List.

removeMember($person)

Removes the given person from the group. This only removes the user from the group itself, it does not traverse into member groups, or modify any entries for a remote group.

removeMembers($list)

Remove person objs from the Group. This method requires a Solstice::List.

removeAllMembers()

Remove all members of the group, non-recursively.

clear()

See removeAllMembers().

isMemberGroup($group)

Returns a bool, TRUE if the group is a member group, FALSE otherwise. Not recursive.

getMemberGroups()

Returns a Solstice::List, containing all groups that are members of the group. This only includes local groups, no remote groups will be in this list.

addMemberGroup($group)

This will add the given group to the current group. This will return TRUE on success, FALSE on failure. This can fail in the case that the given group is not a Solstice::Group, or if the group has not been saved. Group membership can be cyclical.

removeMemberGroup($group)

This will remove the given group from the set of member groups. This will only remove the member group from the group it is called on, it does not recurse into member groups.

isRemoteMemberGroup($group)

Returns a bool, TRUE if the group is a remote member group, FALSE otherwise.

getRemoteGroups()

Returns a Solstice::List, containing instances of any and all remote groups that are members of the given group.

addRemoteGroup($group)

This will add the given group to the current group. This will return TRUE on success, FALSE on failure. This can fail in the case that the given group is not a Solstice::Group::Remote, or if the group has not been saved.

removeRemoteGroup($group)

This will remove the given group from the set of member groups. This will only remove the member group from the group it is called on, it does not recurse into member groups.

removeAllRemoteGroups()

Remove all remote groups that are currently attached to the group.

getSubgroups()

Returns a Solstice::List, containing all subgroups of the given list. This does not recurse into member groups.

addSubgroup($subgroup)

Adds the given subgroup to the set of subgroups in the current group. Subgroup membership can overlap, and can include membership from member groups and remote groups. The subgroup must watch the membership of the group it is attached to, and if a member of the subgroup is no longer a member of the subgroup, display and use of that member must cease.

The subgroup must be in the data store before being added to the group.

removeSubgroup($subgroup)

Removes the given subgroup from the set of subgroups.

getSubgroupCount()

Returns the number of subgroups for the group.

Private Methods

_initEmpty()
_initMin($group_id)

Initializes the minimum amount of data about the group as it can. Loads no member groups, subgroups, people, or class lists.

_initFromHash($hash_ref)

Does a minimal initialization, with data from an outside source.

_initializeOwners()

Goes to the data store to retrieve the list of owners of this group.

_initializeMembers()

Goes to the data store to retrive the list of members for this group.

_initializeMemberGroups()

Goes to the data store to retrieve the list of member groups for this group.

_initializeRemoteGroups()

Goes to the data store to retrieve the list of remote groups for this group.

_initializeSubgroups()

Goes to the data store to retrieve the list of subgroups for this group.

_isValidSubgroup($group)
_isValidRemoteGroup($group)
_getAllMembers($seen_group_hash)

A private method for recursing through groups, getting membership lists.

_populateMemberHash(\%member_hash)

Recursive function that builds a hash of group members

_populateDBMemberHash(\%member_hash)
_getAccessorDefinition()

Returns the array_ref that creates the basic accessors of Solstice::Group.

AUTHOR

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

VERSION

$Revision: $

COPYRIGHT

Copyright 1998-2007 Office of Learning Technologies, University of Washington

Licensed under the Educational Community License, Version 1.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: http://www.opensource.org/licenses/ecl1.php

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.