| Solstice documentation | view source | Contained in the Solstice distribution. |
Solstice::Group::Remote - Model of groups who sync from a remote source.
No symbols exported.
sub clone { my $self = shift; cluck "clone(): Not implemented"; return FAIL; }
sub delete { my $self = shift; cluck "delete(): Not implemented"; return FAIL; }
sub reconcile { my $self = shift; my $list = shift;
unless ($self->isValidList($list)) {
cluck 'reconcile(): requires a Solstice::List';
return FAIL;
}
$self->SUPER::removeAllMembers();
my $iterator = $list->iterator();
while ($iterator->hasNext()) {
return FALSE unless $self->SUPER::addMember($iterator->next());
}
$self->{'_is_reconciliation'} = TRUE;
$self->{'_tainted_members'} = TRUE;
# Make sure we don't initialize group membership on store, otherwise
# people who leave the remote group won't actually leave.
$self->{'_initialized_members'} = TRUE;
return SUCCESS;
}
sub store { my $self = shift;
return SUCCESS unless $self->{'_tainted_members'};
# Not sure this is needed if we're tainted...
$self->_initializeMembers() unless $self->{'_initialized_members'};
my $db = Solstice::Database->new();
my $config = Solstice::Configure->new();
my $db_name = $config->getDBName();
my $id = $self->getID();
if (defined $id) {
if ($self->{'_is_reconciliation'}) {
$db->writeQuery('UPDATE '.$db_name.'.RemoteGroup SET date_reconciled = NOW() WHERE remote_group_id = ?',$id);
$self->{'_is_reconciliation'} = FALSE;
}
} else {
$db->readQuery('SELECT remote_group_source_id FROM '.$db_name.'.RemoteGroupSource WHERE package = ?',ref($self));
my $remote_source_id = $db->fetchRow()->{'remote_group_source_id'};
my $remote_key = $self->getRemoteKey();
$db->readQuery('SELECT remote_group_id from '.$db_name.'.RemoteGroup where remote_key=? AND remote_group_source_id=?',$remote_key, $remote_source_id);
$id = $db->fetchRow()->{'remote_group_id'};
unless (defined $id) {
my $name = $self->getName();
my ($date_created, $date_modified);
$db->writeQuery('INSERT INTO '.$db_name.'.RemoteGroup (remote_group_id, remote_group_source_id, remote_key, name, date_created, date_modified) VALUES (NULL,?,?,?, NOW(),NOW())', $remote_source_id, $remote_key, $name,);
$id = $db->getLastInsertID();
$db->readQuery('SELECT date_created, date_modified FROM '.$db_name.'.RemoteGroup WHERE remote_group_id=?', $id);
my $data_ref = $db->fetchRow();
$self->_setCreationDate(Solstice::DateTime->new($data_ref->{'date_created'}));
$self->_setModificationDate(Solstice::DateTime->new($data_ref->{'date_modified'}));
}
$self->_setID($id);
}
my $person_insert = join ',', map { "(NULL, $id, $_)" } keys %{$self->{'_member_people'}};
$db->writeQuery('DELETE FROM '.$db_name.'.PeopleInRemoteGroup WHERE remote_group_id = ?',$id);
if ($person_insert) {
$db->writeQuery('INSERT INTO '.$db_name.'.PeopleInRemoteGroup VALUES '.$person_insert);
}
$self->{'_tainted_members'} = FALSE;
return SUCCESS;
}
sub getOwners { my $self = shift; cluck "getOwners(): Not implemented"; return Solstice::List->new(); }
sub addOwner { my $self = shift; cluck "addOwner(): Not implemented"; return FAIL; }
sub removeOwner { my $self = shift; cluck "removeOwner(): Not implemented"; return FAIL; }
sub isOwner { my $self = shift; #there are currently no owners to remote groups return FAIL; }
sub addMember { my $self = shift; cluck "addMember(): Not implemented"; return FAIL; }
sub addMembers { my $self = shift; cluck "addMembers(): Not implemented"; return FAIL; }
sub removeMember { my $self = shift; cluck "removeMember(): Not implemented"; return FAIL; }
sub removeMembers { my $self = shift; cluck "removeMember(): Not implemented"; return FAIL; }
sub removeAllMembers { my $self = shift; cluck "removeAllMembers(): Not implemented"; return FAIL; }
sub isMemberGroup { return FALSE; }
sub getMemberGroups { my $self = shift; cluck "getMemberGroups(): Not implemented"; return Solstice::List->new(); }
sub addMemberGroup { my $self = shift; cluck "addMemberGroup(): Not implemented"; return FAIL; }
sub removeMemberGroup { my $self = shift; cluck "removeMemberGroup(): Not implemented"; return FAIL; }
sub isRemoteMemberGroup { my $self = shift; cluck "isRemoteMemberGroup(): Not implemented"; return FALSE; }
sub getRemoteGroups { my $self = shift; cluck "getRemoteGroups(): Not implemented"; return Solstice::List->new(); }
sub addRemoteGroup { my $self = shift; cluck "addRemoteGroup(): Not implemented"; return FAIL; }
sub removeRemoteGroup { my $self = shift; cluck "addRemoteGroup(): Not implemented"; return FAIL; }
sub getSubgroups { my $self = shift; cluck "getSubgroups(): Not implemented"; return FAIL; }
sub removeSubgroup { my $self = shift; cluck "removeSubgroup(): Not implemented"; return FAIL; }
sub getSubgroupCount { my $self = shift; cluck "getSubgroupCount(): Not implemented"; return 0; }
Initializes the minimum amount of data about the group as it can. Loads no member groups, subgroups, people, or class lists.
Does a minimal initialization, with data from an outside source.
Goes to the data store to retrive the list of members for this group.
sub _initializeOwners { return TRUE; }
sub _initializeMemberGroups { my $self = shift; $self->{'_member_groups'} = {}; return TRUE; }
sub _initializeRemoteGroups { my $self = shift; $self->{'_remote_groups'} = {}; return TRUE; }
Catalyst Group, <catalyst@u.washington.edu>
$Revision: $
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.
| Solstice documentation | view source | Contained in the Solstice distribution. |